/** * 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); }
/** * 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.'); }
/** * 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); }
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); }