// error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { echo "WARNING: myErrorHandler({$errno}, '{$errstr}', '{$errfile}', {$errline})\n"; return true; } // set to the user defined error handler $oldErrorHandler = set_error_handler("myErrorHandler"); // // Creating document, filling static fields. // $doc = new Opus_Document(); $doc->setType(randString($counter++)); $doc->setServerState('published'); $doc->setServerDatePublished('01.01.1900'); $doc->setLanguage('deu' . randString($counter++)); $doc->setThesisDateAccepted('01.02.2003'); $doc->setPublishedYear('2010'); $doc->setPublishedDate('28.09.2010'); $doc->setCompletedYear('2010'); $doc->setCompletedDate('27.09.2010'); $doc->setPublisherName(randString($counter++)); $doc->setPublisherPlace(randString($counter++)); $doc->setPageNumber(randString($counter++)); $doc->setPageFirst(randString($counter++)); $doc->setPageLast(randString($counter++)); $doc->setVolume(randString($counter++)); $doc->setIssue(randString($counter++)); $doc->setCreatingCorporation(randString($counter++)); $doc->setContributingCorporation(randString($counter++)); //
private function processRow($row) { $doc = new Opus_Document(); $oldId = $row[self::OLD_ID]; try { $doc->setLanguage(trim($row[self::LANGUAGE])); // Dokumenttyp muss kleingeschrieben werden (bei Fromm aber groß) $doc->setType(lcfirst(trim($row[self::TYPE]))); $doc->setServerState(trim($row[self::SERVER_STATE])); $doc->setVolume(trim($row[self::VOL_ID])); // speichere die oldId als Identifier old ab, so dass später nach dieser gesucht werden kann // und die Verbindung zwischen Ausgangsdatensatz und importiertem Datensatz erhalten bleibt $this->addIdentifier($doc, 'old', $oldId); $this->processTitlesAndAbstract($row, $doc, $oldId); $this->processDate($row, $doc, $oldId); $this->processIdentifier($row, $doc, $oldId); $this->processNote($row, $doc, $oldId); $this->processCollections($row, $doc); $this->processLicence($row, $doc, $oldId); $this->processSeries($row, $doc); $this->processEnrichmentKindofpublication($row, $doc, $oldId); // TODO Fromm verwendet aktuell sieben Enrichments (muss noch generalisiert werden) $enrichementkeys = array(self::ENRICHMENT_AVAILABILITY, self::ENRICHMENT_FORMAT, self::ENRICHMENT_KINDOFPUBLICATION, self::ENRICHMENT_IDNO, self::ENRICHMENT_COPYRIGHTPRINT, self::ENRICHMENT_COPYRIGHTEBOOK, self::ENRICHMENT_RELEVANCE); foreach ($enrichementkeys as $enrichmentkey) { $this->processEnrichment($enrichmentkey, $row, $doc); } $file = $this->processFile($row, $doc, $oldId); $doc->store(); if (!is_null($file) && $file instanceof Opus_File && !is_null($this->_guestRole)) { $this->_guestRole->appendAccessFile($file->getId()); $this->_guestRole->store(); } } catch (Exception $e) { echo "import of document " . $oldId . " was not successful: " . $e->getMessage() . "\n"; } try { $this->processPersons($row, $doc, $oldId); $doc->store(); return true; } catch (Exception $e) { echo "import of person(s) for document " . $oldId . " was not successful: " . $e->getMessage() . "\n"; } return false; }
* @license http://www.gnu.org/licenses/gpl.html General Public License * @version $Id$ */ $doc = new Opus_Document(); $doc->setType('all'); $doc->setServerState('published'); $doc->setServerDatePublished('1900-01-01'); // damn API. $doc->addPersonSubmiter() doesn't work for link models! // -> we should change this in 4.x $submitter = new Opus_Person(); $submitter->setFirstName('Donald')->setLastName('Duck')->setEmail('*****@*****.**')->setDateOfBirth('1920-03-13')->setPlaceOfBirth('Entenhausen'); $doc->addPersonSubmitter($submitter); $author = new Opus_Person(); $author->setFirstName('Daniel')->setLastName('Düsentrieb')->setAcademicTitle('Dr.-Ing.'); $doc->addPersonAuthor($author); $doc->setLanguage('deu'); $titleMain = $doc->addTitleMain(); $titleMain->setValue('Dokument zur empirischen Unterschung der OAI-Schnittstelle'); $titleMain->setLanguage('deu'); $titleMainEng = $doc->addTitleMain(); $titleMainEng->setValue('Document for empirical testing OAI interface'); $titleMainEng->setLanguage('eng'); $abstract = $doc->addTitleAbstract(); $abstract->setValue('Dokument, dass alle Daten enhält, um testen zu können, wie die OAI-Schnittstelle sie ausgibt.'); $abstract->setLanguage('deu'); $titleSub = $doc->addTitleSub(); $titleSub->setValue('Beispielhaft erleutert an OPUS 4.0.0'); $titleSub->setLanguage('deu'); $titleAdditional = $doc->addTitleAdditional(); $titleAdditional->setValue('OAI-Schnittstellen empirisch testen am Beispiel von OPUS 4.0'); $titleAdditional->setLanguage('deu');
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Application * @author Thoralf Klein <*****@*****.**> * @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);
/** * Aktualisiert ein Dokument mit den Werten im Formular. * @param Opus_Document $document */ public function updateModel($document) { // Language $value = $this->getElementValue(self::ELEMENT_LANGUAGE); $document->setLanguage($value); // Type $value = $this->getElementValue(self::ELEMENT_TYPE); $document->setType($value); $datesHelper = $this->getDatesHelper(); // CompletedDate $value = $this->getElementValue(self::ELEMENT_COMPLETED_DATE); $date = $datesHelper->getOpusDate($value); $document->setCompletedDate($date); // CompletedYear $value = $this->getElementValue(self::ELEMENT_COMPLETED_YEAR); $document->setCompletedYear($value); // PublishedDate $value = $this->getElementValue(self::ELEMENT_PUBLISHED_DATE); $date = $datesHelper->getOpusDate($value); $document->setPublishedDate($date); // PublishedYear $value = $this->getElementValue(self::ELEMENT_PUBLISHED_YEAR); $document->setPublishedYear($value); $value = $this->getElementValue(self::ELEMENT_EMBARGO_DATE); $date = $datesHelper->getOpusDate($value); $document->setEmbargoDate($date); }
/** * Regression test for OPUSVIER-2165 * * if database contains more than one title in the document's language, * the first title is used as page title */ public function testFrontdoorTitleRespectsDocumentLanguageMultipleCandidates() { $d = new Opus_Document(146); $lang = $d->getLanguage(); $d->setLanguage('deu'); $titles = $d->getTitleMain(); $d->addTitleMain()->setValue('VBOK')->setLanguage('deu'); $d->store(); $this->dispatch('/frontdoor/index/index/docId/146'); // restore language // restore titles $d = new Opus_Document(146); $d->setLanguage($lang); $d->setTitleMain($titles); $d->store(); $this->assertNotContains('<title>OPUS 4 | COLN</title>', $this->getResponse()->getBody()); $this->assertNotContains('<title>OPUS 4 | VBOK</title>', $this->getResponse()->getBody()); $this->assertContains('<title>OPUS 4 | KOBV</title>', $this->getResponse()->getBody()); }