当前位置: 首页>>代码示例>>PHP>>正文


PHP Opus_Document::getServerDateModified方法代码示例

本文整理汇总了PHP中Opus_Document::getServerDateModified方法的典型用法代码示例。如果您正苦于以下问题:PHP Opus_Document::getServerDateModified方法的具体用法?PHP Opus_Document::getServerDateModified怎么用?PHP Opus_Document::getServerDateModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opus_Document的用法示例。


在下文中一共展示了Opus_Document::getServerDateModified方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIntervalOAIPMHQueryWithoutTestDoc

 /**
  * Test list document ids, metadataPrefix=XMetaDissPlus, different intervals
  * list possible intervals *NOT* containing "2010-06-05"
  */
 public function testIntervalOAIPMHQueryWithoutTestDoc()
 {
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $this->docId = $doc->store();
     $doc = new Opus_Document($this->docId);
     $serverDateModified = $doc->getServerDateModified();
     $today = new DateTime();
     $today->setDate($serverDateModified->getYear(), $serverDateModified->getMonth(), $serverDateModified->getDay());
     $yesterday = clone $today;
     $yesterday->modify('-1 day');
     $dayBeforeYesterday = clone $yesterday;
     $dayBeforeYesterday->modify('-1 day');
     $tomorrow = clone $today;
     $tomorrow->modify('+1 day');
     $dayAfterTomorrow = clone $tomorrow;
     $dayAfterTomorrow->modify('+1 day');
     $yesterdayStr = date_format($yesterday, 'Y-m-d');
     $dayBeforeYesterdayStr = date_format($dayBeforeYesterday, 'Y-m-d');
     $tomorrowStr = date_format($tomorrow, 'Y-m-d');
     $dayAfterTomorrowStr = date_format($dayAfterTomorrow, 'Y-m-d');
     $intervals = array(array('from' => $tomorrowStr), array('until' => $yesterdayStr), array('from' => $tomorrowStr, 'until' => $dayAfterTomorrowStr), array('from' => $dayBeforeYesterdayStr, 'until' => $yesterdayStr));
     foreach ($intervals as $interval) {
         $oaiRequest = array('verb' => 'ListRecords', 'metadataPrefix' => 'XMetaDissPlus');
         $oaiRequest = array_merge($interval, $oaiRequest);
         $docListModel = new Oai_Model_DocumentList();
         $docListModel->deliveringDocumentStates = array('published', 'deleted');
         $docListModel->xMetaDissRestriction = array();
         $docIds = $docListModel->query($oaiRequest);
         $this->assertFalse(in_array($this->docId, $docIds), "Response must NOT contain document id {$this->docId}: " . var_export($interval, true));
     }
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:36,代码来源:DocumentListTest.php

示例2: testDocumentServerDateModifiedNotUpdatedWhenCollectionSortOrderChanged

 /**
  * Regression Test for OPUSVIER-3051
  */
 public function testDocumentServerDateModifiedNotUpdatedWhenCollectionSortOrderChanged()
 {
     // check for expected test data
     $collectionRole1 = new Opus_CollectionRole(1);
     $this->assertEquals(1, $collectionRole1->getPosition(), 'Test setup changed');
     $collectionRole2 = new Opus_CollectionRole(2);
     $this->assertEquals(2, $collectionRole2->getPosition(), 'Test setup changed');
     $docfinder = new Opus_DocumentFinder();
     $docfinder->setCollectionRoleId(2);
     $collectionRoleDocs = $docfinder->ids();
     $this->assertTrue(in_array(146, $collectionRoleDocs), 'Test setup changed');
     // test if server_date_modified is altered
     $docBefore = new Opus_Document(146);
     $this->dispatch('/admin/collectionroles/move/roleid/1/pos/2');
     $docAfter = new Opus_Document(146);
     // revert change in test data
     $this->resetRequest();
     $this->resetResponse();
     $this->dispatch('/admin/collectionroles/move/roleid/1/pos/1');
     $this->assertEquals((string) $docBefore->getServerDateModified(), (string) $docAfter->getServerDateModified());
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:24,代码来源:CollectionrolesControllerTest.php

示例3:

 *
 */
$numOfModified = 0;
$numOfErrors = 0;
$finder = new Opus_DocumentFinder();
$finder->setServerState('published');
foreach ($finder->ids() as $docId) {
    // check if document with id $docId is already persisted in search index
    $search = Opus_Search_Service::selectSearchingService();
    $query = Opus_Search_QueryFactory::selectDocumentById($search, $docId);
    if ($search->customSearch($query)->getAllMatchesCount() != 1) {
        echo "ERROR: document # {$docId} is not stored in search index\n";
        $numOfErrors++;
    } else {
        $result = $search->getResults();
        $solrModificationDate = $result[0]->getServerDateModified();
        $document = new Opus_Document($docId);
        $docModificationDate = $document->getServerDateModified()->getUnixTimestamp();
        if ($solrModificationDate != $docModificationDate) {
            $numOfModified++;
            echo "document # {$docId} is modified\n";
        }
    }
}
if ($numOfErrors > 0) {
    echo "{$numOfErrors} missing documents were found\n";
    echo "{$numOfModified} modified documents were found\n";
} else {
    echo "no missing or modified documents were found\n";
}
exit;
开发者ID:belapp,项目名称:opus4-application,代码行数:31,代码来源:find_modified_docs_in_searchindex.php

示例4: checkDatabase

 /**
  * Check for each database document in serverState publish if it exists in
  * Solr index. Furthermore, compare field value of serverDateModified in
  * database and Solr index.
  * 
  */
 private function checkDatabase()
 {
     $finder = new Opus_DocumentFinder();
     $finder->setServerState('published');
     $ids = $finder->ids();
     $this->logger->info('checking ' . $finder->count() . ' published documents for consistency.');
     foreach ($ids as $id) {
         try {
             $doc = new Opus_Document($id);
         } catch (Opus_Model_NotFoundException $e) {
             // ignore: document was deleted from database in meantime
             continue;
         }
         $serverDataModified = $doc->getServerDateModified()->getUnixTimestamp();
         // retrieve document from index and compare serverDateModified fields
         $query = new Opus_SolrSearch_Query(Opus_SolrSearch_Query::DOC_ID);
         $query->setField('id', $id);
         $resultList = $this->searcher->search($query, $this->validateDocIds);
         $results = $resultList->getResults();
         if ($resultList->getNumberOfHits() == 0) {
             $this->logger->info("inconsistency found for document {$id}: document is in database, but is not in Solr index.");
             $this->numOfInconsistencies++;
             if ($this->forceReindexing($doc)) {
                 $this->numOfUpdates++;
             }
         } else {
             if ($resultList->getNumberOfHits() == 1) {
                 if ($results[0]->getServerDateModified() != $serverDataModified) {
                     $this->numOfInconsistencies++;
                     $this->logger->info("inconsistency found for document {$id}: mismatch between values of server_date_modified in database and Solr index.");
                     if ($this->forceReindexing($doc)) {
                         $this->numOfUpdates++;
                     }
                 }
             } else {
                 $this->logger->err('unexpected state: document with id ' . $id . ' exists multiple times in index.');
             }
         }
     }
 }
开发者ID:alexukua,项目名称:opus4,代码行数:46,代码来源:ConsistencyCheck.php


注:本文中的Opus_Document::getServerDateModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。