예제 #1
0
 /**
  * Add the given (key,value) to the documents enrichments.
  *
  * @param mixed $key
  * @param mixed $value
  * @return Matheon_Model_Document Fluent interface.
  */
 public function storeEnrichmentKeyValue($key, $value)
 {
     foreach ($this->_document->getEnrichment() as $e) {
         if ($e->getKeyName() == $key) {
             if ($e->getValue() == $value) {
                 return $this;
             }
         }
     }
     $this->_document->addEnrichment()->setKeyName($key)->setValue($value);
     return $this;
 }
    $lic->setLanguage('deu');
    $lic->setLinkLicence('http://www.test.de');
    $lic->setNameLong('Ein langer LizenzName');
    $lic->store();
}
$doc->setLicence($lic);
// check for enrichment keys before creating enrichments
$enrichmentKeys = Opus_EnrichmentKey::getAll();
$enrichmentKeyNames = array();
foreach ($enrichmentKeys as $enrichmentKey) {
    $enrichmentKeyNames[] = $enrichmentKey->getName();
}
$missingEnrichmentKeyNames = array_diff(array('SourceSwb', 'SourceTitle', 'ClassRvk', 'ContributorsName', 'Event', 'City', 'Country'), $enrichmentKeyNames);
if (!empty($missingEnrichmentKeyNames)) {
    foreach ($missingEnrichmentKeyNames as $missingEnrichmentKeyName) {
        $newEnrichmentKey = new Opus_EnrichmentKey();
        $newEnrichmentKey->setName($missingEnrichmentKeyName);
        $newEnrichmentKey->store();
    }
}
// Some Enrichment-Fields from Opus3-Migration
$doc->addEnrichment()->setKeyName('SourceSwb')->setValue('http://www.test.de');
$doc->addEnrichment()->setKeyName('SourceTitle')->setValue('Dieses Dokument ist auch erschienen als ...');
$doc->addEnrichment()->setKeyName('ClassRvk')->setValue('LI 99660');
$doc->addEnrichment()->setKeyName('ContributorsName')->setValue('John Doe (Foreword) and Jane Doe (Illustration)');
// Additional Enrichment-Fields
$doc->addEnrichment()->setKeyName('Event')->setValue('Opus4 OAI-Event');
$doc->addEnrichment()->setKeyName('City')->setValue('Opus4 OAI-City');
$doc->addEnrichment()->setKeyName('Country')->setValue('Opus4 OAI-Country');
$doc->store();
print "Document stored. ID: " . $doc->getId() . "\n";
예제 #3
0
 /**
  * Rejects documents and adds the given Person as referee.
  *
  * @param array $docIds
  * @param mixed $userId
  * @param Opus_Person $person
  *
  * FIXME capture success or failure for display afterwards
  */
 public function reject(array $docIds = null, $userId = null, $person = null)
 {
     $logger = Zend_Registry::get('Zend_Log');
     foreach ($docIds as $docId) {
         $logger->debug('Deleting document with id: ' . $docId);
         $document = new Opus_Document($docId);
         if (isset($person)) {
             $document->addPersonReferee($person);
         }
         $enrichment = $document->addEnrichment();
         $enrichment->setKeyName('review.rejected_by')->setValue($userId);
         $document->delete();
     }
     return;
 }
 public function debugAction()
 {
     $this->requirePrivilege('admin');
     $docId = $this->_getParam('docId');
     $document = new Opus_Document($docId);
     $document->setServerState('unpublished');
     $loggedUserModel = new Publish_Model_LoggedUser();
     $loggedUserId = $loggedUserModel->getUserId();
     $document->addEnrichment()->setKeyName('submitter.user_id')->setValue($loggedUserId);
     $document->store();
     $session = new Zend_Session_Namespace('Publish');
     $session->depositConfirmDocumentId = $docId;
 }
예제 #5
0
 /**
  *
  * @param DOMNode $node
  * @param Opus_Document $doc
  */
 private function handleEnrichments($node, $doc)
 {
     foreach ($node->childNodes as $childNode) {
         if ($childNode instanceof DOMElement) {
             $key = trim($childNode->getAttribute('key'));
             // check if enrichment key exists
             try {
                 new Opus_EnrichmentKey($key);
             } catch (Opus_Model_NotFoundException $e) {
                 throw new Exception('enrichment key ' . $key . ' does not exist: ' . $e->getMessage());
             }
             $e = $doc->addEnrichment();
             $e->setKeyName($key);
             $e->setValue(trim($childNode->textContent));
         }
     }
 }