コード例 #1
0
 public function testPopulateFromModel()
 {
     $form = new Admin_Form_EnrichmentKey();
     $enrichmentKey = new Opus_EnrichmentKey();
     $enrichmentKey->setName('Test');
     $form->populateFromModel($enrichmentKey);
     $this->assertEquals('Test', $form->getElement('Name')->getValue());
 }
コード例 #2
0
 /**
  * Wenn es keine Übersetzung für den Schlüssel gibt, soll kein Prefix hinzugefügt werden.
  */
 public function testKeysWithoutTranlationNotPrefixed()
 {
     $enrichmentKey = new Opus_EnrichmentKey();
     $enrichmentKey->setName('TestEnrichmentKey');
     $enrichmentKey->store();
     $this->useEnglish();
     $element = $this->getElement();
     $options = $element->getMultiOptions();
     $enrichmentKey->delete();
     // cleanup
     $this->assertContains('TestEnrichmentKey', array_keys($options));
     $this->assertNotEquals('EnrichmentTestEnrichmentKey', $options['TestEnrichmentKey']);
     $this->assertEquals('TestEnrichmentKey', $options['TestEnrichmentKey']);
 }
コード例 #3
0
 /**
  * Checks if a enrichmentkey already used.
  * @param string $login
  * @return boolean
  */
 protected function _isEnrichmentKeyUsed($name)
 {
     $enrichmentkey = Opus_EnrichmentKey::fetchByName($name);
     if (is_null($enrichmentkey)) {
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: Enrichment.php プロジェクト: alexukua/opus4
 /**
  * Initialize model with the following fields:
  * - KeyName
  * - Value
  *
  * @return void
  */
 protected function _init()
 {
     $key = new Opus_Model_Field('KeyName');
     $key->setMandatory(true)->setValidator(new Zend_Validate_NotEmpty())->setSelection(true)->setDefault(Opus_EnrichmentKey::getAll());
     $value = new Opus_Model_Field('Value');
     $value->setMandatory(true)->setValidator(new Zend_Validate_NotEmpty());
     $this->addField($key);
     $this->addField($value);
 }
コード例 #5
0
 public function init()
 {
     parent::init();
     $options = Opus_EnrichmentKey::getAll();
     $values = array();
     $translator = $this->getTranslator();
     $this->setDisableTranslator(true);
     // keys are translated below if possible
     foreach ($options as $index => $option) {
         $keyName = $option->getName();
         $values[] = $keyName;
         $translationKey = 'Enrichment' . $keyName;
         if (!is_null($translator) && $translator->isTranslated($translationKey)) {
             $this->addMultiOption($keyName, $translator->translate($translationKey));
         } else {
             $this->addMultiOption($keyName, $keyName);
         }
     }
     $validator = new Zend_Validate_InArray($values);
     $validator->setMessage('validation_error_unknown_enrichmentkey');
     $this->addValidator($validator);
 }
コード例 #6
0
ファイル: DocumenttypeParser.php プロジェクト: alexukua/opus4
 private function isValidEnrichmentKey($elementName)
 {
     $enrichment = Opus_EnrichmentKey::fetchByName($elementName);
     if (is_null($enrichment)) {
         throw new Publish_Model_FormIncorrectEnrichmentKeyException($elementName);
     }
     return true;
 }
コード例 #7
0
 /**
  * Checks if a enrichmentkey already used.
  * @param string $login
  * @return boolean
  */
 protected function _isEnrichmentKeyUsed($name)
 {
     $enrichmentkey = Opus_EnrichmentKey::fetchByName($name);
     return !is_null($enrichmentkey);
 }
コード例 #8
0
 public function testNoMigrationToEnrichments()
 {
     $this->assertNull(Opus_EnrichmentKey::fetchByName('SubjectUncontrolledEnglish'));
     $this->assertNull(Opus_EnrichmentKey::fetchByName('SubjectUncontrolledGerman'));
     $this->assertNull(Opus_EnrichmentKey::fetchByName('SubjectSwd'));
 }
コード例 #9
0
    $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";
コード例 #10
0
ファイル: Opus3XMLImport.php プロジェクト: alexukua/opus4
 private function createNewEnrichmentKeys()
 {
     $elements = $this->document->getElementsByTagName('Enrichment');
     foreach ($elements as $e) {
         $keyname = $e->getAttribute('KeyName');
         if (is_null(Opus_EnrichmentKey::fetchByName($keyname))) {
             $enrichmentkey = new Opus_EnrichmentKey();
             $enrichmentkey->setName($keyname);
             $enrichmentkey->store();
         }
     }
 }
コード例 #11
0
 protected function _updateEnrichmentkey($id, $name)
 {
     if (!empty($id)) {
         $enrichmentkey = new Opus_EnrichmentKey($id);
     } else {
         $enrichmentkey = new Opus_EnrichmentKey();
     }
     if (!empty($name)) {
         $enrichmentkey->setName($name);
         $enrichmentkey->store();
     }
 }
コード例 #12
0
 public function testValidDocumentData()
 {
     $document = $this->createTestDocument();
     $document->setServerState('temporary');
     $docId = $document->store();
     $enrichment = new Opus_EnrichmentKey();
     $enrichment->setName('Foo2Title');
     $enrichment->store();
     $data = array('PersonSubmitterFirstName_1' => array('value' => 'Hans', 'datatype' => 'Person', 'subfield' => '0'), 'PersonSubmitterLastName_1' => array('value' => 'Hansmann', 'datatype' => 'Person', 'subfield' => '1'), 'PersonSubmitterEmail_1' => array('value' => '*****@*****.**', 'datatype' => 'Person', 'subfield' => '1'), 'PersonSubmitterPlaceOfBirth_1' => array('value' => 'Stadt', 'datatype' => 'Person', 'subfield' => '1'), 'PersonSubmitterDateOfBirth_1' => array('value' => '1970/01/01', 'datatype' => 'Person', 'subfield' => '1'), 'PersonSubmitterAcademicTitle_1' => array('value' => 'Dr.', 'datatype' => 'Person', 'subfield' => '1'), 'PersonSubmitterAllowEmailContact_1' => array('value' => '0', 'datatype' => 'Person', 'subfield' => '1'), 'CompletedDate' => array('value' => '2012/1/1', 'datatype' => 'Date', 'subfield' => '0'), 'PersonAuthorFirstName_1' => array('value' => 'vorname', 'datatype' => 'Person', 'subfield' => '1'), 'PersonAuthorLastName_1' => array('value' => 'nachname', 'datatype' => 'Person', 'subfield' => '0'), 'PersonAuthorLastName_2' => array('value' => 'nurNachname', 'datatype' => 'Person', 'subfield' => '0'), 'TitleMain_1' => array('value' => 'Entenhausen', 'datatype' => 'Title', 'subfield' => '0'), 'TitleMainLanguage_1' => array('value' => 'deu', 'datatype' => 'Language', 'subfield' => '1'), 'TitleMain_2' => array('value' => 'Irgendwas sonst', 'datatype' => 'Title', 'subfield' => '0'), 'TitleMainLanguage_2' => array('value' => 'eng', 'datatype' => 'Language', 'subfield' => '1'), 'Language' => array('value' => 'deu', 'datatype' => 'Language', 'subfield' => '0'), 'Note' => array('value' => 'Dies ist ein Kommentar', 'datatype' => 'Note', 'subfield' => '0'), 'Licence' => array('value' => '3', 'datatype' => 'Licence', 'subfield' => '0'), 'ThesisGrantor' => array('value' => '1', 'datatype' => 'ThesisGrantor', 'subfield' => '0'), 'ThesisPublisher' => array('value' => '2', 'datatype' => 'ThesisPublisher', 'subfield' => '0'), 'ThesisYearAccepted' => array('value' => '2009', 'datatype' => 'Year', 'subfield' => '0'), 'SubjectSwd_1' => array('value' => 'hallo098', 'datatype' => 'Subject', 'subfield' => '0'), 'SubjectUncontrolled_1' => array('value' => 'Keyword', 'datatype' => 'Subject', 'subfield' => '0'), 'SubjectUncontrolledLanguage_1' => array('value' => 'deu', 'datatype' => 'Language', 'subfield' => '1'), 'SubjectMSC_1' => array('value' => '8030', 'datatype' => 'Collection', 'subfield' => '0'), 'SubjectJEL_1' => array('value' => '6740', 'datatype' => 'Collection', 'subfield' => '0'), 'SubjectPACS_1' => array('value' => '2878', 'datatype' => 'Collection', 'subfield' => '0'), 'SubjectBKL_1' => array('value' => '13874', 'datatype' => 'Collection', 'subfield' => '0'), 'IdentifierOld' => array('value' => 'Publish_Model_DepositTest_old', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierSerial' => array('value' => 'Publish_Model_DepositTest_serial', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierUuid' => array('value' => 'Publish_Model_DepositTest_uuid', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierIsbn' => array('value' => 'Publish_Model_DepositTest_isbn', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierDoi' => array('value' => 'Publish_Model_DepositTest_doi', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierHandle' => array('value' => 'Publish_Model_DepositTest_handle', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierUrn' => array('value' => 'Publish_Model_DepositTest_urn', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierUrl' => array('value' => 'Publish_Model_DepositTest_url', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierIssn' => array('value' => 'Publish_Model_DepositTest_issn', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierStdDoi' => array('value' => 'Publish_Model_DepositTest_stddoi', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierArxiv' => array('value' => 'Publish_Model_DepositTest_arxiv', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierPubmed' => array('value' => 'Publish_Model_DepositTest_pubmed', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierCrisLink' => array('value' => 'Publish_Model_DepositTest_crislink', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierSplashUrl' => array('value' => 'Publish_Model_DepositTest_splashurl', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierOpus3' => array('value' => 'Publish_Model_DepositTest_opus3', 'datatype' => 'Identifier', 'subfield' => '0'), 'IdentifierOpac' => array('value' => 'Publish_Model_DepositTest_opac', 'datatype' => 'Identifier', 'subfield' => '0'), 'ReferenceIsbn' => array('value' => 'Publish_Model_DepositTest_ref_isbn', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceUrn' => array('value' => 'Publish_Model_DepositTest_ref_urn', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceHandle' => array('value' => 'Publish_Model_DepositTest_ref_handle', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceDoi' => array('value' => 'Publish_Model_DepositTest_ref_doi', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceIssn' => array('value' => 'Publish_Model_DepositTest_ref_issn', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceUrl' => array('value' => 'Publish_Model_DepositTest_ref_url', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceCrisLink' => array('value' => 'Publish_Model_DepositTest_ref_crislink', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceStdDoi' => array('value' => 'Publish_Model_DepositTest_ref_stddoi', 'datatype' => 'Reference', 'subfield' => '0'), 'ReferenceSplashUrl' => array('value' => 'Publish_Model_DepositTest_ref_splashurl', 'datatype' => 'Reference', 'subfield' => '0'), 'SeriesNumber1' => array('value' => '5', 'datatype' => 'SeriesNumber', 'subfield' => '0'), 'Series1' => array('value' => '4', 'datatype' => 'Series', 'subfield' => '1'), 'Foo2Title' => array('value' => 'title as enrichment', 'datatype' => 'Enrichment', 'subfield' => '0'));
     $log = Zend_Registry::get('Zend_Log');
     $dep = new Publish_Model_Deposit($docId, $log, $data);
     $document = $dep->getDocument();
     $document->store();
     $personSubmitter = $document->getPersonSubmitter(0);
     $this->assertEquals('Hans', $personSubmitter->getFirstName());
     $this->assertEquals('Hansmann', $personSubmitter->getLastName());
     $this->assertEquals('*****@*****.**', $personSubmitter->getEmail());
     $this->assertEquals('Stadt', $personSubmitter->getPlaceOfBirth());
     $this->assertEquals(new Opus_Date(new Zend_Date('1970/01/01')), $personSubmitter->getDateOfBirth());
     $this->assertEquals('Dr.', $personSubmitter->getAcademicTitle());
     $this->assertEquals('0', $personSubmitter->getAllowEmailContact());
     $this->assertEquals(new Opus_Date(new Zend_Date('2012/1/1')), $document->getCompletedDate());
     $personAuthor1 = $document->getPersonAuthor(0);
     $this->assertEquals('vorname', $personAuthor1->getFirstName());
     $this->assertEquals('nachname', $personAuthor1->getLastName());
     $personAuthor2 = $document->getPersonAuthor(1);
     $this->assertEquals('nurNachname', $personAuthor2->getLastName());
     $titleMains = $document->getTitleMain();
     $titleMain1 = $titleMains[0];
     $this->assertEquals('Entenhausen', $titleMain1->getValue());
     $this->assertEquals('deu', $titleMain1->getLanguage());
     $titleMain2 = $titleMains[1];
     $this->assertEquals('Irgendwas sonst', $titleMain2->getValue());
     $this->assertEquals('eng', $titleMain2->getLanguage());
     $this->assertEquals('deu', $document->getLanguage());
     $this->assertEquals('Dies ist ein Kommentar', $document->getNote(0)->getMessage());
     $this->assertEquals(3, $document->getLicence(0)->getModel()->getId());
     $this->assertEquals(1, $document->getThesisGrantor(0)->getModel()->getId());
     $this->assertEquals(2, $document->getThesisPublisher(0)->getModel()->getId());
     $this->assertEquals('2009', $document->getThesisYearAccepted());
     $this->assertEquals('hallo098', $document->getSubject(0)->getValue());
     $this->assertEquals('Keyword', $document->getSubject(1)->getValue());
     $this->assertEquals('deu', $document->getSubject(1)->getLanguage());
     $this->assertEquals(8030, $document->getCollection(0)->getId());
     $this->assertEquals(6740, $document->getCollection(1)->getId());
     $this->assertEquals(2878, $document->getCollection(2)->getId());
     $this->assertEquals(13874, $document->getCollection(3)->getId());
     $this->assertEquals('Publish_Model_DepositTest_old', $document->getIdentifier(0)->getValue());
     $this->assertEquals('old', $document->getIdentifier(0)->getType());
     $this->assertEquals('Publish_Model_DepositTest_serial', $document->getIdentifier(1)->getValue());
     $this->assertEquals('serial', $document->getIdentifier(1)->getType());
     $this->assertEquals('Publish_Model_DepositTest_uuid', $document->getIdentifier(2)->getValue());
     $this->assertEquals('uuid', $document->getIdentifier(2)->getType());
     $this->assertEquals('Publish_Model_DepositTest_isbn', $document->getIdentifier(3)->getValue());
     $this->assertEquals('isbn', $document->getIdentifier(3)->getType());
     $this->assertEquals('Publish_Model_DepositTest_urn', $document->getIdentifier(4)->getValue());
     $this->assertEquals('urn', $document->getIdentifier(4)->getType());
     $this->assertEquals('Publish_Model_DepositTest_doi', $document->getIdentifier(5)->getValue());
     $this->assertEquals('doi', $document->getIdentifier(5)->getType());
     $this->assertEquals('Publish_Model_DepositTest_handle', $document->getIdentifier(6)->getValue());
     $this->assertEquals('handle', $document->getIdentifier(6)->getType());
     $this->assertEquals('Publish_Model_DepositTest_url', $document->getIdentifier(7)->getValue());
     $this->assertEquals('url', $document->getIdentifier(7)->getType());
     $this->assertEquals('Publish_Model_DepositTest_issn', $document->getIdentifier(8)->getValue());
     $this->assertEquals('issn', $document->getIdentifier(8)->getType());
     $this->assertEquals('Publish_Model_DepositTest_stddoi', $document->getIdentifier(9)->getValue());
     $this->assertEquals('std-doi', $document->getIdentifier(9)->getType());
     $this->assertEquals('Publish_Model_DepositTest_crislink', $document->getIdentifier(10)->getValue());
     $this->assertEquals('cris-link', $document->getIdentifier(10)->getType());
     $this->assertEquals('Publish_Model_DepositTest_splashurl', $document->getIdentifier(11)->getValue());
     $this->assertEquals('splash-url', $document->getIdentifier(11)->getType());
     $this->assertEquals('Publish_Model_DepositTest_opus3', $document->getIdentifier(12)->getValue());
     $this->assertEquals('opus3-id', $document->getIdentifier(12)->getType());
     $this->assertEquals('Publish_Model_DepositTest_opac', $document->getIdentifier(13)->getValue());
     $this->assertEquals('opac-id', $document->getIdentifier(13)->getType());
     $this->assertEquals('Publish_Model_DepositTest_arxiv', $document->getIdentifier(14)->getValue());
     $this->assertEquals('arxiv', $document->getIdentifier(14)->getType());
     $this->assertEquals('Publish_Model_DepositTest_pubmed', $document->getIdentifier(15)->getValue());
     $this->assertEquals('pmid', $document->getIdentifier(15)->getType());
     $this->assertEquals(5, $document->getSeries(0)->getNumber());
     $this->assertEquals(4, $document->getSeries(0)->getModel()->getId());
     $this->assertEquals('title as enrichment', $document->getEnrichment(0)->getValue());
     $document->deletePermanent();
     Opus_EnrichmentKey::fetchbyName('Foo2Title')->delete();
 }
コード例 #13
0
 /**
  * Checks if a model can be modified.
  * @param $model Opus_EnrichmentKey
  * @return bool true if model can be edited and deleted, false if model is protected
  */
 public function isModifiable($model)
 {
     $protectedKeys = $this->_enrichmentKeys->getProtectedEnrichmentKeys();
     return !in_array($model->getId(), array_merge($protectedKeys, Opus_EnrichmentKey::getAllReferenced()));
 }
コード例 #14
0
 public function testNoMigrationToNotes()
 {
     $this->assertNull(Opus_EnrichmentKey::fetchByName('BemExtern'));
 }
コード例 #15
0
 /**
  * @expectedException Opus_Model_NotFoundException
  * @expectedExceptionMessage No Opus_Db_EnrichmentKeys with id CityModified in database.
  */
 public function testEditActionCancelForProtectedEnrichment()
 {
     $this->createsModels = true;
     $enrichmentKey = new Opus_EnrichmentKey();
     $enrichmentKey->setName('MyTestEnrichment');
     $enrichmentKey->store();
     $this->getRequest()->setMethod('POST')->setPost(array('Id' => 'City', 'Name' => 'CityModified', 'Cancel' => 'Abbrechen'));
     $this->dispatch($this->getControllerPath() . '/edit');
     $this->assertRedirectTo($this->getControllerPath());
     $enrichmentKey = new Opus_EnrichmentKey('City');
     $this->assertNotNull($enrichmentKey);
     $this->assertEquals('City', $enrichmentKey->getName());
     new Opus_EnrichmentKey('CityModified');
     $this->fail('Previous statement should have thrown exception.');
 }
コード例 #16
0
function createEnrichmentKey($name)
{
    try {
        $eKey = new Opus_EnrichmentKey();
        $eKey->setName($name)->store();
    } catch (Exception $e) {
    }
    return new Opus_EnrichmentKey($name);
}