Thiemo Mättig (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/390277 )
Change subject: Reformatting in preparation for foreign entities in RDF mapping
......................................................................
Reformatting in preparation for foreign entities in RDF mapping
This is some very basic reformating, only done to make the diffs in
I6acb00b much easier to review.
Bug: T161592
Change-Id: I9aff0eb930cd755582505b641385932ef9217c36
---
M repo/includes/Rdf/PropertyRdfBuilder.php
M repo/includes/Rdf/RdfVocabulary.php
M repo/tests/phpunit/includes/Rdf/FullStatementRdfBuilderTest.php
3 files changed, 138 insertions(+), 70 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/77/390277/1
diff --git a/repo/includes/Rdf/PropertyRdfBuilder.php
b/repo/includes/Rdf/PropertyRdfBuilder.php
index 5ff896d..b9f224b 100644
--- a/repo/includes/Rdf/PropertyRdfBuilder.php
+++ b/repo/includes/Rdf/PropertyRdfBuilder.php
@@ -42,48 +42,113 @@
* and if so does the property normalize to data or objects?
*/
private function writePropertyPredicates( $id, $propertyRdfType,
$normalizedPropertyRdfType ) {
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'directClaim'
)->is( RdfVocabulary::NSP_DIRECT_CLAIM, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'claim' )->is(
RdfVocabulary::NSP_CLAIM, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'statementProperty' )->is( RdfVocabulary::NSP_CLAIM_STATEMENT, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'statementValue' )->is( RdfVocabulary::NSP_CLAIM_VALUE, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'qualifier'
)->is( RdfVocabulary::NSP_QUALIFIER, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'qualifierValue' )->is( RdfVocabulary::NSP_QUALIFIER_VALUE, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'reference'
)->is( RdfVocabulary::NSP_REFERENCE, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'referenceValue' )->is( RdfVocabulary::NSP_REFERENCE_VALUE, $id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'novalue'
)->is( RdfVocabulary::NSP_NOVALUE, $id );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'directClaim'
)->is(
+ RdfVocabulary::NSP_DIRECT_CLAIM,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'claim' )->is(
+ RdfVocabulary::NSP_CLAIM,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'statementProperty' )->is( RdfVocabulary::NSP_CLAIM_STATEMENT, $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'statementValue' )->is(
+ RdfVocabulary::NSP_CLAIM_VALUE,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'qualifier'
)->is(
+ RdfVocabulary::NSP_QUALIFIER,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'qualifierValue' )->is(
+ RdfVocabulary::NSP_QUALIFIER_VALUE,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'reference'
)->is(
+ RdfVocabulary::NSP_REFERENCE,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'referenceValue' )->is(
+ RdfVocabulary::NSP_REFERENCE_VALUE,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY, 'novalue' )->is(
+ RdfVocabulary::NSP_NOVALUE,
+ $id
+ );
if ( $normalizedPropertyRdfType !== self::NO_NORMALIZATION ) {
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'directClaimNormalized' )
- ->is( RdfVocabulary::NSP_DIRECT_CLAIM_NORM, $id
);
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'statementValueNormalized' )
- ->is( RdfVocabulary::NSP_CLAIM_VALUE_NORM, $id
);
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'qualifierValueNormalized' )
- ->is( RdfVocabulary::NSP_QUALIFIER_VALUE_NORM,
$id );
- $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'referenceValueNormalized' )
- ->is( RdfVocabulary::NSP_REFERENCE_VALUE_NORM,
$id );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'directClaimNormalized' )->is(
+ RdfVocabulary::NSP_DIRECT_CLAIM_NORM,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'statementValueNormalized' )->is(
+ RdfVocabulary::NSP_CLAIM_VALUE_NORM,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'qualifierValueNormalized' )->is(
+ RdfVocabulary::NSP_QUALIFIER_VALUE_NORM,
+ $id
+ );
+ $this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'referenceValueNormalized' )->is(
+ RdfVocabulary::NSP_REFERENCE_VALUE_NORM,
+ $id
+ );
}
// Always object properties
- $this->writer->about( RdfVocabulary::NSP_CLAIM, $id )->a(
'owl', 'ObjectProperty' );
- $this->writer->about( RdfVocabulary::NSP_CLAIM_VALUE, $id )->a(
'owl', 'ObjectProperty' );
- $this->writer->about( RdfVocabulary::NSP_QUALIFIER_VALUE, $id
)->a( 'owl', 'ObjectProperty' );
- $this->writer->about( RdfVocabulary::NSP_REFERENCE_VALUE, $id
)->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_CLAIM,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_CLAIM_VALUE,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_QUALIFIER_VALUE,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_REFERENCE_VALUE,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
- $this->writer->about( RdfVocabulary::NSP_DIRECT_CLAIM, $id
)->a( 'owl', $propertyRdfType );
- $this->writer->about( RdfVocabulary::NSP_CLAIM_STATEMENT, $id
)->a( 'owl', $propertyRdfType );
- $this->writer->about( RdfVocabulary::NSP_QUALIFIER, $id )->a(
'owl', $propertyRdfType );
- $this->writer->about( RdfVocabulary::NSP_REFERENCE, $id )->a(
'owl', $propertyRdfType );
+ $this->writer->about(
+ RdfVocabulary::NSP_DIRECT_CLAIM,
+ $id
+ )->a( 'owl', $propertyRdfType );
+ $this->writer->about(
+ RdfVocabulary::NSP_CLAIM_STATEMENT,
+ $id
+ )->a( 'owl', $propertyRdfType );
+ $this->writer->about(
+ RdfVocabulary::NSP_QUALIFIER,
+ $id
+ )->a( 'owl', $propertyRdfType );
+ $this->writer->about(
+ RdfVocabulary::NSP_REFERENCE,
+ $id
+ )->a( 'owl', $propertyRdfType );
if ( $normalizedPropertyRdfType !== self::NO_NORMALIZATION ) {
- $this->writer->about(
RdfVocabulary::NSP_CLAIM_VALUE_NORM, $id )
- ->a( 'owl', 'ObjectProperty' );
- $this->writer->about(
RdfVocabulary::NSP_QUALIFIER_VALUE_NORM, $id )
- ->a( 'owl', 'ObjectProperty' );
- $this->writer->about(
RdfVocabulary::NSP_REFERENCE_VALUE_NORM, $id )
- ->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_CLAIM_VALUE_NORM,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_QUALIFIER_VALUE_NORM,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
+ $this->writer->about(
+ RdfVocabulary::NSP_REFERENCE_VALUE_NORM,
+ $id
+ )->a( 'owl', 'ObjectProperty' );
- $this->writer->about(
RdfVocabulary::NSP_DIRECT_CLAIM_NORM, $id )
- ->a( 'owl', $normalizedPropertyRdfType );
+ $this->writer->about(
+ RdfVocabulary::NSP_DIRECT_CLAIM_NORM,
+ $id
+ )->a( 'owl', $normalizedPropertyRdfType );
}
}
diff --git a/repo/includes/Rdf/RdfVocabulary.php
b/repo/includes/Rdf/RdfVocabulary.php
index 5e219db..f9a465f 100644
--- a/repo/includes/Rdf/RdfVocabulary.php
+++ b/repo/includes/Rdf/RdfVocabulary.php
@@ -81,9 +81,9 @@
];
// Value properties
public static $claimToValue = [
- self::NSP_CLAIM_STATEMENT => self::NSP_CLAIM_VALUE,
- self::NSP_QUALIFIER => self::NSP_QUALIFIER_VALUE,
- self::NSP_REFERENCE => self::NSP_REFERENCE_VALUE,
+ self::NSP_CLAIM_STATEMENT => self::NSP_CLAIM_VALUE,
+ self::NSP_QUALIFIER => self::NSP_QUALIFIER_VALUE,
+ self::NSP_REFERENCE => self::NSP_REFERENCE_VALUE,
];
// Value properties for normalized values
public static $claimToValueNormalized = [
@@ -165,38 +165,38 @@
$propUri = $topUri."prop/";
$this->namespaces = [
- 'rdf' =>
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
- 'rdfs' =>
'http://www.w3.org/2000/01/rdf-schema#',
- 'xsd' => 'http://www.w3.org/2001/XMLSchema#',
- 'owl' => 'http://www.w3.org/2002/07/owl#',
- // TODO: drop beta once we have stable ontology
- self::NS_ONTOLOGY => self::ONTOLOGY_BASE_URI .
"-beta#",
- // nodes
- self::NS_DATA => $this->dataUri,
- self::NS_ENTITY => $this->baseUri,
- self::NS_STATEMENT => $this->baseUri .
'statement/',
- self::NS_REFERENCE => $topUri . 'reference/',
- self::NS_VALUE => $topUri . 'value/',
- // predicates
- self::NSP_DIRECT_CLAIM => $propUri . 'direct/',
- self::NSP_DIRECT_CLAIM_NORM => $propUri .
'direct-normalized/',
- self::NSP_CLAIM => $propUri,
- self::NSP_CLAIM_STATEMENT => $propUri .
'statement/',
- self::NSP_CLAIM_VALUE => $propUri .
'statement/value/',
- self::NSP_CLAIM_VALUE_NORM => $propUri .
'statement/value-normalized/',
- self::NSP_QUALIFIER => $propUri . 'qualifier/',
- self::NSP_QUALIFIER_VALUE => $propUri .
'qualifier/value/',
- self::NSP_QUALIFIER_VALUE_NORM => $propUri .
'qualifier/value-normalized/',
- self::NSP_REFERENCE => $propUri . 'reference/',
- self::NSP_REFERENCE_VALUE => $propUri .
'reference/value/',
- self::NSP_REFERENCE_VALUE_NORM => $propUri .
'reference/value-normalized/',
- self::NSP_NOVALUE => $propUri . 'novalue/',
- // external
- self::NS_SKOS => self::SKOS_URI,
- self::NS_SCHEMA_ORG => self::SCHEMA_ORG_URI,
- self::NS_CC => self::CC_URI,
- self::NS_GEO => self::GEO_URI,
- self::NS_PROV => self::PROV_URI,
+ 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+ 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
+ 'xsd' => 'http://www.w3.org/2001/XMLSchema#',
+ 'owl' => 'http://www.w3.org/2002/07/owl#',
+ // TODO: drop beta once we have stable ontology
+ self::NS_ONTOLOGY => self::ONTOLOGY_BASE_URI . "-beta#",
+ // nodes
+ self::NS_DATA => $this->dataUri,
+ self::NS_ENTITY => $this->baseUri,
+ self::NS_STATEMENT => $this->baseUri . 'statement/',
+ self::NS_REFERENCE => $topUri . 'reference/',
+ self::NS_VALUE => $topUri . 'value/',
+ // predicates
+ self::NSP_DIRECT_CLAIM => $propUri . 'direct/',
+ self::NSP_DIRECT_CLAIM_NORM => $propUri .
'direct-normalized/',
+ self::NSP_CLAIM => $propUri,
+ self::NSP_CLAIM_STATEMENT => $propUri . 'statement/',
+ self::NSP_CLAIM_VALUE => $propUri . 'statement/value/',
+ self::NSP_CLAIM_VALUE_NORM => $propUri .
'statement/value-normalized/',
+ self::NSP_QUALIFIER => $propUri . 'qualifier/',
+ self::NSP_QUALIFIER_VALUE => $propUri .
'qualifier/value/',
+ self::NSP_QUALIFIER_VALUE_NORM => $propUri .
'qualifier/value-normalized/',
+ self::NSP_REFERENCE => $propUri . 'reference/',
+ self::NSP_REFERENCE_VALUE => $propUri .
'reference/value/',
+ self::NSP_REFERENCE_VALUE_NORM => $propUri .
'reference/value-normalized/',
+ self::NSP_NOVALUE => $propUri . 'novalue/',
+ // external
+ self::NS_SKOS => self::SKOS_URI,
+ self::NS_SCHEMA_ORG => self::SCHEMA_ORG_URI,
+ self::NS_CC => self::CC_URI,
+ self::NS_GEO => self::GEO_URI,
+ self::NS_PROV => self::PROV_URI,
];
}
diff --git a/repo/tests/phpunit/includes/Rdf/FullStatementRdfBuilderTest.php
b/repo/tests/phpunit/includes/Rdf/FullStatementRdfBuilderTest.php
index 2c9a4b1..62c7a1d 100644
--- a/repo/tests/phpunit/includes/Rdf/FullStatementRdfBuilderTest.php
+++ b/repo/tests/phpunit/includes/Rdf/FullStatementRdfBuilderTest.php
@@ -3,6 +3,7 @@
namespace Wikibase\Repo\Tests\Rdf;
use Wikibase\DataModel\Entity\EntityId;
+use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\Rdf\DedupeBag;
use Wikibase\Rdf\EntityMentionListener;
use Wikibase\Rdf\FullStatementRdfBuilder;
@@ -118,8 +119,10 @@
public function provideAddEntity() {
$props = array_map(
- function ( $row ) {
- return $row[0];
+ function ( $data ) {
+ /** @var PropertyId $propertyId */
+ $propertyId = $data[0];
+ return $propertyId->getSerialization();
},
$this->getTestData()->getTestProperties()
);
--
To view, visit https://gerrit.wikimedia.org/r/390277
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9aff0eb930cd755582505b641385932ef9217c36
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits