/** * {@inheritDoc} */ protected function doLoad(ObjectManager $manager) { $d0 = new Deposit(); $d0->setAction('add'); $d0->setChecksumType('SHA1'); $d0->setChecksumValue('b4b0bfbaadf33f8e678ad9cd0c1da2c9a6e7d204'); $d0->setDepositUuid('d38e7ecb-7d7e-408d-94b0-b00d434fdbd2'); $d0->setDepositReceipt('http://example.com/path/to/receipt'); $d0->setFileType('application/zip'); $d0->setIssue(2); $d0->setJournal($this->getReference('journal')); $d0->setPubDate(new DateTime()); $d0->setSize(100); $d0->setState('depositedByJournal'); $d0->setUrl('http://journal.example.com/path/to/deposit'); $d0->setVolume(1); $manager->persist($d0); $d1 = new Deposit(); $d1->setAction('add'); $d1->setChecksumType('SHA1'); $d1->setChecksumValue('f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'); $d1->setDepositUuid('578205CB-0947-4CD3-A384-CDF186F5E86B'); $d1->setDepositReceipt('http://example2.com/path/to/receipt'); $d1->setFileType('application/zip'); $d1->setIssue(4); $d1->setJournal($this->getReference('journal')); $d1->setPubDate(new DateTime()); $d1->setSize(1000); $d1->setState('harvested'); $d1->setUrl('http://journal.example2.com/path/to/deposit'); $d1->setVolume(2); $manager->persist($d1); $manager->flush(); $this->setReference('deposit', $d0); }
/** * Build a deposit from XML. * * @param Journal $journal * @param SimpleXMLElement $xml * @param string $action * * @return Deposit */ public function fromXml(Journal $journal, SimpleXMLElement $xml) { $id = $this->getXmlValue($xml, '//atom:id'); $deposit_uuid = strtoupper(substr($id, 9, 36)); $deposit = $this->em->getRepository('AppBundle:Deposit')->findOneBy(array('depositUuid' => $deposit_uuid)); $action = 'edit'; if (!$deposit) { $action = 'add'; $deposit = new Deposit(); } $deposit->setAction($action); $deposit->setState('depositedByJournal'); $deposit->setChecksumType($this->getXmlValue($xml, 'pkp:content/@checksumType')); $deposit->setChecksumValue($this->getXmlValue($xml, 'pkp:content/@checksumValue')); $deposit->setDepositUuid($deposit_uuid); $deposit->setFileType(''); $deposit->setIssue($this->getXmlValue($xml, 'pkp:content/@issue')); $deposit->setVolume($this->getXmlValue($xml, 'pkp:content/@volume')); $deposit->setPubDate(new DateTime($this->getXmlValue($xml, 'pkp:content/@pubdate'))); $deposit->setJournal($journal); $deposit->setSize($this->getXmlValue($xml, 'pkp:content/@size')); $deposit->setUrl(html_entity_decode($this->getXmlValue($xml, 'pkp:content'))); $deposit->setDepositReceipt($this->buildDepositReceiptUrl($deposit)); $this->getLicensingInfo($deposit, $xml); if ($action === 'add') { $deposit->addToProcessingLog('Deposit received.'); } else { $deposit->addToProcessingLog('Deposit edited or reset by journal manager.'); } $this->em->persist($deposit); $this->em->flush(); return $deposit; }