當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SMW\SemanticData類代碼示例

本文整理匯總了PHP中SMW\SemanticData的典型用法代碼示例。如果您正苦於以下問題:PHP SemanticData類的具體用法?PHP SemanticData怎麽用?PHP SemanticData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SemanticData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteSubject

 /**
  * @see SMWStore::deleteSubject
  *
  * @since 1.8
  * @param Title $title
  */
 public function deleteSubject(Title $title)
 {
     // @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
     wfRunHooks('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
     wfRunHooks('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
     $id = $this->store->getObjectIds()->getSMWPageID($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), '', false);
     $emptySemanticData = new SemanticData(DIWikiPage::newFromTitle($title));
     $subobjects = $this->getSubobjects($emptySemanticData->getSubject());
     $this->doDataUpdate($emptySemanticData);
     if ($title->getNamespace() === SMW_NS_CONCEPT) {
         // make sure to clear caches
         $db = $this->store->getConnection();
         $db->delete('smw_fpt_conc', array('s_id' => $id), 'SMW::deleteSubject::Conc');
         $db->delete(SMWSQLStore3::CONCEPT_CACHE_TABLE, array('o_id' => $id), 'SMW::deleteSubject::Conccache');
     }
     // Mark subject/subobjects with a special IW, the final removal is being
     // triggered by the `ByIdDataRebuildDispatcher`
     $this->store->getObjectIds()->updateInterwikiField($id, $emptySemanticData->getSubject(), SMW_SQL3_SMWDELETEIW);
     foreach ($subobjects as $smw_id => $subobject) {
         $this->store->getObjectIds()->updateInterwikiField($smw_id, $subobject, SMW_SQL3_SMWDELETEIW);
     }
     // 1.9.0.1
     // The update of possible associative entities is handled by DeleteSubjectJob which is invoked during
     // the ArticleDelete hook
     // @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
     wfRunHooks('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
     wfRunHooks('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
 }
開發者ID:ReachingOut,項目名稱:SemanticMediaWiki,代碼行數:34,代碼來源:SMW_SQLStore3_Writers.php

示例2: asEntity

 /**
  * @since 2.1
  *
  * @return SemanticData
  */
 public function asEntity()
 {
     $semanticData = new SemanticData($this->asSubject());
     $semanticData->addDataValue($this->getLocatedInValue());
     $countryCategory = new CountryCategory();
     $semanticData->addDataValue($countryCategory->getCategoryValue());
     return $semanticData;
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:13,代碼來源:FranceFactsheet.php

示例3: doSerialize

 private function doSerialize(SemanticData $semanticData)
 {
     $data = array('subject' => $semanticData->getSubject()->getSerialization(), 'data' => $this->serializeProperty($semanticData));
     $subobjects = $this->serializeSubobject($semanticData->getSubSemanticData());
     if ($subobjects !== array()) {
         $data['sobj'] = $subobjects;
     }
     return $data;
 }
開發者ID:WolfgangFahl,項目名稱:SemanticMediaWiki,代碼行數:9,代碼來源:SemanticDataSerializer.php

示例4: testAddAnnotationOnMockShortUrl

 public function testAddAnnotationOnMockShortUrl()
 {
     $title = Title::newFromText(__METHOD__);
     $semanticData = new SemanticData(DIWikiPage::newFromTitle($title));
     $instance = $this->getMock('\\SESP\\Annotator\\ShortUrlAnnotator', array('hasShortUrlUtils', 'getShortUrl'), array($semanticData));
     $instance->expects($this->once())->method('hasShortUrlUtils')->will($this->returnValue(true));
     $instance->expects($this->once())->method('getShortUrl')->with($this->equalTo($title))->will($this->returnValue('example.org'));
     $instance->setShortUrlPrefix('foo');
     $instance->addAnnotation();
     $this->assertArrayHasKey(PropertyRegistry::getInstance()->getPropertyId('_SHORTURL'), $semanticData->getProperties());
 }
開發者ID:smthmsn,項目名稱:SemanticExtraSpecialProperties,代碼行數:11,代碼來源:ShortUrlAnnotatorTest.php

示例5: testRedirectTragetLookupForExistingEntry

 public function testRedirectTragetLookupForExistingEntry()
 {
     $property = new DIProperty('RedirectLookupForExistingEntry');
     $semanticData = new SemanticData(new DIWikiPage(__METHOD__, NS_MAIN, ''));
     $semanticData->addDataValue(DataValueFactory::getInstance()->newPropertyObjectValue($property, 'Bar'));
     $this->store->doSparqlDataUpdate($semanticData);
     $expNsResource = new ExpNsResource('RedirectLookupForExistingEntry', Exporter::getNamespaceUri('property'), 'property');
     $instance = new RedirectLookup($this->sparqlDatabase);
     $instance->clear();
     $exists = null;
     $this->assertSame($expNsResource, $instance->findRedirectTargetResource($expNsResource, $exists));
     $this->assertTrue($exists);
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:13,代碼來源:RedirectLookupIntegrationTest.php

示例6: testRoundtripOfSerializedSemanticDataAfterStoreUpdate

 public function testRoundtripOfSerializedSemanticDataAfterStoreUpdate()
 {
     $subject = DIWikiPage::newFromTitle(Title::newFromText(__METHOD__));
     $semanticDataBeforeUpdate = new SemanticData($subject);
     $subobject = new Subobject($subject->getTitle());
     $subobject->setEmptyContainerForId('SomeSubobjectToSerialize');
     $subobject->getSemanticData()->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Foo', 'Bar'));
     $semanticDataBeforeUpdate->addSubobject($subobject);
     $this->getStore()->updateData($semanticDataBeforeUpdate);
     $semanticDataAfterUpdate = $this->getStore()->getSemanticData($subject);
     $serializerFactory = new SerializerFactory();
     $this->assertEquals($semanticDataAfterUpdate->getHash(), $serializerFactory->deserialize($serializerFactory->serialize($semanticDataAfterUpdate))->getHash());
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:13,代碼來源:SemanticDataSerializationDBIntegrationTest.php

示例7: getSemanticData

 /**
  * @since 2.0
  *
  * @return SemanticData
  */
 public function getSemanticData(DIWikiPage $subject)
 {
     $requestOptions = new RequestOptions();
     $requestOptions->sort = true;
     $semanticData = new SemanticData($subject);
     $incomingProperties = $this->store->getInProperties($subject, $requestOptions);
     foreach ($incomingProperties as $property) {
         $values = $this->store->getPropertySubjects($property, null);
         foreach ($values as $value) {
             $semanticData->addPropertyObjectValue($property, $value);
         }
     }
     return $semanticData;
 }
開發者ID:jongfeli,項目名稱:SemanticMediaWiki,代碼行數:19,代碼來源:InSemanticDataFetcher.php

示例8: asEntity

 /**
  * @since 2.1
  *
  * @return SemanticData
  */
 public function asEntity()
 {
     $semanticData = new SemanticData($this->asSubject());
     $semanticData->addDataValue($this->getAreaValue());
     $semanticData->addDataValue($this->getAverageHighTemperatureValue());
     $semanticData->addDataValue($this->getPopulationValue());
     $semanticData->addDataValue($this->getPopulationDensityValue());
     $semanticData->addDataValue($this->getLocatedInValue());
     $semanticData->addDataValue($this->getFoundedValue());
     $semanticData->addSubobject($this->getDemographics());
     $cityCategory = new CityCategory();
     $semanticData->addDataValue($cityCategory->getCategoryValue());
     return $semanticData;
 }
開發者ID:jongfeli,項目名稱:SemanticMediaWiki,代碼行數:19,代碼來源:BerlinFactsheet.php

示例9: fetchIncomingDataFromStore

 /**
  * @since 1.9.2
  *
  * @return SemanticData
  */
 public function fetchIncomingDataFromStore()
 {
     $requestOptions = new \SMWRequestOptions();
     $requestOptions->sort = true;
     $subject = $this->getPageData()->getSubject();
     $semanticData = new SemanticData($subject);
     $incomingProperties = $this->getStore()->getInProperties($subject, $requestOptions);
     foreach ($incomingProperties as $property) {
         $values = $this->getStore()->getPropertySubjects($property, null);
         foreach ($values as $value) {
             $semanticData->addPropertyObjectValue($property, $value);
         }
     }
     return $semanticData;
 }
開發者ID:jongfeli,項目名稱:SemanticMediaWiki,代碼行數:20,代碼來源:ByPageSemanticDataFinder.php

示例10: testDoSparqlDataUpdateOnMockBaseStore

 public function testDoSparqlDataUpdateOnMockBaseStore()
 {
     $semanticData = new SemanticData(new DIWikiPage(__METHOD__, NS_MAIN));
     $semanticData->addPropertyObjectValue(new DIProperty('Foo'), $semanticData->getSubject());
     $repositoryResult = $this->getMockBuilder('\\SMW\\SPARQLStore\\QueryEngine\\RepositoryResult')->disableOriginalConstructor()->getMock();
     $baseStore = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $sparqlDatabase = $this->getMockBuilder('\\SMWSparqlDatabase')->disableOriginalConstructor()->getMock();
     $sparqlDatabase->expects($this->atLeastOnce())->method('select')->will($this->returnValue($repositoryResult));
     $sparqlDatabase->expects($this->once())->method('insertData');
     $connectionManager = $this->getMockBuilder('\\SMW\\ConnectionManager')->disableOriginalConstructor()->getMock();
     $connectionManager->expects($this->any())->method('getConnection')->will($this->returnValue($sparqlDatabase));
     $instance = new SPARQLStore($baseStore);
     $instance->setConnectionManager($connectionManager);
     $instance->doSparqlDataUpdate($semanticData);
 }
開發者ID:jongfeli,項目名稱:SemanticMediaWiki,代碼行數:15,代碼來源:SPARQLStoreTest.php

示例11: createFromSemanticData

 /**
  * @since 2.4
  *
  * @param SemanticData $semanticData
  *
  * @return string
  */
 public static function createFromSemanticData(SemanticData $semanticData)
 {
     $hash = array();
     $hash[] = $semanticData->getSubject()->getSerialization();
     foreach ($semanticData->getProperties() as $property) {
         $hash[] = $property->getKey();
         foreach ($semanticData->getPropertyValues($property) as $di) {
             $hash[] = $di->getSerialization();
         }
     }
     foreach ($semanticData->getSubSemanticData() as $data) {
         $hash[] = $data->getHash();
     }
     sort($hash);
     return md5(implode('#', $hash));
 }
開發者ID:jongfeli,項目名稱:SemanticMediaWiki,代碼行數:23,代碼來源:HashBuilder.php

示例12: deleteSubject

 /**
  * @see SMWStore::deleteSubject
  *
  * @since 1.8
  * @param Title $title
  */
 public function deleteSubject(Title $title)
 {
     // @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
     \Hooks::run('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
     \Hooks::run('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
     // Fetch all possible matches (including any duplicates created by
     // incomplete rollback or DB deadlock)
     $ids = $this->store->getObjectIds()->getListOfIdMatchesFor($title->getDBkey(), $title->getNamespace(), $title->getInterwiki());
     $subject = DIWikiPage::newFromTitle($title);
     $emptySemanticData = new SemanticData($subject);
     $this->entitySubobjectListIterator->setSubject($emptySemanticData->getSubject());
     $subobjects = $this->entitySubobjectListIterator->getIterator();
     $this->doDataUpdate($emptySemanticData);
     foreach ($ids as $id) {
         $this->doDelete($id, $subject, $subobjects);
     }
     // @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
     \Hooks::run('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
     \Hooks::run('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
 }
開發者ID:jongfeli,項目名稱:SemanticMediaWiki,代碼行數:26,代碼來源:SMW_SQLStore3_Writers.php

示例13: deleteSubject

 /**
  * @see SMWStore::deleteSubject
  *
  * @since 1.8
  * @param Title $title
  */
 public function deleteSubject(Title $title)
 {
     // @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
     \Hooks::run('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
     \Hooks::run('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
     // Fetch all possible matches (including any duplicates created by
     // incomplete rollback or DB deadlock)
     $ids = $this->store->getObjectIds()->getListOfIdMatchesFor($title->getDBkey(), $title->getNamespace(), $title->getInterwiki());
     $subject = DIWikiPage::newFromTitle($title);
     $emptySemanticData = new SemanticData($subject);
     $subobjects = $this->getSubobjects($emptySemanticData->getSubject());
     $this->doDataUpdate($emptySemanticData);
     foreach ($ids as $id) {
         $this->doDeleteReferencesFor($id, $subject, $subobjects);
     }
     // 1.9.0.1
     // The update of possible associative entities is handled by DeleteSubjectJob which is invoked during
     // the ArticleDelete hook
     // @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
     \Hooks::run('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
     \Hooks::run('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
 }
開發者ID:jaideraf,項目名稱:SemanticMediaWiki,代碼行數:28,代碼來源:SMW_SQLStore3_Writers.php

示例14: typeChangeSemanticDataProvider

 /**
  * @return array
  */
 public function typeChangeSemanticDataProvider()
 {
     $provider = array();
     $title = \Title::newFromText(__METHOD__);
     // #0 Single entry
     $foo = new SemanticData(DIWikiPage::newFromTitle($title));
     $foo->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fooQuex', 'Bar'));
     $provider[] = array($foo, 'Has_fooQuex');
     // #1 Single subobject entry
     $foo = new SemanticData(DIWikiPage::newFromTitle($title));
     $subobject = new Subobject($title);
     $subobject->setSemanticData('Foo');
     $subobject->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fomQuex', 'Bam'));
     $foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
     $provider[] = array($foo, 'Has_fomQuex');
     // #2 Combined
     $foo = new SemanticData(DIWikiPage::newFromTitle($title));
     $foo->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fooQuex', 'Bar'));
     $foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
     $provider[] = array($foo, 'Has_fomQuex');
     return $provider;
 }
開發者ID:WolfgangFahl,項目名稱:SemanticMediaWiki,代碼行數:25,代碼來源:SemanticDataSerializerDeserializerRoundtripTest.php

示例15: testDeleteFor

 public function testDeleteFor()
 {
     $subject = new DIWikiPage('Foobar', NS_MAIN, '', 'abc');
     $semanticData = new SemanticData($subject);
     $semanticData->addPropertyObjectValue(new DIProperty('_REDI'), new DIWikiPage('Bar', NS_MAIN));
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $container = $this->getMockBuilder('\\Onoi\\BlobStore\\Container')->disableOriginalConstructor()->getMock();
     $container->expects($this->at(0))->method('has')->with($this->stringContains('sd:'))->will($this->returnValue(true));
     $container->expects($this->at(1))->method('get')->with($this->stringContains('sd:'))->will($this->returnValue($semanticData));
     $container->expects($this->at(2))->method('has')->with($this->stringContains('list'))->will($this->returnValue(true));
     $container->expects($this->at(3))->method('get')->with($this->stringContains('list'))->will($this->returnValue(array('abc', '123')));
     $blobStore = $this->getMockBuilder('\\Onoi\\BlobStore\\BlobStore')->disableOriginalConstructor()->getMock();
     $blobStore->expects($this->any())->method('canUse')->will($this->returnValue(true));
     $blobStore->expects($this->atLeastOnce())->method('read')->will($this->returnValue($container));
     $blobStore->expects($this->exactly(4))->method('delete');
     $instance = new CachedValueLookupStore($store, $blobStore);
     $instance->setValueLookupFeatures(SMW_VL_SD);
     $instance->deleteFor($subject);
 }
開發者ID:WolfgangFahl,項目名稱:SemanticMediaWiki,代碼行數:19,代碼來源:CachedValueLookupStoreTest.php


注:本文中的SMW\SemanticData類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。