public function testPopulateFromModel()
 {
     $form = new Admin_Form_Collection();
     $model = new Opus_Collection();
     $model->setName('TestName');
     $model->setNumber('50');
     $model->setVisible(1);
     $model->setVisiblePublish(1);
     $model->setOaiSubset('TestSubset');
     $model->setTheme('plain');
     $form->populateFromModel($model);
     $this->assertEquals('TestName', $form->getElement('Name')->getValue());
     $this->assertEquals(50, $form->getElement('Number')->getValue());
     $this->assertEquals(1, $form->getElement('Visible')->getValue());
     $this->assertEquals(1, $form->getElement('VisiblePublish')->getValue());
     $this->assertEquals('TestSubset', $form->getElement('OaiSubset')->getValue());
     $this->assertEquals('plain', $form->getElement('Theme')->getValue());
 }
Beispiel #2
0
    echo "Error: collection with id {$parent_collection_id} does not exist\n";
    exit;
}
if (!is_null($root_collection)) {
    $line_count = 0;
    $lines_imported = 0;
    foreach (file($input_file) as $line) {
        $line_count++;
        if (trim($line) === '') {
            continue;
        }
        $parts = explode('|', $line);
        if (count($parts) > 2) {
            echo "Warning: ignore line number {$line_count} (more than one | character exists): {$line}\n";
            continue;
        }
        if (count($parts) < 2) {
            echo "Warning: ignore line number {$line_count} (| character does not exist): {$line}\n";
            continue;
        }
        $collection = new Opus_Collection();
        $collection->setName(trim($parts[0]));
        $collection->setNumber(trim($parts[1]));
        $collection->setVisible($visible);
        $root_collection->addLastChild($collection);
        $root_collection->store();
        $lines_imported++;
    }
    echo "{$lines_imported} collections were successfully imported\n";
}
exit;
Beispiel #3
0
 /**
  * Imports metadata from an XML-Document
  *
  * @param DOMDocument $data XML-Document to be imported
  * @return array information about the document that has been imported
  */
 public function import($document)
 {
     $this->collections = array();
     $this->values = array();
     $this->series = array();
     $this->personSortOrder = array();
     $this->document = $document;
     $this->oldId = $this->document->getElementsByTagName('IdentifierOpus3')->Item(0)->getAttribute('Value');
     $this->skipEmptyFields();
     $this->validatePersonSubmitterEmail();
     $this->checkTitleMainAbstractForDuplicateLanguage();
     $this->checkTitleAdditional();
     $this->mapDocumentTypeAndLanguage();
     $this->mapElementLanguage();
     $this->mapClassifications();
     $this->mapCollections();
     $this->mapValues();
     $this->getSortOrder();
     $this->createNewEnrichmentKeys();
     $imported = array();
     $doc = null;
     try {
         $doc = Opus_Document::fromXml('<Opus>' . $this->completeXML->saveXML($this->document) . '</Opus>');
         // ThesisGrantor and ThesisPublisher only for Thesis-Documents
         if (in_array($doc->getType(), $this->thesistypes)) {
             if (array_key_exists('grantor', $this->values)) {
                 $dnbGrantor = new Opus_DnbInstitute($this->values['grantor']);
                 $doc->setThesisGrantor($dnbGrantor);
             }
             if (array_key_exists('publisherUniversity', $this->values)) {
                 $dnbPublisher = new Opus_DnbInstitute($this->values['publisherUniversity']);
                 $doc->setThesisPublisher($dnbPublisher);
             }
         }
         if (array_key_exists('licence', $this->values)) {
             $doc->addLicence(new Opus_Licence($this->values['licence']));
         }
         // TODO Opus4.x : Handle SortOrder via Opus_Document_Model
         foreach ($doc->getPersonAuthor() as $a) {
             $lastname = $a->getLastName();
             $firstname = $a->getFirstName();
             $sortorder = $this->personSortOrder[$lastname . "," . $firstname];
             $a->setSortOrder($sortorder);
         }
         foreach ($this->collections as $c) {
             $coll = new Opus_Collection($c);
             $coll->setVisible(1);
             $coll->store();
             $doc->addCollection($coll);
         }
         foreach ($this->series as $s) {
             $series = new Opus_Series($s[0]);
             $doc->addSeries($series)->setNumber($s[1]);
         }
         //$this->logger->log("(3):".$this->completeXML->saveXML($this->document), Zend_Log::DEBUG);
         $doc->store();
         $imported['result'] = 'success';
         $imported['oldid'] = $this->oldId;
         $imported['newid'] = $doc->getId();
         if (array_key_exists('role', $this->values)) {
             $imported['roleid'] = $this->values['role'];
             //$this->logger->log("ROLE_ID'" . $this->values['roleid'] . "', Zend_Log::DEBUG);
         }
     } catch (Exception $e) {
         $imported['result'] = 'failure';
         $imported['message'] = $e->getMessage();
         if (!is_null($doc)) {
             $imported['entry'] = $doc->toXml()->saveXML();
         } else {
             $imported['entry'] = $this->completeXML->saveXML($this->document);
         }
         $imported['oldid'] = $this->oldId;
     }
     unset($this->collections);
     unset($this->series);
     unset($this->values);
     unset($this->document);
     unset($this->oldId);
     return $imported;
 }
 /**
  * Wenn eine übergeordnete Collection (z.B. die Root-Collection) für das Attribut visiblePublish = false gesetzt ist,
  * sollen die Kinder auch unsichtbar sein im Publish-Modul.
  */
 public function testRootCollectionFieldVisiblePublish()
 {
     $collectionRole = new Opus_CollectionRole();
     $collectionRole->setName("test");
     $collectionRole->setOaiName("test");
     $collectionRole->setDisplayBrowsing("Name");
     $collectionRole->setDisplayFrontdoor("Name");
     $collectionRole->setDisplayOai("Name");
     $collectionRole->setPosition(101);
     $collectionRole->setVisible(true);
     $collectionRole->store();
     $rootCollection = $collectionRole->addRootCollection();
     $rootCollection->setName("rootInvisible");
     $rootCollection->setVisible(true);
     $rootCollection->setVisiblePublish(false);
     $rootCollection->store();
     $visibleCollection = new Opus_Collection();
     $visibleCollection->setName("visible collection");
     $visibleCollection->setNumber("123");
     $visibleCollection->setVisible(true);
     $visibleCollection->setVisiblePublish(true);
     $rootCollection->addFirstChild($visibleCollection);
     $visibleCollection->store();
     $invisibleCollection = new Opus_Collection();
     $invisibleCollection->setName("collection to invisible root collection");
     $invisibleCollection->setNumber("123");
     $invisibleCollection->setVisible(true);
     $invisibleCollection->setVisiblePublish(false);
     $rootCollection->addFirstChild($invisibleCollection);
     $invisibleCollection->store();
     $childCollection = new Opus_Collection();
     $childCollection->setName("collection child");
     $childCollection->setNumber("123");
     $childCollection->setVisible(true);
     $childCollection->setVisiblePublish(true);
     $invisibleCollection->addFirstChild($childCollection);
     $childCollection->store();
     $val = new Publish_Model_Validation('Collection', $this->session, 'test');
     $children = $val->selectOptions('Collection');
     // clean-up
     $collectionRole->delete();
     $this->assertEquals(0, count($children), "root collection should be invisible in publish");
 }