/**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     $value = $snak->getDataValue();
     $entityId = $value->getValue()->getEntityId();
     $entityLName = $this->vocabulary->getEntityLName($entityId);
     $writer->say($propertyValueNamespace, $propertyValueLName)->is(RdfVocabulary::NS_ENTITY, $entityLName);
     $this->mentionedEntityTracker->entityReferenceMentioned($entityId);
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     $writer->say($propertyValueNamespace, $propertyValueLName);
     /** @var TimeValue $value */
     $value = $snak->getDataValue();
     $this->sayDateLiteral($writer, $value);
     if ($this->complexValueHelper !== null) {
         $this->addValueNode($writer, $propertyValueNamespace, $propertyValueLName, $dataType, $value);
     }
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     /** @var GlobeCoordinateValue $value */
     $value = $snak->getDataValue();
     $point = "Point({$value->getLatitude()} {$value->getLongitude()})";
     $writer->say($propertyValueNamespace, $propertyValueLName)->value($point, RdfVocabulary::NS_GEO, "wktLiteral");
     if ($this->complexValueHelper !== null) {
         $this->addValueNode($writer, $propertyValueNamespace, $propertyValueLName, $dataType, $value);
     }
 }
 /**
  * Creates a value node for $value, and attaches it to the current subject of $writer.
  * If a value node for $value was already created, null is returned. Otherwise, the
  * value node's lname is returned, which should be used to generate detailed about the
  * value into the writer returned by getValueNodeWriter().
  *
  * When this method returns a non-null lname, the current subject of the RdfWriter returned by
  * getValueNodeWriter() will the be value node with that lname.
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type (unused, passed here for symmetry
  *        with the signature of ValueSnakRdfBuilder::addValue).
  * @param DataValue $value
  *
  * @return string|null The LName of the value node (in the RdfVocabulary::NS_VALUE namespace),
  *  or null if the value node should not be processed (generally, because it already has
  *  been processed).
  */
 public function attachValueNode(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, DataValue $value)
 {
     $valueLName = $value->getHash();
     $writer->say(RdfVocabulary::$claimToValue[$propertyValueNamespace], $propertyValueLName)->is(RdfVocabulary::NS_VALUE, $valueLName);
     if ($this->dedupeBag->alreadySeen($valueLName, 'V') !== false) {
         return null;
     }
     $this->valueNodeWriter->about(RdfVocabulary::NS_VALUE, $valueLName)->a(RdfVocabulary::NS_ONTOLOGY, $this->vocabulary->getValueTypeName($value));
     return $valueLName;
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     /** @var QuantityValue $value */
     $value = $snak->getDataValue();
     $writer->say($propertyValueNamespace, $propertyValueLName)->value($value->getAmount(), 'xsd', 'decimal');
     //FIXME: this is meaningless without a unit identifier!
     if ($this->complexValueHelper !== null) {
         $this->addValueNode($writer, $propertyValueNamespace, $propertyValueLName, $dataType, $value);
     }
 }
 /**
  * Adds meta-information about an entity (such as the ID and type) to the RDF graph.
  *
  * @todo: extract into MetaDataRdfBuilder
  *
  * @param EntityDocument $entity
  */
 private function addEntityMetaData(EntityDocument $entity)
 {
     $entityLName = $this->vocabulary->getEntityLName($entity->getId());
     $this->writer->about(RdfVocabulary::NS_ENTITY, $entityLName)->a(RdfVocabulary::NS_ONTOLOGY, $this->vocabulary->getEntityTypeName($entity->getType()));
     if ($entity instanceof Property) {
         $this->writer->say(RdfVocabulary::NS_ONTOLOGY, 'propertyType')->is(RdfVocabulary::NS_ONTOLOGY, $this->vocabulary->getDataTypeName($entity));
         $id = $entity->getId()->getSerialization();
         $this->writePropertyPredicates($id, $this->propertyIsLink($entity));
         $this->writeNovalueClass($id);
     }
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     /** @var GlobeCoordinateValue $value */
     $value = $snak->getDataValue();
     $point = "Point({$value->getLatitude()} {$value->getLongitude()})";
     $globe = $value->getGlobe();
     if ($globe && $globe !== GlobeCoordinateValue::GLOBE_EARTH) {
         $globe = str_replace('>', '%3E', $globe);
         // Add coordinate system according to http://www.opengeospatial.org/standards/geosparql
         // Per https://portal.opengeospatial.org/files/?artifact_id=47664 sec 8.5.1
         //    All RDFS Literals of type geo:wktLiteral shall consist of an optional URI
         //    identifying the coordinate reference system followed by Simple Features Well Known
         //   Text (WKT) describing a geometric value.
         // Example: "<http://www.opengis.net/def/crs/EPSG/0/4326> Point(33.95 -83.38)"^^<http://www.opengis.net/ont/geosparql#wktLiteral>
         $point = "<{$globe}> {$point}";
     }
     $writer->say($propertyValueNamespace, $propertyValueLName)->value($point, RdfVocabulary::NS_GEO, "wktLiteral");
     if ($this->complexValueHelper !== null) {
         $this->addValueNode($writer, $propertyValueNamespace, $propertyValueLName, $dataType, $value);
     }
 }
 /**
  * Adds the site links of the given item to the RDF graph.
  *
  * @param Item $item
  */
 public function addSiteLinks(Item $item)
 {
     $entityLName = $this->vocabulary->getEntityLName($item->getId());
     /** @var SiteLink $siteLink */
     foreach ($item->getSiteLinkList() as $siteLink) {
         if (!$this->isSiteIncluded($siteLink->getSiteId())) {
             continue;
         }
         // FIXME: we should check the site exists using hasGlobalId here before asuming it does
         $site = $this->siteLookup->getSite($siteLink->getSiteId());
         // XXX: ideally, we'd use https if the target site supports it.
         $baseUrl = str_replace('$1', rawurlencode($siteLink->getPageName()), $site->getLinkPath());
         // $site->getPageUrl( $siteLink->getPageName() );
         if (!parse_url($baseUrl, PHP_URL_SCHEME)) {
             $url = "http:" . $baseUrl;
         } else {
             $url = $baseUrl;
         }
         $this->writer->about($url)->a(RdfVocabulary::NS_SCHEMA_ORG, 'Article')->say(RdfVocabulary::NS_SCHEMA_ORG, 'about')->is(RdfVocabulary::NS_ENTITY, $entityLName)->say(RdfVocabulary::NS_SCHEMA_ORG, 'inLanguage')->text($this->vocabulary->getCanonicalLanguageCode($site->getLanguageCode()));
         foreach ($siteLink->getBadges() as $badge) {
             $this->writer->say(RdfVocabulary::NS_ONTOLOGY, 'badge')->is(RdfVocabulary::NS_ENTITY, $this->vocabulary->getEntityLName($badge));
         }
     }
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     $uri = $this->getValueUri($snak->getDataValue());
     $writer->say($propertyValueNamespace, $propertyValueLName)->is($uri);
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     /** @var MonolingualTextValue $value */
     $value = $snak->getDataValue();
     $writer->say($propertyValueNamespace, $propertyValueLName)->text($value->getText(), $value->getLanguageCode());
 }
 /**
  * Adds specific value
  *
  * @param RdfWriter $writer
  * @param string $propertyValueNamespace Property value relation namespace
  * @param string $propertyValueLName Property value relation name
  * @param string $dataType Property data type
  * @param PropertyValueSnak $snak
  */
 public function addValue(RdfWriter $writer, $propertyValueNamespace, $propertyValueLName, $dataType, PropertyValueSnak $snak)
 {
     $literalValue = $this->getLiteralValue($snak->getDataValue());
     $nsType = $this->typeBase ?: ($this->typeLocal === null ? null : 'xsd');
     $writer->say($propertyValueNamespace, $propertyValueLName)->value($literalValue, $nsType, $this->typeLocal);
 }