public function createAction() { if (!$this->getRequest()->isPost()) { return $this->_redirectToAndExit('index', '', 'collectionroles'); } $data = $this->getRequest()->getPost(); $collectionModel = new Admin_Model_Collection($this->getRequest()->getParam('oid')); $collection = $collectionModel->getObject(); $form = new Admin_Form_Collection(); if (!$form->isValid($data)) { if ($collection->isNewRecord()) { $form->setAction($this->view->url(array('action' => 'create', 'id' => $this->getRequest()->getParam('id'), 'type' => $this->getRequest()->getParam('type')))); $this->view->title = 'admin_collections_collection_new'; } else { $form->setAction($this->view->url(array('action' => 'create', 'oid' => $collection->getId(), 'id' => $this->getRequest()->getParam('id'), 'type' => $this->getRequest()->getParam('type')))); $this->view->title = 'admin_collections_collection_edit'; } $form->populate($data); $this->view->form = $form; return; } $form->updateModel($collection); if (true === $collection->isNewRecord()) { $id = $this->getRequest()->getParam('id'); if (is_null($id)) { return $this->_redirectToAndExit('index', array('failure' => 'id parameter is missing'), 'collectionroles'); } $type = $this->getRequest()->getParam('type'); if (is_null($type)) { return $this->_redirectToAndExit('index', array('failure' => 'type parameter is missing'), 'collectionroles'); } switch ($type) { case 'child': $refCollection = new Opus_Collection($id); $refCollection->addFirstChild($collection); $refCollection->store(); $message = $this->view->translate('admin_collections_add', $collectionModel->getName()); break; case 'sibling': $refCollection = new Opus_Collection($id); $refCollection->addNextSibling($collection); $refCollection->store(); $message = $this->view->translate('admin_collections_add', $collectionModel->getName()); break; default: return $this->_redirectToAndExit('index', array('failure' => 'type paramter invalid'), 'collectionroles'); } return $this->_redirectTo('show', $message, 'collection', 'admin', array('id' => $collection->getId())); } // nur Ă„nderungen $collection->store(); $message = $this->view->translate('admin_collections_edit', $collectionModel->getName()); $parents = $collection->getParents(); if (count($parents) === 1) { return $this->_redirectTo('show', $message, 'collection', 'admin', array('id' => $collection->getRoleId())); } return $this->_redirectTo('show', $message, 'collection', 'admin', array('id' => $parents[1]->getId())); }
/** * Imports Institutes from Opus3 to Opus4 directly (without XML) * * @param DOMDocument $data XML-Document to be imported * @return array List of documents that have been imported */ protected function importInstitutes($data, $pColls) { $mf = $this->_config->migration->mapping->institutes; $fp = null; try { $fp = @fopen($mf, 'w'); if (!$fp) { throw new Exception("ERROR Opus3InstituteImport: Could not create '" . $mf . "' for Institutes.\n"); } } catch (Exception $e) { $this->_logger->log($e->getMessage(), Zend_Log::ERR); return; } $classification = $this->transferOpusClassification($data); foreach ($classification as $class) { if (array_key_exists('fakultaet', $class) === false || array_key_exists('name', $class) === false || array_key_exists('nr', $class) === false) { $invalidInstitute = ''; foreach ($class as $key => $val) { $invalidInstitute .= "[{$key}:'{$val}'] "; } $this->_logger->log("Invalid entry for Institute will be ignored: '" . $invalidInstitute, Zend_Log::ERR); continue; } if (array_key_exists($class['fakultaet'], $pColls) === false) { $this->_logger->log("No Faculty with ID '" . $class['fakultaet'] . "' for Institute with ID '" . $class['nr'] . "'", Zend_Log::ERR); continue; } /* Create a Collection for Institute */ $root = new Opus_Collection($pColls[$class['fakultaet']]); $coll = $root->addLastChild(); $coll->setName($class['name']); $coll->setVisible(1); $root->store(); $this->_logger->log("Institute imported: " . $class['name'], Zend_Log::DEBUG); fputs($fp, $class['nr'] . ' ' . $coll->getId() . "\n"); } fclose($fp); }
$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(); if (!is_null($rootCollection)) { $line_count = 0; $lines_imported = 0; foreach (file($input_file) as $line) { $line_count++; if (trim($line) === '') { continue; } $parts = explode($fieldSeparator, $line); if (count($parts) > 2) { echo "Warning: ignore line number {$line_count} (more than one field separating character exists): {$line}\n"; continue; } if (count($parts) < 2) { echo "Warning: ignore line number {$line_count} (field separating character does not exist): {$line}\n";
/** * 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; }
/** * Store root collection: Initialize Node. * * @param Opus_Collection $collection Collection to store as Root. * * @see Opus_Model_AbstractDb */ public function _storeRootCollection($collection) { if (!isset($collection)) { return; } if ($collection->isNewRecord()) { $collection->setPositionKey('Root'); $collection->setRoleId($this->getId()); } $collection->store(); }