Ejemplo n.º 1
0
 /**
  * Returns true if the given collection role has at least one associated document
  * in server_state published.
  *
  * @param Opus_CollectionRole $collectionRole
  * @return bool
  */
 private function hasPublishedDocs($collectionRole)
 {
     $rootCollection = $collectionRole->getRootCollection();
     if (is_null($rootCollection)) {
         return false;
     }
     $publishedDocIDs = $rootCollection->getPublishedDocumentIds();
     return is_array($publishedDocIDs) && !empty($publishedDocIDs);
 }
 public function testGetModel()
 {
     $collectionRole = new Opus_CollectionRole();
     $collectionRole->setName('NewTestColRoleName');
     $collectionRole->setOaiName('NewTestColRoleOaiName');
     $collectionRole->store();
     $method = new ReflectionMethod('Application_Form_Validate_CollectionRoleOaiNameUnique', '_getModel');
     $method->setAccessible(true);
     $model = $method->invoke($this->validator, array('NewTestColRoleOaiName'));
     $this->assertNotNull($model);
     $this->assertEquals('NewTestColRoleOaiName', $model->getOaiName());
 }
Ejemplo n.º 3
0
 /**
  */
 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;
 }
Ejemplo n.º 4
0
 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');
 }
Ejemplo n.º 5
0
 public function testOptions()
 {
     $element = $this->getElement();
     $options = $element->getMultiOptions();
     $collectionRoles = Opus_CollectionRole::fetchAll();
     // One additional option for last position
     $this->assertEquals(count($collectionRoles) + 1, count($options));
     $this->assertEquals('admin_collectionroles_last_position', array_pop($options));
 }
Ejemplo n.º 6
0
 /**
  * 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);
         }
     }
 }
 /**
  * Zeigt Formular für das Editieren einer CollectionRole.
  */
 public function editAction()
 {
     Opus_CollectionRole::fixPositions();
     try {
         $collectionRoleModel = new Admin_Model_CollectionRole($this->getRequest()->getParam('roleid', ''));
         $this->view->form = $this->getRoleForm($collectionRoleModel->getObject());
         $this->setCollectionBreadcrumb('default_collection_role_' . $collectionRoleModel->getObject()->getName());
     } catch (Application_Exception $e) {
         return $this->_redirectToAndExit('index', array('failure' => $e->getMessage()));
     }
 }
Ejemplo n.º 8
0
 public function init()
 {
     parent::init();
     $allCollectionRoles = Opus_CollectionRole::fetchAll();
     $translator = Zend_Registry::get('Zend_Translate');
     foreach ($allCollectionRoles as $collectionRole) {
         $position = $collectionRole->getPosition();
         $this->addMultiOption($position, $position . ' - ' . $translator->translate('default_collection_role_' . $collectionRole->getDisplayName()));
     }
     $this->addMultiOption(count($allCollectionRoles) + 1, 'admin_collectionroles_last_position');
 }
 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());
 }
Ejemplo n.º 10
0
 /**
  * Returns array with information about collection roles.
  * @return array
  *
  * TODO using view in action helper is not best design
  */
 public function getCollectionRolesInfo()
 {
     $collections = array();
     $collectionRoles = Opus_CollectionRole::fetchAll();
     foreach ($collectionRoles as $collectionRole) {
         $rootCollection = $collectionRole->getRootCollection();
         if (!is_null($rootCollection)) {
             array_push($collections, array('id' => $rootCollection->getId(), 'name' => $this->view->translate('default_collection_role_' . $collectionRole->getDisplayName()), 'hasChildren' => $rootCollection->hasChildren(), 'visible' => $collectionRole->getVisible()));
         }
     }
     return $collections;
 }
Ejemplo n.º 11
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());
 }
Ejemplo n.º 13
0
 /**
  * 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);
         }
     }
 }
Ejemplo n.º 14
0
 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();
 }
Ejemplo n.º 15
0
 public function __construct($collectionId)
 {
     if (is_null($collectionId)) {
         throw new Solrsearch_Model_Exception('Could not browse collection due to missing id parameter.');
     }
     $collection = null;
     try {
         $collection = new Opus_Collection((int) $collectionId);
     } catch (Opus_Model_NotFoundException $e) {
         throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' does not exist.");
     }
     // check if an unvisible collection exists along the path to the root collection
     foreach ($collection->getParents() as $parent) {
         if (!$parent->isRoot() && $parent->getVisible() !== '1') {
             throw new Solrsearch_Model_Exception("Collection with id '" . $collectionId . "' is not visible.");
         }
     }
     $collectionRole = null;
     try {
         $collectionRole = new Opus_CollectionRole($collection->getRoleId());
     } catch (Opus_Model_NotFoundException $e) {
         throw new Solrsearch_Model_Exception("Collection role with id '" . $collection->getRoleId() . "' does not exist.");
     }
     if (!($collectionRole->getVisible() === '1' && $collectionRole->getVisibleBrowsingStart() === '1')) {
         throw new Solrsearch_Model_Exception("Collection role with id '" . $collectionRole->getId() . "' is not visible.");
     }
     // additional root collection check
     $rootCollection = $collectionRole->getRootCollection();
     if (!is_null($rootCollection)) {
         // check if at least one visible child exists or current collection has at least one associated document
         if (!$rootCollection->hasVisibleChildren() && count($rootCollection->getPublishedDocumentIds()) == 0) {
             throw new Solrsearch_Model_Exception("Collection role with id '" . $collectionRole->getId() . "' is not clickable and therefore not displayed.");
         }
     }
     $this->_collectionRole = $collectionRole;
     $this->_collection = $collection;
 }
Ejemplo n.º 16
0
$fieldSeparator = '	';
if (!file_exists($input_file)) {
    echo "Error: input file {$input_file} does not exist\n";
    exit;
}
if (!is_readable($input_file)) {
    echo "Error: input file {$input_file} is not readable\n";
    exit;
}
// find next valid position for collection role
$table = Opus_Db_TableGateway::getInstance(Opus_CollectionRole::getTableGatewayClass());
$select = $table->select()->from($table, array('MAX(position) AS max_position'));
$row = $table->fetchRow($select);
$position = $row->max_position + 1;
// create root collection
$collectionRole = new Opus_CollectionRole();
$collectionRole->setPosition($position);
$collectionRole->setName('ddc_dnb');
$collectionRole->setOaiName('ddc_dnb');
$collectionRole->setVisible(true);
$collectionRole->setVisibleBrowsingStart(true);
$collectionRole->setDisplayBrowsing('Number,Name');
$collectionRole->setDisplayFrontdoor('Number,Name');
$collectionRole->setVisibleFrontdoor(true);
$collectionRole->setVisibleOai(true);
$collectionRoleId = $collectionRole->store();
$rootCollection = new Opus_Collection();
$rootCollection->setPositionKey('Root');
$rootCollection->setVisible(true);
$rootCollection->setRoleId($collectionRoleId);
$rootCollection->store();
 public function showAction()
 {
     $roleId = $this->getRequest()->getParam('role');
     $id = null;
     if (!is_null($roleId)) {
         $collectionRole = new Opus_CollectionRole($roleId);
         $rootCollection = $collectionRole->getRootCollection();
         if (is_null($rootCollection)) {
             // collection role without root collection: create a new root collection
             $rootCollection = $collectionRole->addRootCollection();
             $collectionRole->store();
         }
         $id = $rootCollection->getId();
     } else {
         $id = $this->getRequest()->getParam('id', '');
     }
     $collectionModel = null;
     try {
         $collectionModel = new Admin_Model_Collection($id);
     } catch (Application_Exception $e) {
         $this->_redirectToAndExit('index', array('failure' => $e->getMessage()), 'collectionroles');
         return;
     }
     $collection = $collectionModel->getObject();
     $this->view->breadcrumb = array_reverse($collection->getParents());
     $this->view->collections = $collection->getChildren();
     $this->view->collection_id = $collection->getId();
     $role = $collection->getRole();
     $this->view->role_id = $role->getId();
     $this->view->role_name = $role->getDisplayName();
     $this->setCollectionBreadcrumb($role);
 }
$contributor->setFirstName('Jeff' . randString($counter++));
$contributor->setLastName('Smart' . randString($counter++));
$contributor->store();
$doc->addPersonContributor($contributor);
//
// Titles
//
foreach (array('addTitleMain', 'addTitleAbstract', 'addTitleParent', 'addTitleSub', 'addTitleAdditional') as $titleMethod) {
    $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage(randString($counter++));
    $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage('deu');
    $doc->{$titleMethod}()->setValue(randString($counter++))->setLanguage('eng');
}
//
// Collections
//
$institutesRole = new Opus_CollectionRole();
$institutesRole->setName('institutes' . randString($counter++) . rand())->setOaiName('institutes' . randString($counter++) . rand())->setPosition(1)->setVisible(1)->setVisibleBrowsingStart(1)->setDisplayBrowsing('Name')->setVisibleFrontdoor(1)->setDisplayFrontdoor('Name')->setVisibleOai('Name')->setDisplayOai('Name')->store();
$instituteName = 'Institut für empirische Forschung ' . randString($counter++);
$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();
    $instituteCollection->setVisible(1)->setName(randString($counter++))->store();
}
Ejemplo n.º 19
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;
 }
Ejemplo n.º 20
0
 /**
  * Regression test for OPUSVIER-2564
  */
 public function testForInvalidSetSpecsInGetRecord79()
 {
     $collectionRole = Opus_CollectionRole::fetchByOaiName('pacs');
     $this->assertNotNull($collectionRole);
     $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:07.75.+h'));
     $this->assertContains(79, $collectionRole->getDocumentIdsInSet('pacs:85.85.+j'));
     $this->dispatch('/oai?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:opus4.demo:79');
     $body = $this->getResponse()->getBody();
     $this->assertContains('<setSpec>pacs:07.07.Df</setSpec>', $body);
     $this->assertContains(':79</identifier>', $body);
     // Regression test for OPUSVIER-2564: invalid SetSpec characters
     $this->assertNotContains('<setSpec>pacs:07.75.', $body);
     $this->assertNotContains('<setSpec>pacs:85.85.', $body);
 }
Ejemplo n.º 21
0
 /**
  * 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");
 }
Ejemplo n.º 22
0
 /**
  * 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']);
         }
     }
 }
Ejemplo n.º 23
0
 public function setCurrentCollectionId($setRoot = false)
 {
     if (!$setRoot) {
         $collectionRole = Opus_CollectionRole::fetchByOaiName($this->collectionRole);
         if (!is_null($collectionRole)) {
             $rootCollection = $collectionRole->getRootCollection();
             if (!is_null($rootCollection)) {
                 $collectionId = $rootCollection->getId();
                 $this->log->debug("CollectionRoot: " . $this->collectionRole . " * CollectionId: " . $collectionId);
                 $this->collectionId = $collectionId;
             }
         }
     }
 }
Ejemplo n.º 24
0
 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;
 }
Ejemplo n.º 25
0
 /**
  * Bereitet die Einstiegseite für das Zuweisen von einer Collection zu einem Dokument vor.
  * 
  * Auf der Einstiegsseite werden die CollectionRoles mit Root-Collections aufgelistet. Da ein Dokument nur einer
  * Collection zugewiesen werden kann wird die Sichtbarkeit der Root-Collection als Kriterium für die Markierung
  * als sichtbare oder unsichtbare Collection verwendet.
  * 
  * @param int $documentId
  */
 private function prepareAssignStartPage($documentId)
 {
     $collectionRoles = Opus_CollectionRole::fetchAll();
     $this->view->collections = array();
     foreach ($collectionRoles as $collectionRole) {
         $rootCollection = $collectionRole->getRootCollection();
         if (!is_null($rootCollection)) {
             array_push($this->view->collections, array('id' => $rootCollection->getId(), 'name' => $this->view->translate('default_collection_role_' . $collectionRole->getDisplayName()), 'hasChildren' => $rootCollection->hasChildren(), 'visible' => $rootCollection->getVisible()));
         }
     }
     $this->view->documentId = $documentId;
     $this->view->breadcrumb = array();
     $this->view->role_name = $collectionRole->getDisplayName();
 }
Ejemplo n.º 26
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);
         }
     }
 }
Ejemplo n.º 27
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;
 }
Ejemplo n.º 28
0
 /**
  * Implements response for OAI-PMH verb 'ListSets'.
  *
  * @param  array &$oaiRequest Contains full request information
  * @return void
  */
 private function __handleListSets()
 {
     $repIdentifier = $this->_configuration->getRepositoryIdentifier();
     $this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
     $this->_xml->appendChild($this->_xml->createElement('Documents'));
     $sets = array('bibliography:true' => 'Set for bibliographic entries', 'bibliography:false' => 'Set for non-bibliographic entries');
     $logger = $this->getLogger();
     $setSpecPattern = '[A-Za-z0-9\\-_\\.!~\\*\'\\(\\)]+';
     $finder = new Opus_DocumentFinder();
     $finder->setServerState('published');
     foreach ($finder->groupedTypesPlusCount() as $doctype => $row) {
         if (0 == preg_match("/^{$setSpecPattern}\$/", $doctype)) {
             $msg = "Invalid SetSpec (doctype='" . $doctype . "')." . " Allowed characters are [{$setSpecPattern}].";
             $logger->err("OAI-PMH: {$msg}");
             continue;
         }
         $setSpec = 'doc-type:' . $doctype;
         // $count = $row['count'];
         $sets[$setSpec] = "Set for document type '{$doctype}'";
     }
     $oaiRolesSets = Opus_CollectionRole::fetchAllOaiEnabledRoles();
     foreach ($oaiRolesSets as $result) {
         if ($result['oai_name'] == 'doc-type') {
             continue;
         }
         if (0 == preg_match("/^{$setSpecPattern}\$/", $result['oai_name'])) {
             $msg = "Invalid SetSpec (oai_name='" . $result['oai_name'] . "'). " . " Please check collection role " . $result['id'] . ". " . " Allowed characters are {$setSpecPattern}.";
             $logger->err("OAI-PMH: {$msg}");
             continue;
         }
         $setSpec = $result['oai_name'];
         // $count = $result['count'];
         $sets[$setSpec] = "Set for collection '" . $result['oai_name'] . "'";
         $role = new Opus_CollectionRole($result['id']);
         foreach ($role->getOaiSetNames() as $subset) {
             $subSetSpec = "{$setSpec}:" . $subset['oai_subset'];
             // $subSetCount = $subset['count'];
             if (0 == preg_match("/^{$setSpecPattern}\$/", $subset['oai_subset'])) {
                 $msg = "Invalid SetSpec (oai_name='" . $subset['oai_subset'] . "')." . " Please check collection " . $subset['id'] . ". " . " Allowed characters are [{$setSpecPattern}].";
                 $logger->err("OAI-PMH: {$msg}");
                 continue;
             }
             $sets[$subSetSpec] = "Subset '" . $subset['oai_subset'] . "'" . " for collection '" . $result['oai_name'] . "'" . ': "' . trim($subset['name']) . '"';
         }
     }
     foreach ($sets as $type => $name) {
         $opusDoc = $this->_xml->createElement('Opus_Sets');
         $typeAttr = $this->_xml->createAttribute('Type');
         $typeValue = $this->_xml->createTextNode($type);
         $typeAttr->appendChild($typeValue);
         $opusDoc->appendChild($typeAttr);
         $nameAttr = $this->_xml->createAttribute('TypeName');
         $nameValue = $this->_xml->createTextNode($name);
         $nameAttr->appendChild($nameValue);
         $opusDoc->appendChild($nameAttr);
         $this->_xml->documentElement->appendChild($opusDoc);
     }
 }
Ejemplo n.º 29
0
 public function __construct($logfile)
 {
     $this->seriesRole = Opus_CollectionRole::fetchByName('series');
     $this->initLogger($logfile);
 }
 /**
  * Holt CollectionRole mit Identifier.
  * @param $identifier
  * @return Opus_CollectionRole
  */
 protected function _getModel($identifier)
 {
     return Opus_CollectionRole::fetchByName($identifier);
 }