/**
  * @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->addSubobject($this->getDemographics());
     $cityCategory = new CityCategory();
     $semanticData->addDataValue($cityCategory->getCategoryValue());
     return $semanticData;
 }
 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());
 }
Ejemplo n.º 3
0
 public function testVisibility()
 {
     $title = Title::newFromText(__METHOD__);
     $instance = new SemanticData(DIWikiPage::newFromTitle($title));
     $instance->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fooQuex', 'Bar'));
     $this->assertTrue($instance->hasVisibleProperties());
     $instance->addSubobject($this->newSubobject($title));
     $this->assertTrue($instance->hasVisibleSpecialProperties());
 }