/** * {@inheritDoc} */ public function load(ObjectManager $vm) { $vm = $this->container->get('vib.doctrine.registry')->getManagerForClass('VIB\\FliesBundle\\Entity\\StockVial'); $vm->disableAutoAcl(); $user = $this->getReference('user'); $vial_1 = new StockVial(); $vial_1->setStock($this->getReference('stock_4')); $vm->persist($vial_1); $vm->flush(); $vm->createACL($vial_1, $user); $this->addReference('vial_1', $vial_1); $vial_2 = new StockVial(); $vial_2->setStock($this->getReference('stock_1')); $vial_2->getSetupDate()->sub(new \DateInterval('P3M')); $vm->persist($vial_2); $vm->flush(); $vm->createACL($vial_2, $user); $vial_3 = new StockVial(); $vial_3->setStock($this->getReference('stock_1')); $vial_3->setTrashed(true); $vm->persist($vial_3); $vm->flush(); $vm->createACL($vial_3, $user); $vm->enableAutoAcl(); }
public function crossParentNameProvider() { $stock = new Stock(); $stock->setGenotype('test genotype'); $stock->setName('test stock'); $stockVial = new StockVial(); $stockVial->setStock($stock); $injection = new InjectionVial(); $injection->setTargetStock($stock); $injection->setConstructName('test'); return array(array(new FakeCrossVial(), null, 'test'), array(new FakeCrossVial(), $stockVial, 'test parent'), array(new FakeCrossVial(), $injection, 'test parent'), array(new FakeCrossVial(), new CrossVial(), 'test')); }
/** * Set target stock * * @param \VIB\FliesBundle\Entity\StockVial $targetStockVial */ public function setTargetStockVial(StockVial $targetStockVial = null) { $this->targetStockVial = $targetStockVial; if (null !== $targetStockVial) { $this->setTargetStock($targetStockVial->getStock()); } }
protected function execute(InputInterface $input, OutputInterface $output) { $listfilename = $input->getArgument('listfile'); $stocks = array(); if ($listfilename) { $listfile = fopen($listfilename, 'r'); if ($listfile) { while ($data = fgetcsv($listfile, 0, "\t")) { $stocks[] = $data[0]; } } } natsort($stocks); $dialog = $this->getHelperSet()->get('dialog'); $this->container = $this->getApplication()->getKernel()->getContainer(); $user = $this->container->get('user_provider')->loadUserByUsername($input->getArgument('owner')); $om = $this->container->get('vib.doctrine.registry')->getManagerForClass('VIB\\CoreBundle\\Entity\\Entity'); $vm = $this->container->get('vib.doctrine.registry')->getManagerForClass('VIB\\FliesBundle\\Entity\\Vial'); $om->disableAutoAcl(); $vm->disableAutoAcl(); $om->getConnection()->beginTransaction(); $vials = new ArrayCollection(); foreach ($stocks as $stockname) { try { $stock = $om->getRepository('VIB\\FliesBundle\\Entity\\Stock')->createQueryBuilder('b')->where('b.name = :name')->setParameter('name', $stockname)->getQuery()->getSingleResult(); } catch (\Exception $e) { echo "{$stockname} not found!\n"; $stock = null; } if (null !== $stock) { echo $stock->getName() . "\n"; $vial = new StockVial(); $vial->setStock($stock); $vials[] = $vial; $vm->persist($vial); } } $output->writeln("Objects imported. Flushing DB buffer."); $om->flush(); $output->writeln("Creating ACLs."); $vm->createACL($vials, $user); $message = 'Everything seems to be OK. Commit?'; if ($dialog->askConfirmation($output, '<question>' . $message . '</question>', true)) { $om->getConnection()->commit(); if ($input->getOption('print')) { echo "Will print labels now.\n"; $pdf = $this->container->get('vibfolks.pdflabel'); foreach ($vials as $vial) { $pdf->addLabel($vial); $vm->markPrinted($vial); } $vm->flush(); $jobStatus = $pdf->printPDF(); echo $jobStatus . "\n"; } } else { $om->getConnection()->rollback(); $om->close(); } $om->enableAutoAcl(); $vm->enableAutoAcl(); }
/** * @dataProvider vialProvider */ public function testTargetStockVial($vial) { $this->assertInstanceOf('VIB\\FliesBundle\\Entity\\StockVial', $vial->getTargetStockVial()); $vial->setTargetStockVial(null); $this->assertNull($vial->getTargetStockVial()); $this->assertNull($vial->getTargetStock()); $stock = new Stock(); $stockVial = new StockVial(); $stockVial->setStock($stock); $vial->setTargetStockVial($stockVial); $this->assertEquals($stock, $vial->getTargetStock()); $this->assertEquals($stockVial, $vial->getTargetStockVial()); }
public function __construct(Vial $template = null, $flip = true) { parent::__construct($template, $flip); $this->id = 1; $this->stock = new Stock(); $this->stock->setName('Test'); $this->stock->setGenotype('test'); }