public function appendChild($number, $title) { $collections = Opus_Collection::fetchCollectionsByRoleNumber($this->_role->getId(), $number); if (count($collections) > 0) { throw new Remotecontrol_Model_Exception("Model_Collection: Collection with number '{$number}' already exists."); } $newChild = $this->_collection->addLastChild(); $newChild->setNumber($number)->setName($title)->setVisible(1)->store(); return $newChild; }
public function testCollectionMsc() { $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '51H10'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '90B06'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '90B90'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); $msc_collections = Opus_Collection::fetchCollectionsByRoleNumber('6', '05D99'); $this->assertTrue($msc_collections[0]->holdsDocumentById($this->doc->getId())); }
public function testCollectionPacs() { $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '82.56.-b'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '84.60.-h'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '78.20.-e'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); $pacs_collections = Opus_Collection::fetchCollectionsByRoleNumber('4', '42.70.-a'); $this->assertTrue($pacs_collections[0]->holdsDocumentById($this->doc->getId())); }
public function testCollectionJel() { $this->markTestIncomplete(); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'P31'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'H20'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'I2'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); $jel_collections = Opus_Collection::fetchCollectionsByRoleNumber('5', 'F21'); $this->assertTrue($jel_collections[0]->holdsDocumentById($this->doc->getId())); }
public function testCollectionCcs() { $this->markTestIncomplete(); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'K.6.0'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'UP 7500'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'D.2.12'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'I.2.10'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); $ccs_collections = Opus_Collection::fetchCollectionsByRoleNumber('3', 'E.1'); $this->assertTrue($ccs_collections[0]->holdsDocumentById($this->doc->getId())); }
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); } } }
/** * 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; }
function migrateSubjectToCollection($doc, $subjectType, $roleId, $eKeyName) { global $logger; $logPrefix = sprintf("[docId % 5d] ", $doc->getId()); $keepSubjects = array(); $removeSubjects = array(); foreach ($doc->getSubject() as $subject) { $keepSubjects[$subject->getId()] = $subject; $type = $subject->getType(); $value = $subject->getValue(); if ($type !== $subjectType) { // $logger->debug("$logPrefix Skipping subject (type '$type', value '$value')"); continue; } // From now on, every subject will be migrated $keepSubjects[$subject->getId()] = false; $removeSubjects[] = $subject; // check if (unique) collection for subject value exists $collections = Opus_Collection::fetchCollectionsByRoleNumber($roleId, $value); if (!is_array($collections) or count($collections) < 1) { $logger->warn("{$logPrefix} No collection found for value '{$value}' -- migrating to enrichment {$eKeyName}."); // migrate subject to enrichments $doc->addEnrichment()->setKeyName($eKeyName)->setValue($value); continue; } if (count($collections) > 1) { $logger->warn("{$logPrefix} Ambiguous collections for value '{$value}' -- migrating to enrichment {$eKeyName}."); // migrate subject to enrichments $doc->addEnrichment()->setKeyName($eKeyName)->setValue($value); continue; } $collection = $collections[0]; if ($collection->isRoot()) { $logger->warn("{$logPrefix} No non-root collection found for value '{$value}' -- migrating to enrichment {$eKeyName}."); // migrate subject to enrichments $doc->addEnrichment()->setKeyName($eKeyName)->setValue($value); continue; } $collectionId = $collection->getId(); // check if document already belongs to this collection if (checkDocumentHasCollectionId($doc, $collectionId)) { // nothing to do $logger->info("{$logPrefix} Migrating subject (type '{$type}', value '{$value}') -- collection already assigned to collection {$collectionId}."); continue; } // migrate subject to collections $logger->info("{$logPrefix} Migrating subject (type '{$type}', value '{$value}') to collection {$collectionId}."); $doc->addCollection($collection); } if (count($removeSubjects) > 0) { // debug: removees foreach ($removeSubjects as $r) { $logger->debug("{$logPrefix} Removing subject (type '" . $r->getType() . "', value '" . $r->getValue() . "')"); } $newSubjects = array_filter(array_values($keepSubjects)); foreach ($newSubjects as $k) { $logger->debug("{$logPrefix} Keeping subject (type '" . $k->getType() . "', value '" . $k->getValue() . "')"); } $doc->setSubject($newSubjects); } return $removeSubjects; }
public function testCollectionDdc() { $ddc_collections = Opus_Collection::fetchCollectionsByRoleNumber('2', '000'); $this->assertTrue($ddc_collections[0]->holdsDocumentById($this->doc->getId())); }