コード例 #1
0
ファイル: XmlCache.php プロジェクト: alexukua/opus4
 /**
  * Function is only called if document was modified.
  *
  * @see {Opus_Model_Plugin_Interface::postStore}
  */
 public function postStore(Opus_Model_AbstractDb $model)
 {
     $logger = Zend_Registry::get('Zend_Log');
     if (null !== $logger) {
         $logger->debug('Opus_Document_Plugin_XmlCache::postStore() with id ' . $model->getId());
     }
     // TODO can that be eleminated? why is it necessary?
     $model = new Opus_Document($model->getId());
     $cache = new Opus_Model_Xml_Cache();
     $omx = new Opus_Model_Xml();
     // remove document from cache. This can always be done, because postStore is only called if model was modified.
     $cache->removeAllEntriesWhereDocumentId($model->getId());
     // refresh cache (TODO does it make sense?)
     $omx->setStrategy(new Opus_Model_Xml_Version1())->excludeEmptyFields()->setModel($model)->setXmlCache($cache);
     $dom = $omx->getDomDocument();
     // Skip caching of XML-Version2.
     // TODO why?
     $index_version_two = false;
     if ($index_version_two) {
         // xml version 2
         $omx = new Opus_Model_Xml();
         $omx->setStrategy(new Opus_Model_Xml_Version2())->setModel($model)->setXmlCache($cache);
         $dom = $omx->getDomDocument();
     }
 }
コード例 #2
0
ファイル: Document.php プロジェクト: belapp/opus4-application
 /**
  * @return boolean
  */
 private function checkPermission()
 {
     if ($this->_document->getServerState() === 'published') {
         return true;
     }
     $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl');
     return Opus_Security_Realm::getInstance()->checkDocument($this->_document->getId()) || $accessControl->accessAllowed('documents');
 }
コード例 #3
0
ファイル: DocumentAdapter.php プロジェクト: alexukua/opus4
 /**
  * Constructs wrapper around document.
  * @param Zend_View $view
  * @param int $id
  */
 public function __construct($view, $value)
 {
     $this->view = $view;
     if ($value instanceof Opus_Document) {
         $this->document = $value;
         $this->docId = $this->document->getId();
     } else {
         $this->docId = $value;
         $this->document = new Opus_Document((int) $value);
     }
 }
コード例 #4
0
 public function testGetModel()
 {
     $form = new Admin_Form_Document_Institute(Admin_Form_Document_Institute::ROLE_PUBLISHER);
     $doc = new Opus_Document(146);
     $publishers = $doc->getThesisPublisher();
     $publisher = $publishers[0];
     $publisherId = $publisher->getModel()->getId();
     $form->getElement('Id')->setValue($doc->getId());
     $form->getElement('Institute')->setValue($publisherId);
     $model = $form->getModel();
     $modelId = $model->getId();
     $this->assertNotNull($model);
     $this->assertNotNull($modelId);
     $this->assertEquals($doc->getId(), $modelId[0]);
     $this->assertEquals($publisherId, $modelId[1]);
     $this->assertEquals('publisher', $modelId[2]);
     $this->assertEquals($publisherId, $model->getModel()->getId());
 }
コード例 #5
0
 public function testIndexActionOnNonExistent()
 {
     $doc_id = $this->_document->getId();
     $this->dispatch('/frontdoor/index/index/docId/' . $doc_id . $doc_id . '100');
     $this->assertResponseCode(404);
     $this->assertController('index');
     $this->assertAction('index');
     $response = $this->getResponse();
     $this->assertContains('<div class="frontdoor-error">', $response->getBody());
 }
コード例 #6
0
ファイル: File.php プロジェクト: KOBV/opus4-matheon
 private function fetchFile($realm)
 {
     $targetFile = Opus_File::fetchByDocIdPathName($this->_doc->getId(), $this->_filename);
     if (is_null($targetFile)) {
         throw new Frontdoor_Model_FileNotFoundException();
     }
     if (!$this->isFileAccessAllowed($targetFile, $realm)) {
         throw new Frontdoor_Model_FileAccessNotAllowedException();
     }
     return $targetFile;
 }
コード例 #7
0
 public function testGetModel()
 {
     $form = new Admin_Form_Document_Series();
     $doc = new Opus_Document(146);
     $series = $doc->getSeries();
     $form->getElement('Id')->setValue($doc->getId());
     $form->getElement('SeriesId')->setValue($series[0]->getModel()->getId());
     $form->getElement('Number')->setValue('b');
     $form->getElement('SortOrder')->setValue(7);
     $model = $form->getModel();
     $modelId = $model->getId();
     $this->assertEquals(146, $modelId[0]);
     $this->assertEquals($series[0]->getModel()->getId(), $modelId[1]);
     $this->assertEquals('b', $model->getNumber());
     $this->assertEquals(7, $model->getDocSortOrder());
 }
コード例 #8
0
ファイル: Notification.php プロジェクト: alexukua/opus4
 /**
  *
  * @param Opus_Document $document das Dokument auf das sich die Notifizierung bezieht
  * @param String $context Notifizierungskontext
  * @param String $url vollständiger Deeplink, der in der Mail angezeigt werden soll
  * @param boolean $notifySubmitter Wenn false, wird der Submitter nicht notifiziert
  * @param array $notifyAuthors Bitmaske, die für jeden Autor (über den Index referenziert) angibt, ob ihm/ihr eine
  *                             E-Mail gesendet werden kann (wenn false, dann wird keine Notifizierung versendet)
  */
 public function prepareMail($document, $context, $url, $notifySubmitter = true, $notifyAuthors = array())
 {
     if (!$this->validateContext($context)) {
         $this->logger->err("context {$context} is currently not supported or delivery of notification mails is not" . ' enabled for the current context');
         return;
     }
     $this->logger->info("prepare {$context} notification email for document id " . $document->getId());
     $authorAddresses = array();
     $authors = array();
     $title = "";
     $personAuthors = $document->getPersonAuthor();
     if (!empty($personAuthors)) {
         $index = 0;
         foreach ($personAuthors as $author) {
             $name = trim($author->getLastName() . ", " . $author->getFirstName());
             // TODO Komma nur wenn FirstName present
             array_push($authors, $name);
             if ($context == self::PUBLICATION) {
                 $email = trim($author->getEmail());
                 if (!empty($email) && (empty($notifyAuthors) || isset($notifyAuthors[$index]) && $notifyAuthors[$index])) {
                     array_push($authorAddresses, array("name" => $name, "address" => $email));
                 }
             }
             $index++;
         }
     }
     // TODO Funktionalität existiert bereits (Documents Helper oder so)
     $titlesMain = $document->getTitleMain();
     if (!empty($titlesMain)) {
         // ermittle (den ersten) TitleMain in Dokumentsprache
         $language = $document->getLanguage();
         foreach ($titlesMain as $titleMain) {
             if ($titleMain->getLanguage() == $language) {
                 $title = trim($titleMain->getValue());
                 break;
             }
         }
     }
     $this->scheduleNotification($this->getMailSubject($context, $document->getId(), $authors, $title), $this->getMailBody($context, $document->getId(), $authors, $title, $url), $this->getRecipients($context, $authorAddresses, $document, $notifySubmitter));
     $this->logger->info("{$context} notification mail creation was completed successfully");
 }
コード例 #9
0
ファイル: Index.php プロジェクト: alexukua/opus4
 /**
  * Helper method to add document to index.
  *
  * @param Opus_Document $document
  * @return void
  */
 private function addDocumentToIndex(Opus_Document $document)
 {
     $log = Zend_Registry::get('Zend_Log');
     // create job if asynchronous is set
     if (isset($this->config->runjobs->asynchronous) && $this->config->runjobs->asynchronous) {
         $log->debug(__METHOD__ . ': ' . 'Adding index job for document ' . $document->getId() . '.');
         $job = new Opus_Job();
         $job->setLabel(Opus_Job_Worker_IndexOpusDocument::LABEL);
         $job->setData(array('documentId' => $document->getId(), 'task' => 'index'));
         // skip creating job if equal job already exists
         if (true === $job->isUniqueInQueue()) {
             $job->store();
         } else {
             $log->debug(__METHOD__ . ': ' . 'Indexing job for document ' . $document->getId() . ' already exists!');
         }
     } else {
         $log->debug(__METHOD__ . ': ' . 'Index document ' . $document->getId() . '.');
         try {
             $indexer = new Opus_SolrSearch_Index_Indexer();
             $indexer->addDocumentToEntryIndex($document);
             $indexer->commit();
         } catch (Opus_SolrSearch_Index_Exception $e) {
             $log->debug(__METHOD__ . ': ' . 'Indexing document ' . $document->getId() . ' failed: ' . $e->getMessage());
         } catch (InvalidArgumentException $e) {
             $log->warn(__METHOD__ . ': ' . $e->getMessage());
         }
     }
 }
コード例 #10
0
 /**
  * Create xml structure for one record
  *
  * @param  Opus_Document $document
  * @param  string        $metadataPrefix
  * @return void
  */
 private function createXmlRecord(Opus_Document $document)
 {
     $docId = $document->getId();
     $domNode = $this->getDocumentXmlDomNode($document);
     // add frontdoor url
     $this->_addFrontdoorUrlAttribute($domNode, $docId);
     // add ddb transfer element
     $this->_addDdbTransferElement($domNode, $docId);
     // add access rights to element
     $this->_addAccessRights($domNode, $document);
     // remove file elements which should not be exported through OAI
     // Iterating over DOMNodeList is only save for readonly-operations;
     // copy element-by-element before removing!
     $filenodes = $domNode->getElementsByTagName('File');
     $filenodesList = array();
     foreach ($filenodes as $filenode) {
         $filenodesList[] = $filenode;
         // add file download urls
         $this->_addFileUrlAttribute($filenode, $docId, $filenode->getAttribute('PathName'));
     }
     // remove file elements which should not be exported through OAI
     foreach ($filenodesList as $filenode) {
         if (false === $filenode->hasAttribute('VisibleInOai') or '1' !== $filenode->getAttribute('VisibleInOai')) {
             $domNode->removeChild($filenode);
         }
     }
     $node = $this->_xml->importNode($domNode, true);
     $type = $document->getType();
     $this->_addSpecInformation($node, 'doc-type:' . $type);
     $bibliography = $document->getBelongsToBibliography() == 1 ? 'true' : 'false';
     $this->_addSpecInformation($node, 'bibliography:' . $bibliography);
     $logger = $this->getLogger();
     $setSpecs = Oai_Model_SetSpec::getSetSpecsFromCollections($document->getCollection());
     foreach ($setSpecs as $setSpec) {
         if (preg_match("/^([A-Za-z0-9\\-_\\.!~\\*'\\(\\)]+)(:[A-Za-z0-9\\-_\\.!~\\*'\\(\\)]+)*\$/", $setSpec)) {
             $this->_addSpecInformation($node, $setSpec);
             continue;
         }
         $logger->info("skipping invalid setspec: " . $setSpec);
     }
     $this->_xml->documentElement->appendChild($node);
 }
コード例 #11
0
ファイル: Container.php プロジェクト: KOBV/opus4-matheon
 /**
  * Oai_Model_Container constructor.
  * @param $docId
  * @param null $logger
  */
 public function __construct($docId)
 {
     $this->_doc = $this->validateId($docId);
     $this->_docId = $this->_doc->getId();
     $this->_appConfig = Application_Configuration::getInstance();
 }
コード例 #12
0
 /**
  * Returns form for asking yes/no question like 'Delete file?'.
  *
  * @param Opus_Document $document
  * @param string $action Target action that needs to be confirmed
  * @return Admin_Form_YesNoForm
  */
 private function _getConfirmationForm($document, $targetState)
 {
     $form = new Admin_Form_YesNoForm();
     $form->setAction($this->view->url(array('controller' => 'workflow', 'action' => 'changestate', 'targetState' => $targetState)));
     $form->setMethod('post');
     $idElement = new Zend_Form_Element_Hidden('id');
     $idElement->setValue($document->getId());
     $form->addElement($idElement);
     $config = Zend_Registry::get('Zend_Config');
     if ($targetState == 'published' && isset($config->notification->document->published->enabled) && $config->notification->document->published->enabled == 1) {
         $this->_addPublishNotificationSelection($document, $form);
     }
     return $form;
 }
コード例 #13
0
 public function testIndexActionRisPrivateNote()
 {
     $doc = new Opus_Document(146);
     $this->dispatch('/citationExport/index/index/output/ris/docId/' . $doc->getId());
     $this->assertResponseCode(200);
     $response = $this->getResponse();
     $this->assertNotContains('N1  - Für den Admin.', $response->getBody());
 }
コード例 #14
0
    $d = null;
    try {
        $d = new Opus_Document($id);
    } catch (Opus_Model_NotFoundException $e) {
        // document with id $id does not exist
        continue;
    }
    $files = $d->getFile();
    if (count($files) == 0) {
        continue;
    }
    foreach ($files as $file) {
        $overallNumOfFulltexts++;
        $response = null;
        try {
            $response = $solrServer->extract($file->getPath(), array('extractOnly' => 'true', 'extractFormat' => 'text'));
        } catch (Exception $e) {
            echo "error while extracting full text for document # " . $d->getId() . " (file name : " . $file->getPath() . " )\n";
            $numOfNonExtractableFulltexts++;
            continue;
        }
        if (is_null($response->getRawResponse()) || strlen(trim($response->getRawResponse())) == 0) {
            echo "non-extractable full text for document # " . $d->getId() . " (file name: " . $file->getPath() . " )\n";
            $numOfNonExtractableFulltexts++;
        }
    }
}
echo "overall num of full texts: {$overallNumOfFulltexts}\n";
$errorRate = 100.0 * $numOfNonExtractableFulltexts / $overallNumOfFulltexts;
echo "num of non extractable full texts: {$numOfNonExtractableFulltexts} ({$errorRate} %)\n";
exit;
コード例 #15
0
ファイル: Document.php プロジェクト: KOBV/opus4-matheon
 /**
  * Get current document Id.
  *
  * @return integer
  */
 public function getId()
 {
     return $this->_document->getId();
 }
コード例 #16
0
//
// Subjects
//
$doc->addSubject()->setType('swd')->setValue(randString($counter++));
foreach (array('uncontrolled', 'msc', 'ddc') as $type) {
    $doc->addSubject()->setType($type)->setLanguage(randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("eng" . randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("deu")->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("eng")->setValue(randString($counter++))->setExternalKey(randString($counter++));
}
//
// Notes
//
$doc->addNote()->setVisibility('public')->setMessage(randString($counter++));
$doc->addNote()->setVisibility('private')->setMessage(randString($counter++));
//
// Licenses
//
$lic = new Opus_Licence();
$lic->setActive(1);
$lic->setLanguage('deu' . randString($counter++));
$lic->setLinkLicence(randString($counter++));
$lic->setNameLong(randString($counter++));
$lic->store();
$doc->setLicence($lic);
//
// Storing...
//
$doc->store();
print "Document stored. ID: " . $doc->getId() . "\n";
コード例 #17
0
        echo "sorting documents in series #" . $series->getId() . " numerically\n";
        if (!asort($seriesNumbers, SORT_NUMERIC)) {
            echo "Error while sorting docs -- skip series #" . $series->getId() . "\n";
            break;
        }
    } else {
        echo "sorting documents in series #" . $series->getId() . " lexicographically\n";
        if (!asort($seriesNumbers, SORT_STRING)) {
            echo "Error while sorting docs -- skip series #" . $series->getId() . "\n";
            break;
        }
    }
    $seriesCounter = 0;
    foreach ($seriesNumbers as $docId => $seriesNumber) {
        $doc = new Opus_Document($docId);
        $allSeries = $doc->getSeries();
        $doc->setSeries(array());
        $doc->store();
        foreach ($allSeries as $docSeries) {
            $seriesInstance = $docSeries->getModel();
            if ($seriesInstance->getId() === $series->getId()) {
                echo "reassign doc_sort_order for doc #" . $doc->getId() . " (series number: " . $docSeries->getNumber() . ") -- old / new doc_sort_order: " . $docSeries->getDocSortOrder() . " / " . $seriesCounter . "\n";
                $doc->addSeries($seriesInstance)->setNumber($docSeries->getNumber())->setDocSortOrder($seriesCounter++);
            } else {
                $doc->addSeries($seriesInstance)->setNumber($docSeries->getNumber())->setDocSortOrder($docSeries->getDocSortOrder());
            }
        }
        $doc->store();
    }
}
exit;
コード例 #18
0
 * @version     $Id$
 */
/**
 * Removes associated Opus_File objects for all HHAR test documents (id = 1..90)
 * since full text files do not exist in file system
 */
$startId = 1;
$endId = 90;
for ($i = $startId; $i <= $endId; $i++) {
    $d = null;
    try {
        $d = new Opus_Document($i);
    } catch (Opus_Model_NotFoundException $e) {
        // document with id $i does not exist
        continue;
    }
    $files = $d->getFile();
    foreach ($files as $file) {
        try {
            $file->doDelete($file->delete());
        } catch (Exception $e) {
            // ignore exception (is thrown since file does not exist physically)
        }
    }
    $numOfFiles = count($files);
    if ($numOfFiles > 0) {
        echo 'delete ' . $numOfFiles . ' file(s) associated with docId: ' . $d->getId() . "\n";
    }
}
echo "done.\n";
exit;