예제 #1
0
 /**
  * Aktualisiert Opus_Identifier Instanz aus Formularelementen.
  * @param Opus_Identifier $identifier
  */
 public function updateModel($identifier)
 {
     $value = $this->getElement(self::ELEMENT_TYPE)->getValue();
     $identifier->setType($value);
     $value = $this->getElement(self::ELEMENT_VALUE)->getValue();
     $identifier->setValue($value);
 }
예제 #2
0
 public function init()
 {
     parent::init();
     $identifier = new Opus_Identifier();
     $types = $identifier->getField('Type')->getDefault();
     foreach ($types as $type) {
         $this->addMultiOption($type, 'Opus_Identifier_Type_Value_' . ucfirst($type));
     }
 }
예제 #3
0
 public function testOptions()
 {
     $element = $this->getElement();
     $translator = $element->getTranslator();
     $identifier = new Opus_Identifier();
     $types = $identifier->getField('Type')->getDefault();
     $this->assertEquals(count($types), count($element->getMultiOptions()));
     foreach ($element->getMultiOptions() as $type => $label) {
         $this->assertContains($type, $types);
         $translationKey = 'Opus_Identifier_Type_Value_' . ucfirst($type);
         $this->assertTrue($translator->isTranslated($translationKey));
         $this->assertEquals($translator->translate($translationKey), $label);
     }
 }
예제 #4
0
 /**
  * Testet, ob beim MetaDataPrefix "epicur" nur Dokumente mit URN ausgegeben werden.
  */
 public function testDocumentOutputUrn()
 {
     $docWithUrn = $this->createTestDocument();
     $docWithUrn->setServerState('published');
     $identifier = new Opus_Identifier();
     $identifier->setValue('urn_value1');
     $identifier->setType('urn');
     $docWithUrn->addIdentifier($identifier);
     $docWithUrnId = $docWithUrn->store();
     $docWoUrn = $this->createTestDocument();
     $docWoUrn->setServerState('published');
     $docWoUrnId = $docWoUrn->store();
     $oaiRequest = array('metadataPrefix' => 'epicur');
     $docListModel = new Oai_Model_DocumentList();
     $docListModel->deliveringDocumentStates = array('published');
     $docIds = $docListModel->query($oaiRequest);
     $this->assertTrue(in_array($docWithUrnId, $docIds), 'Document with URN is not returned.');
     $this->assertFalse(in_array($docWoUrnId, $docIds), 'Document without URN is returned.');
 }
예제 #5
0
 /**
  * Generates a new URN for any document that has no URN assigned yet.
  * URN's are generated for Opus_Document instances only.
  */
 public function postStoreInternal(Opus_Model_AbstractDb $model)
 {
     if (!$model instanceof Opus_Document) {
         return;
     }
     if ($model->getServerState() !== 'published') {
         return;
     }
     $config = Zend_Registry::get('Zend_Config');
     $log = Zend_Registry::get('Zend_Log');
     $log->debug('IdentifierUrn postStoreInternal for ' . $model->getDisplayName());
     if (!isset($config->urn->autoCreate) or $config->urn->autoCreate != '1') {
         $log->debug('URN auto creation is not configured. skipping...');
         return;
     }
     if (!isset($config->urn->nid) || !isset($config->urn->nss)) {
         throw new Opus_Document_Exception('URN data is not present in config. Aborting...');
     }
     $log->debug('config.ini is set to support urn auto generation');
     if ($this->urnAlreadyPresent($model)) {
         $log->debug('Model ' . $model->getDisplayName() . ' already has a URN. Skipping automatic generation.');
         return;
     }
     if (!$this->allowUrnOnThisDocument($model)) {
         $log->debug('Model ' . $model->getDisplayName() . ' has no oai-visible files. Skipping automatic URN generation.');
         return;
     }
     $log->debug('Generating URN for document ' . $model->getDisplayName());
     $nid = $config->urn->nid;
     $nss = $config->urn->nss;
     $urn = new Opus_Identifier_Urn($nid, $nss);
     $urn_value = $urn->getUrn($model->getId());
     $urn_model = new Opus_Identifier();
     $urn_model->setValue($urn_value);
     $urn_model->setType('urn');
     $model->addIdentifier($urn_model);
     $model->addIdentifierUrn($urn_model);
 }
예제 #6
0
 private function addIdentifier($doc, $type, $value)
 {
     $identifier = new Opus_Identifier();
     $identifier->setValue(trim($value));
     $identifier->setType(trim($type));
     $method = 'addIdentifier' . ucfirst(trim($type));
     $doc->{$method}($identifier);
 }
예제 #7
0
 public function testTranslationOfOpusIdentifierFields()
 {
     $model = new Opus_Identifier();
     $fieldNames = $model->describe();
     foreach ($fieldNames as $name) {
         $key = $this->helper->getKeyForField('Opus_Identifier', $name);
         $this->assertTrue($this->translate->isTranslated($key), 'Translation key \'' . $key . '\' is missing.');
     }
 }
예제 #8
0
 private function storeIdentifierObject($dataKey, $dataValue)
 {
     $identifier = new Opus_Identifier();
     $identifier->setValue($dataValue);
     try {
         if (strstr($dataKey, 'Old')) {
             $this->_document->addIdentifierOld($identifier);
         } else {
             if (strstr($dataKey, 'Serial')) {
                 $this->_document->addIdentifierSerial($identifier);
             } else {
                 if (strstr($dataKey, 'Uuid')) {
                     $this->_document->addIdentifierUuid($identifier);
                 } else {
                     if (strstr($dataKey, 'Isbn')) {
                         $this->_document->addIdentifierIsbn($identifier);
                     } else {
                         if (strstr($dataKey, 'Urn')) {
                             $this->_document->addIdentifierUrn($identifier);
                         } else {
                             if (strstr($dataKey, 'StdDoi')) {
                                 $this->_document->addIdentifierStdDoi($identifier);
                             } else {
                                 if (strstr($dataKey, 'Doi')) {
                                     $this->_document->addIdentifierDoi($identifier);
                                 } else {
                                     if (strstr($dataKey, 'Handle')) {
                                         $this->_document->addIdentifierHandle($identifier);
                                     } else {
                                         if (strstr($dataKey, 'SplashUrl')) {
                                             $this->_document->addIdentifierSplashUrl($identifier);
                                         } else {
                                             if (strstr($dataKey, 'Url')) {
                                                 $this->_document->addIdentifierUrl($identifier);
                                             } else {
                                                 if (strstr($dataKey, 'Issn')) {
                                                     $this->_document->addIdentifierIssn($identifier);
                                                 } else {
                                                     if (strstr($dataKey, 'CrisLink')) {
                                                         $this->_document->addIdentifierCrisLink($identifier);
                                                     } else {
                                                         if (strstr($dataKey, 'SplashUrl')) {
                                                             $this->_document->addIdentifierSplashUrl($identifier);
                                                         } else {
                                                             if (strstr($dataKey, 'Opus3')) {
                                                                 $this->_document->addIdentifierOpus3($identifier);
                                                             } else {
                                                                 if (strstr($dataKey, 'Opac')) {
                                                                     $this->_document->addIdentifierOpac($identifier);
                                                                 } else {
                                                                     if (strstr($dataKey, 'Arxiv')) {
                                                                         $this->_document->addIdentifierArxiv($identifier);
                                                                     } else {
                                                                         if (strstr($dataKey, 'Pubmed')) {
                                                                             $this->_document->addIdentifierPubmed($identifier);
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } catch (Opus_Model_Exception $e) {
         $this->_log->err("could not add identifier of type {$dataKey} with value {$dataValue} to document " . $this->_docId . " : " . $e->getMessage());
         throw new Publish_Model_Exception();
     }
 }
 /**
  * test for OPUSVIER-2475
  */
 public function testCatchAllSearchConsidersIdentifiers()
 {
     $this->requireSolrConfig();
     // create a test doc with all available identifier types
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->setLanguage('eng');
     $title = new Opus_Title();
     $title->setValue('test document for OPUSVIER-2475');
     $title->setLanguage('eng');
     $doc->setTitleMain($title);
     $id = new Opus_Identifier();
     $field = $id->getField('Type');
     $identifierTypes = array_keys($field->getDefault());
     foreach ($identifierTypes as $identifierType) {
         $doc->addIdentifier()->setType($identifierType)->setValue($identifierType . '-opusvier-2475');
     }
     $doc->store();
     // search for document based on identifiers
     foreach ($identifierTypes as $identifierType) {
         $searchString = $identifierType . '-opusvier-2475';
         $this->dispatch('/solrsearch/index/search/searchtype/simple/query/' . $searchString);
         $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
         $this->assertContains('test document for OPUSVIER-2475', $this->getResponse()->getBody());
         $this->getResponse()->clearAllHeaders();
         $this->getResponse()->clearBody();
     }
 }
예제 #10
0
파일: Document.php 프로젝트: alexukua/opus4
 /**
  * Add UUID identifier if none has been added.
  *
  * @return void
  */
 protected function _storeIdentifierUuid($value)
 {
     if (true === is_null($value)) {
         $uuid_model = new Opus_Identifier();
         $uuid_model->setValue(Opus_Identifier_UUID::generate());
         $this->setIdentifierUuid($uuid_model);
     }
     $options = null;
     if (array_key_exists('options', $this->_externalFields['IdentifierUuid']) === true) {
         $options = $this->_externalFields['IdentifierUuid']['options'];
     }
     $this->_storeExternal($this->_fields['IdentifierUuid']->getValue(), $options);
 }