Exemplo n.º 1
0
 public function testOptions()
 {
     $element = $this->getElement();
     $grantors = Opus_DnbInstitute::getGrantors();
     $this->assertEquals(count($grantors), count($element->getMultiOptions()));
     $index = 0;
     foreach ($element->getMultiOptions() as $modelId => $label) {
         $this->assertEquals($grantors[$index]->getId(), $modelId);
         $this->assertEquals($grantors[$index]->getDisplayName(), $label);
         $index++;
     }
 }
Exemplo n.º 2
0
 public function init()
 {
     parent::init();
     $this->setRequired(true);
     $this->setDisableTranslator(true);
     // publishing institutions are not translated
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $options = Opus_DnbInstitute::getPublishers();
     foreach ($options as $option) {
         $this->addMultiOption($option->getId(), $option->getDisplayName());
     }
 }
Exemplo n.º 3
0
 public function testPopulateFromModel()
 {
     $form = new Admin_Form_DnbInstitute();
     $model = new Opus_DnbInstitute();
     $model->setName('TestName');
     $model->setDepartment('TestDepartment');
     $model->setAddress('TestAddress');
     $model->setCity('TestCity');
     $model->setPhone('TestPhone');
     $model->setDnbContactId('TestDnbContactId');
     $model->setIsGrantor(true);
     $model->setIsPublisher(false);
     $form->populateFromModel($model);
     $this->assertEquals('TestName', $form->getElement('Name')->getValue());
     $this->assertEquals('TestDepartment', $form->getElement('Department')->getValue());
     $this->assertEquals('TestAddress', $form->getElement('Address')->getValue());
     $this->assertEquals('TestCity', $form->getElement('City')->getValue());
     $this->assertEquals('TestPhone', $form->getElement('Phone')->getValue());
     $this->assertEquals('TestDnbContactId', $form->getElement('DnbContactId')->getValue());
     $this->assertTrue($form->getElement('IsGrantor')->getValue());
     $this->assertEquals('0', $form->getElement('IsPublisher')->getValue());
     $this->assertNull($form->getElement('Id')->getValue());
 }
Exemplo n.º 4
0
 public function testBibtexAttributeSchoolWithDepartment()
 {
     $document = new Opus_Document($this->_documentId);
     $document->setType('masterthesis');
     $institute = new Opus_DnbInstitute();
     $institute->setName('Test Uni');
     $institute->setDepartment('Test Dep');
     $institute->setIsPublisher(true);
     $institute->setCity('Berlin');
     $institute->store();
     $document->addThesisPublisher($institute);
     $document->store();
     $request = $this->getRequest();
     $request->setParam('docId', $this->_documentId);
     $request->setParam('output', 'bibtex');
     $output = $this->_helper->getOutput($request);
     $institute->delete();
     $this->assertContains('school      = {Test Uni, Test Dep},', $output);
 }
// Identifiers
//
$oldOpusId = $doc->addIdentifierOpus3();
$oldOpusId->setValue(randString($counter++));
// empty URN will be automaticaly replace by new URN.
$urn = $doc->addIdentifierUrn();
$urn->setValue('urn:nbn:de:kobv:nn-opus-173:' . randString($counter++));
$isbn = $doc->addIdentifierIsbn();
$isbn->setValue('978-3-86680-192-9');
$issn = $doc->addIdentifierIssn();
$issn->setValue('1234-5678');
$doc->addIdentifierOpac()->setValue(randString($counter++));
//
// DnbInstitutes
//
$dnbInstitute = new Opus_DnbInstitute();
$dnbInstitute->setName(randString($counter++) . rand())->setAddress(randString($counter++))->setCity(randString($counter++))->setPhone(randString($counter++))->setDnbContactId(randString($counter++))->setIsGrantor(1)->store();
$doc->setThesisGrantor($dnbInstitute);
$doc->setThesisPublisher($dnbInstitute);
//
// Subjects
//
$doc->addSubject()->setType('swd')->setValue(randString($counter++));
foreach (array('uncontrolled', 'msc', 'ddc') as $type) {
    $doc->addSubject()->setType($type)->setLanguage(randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("eng" . randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("deu")->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("eng")->setValue(randString($counter++))->setExternalKey(randString($counter++));
}
//
// Notes
Exemplo n.º 6
0
 /**
  * Imports Faculties from Opus3 to Opus4 directly (without XML)
  * Faculty is also a DNB Institute
  *
  * @param DOMDocument $data XML-Document to be imported
  * @return array List of documents that have been imported
  */
 protected function importFaculties($data, $role)
 {
     $mapFaculties = $this->_config->migration->mapping->faculties;
     $fileFaculties = null;
     try {
         $fileFaculties = @fopen($mapFaculties, 'w');
         if (!$fileFaculties) {
             throw new Exception("Could not create '" . $mapFaculties . "' for Faculties.\n");
         }
     } catch (Exception $e) {
         $this->_logger->log($e->getMessage(), Zend_Log::ERR);
         return;
     }
     $mapGrantors = $this->_config->migration->mapping->grantors;
     $fileGrantors = null;
     try {
         $fileGrantors = @fopen($mapGrantors, 'w');
         if (!$fileGrantors) {
             throw new Exception("Could not create '" . $mapGrantors . "' for Grantors.\n");
         }
     } catch (Exception $e) {
         $this->_logger->log($e->getMessage(), Zend_Log::ERR);
         fclose($fileFaculties);
         return;
     }
     $classification = $this->transferOpusClassification($data);
     $subcoll = array();
     foreach ($classification as $class) {
         if (array_key_exists('fakultaet', $class) === false) {
             continue;
         }
         if (array_key_exists('nr', $class) === false) {
             continue;
         }
         /* Create a Collection for Faculty */
         $root = $role->getRootCollection();
         $coll = $root->addLastChild();
         $coll->setName($class['fakultaet']);
         $coll->setVisible(1);
         $root->store();
         $subcoll[$class["nr"]] = $coll->getId();
         /* Create a DNB-Institute for Faculty */
         $fac = new Opus_DnbInstitute();
         $fac->setName($this->uniname);
         /* Changed since Opus 4.4.1: faculty is stored in distinct field 'department'
          * See Issue #OPUSVIER-3041
          */
         $fac->setDepartment($class['fakultaet']);
         $fac->setCity($this->unicity);
         $fac->setIsGrantor('1');
         $fac->store();
         $this->_logger->log("Faculty imported: " . $class['fakultaet'], Zend_Log::DEBUG);
         // echo "Faculty imported: " . $class['fakultaet'] ."\t" . $class['nr'] . "\t" . $subcoll[$class["nr"]]
         // . "\n";
         fputs($fileFaculties, $class['nr'] . ' ' . $subcoll[$class["nr"]] . "\n");
         fputs($fileGrantors, $class['nr'] . ' ' . $fac->getId() . "\n");
     }
     fclose($fileFaculties);
     fclose($fileGrantors);
     return $subcoll;
 }
$isbn = $doc->addIdentifierIsbn();
$isbn->setValue('978-3-86680-192-9');
$issn = $doc->addIdentifierIssn();
$issn->setValue('1234-5678');
$doc->addIdentifierOpac()->setValue('OPAC-ID 001 1237890654');
// Valid Arxiv-Identifier from ArXiv.org Homepage: http://arxiv.org/help/arxiv_identifier
$arxiv = $doc->addIdentifierArxiv();
$arxiv->setValue('arXiv:0706.0001');
// Valid DOI Identifier from DOI Homepage: http://www.doi.org/
$doi = $doc->addIdentifierDoi();
$doi->setValue('10.1000/182');
// Valid Pubmed-Identifier from official Pubmed Tutorial: http://www.nlm.nih.gov/bsd/disted/pubmedtutorial/020_830.html
$pubmed = $doc->addIdentifierPubmed();
$pubmed->setValue('9382368');
$doc->setThesisDateAccepted('2003-02-01');
$dnbInstitute = new Opus_DnbInstitute();
$dnbInstitute->setName('Forschungsinstitut für Code Coverage');
foreach (Opus_DnbInstitute::getGrantors() as $grantor) {
    if ($dnbInstitute->getName() === $grantor->getName()) {
        $dnbInstitute = $grantor;
        break;
    }
}
if (is_null($dnbInstitute->getId()) === true) {
    $dnbInstitute->setCity('Mousetown')->setIsGrantor(1)->store();
}
$doc->setThesisGrantor($dnbInstitute);
$doc->setThesisPublisher($dnbInstitute);
$referee = new Opus_Person();
$referee->setFirstName('Gyro');
$referee->setLastName('Gearloose');
 public function testNewActionCancel()
 {
     $this->createsModels = true;
     $modelCount = count($this->getModels());
     $post = array('Name' => 'TestName', 'City' => 'TestCity', 'Cancel' => 'Abbrechen');
     $this->getRequest()->setPost($post)->setMethod('POST');
     $this->dispatch('/admin/dnbinstitute/new');
     $this->assertRedirectTo('/admin/dnbinstitute', 'Should be a redirect to index action.');
     $this->assertEquals($modelCount, count(Opus_DnbInstitute::getAll()), 'Es sollte keine neue Sprache geben.');
 }
 public function testDnbInstituteFaculty()
 {
     $dnbinst = new Opus_DnbInstitute(2);
     $this->assertEquals('Universität XYZ', $dnbinst->getName());
     $this->assertEquals('Fakultät Test 1', $dnbinst->getDepartment());
     $this->assertNull($dnbinst->getAddress());
     $this->assertEquals($dnbinst->getCity(), 'Ort');
     $this->assertNull($dnbinst->getDnbContactId());
     $this->assertNull($dnbinst->getPhone());
     $this->assertEquals($dnbinst->getIsGrantor(), '1');
     $this->assertEquals($dnbinst->getIsPublisher(), '0');
 }
Exemplo n.º 10
0
 /**
  * Retrieves all available ThesisGrantors or ThesisPublishers in a array.
  * Used for generating a select box.
  *
  * @param $grantors true -> get thesis grantors
  *                  null -> get thesis publishers
  * @return Array of Dnb_Institutes Objects
  */
 private function getThesis($grantors = null)
 {
     $thesises = array();
     if ($grantors === true) {
         $thesises = Opus_DnbInstitute::getGrantors();
     } else {
         if (is_null($grantors)) {
             $thesises = Opus_DnbInstitute::getPublishers();
         }
     }
     if (empty($thesises)) {
         return null;
     }
     $thesisList = array();
     foreach ($thesises as $thesis) {
         $thesisList[$thesis->getId()] = $thesis->getDisplayName();
     }
     return $thesisList;
 }