$institutesRole->setName('institutes' . randString($counter++) . rand())->setOaiName('institutes' . randString($counter++) . rand())->setPosition(1)->setVisible(1)->setVisibleBrowsingStart(1)->setDisplayBrowsing('Name')->setVisibleFrontdoor(1)->setDisplayFrontdoor('Name')->setVisibleOai('Name')->setDisplayOai('Name')->store(); $instituteName = 'Institut für empirische Forschung ' . randString($counter++); $instituteCollections = Opus_Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName); if (count($instituteCollections) >= 1) { $instituteCollection = $instituteCollections[0]; } else { $rootCollection = $institutesRole->getRootCollection(); if (is_null($rootCollection) === true) { $rootCollection = $institutesRole->addRootCollection(); $rootCollection->setVisible(1)->store(); $institutesRole->store(); } $instituteCollection = $rootCollection->addLastChild(); $instituteCollection->setVisible(1)->setName(randString($counter++))->store(); } $doc->addCollection($instituteCollection); // // Identifiers // $oldOpusId = $doc->addIdentifierOpus3(); $oldOpusId->setValue(randString($counter++)); // empty URN will be automaticaly replace by new URN. $urn = $doc->addIdentifierUrn(); $urn->setValue('urn:nbn:de:kobv:nn-opus-173:' . randString($counter++)); $isbn = $doc->addIdentifierIsbn(); $isbn->setValue('978-3-86680-192-9'); $issn = $doc->addIdentifierIssn(); $issn->setValue('1234-5678'); $doc->addIdentifierOpac()->setValue(randString($counter++)); // // DnbInstitutes
public function addDocument($documentId) { if (is_null($documentId)) { throw new Admin_ModelException('missing document id'); } $document = null; try { $document = new Opus_Document($documentId); } catch (Opus_Model_Exception $e) { throw new Admin_Model_Exception('invalid document id'); } $document->addCollection($this->_collection); $document->store(); }
* @copyright Copyright (c) 2008-2011, OPUS 4 development team * @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id$ */ /** * script to create 10000 documents, e.g., for performance testing */ for ($i = 1; $i < 10000; $i++) { $d = new Opus_Document(); $d->setServerState('published'); $d->setType('preprint'); $d->setLanguage('deu'); $title = $d->addTitleMain(); $title->setLanguage('deu'); $title->setValue('title-' . rand()); $date = new Opus_Date(); $date->setNow(); $date->setYear(1990 + $i % 23); $d->setPublishedDate($date); $p = new Opus_Person(); $p->setFirstName("foo-" . $i % 7); $p->setLastName("bar-" . $i % 5); $p = $d->addPersonAuthor($p); $c = new Opus_Collection(15990 + $i % 103); $d->addCollection($c); $s = $d->addSubject()->setType('ddc'); $s->setValue($i % 97); $docId = $d->store(); echo "docId: {$docId}\n"; } exit;
/** * * @param DOMNode $node * @param Opus_Document $doc */ private function handleCollections($node, $doc) { foreach ($node->childNodes as $childNode) { if ($childNode instanceof DOMElement) { $collectionId = trim($childNode->getAttribute('id')); // check if collection with given id exists try { $c = new Opus_Collection($collectionId); $doc->addCollection($c); } catch (Opus_Model_NotFoundException $e) { throw new Exception('collection id ' . $collectionId . ' does not exist: ' . $e->getMessage()); } } } }