Smalyshev has uploaded a new change for review.
https://gerrit.wikimedia.org/r/215984
Change subject: T98809: add owl property types to the properties
......................................................................
T98809: add owl property types to the properties
Change-Id: Id2902027d50f1a892347805e1082c3fb248b3673
---
M repo/includes/rdf/RdfBuilder.php
M repo/tests/phpunit/data/rdf/Q4_props.nt
M repo/tests/phpunit/data/rdf/dump_entities.nt
M repo/tests/phpunit/data/rdf/dump_redirect.nt
4 files changed, 111 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/84/215984/1
diff --git a/repo/includes/rdf/RdfBuilder.php b/repo/includes/rdf/RdfBuilder.php
index 076c2a0..bd3ccbd 100644
--- a/repo/includes/rdf/RdfBuilder.php
+++ b/repo/includes/rdf/RdfBuilder.php
@@ -300,8 +300,9 @@
/**
* Write predicates linking property entity to property predicates
* @param string $id
+ * @param boolean $isObjectProperty Is the property data or object
property?
*/
- private function writePropertyPredicates( $id ) {
+ private function writePropertyPredicates( $id, $isObjectProperty ) {
$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 );
@@ -311,6 +312,33 @@
$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 );
+ // 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' );
+ // Depending on property type
+ if( $isObjectProperty ) {
+ $datatype = 'ObjectProperty';
+ } else {
+ $datatype = 'DatatypeProperty';
+ }
+ $this->writer->about( RdfVocabulary::NSP_DIRECT_CLAIM, $id
)->a( 'owl', $datatype );
+ $this->writer->about( RdfVocabulary::NSP_CLAIM_STATEMENT, $id
)->a( 'owl', $datatype );
+ $this->writer->about( RdfVocabulary::NSP_QUALIFIER, $id )->a(
'owl', $datatype );
+ $this->writer->about( RdfVocabulary::NSP_REFERENCE, $id )->a(
'owl', $datatype );
+ }
+
+ /**
+ * Check if the property describes link between objects
+ * or just data item.
+ *
+ * @param Property $property
+ * @return boolean
+ */
+ private function propertyIsLink( Property $property ) {
+ // For now, it's very simple but can be more complex later
+ return $property->getDataTypeId() == 'wikibase-entityid';
}
/**
@@ -344,7 +372,7 @@
$this->writer->say( RdfVocabulary::NS_ONTOLOGY,
'propertyType' )
->is( RdfVocabulary::NS_ONTOLOGY,
$this->vocabulary->getDataTypeName( $entity ) );
$id = $entity->getId()->getSerialization();
- $this->writePropertyPredicates( $id );
+ $this->writePropertyPredicates( $id,
$this->propertyIsLink( $entity ) );
$this->writeNovalueClass( $id );
}
}
@@ -398,7 +426,7 @@
}
// If we encountered redirects, the redirect targets may now
need resolving.
- // They actually got added to $this->entitiesResolved, but may
not have been
+ // They actually got added to $this->entitiesResolved, but may
not have been
// processed by the loop above, because they got added while
the loop was in progress.
if ( $hasRedirect ) {
// Call resolveMentionedEntities() recursively to
resolve any yet unresolved
diff --git a/repo/tests/phpunit/data/rdf/Q4_props.nt
b/repo/tests/phpunit/data/rdf/Q4_props.nt
index 5f0db71..e5abb8b 100644
--- a/repo/tests/phpunit/data/rdf/Q4_props.nt
+++ b/repo/tests/phpunit/data/rdf/Q4_props.nt
@@ -213,3 +213,67 @@
_:genid9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#Restriction> .
_:genid9 <http://www.w3.org/2002/07/owl#onProperty>
<http://acme.test/prop/direct/P9> .
_:genid9 <http://www.w3.org/2002/07/owl#someValuesFrom>
<http://www.w3.org/2002/07/owl#Thing> .
+<http://acme.test/prop/P2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/qualifier/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/qualifier/value/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/value/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/value/P2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P3>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P4>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P5> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P5>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P6> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P6>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P7>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P8> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P8>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/P9> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P9>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
diff --git a/repo/tests/phpunit/data/rdf/dump_entities.nt
b/repo/tests/phpunit/data/rdf/dump_entities.nt
index 5c29dfc..811a036 100644
--- a/repo/tests/phpunit/data/rdf/dump_entities.nt
+++ b/repo/tests/phpunit/data/rdf/dump_entities.nt
@@ -36,3 +36,11 @@
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#Restriction> .
_:genid1 <http://www.w3.org/2002/07/owl#onProperty>
<http://acme.test/prop/direct/P10> .
_:genid1 <http://www.w3.org/2002/07/owl#someValuesFrom>
<http://www.w3.org/2002/07/owl#Thing> .
+<http://acme.test/prop/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
diff --git a/repo/tests/phpunit/data/rdf/dump_redirect.nt
b/repo/tests/phpunit/data/rdf/dump_redirect.nt
index 384c4d4..8949294 100644
--- a/repo/tests/phpunit/data/rdf/dump_redirect.nt
+++ b/repo/tests/phpunit/data/rdf/dump_redirect.nt
@@ -26,3 +26,11 @@
<http://acme.test/P10> <http://wikiba.se/ontology-beta#referenceValue>
<http://acme.test/prop/reference/value/P10> .
<http://acme.test/P10> <http://wikiba.se/ontology-beta#statementProperty>
<http://acme.test/prop/statement/P10> .
<http://acme.test/P10> <http://wikiba.se/ontology-beta#statementValue>
<http://acme.test/prop/statement/value/P10> .
+<http://acme.test/prop/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/value/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/value/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/value/P10>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://www.w3.org/2002/07/owl#ObjectProperty> .
--
To view, visit https://gerrit.wikimedia.org/r/215984
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2902027d50f1a892347805e1082c3fb248b3673
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits