当前位置: 首页>>代码示例>>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;未经允许,请勿转载。