Skip to content

Commit

Permalink
Remove usages of deprecated code and bad assumptions from RdfBuilder
Browse files Browse the repository at this point in the history
Change-Id: I47c99c5c73aa4d555d8b1edb948477d68ba1f65a
  • Loading branch information
JeroenDeDauw committed Dec 1, 2014
1 parent b2e7f00 commit 8e70817
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions repo/includes/rdf/RdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
use Wikibase\DataModel\Claim\Claim;
use Wikibase\DataModel\Entity\BasicEntityIdParser;
use Wikibase\DataModel\Entity\Entity;
use Wikibase\DataModel\Entity\EntityDocument;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\SiteLink;
use Wikibase\DataModel\Snak\PropertyValueSnak;
use Wikibase\DataModel\StatementListProvider;
use Wikibase\Lib\Store\EntityLookup;

/**
Expand Down Expand Up @@ -337,7 +340,10 @@ public function addAliases( Entity $entity ) {
public function addSiteLinks( Item $item ) {
$entityResource = $this->getEntityResource( $item->getId() );

foreach ( $item->getSiteLinks() as $siteLink ) {
/**
* @var SiteLink $siteLink
*/
foreach ( $item->getSiteLinkList() as $siteLink ) {
$site = $this->sites->getSite( $siteLink->getSiteId() );

$languageCode = $site->getLanguageCode();
Expand All @@ -360,23 +366,26 @@ public function addSiteLinks( Item $item ) {
/**
* Adds all Claims/Statements from the given entity to the RDF graph.
*
* @param Entity $entity
* @param EntityDocument $entity
*/
public function addClaims( Entity $entity ) {
/* @var Claim $claim */
foreach( $entity->getClaims() as $claim ) {
$this->addClaim( $entity, $claim );
public function addClaims( EntityDocument $entity ) {
$id = $entity->getId();

if ( $entity instanceof StatementListProvider ) {
foreach ( $entity->getStatements() as $statement ) {
$this->addClaim( $id, $statement );
}
}
}

/**
* Adds the given Claim from the given Entity to the RDF graph.
*
* @param Entity $entity
* @param Claim $claim
* @param EntityId $entityId
* @param Claim $claim
*/
public function addClaim( Entity $entity, Claim $claim ) {
$this->addMainSnak( $entity, $claim );
private function addClaim( EntityId $entityId, Claim $claim ) {
$this->addMainSnak( $entityId, $claim );

//TODO: add qualifiers
//TODO: add references
Expand All @@ -385,14 +394,14 @@ public function addClaim( Entity $entity, Claim $claim ) {
/**
* Adds the given Claim's main Snak to the RDF graph.
*
* @param Entity $entity
* @param Claim $claim
* @param EntityId $entityId
* @param Claim $claim
*/
public function addMainSnak( Entity $entity, Claim $claim ) {
private function addMainSnak( EntityId $entityId, Claim $claim ) {
$snak = $claim->getMainSnak();

if ( $snak instanceof PropertyValueSnak ) {
$this->addPropertyValueSnak( $entity, $claim, $snak );
$this->addPropertyValueSnak( $entityId, $claim, $snak );
} else {
//TODO: NoValueSnak, SomeValueSnak
wfDebug( __METHOD__ . ": Unsupported snak type: " . get_class( $snak ) );
Expand All @@ -415,12 +424,12 @@ public function getStatementResource( Claim $claim ) {
/**
* Adds the given PropertyValueSnak to the RDF graph.
*
* @param Entity $entity
* @param EntityId $entityId
* @param PropertyValueSnak $snak
* @param Claim $claim
* @param Claim $claim
*/
public function addPropertyValueSnak( Entity $entity, Claim $claim, PropertyValueSnak $snak ) {
$entityResource = $this->getEntityResource( $entity->getId() );
private function addPropertyValueSnak( EntityId $entityId, Claim $claim, PropertyValueSnak $snak ) {
$entityResource = $this->getEntityResource( $entityId );

$propertyId = $claim->getMainSnak()->getPropertyId();
$propertyQName = $this->getEntityQName( self::NS_ENTITY, $propertyId );
Expand Down

0 comments on commit 8e70817

Please sign in to comment.