/**
  */
 public function prepareViewFacets($result, $request)
 {
     $facets = $result->getFacets();
     $facetLimit = Opus_Search_Config::getFacetLimits();
     $facetArray = array();
     $selectedFacets = array();
     $facetNumberContainer = array();
     $showFacetExtender = array();
     foreach ($facets as $key => $facet) {
         $showFacetExtender[$key] = $facetLimit[$key] <= sizeof($facet);
         $this->getLogger()->debug("found {$key} facet in search results");
         $facetNumberContainer[$key] = sizeof($facet);
         $facetValue = $request->getParam($key . 'fq', '');
         if ($facetValue !== '') {
             $selectedFacets[$key] = $facetValue;
             $showFacetExtender[$key] = false;
         }
         if (count($facets[$key]) > 1 || $facetValue !== '') {
             $facetArray[$key] = $facet;
         }
     }
     // Hide institutes facet if collection does not exist or is hidden
     $institutes = Opus_CollectionRole::fetchByName('institutes');
     if (is_null($institutes) || !$institutes->getVisible()) {
         unset($facetArray['institute']);
     }
     $this->_facets = $facetArray;
     $this->_selectedFacets = $selectedFacets;
     $this->_facetNumberContainer = $facetNumberContainer;
     $this->_showFacetExtender = $showFacetExtender;
 }
 public function tearDown()
 {
     $collectionRole = Opus_CollectionRole::fetchByName('NewTestColRoleName');
     if (!is_null($collectionRole)) {
         $collectionRole->delete();
     }
     parent::tearDown();
 }
 public function testNewModelOnCollectionRoleWithoutRoot()
 {
     // In our test data, this role does not have any associated collections.
     $role = Opus_CollectionRole::fetchByName('no-root-test');
     $root = $role->getRootCollection();
     $this->assertNull($root, 'CollectionRole "no-root-test" should not have a root collection.');
     $this->setExpectedException('Remotecontrol_Model_Exception');
     new Remotecontrol_Model_Collection('no-root-test');
 }
 /**
  * Public Method for import of Collections
  *
  * @param void
  * @return void
  *
  */
 public function start()
 {
     $collRole = Opus_CollectionRole::fetchByName('collections');
     $doclist = $this->_data->getElementsByTagName('table_data');
     foreach ($doclist as $document) {
         if ($document->getAttribute('name') === 'collections') {
             $this->importCollectionsDirectly($document, $collRole);
         }
     }
 }
 public function testInstituteStructure()
 {
     $root = Opus_CollectionRole::fetchByName('institutes')->getRootCollection();
     $faculty1 = Opus_Collection::fetchCollectionsByRoleName('1', 'Fakultät Test 1');
     $this->assertEquals($faculty1[0]->getParentNodeId(), $root->getId());
     $faculty2 = Opus_Collection::fetchCollectionsByRoleName('1', 'Fakultät Test 2');
     $this->assertEquals($faculty2[0]->getParentNodeId(), $root->getId());
     $institute1 = Opus_Collection::fetchCollectionsByRoleName('1', 'Institut 1');
     $this->assertEquals($institute1[0]->getParentNodeId(), $faculty1[0]->getId());
     $institute2 = Opus_Collection::fetchCollectionsByRoleName('1', 'Institut 2');
     $this->assertEquals($institute2[0]->getParentNodeId(), $faculty2[0]->getId());
 }
Exemple #6
0
 public function __construct($roleName, $collectionNumber = null)
 {
     $this->_role = Opus_CollectionRole::fetchByName($roleName);
     if (is_null($this->_role)) {
         throw new Remotecontrol_Model_Exception("Model_Collection: Role with name '{$roleName}' not found");
     }
     $root = $this->_role->getRootCollection();
     if (is_null($root)) {
         throw new Remotecontrol_Model_Exception("Model_Collection: Root Collection for role '{$roleName}' does not exist.");
     }
     if (!isset($collectionNumber)) {
         $this->_collection = $root;
     } else {
         $this->_collection = $this->findByNumber($collectionNumber);
     }
 }
 public function testCollectionsHierarchy()
 {
     $root = Opus_CollectionRole::fetchByName('collections')->getRootCollection();
     $top = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'top');
     $this->assertEquals($root->getId(), $top[0]->getParentNodeId());
     $middle1 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'middle1');
     $this->assertEquals($top[0]->getId(), $middle1[0]->getParentNodeId());
     $middle2 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'middle2');
     $this->assertEquals($top[0]->getId(), $middle2[0]->getParentNodeId());
     $middle3 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'middle3');
     $this->assertEquals($top[0]->getId(), $middle3[0]->getParentNodeId());
     $bottom1 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'bottom1');
     $this->assertEquals($middle2[0]->getId(), $bottom1[0]->getParentNodeId());
     $bottom2 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'bottom2');
     $this->assertEquals($middle3[0]->getId(), $bottom2[0]->getParentNodeId());
     $bottom3 = Opus_Collection::fetchCollectionsByRoleName($this->role_id, 'bottom3');
     $this->assertEquals($middle3[0]->getId(), $bottom3[0]->getParentNodeId());
 }
 /**
  * Public Method for import of Institutes
  *
  * @param void
  * @return void
  *
  */
 public function start()
 {
     $role = Opus_CollectionRole::fetchByName('institutes');
     $xml = new DomDocument();
     $xslt = new DomDocument();
     $xslt->load($this->_stylesheetPath);
     $proc = new XSLTProcessor();
     $proc->registerPhpFunctions();
     $proc->importStyleSheet($xslt);
     $xml->loadXML($proc->transformToXml($this->_data));
     $doclist = $xml->getElementsByTagName('table_data');
     foreach ($doclist as $document) {
         if ($document->getAttribute('name') === 'university_de') {
             $this->importUniversities($document);
         }
         if ($document->getAttribute('name') === 'faculty_de') {
             $facNumbers = $this->importFaculties($document, $role);
         }
         if ($document->getAttribute('name') === 'institute_de') {
             $instNumbers = $this->importInstitutes($document, $facNumbers);
         }
     }
 }
 private function create_collection_roles()
 {
     $roles = array("Collections" => array("name" => "collections", "position" => 9));
     foreach ($roles as $r) {
         $role = new Opus_CollectionRole();
         $role->setName($r["name"]);
         $role->setOaiName($r["name"]);
         $role->setPosition($r["position"]);
         $role->setVisible(1);
         $role->setVisibleBrowsingStart(1);
         $role->setDisplayBrowsing('Name');
         $role->setVisibleFrontdoor(1);
         $role->setDisplayFrontdoor('Name');
         $role->setVisibleOai(1);
         $role->setDisplayOai('Name');
         $role->store();
         $root = $role->addRootCollection()->setVisible(1);
         $root->store();
     }
     $role = Opus_CollectionRole::fetchByName('institutes');
     $root = $role->addRootCollection()->setVisible(1);
     $root->store();
 }
 public function testVisibleCollectionRoleDDC()
 {
     $val = new Publish_Model_Validation('Collection', $this->session, 'ddc');
     $collectionRole = Opus_CollectionRole::fetchByName($val->collectionRole);
     $visibleFlag = $collectionRole->getVisible();
     $collectionRole->setVisible(1);
     $collectionRole->store();
     $children = $val->selectOptions('Collection');
     $this->assertInternalType('array', $children);
     $this->assertArrayHasKey('3', $children);
     $collectionRole->setVisible($visibleFlag);
     $collectionRole->store();
 }
 /**
  * Holt CollectionRole mit Identifier.
  * @param $identifier
  * @return Opus_CollectionRole
  */
 protected function _getModel($identifier)
 {
     return Opus_CollectionRole::fetchByName($identifier);
 }
$titleSub = $doc->addTitleSub();
$titleSub->setValue('Beispielhaft erleutert an OPUS 4.0.0');
$titleSub->setLanguage('deu');
$titleAdditional = $doc->addTitleAdditional();
$titleAdditional->setValue('OAI-Schnittstellen empirisch testen am Beispiel von OPUS 4.0');
$titleAdditional->setLanguage('deu');
$titleParent = $doc->addTitleParent();
$titleParent->setValue('Tester interface d\'OAI en OPUS 4.0');
$titleParent->setLanguage('fra');
$doc->setPageNumber('123');
$doc->setPageFirst('122');
$doc->setPageLast('124');
$doc->setVolume('4');
$doc->setIssue('18');
$instituteName = 'Institut für empirische Forschung';
$institutesRole = Opus_CollectionRole::fetchByName('institutes');
if (is_null($institutesRole) === true) {
    $institutesRole = new Opus_CollectionRole();
    $institutesRole->setName('institutes')->setOaiName('institutes')->setPosition(1)->setVisible(1)->setVisibleBrowsingStart(1)->setDisplayBrowsing('Name')->setVisibleFrontdoor(1)->setDisplayFrontdoor('Name')->setVisibleOai('Name')->setDisplayOai('Name')->store();
}
$instituteCollections = Opus_Collection::fetchCollectionsByRoleName($institutesRole->getId(), $instituteName);
if (count($instituteCollections) >= 1) {
    $instituteCollection = $instituteCollections[0];
} else {
    $rootCollection = $institutesRole->getRootCollection();
    if (is_null($rootCollection) === true) {
        $rootCollection = $institutesRole->addRootCollection();
        $rootCollection->setVisible(1)->store();
        $institutesRole->store();
    }
    $instituteCollection = $rootCollection->addLastChild();
Exemple #13
0
 private function mapClassifications()
 {
     $old_bkl = array('name' => 'OldBkl', 'role' => 'bkl');
     $old_ccs = array('name' => 'OldCcs', 'role' => 'ccs');
     $old_ddc = array('name' => 'OldDdc', 'role' => 'ddc');
     $old_jel = array('name' => 'OldJel', 'role' => 'jel');
     $old_msc = array('name' => 'OldMsc', 'role' => 'msc');
     $old_pacs = array('name' => 'OldPacs', 'role' => 'pacs');
     $old_array = array($old_bkl, $old_ccs, $old_ddc, $old_jel, $old_msc, $old_pacs);
     foreach ($old_array as $oa) {
         $elements = $this->document->getElementsByTagName($oa['name']);
         while ($elements->length > 0) {
             $e = $elements->Item(0);
             $value = $e->getAttribute('Value');
             $role = Opus_CollectionRole::fetchByName($oa['role']);
             $colls = Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $value);
             if (count($colls) > 0) {
                 foreach ($colls as $c) {
                     /* TODO: DDC-Hack */
                     if ($oa['role'] === 'ddc' and $c->hasChildren()) {
                         continue;
                     }
                     array_push($this->collections, $c->getId());
                 }
             } else {
                 $this->logger->log("Old ID '" . $this->oldId . "' : Document not added to '" . $oa['role'] . "' '" . $value . "'", Zend_Log::ERR);
             }
             $this->document->removeChild($e);
         }
     }
 }
 /**
  * Checks that hidden collection role has visible = 0.
  */
 public function testRoleInvisible()
 {
     $collectionRole = Opus_CollectionRole::fetchByName('TestCollectionRole-Name');
     $collectionRole->setVisible(0);
     $collectionRole->store();
     $collections = $this->model->getCollectionRolesInfo();
     $this->assertNotNull($collections);
     $this->assertInternalType('array', $collections);
     foreach ($collections as $collection) {
         $this->assertInternalType('array', $collection);
         $this->assertCount(4, $collection);
         $this->assertArrayHasKey('id', $collection);
         $this->assertArrayHasKey('name', $collection);
         $this->assertArrayHasKey('hasChildren', $collection);
         $this->assertArrayHasKey('visible', $collection);
         if (strcmp($collection['name'], 'default_collection_role_TestCollectionRole-Name') === 0) {
             $this->assertEquals(0, $collection['visible']);
         }
     }
 }
Exemple #15
0
 /**
  * Builds institute statistics.
  *
  * Returns sum of published documents sorted by institutes.
  */
 public function getInstituteStatistics($selectedYear)
 {
     $role = Opus_CollectionRole::fetchByName('institutes');
     $instStat = array();
     if (isset($role)) {
         $query = "SELECT c.name name, COUNT(DISTINCT(d.id)) entries\n                 FROM documents d\n                 LEFT JOIN link_documents_collections ldc ON d.id=ldc.document_id\n                 LEFT JOIN collections c ON ldc.collection_id=c.id\n                 WHERE c.role_id=? AND YEAR(server_date_published)=? AND server_state='published'\n                group by name";
         $db = Zend_Registry::get('db_adapter');
         $res = $db->query($query, array($role->getId(), $selectedYear))->fetchAll();
         foreach ($res as $result) {
             $instStat[$result['name']] = $result['entries'];
         }
     }
     return $instStat;
 }
 private function _collectionSelect()
 {
     $collectionRole = Opus_CollectionRole::fetchByName($this->collectionRole);
     if (is_null($collectionRole) || is_null($collectionRole->getRootCollection())) {
         return null;
     }
     if ($collectionRole->getVisible() == '1' && $collectionRole->getRootCollection()->getVisiblePublish() == '1' && $this->hasVisiblePublishChildren($collectionRole)) {
         $children = array();
         $collectionId = $collectionRole->getRootCollection()->getId();
         $collection = new Opus_Collection($collectionId);
         $colls = $collection->getVisiblePublishChildren();
         foreach ($colls as $coll) {
             $children[$coll->getId()] = $coll->getDisplayNameForBrowsingContext($collectionRole);
         }
         return $children;
     }
     return null;
 }
Exemple #17
0
 /**
  * Maps query for publist action.
  */
 public function mapQuery($roleParam, $numberParam)
 {
     if (is_null(Opus_CollectionRole::fetchByName($roleParam))) {
         throw new Application_Exception('specified role does not exist');
     }
     $role = Opus_CollectionRole::fetchByName($roleParam);
     if ($role->getVisible() != '1') {
         throw new Application_Exception('specified role is invisible');
     }
     if (count(Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam)) == 0) {
         throw new Application_Exception('specified number does not exist for specified role');
     }
     $collection = null;
     foreach (Opus_Collection::fetchCollectionsByRoleNumber($role->getId(), $numberParam) as $coll) {
         if ($coll->getVisible() == '1' && is_null($collection)) {
             $collection = $coll;
         }
     }
     if (is_null($collection)) {
         throw new Application_Exception('specified collection is invisible');
     }
     return $collection;
 }
 public function __construct($logfile)
 {
     $this->seriesRole = Opus_CollectionRole::fetchByName('series');
     $this->initLogger($logfile);
 }
    exit(-1);
}
echo "\nmigrating classification subjects -- can take a while";
// Initialize logger.
$logfileName = $argv[1];
$logfile = @fopen($logfileName, 'a', false);
$writer = new Zend_Log_Writer_Stream($logfile);
$formatter = new Zend_Log_Formatter_Simple('%timestamp% %priorityName%: %message%' . PHP_EOL);
$writer->setFormatter($formatter);
$logger = new Zend_Log($writer);
// load collections (and check existence)
$mscRole = Opus_CollectionRole::fetchByName('msc');
if (!is_object($mscRole)) {
    $logger->warn("MSC collection does not exist.  Cannot migrate SubjectMSC.");
}
$ddcRole = Opus_CollectionRole::fetchByName('ddc');
if (!is_object($ddcRole)) {
    $logger->warn("DDC collection does not exist.  Cannot migrate SubjectDDC.");
}
// create enrichment keys (if neccessary)
createEnrichmentKey('MigrateSubjectMSC');
createEnrichmentKey('MigrateSubjectDDC');
// Iterate over all documents.
$docFinder = new Opus_DocumentFinder();
$changedDocumentIds = array();
foreach ($docFinder->ids() as $docId) {
    $doc = null;
    try {
        $doc = new Opus_Document($docId);
    } catch (Opus_Model_NotFoundException $e) {
        continue;