Skip to content

Commit

Permalink
Fixed URIs and property declarations; renamed some constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroetzsch committed Feb 8, 2016
1 parent dc1a1bc commit 38e2100
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 82 deletions.
Expand Up @@ -32,38 +32,46 @@ public interface DatatypeIdValue extends IriIdentifiedValue {
/**
* IRI of the item datatype in Wikibase.
*/
String DT_ITEM = "http://wikiba.se/ontology#propertyTypeItem";
String DT_ITEM = "http://wikiba.se/ontology#WikibaseItem";
/**
* IRI of the property datatype in Wikibase.
*/
String DT_PROPERTY = "http://wikiba.se/ontology#propertyTypeProperty";
String DT_PROPERTY = "http://wikiba.se/ontology#WikibaseProperty";
/**
* IRI of the string datatype in Wikibase.
*/
String DT_STRING = "http://wikiba.se/ontology#propertyTypeString";
String DT_STRING = "http://wikiba.se/ontology#String";
/**
* IRI of the URL datatype in Wikibase.
*/
String DT_URL = "http://wikiba.se/ontology#propertyTypeUrl";
String DT_URL = "http://wikiba.se/ontology#Url";
/**
* IRI of the Commons media datatype in Wikibase.
*/
String DT_COMMONS_MEDIA = "http://wikiba.se/ontology#propertyTypeCommonsMedia";
String DT_COMMONS_MEDIA = "http://wikiba.se/ontology#CommonsMedia";
/**
* IRI of the time datatype in Wikibase.
*/
String DT_TIME = "http://wikiba.se/ontology#propertyTypeTime";
String DT_TIME = "http://wikiba.se/ontology#Time";
/**
* IRI of the globe coordinates datatype in Wikibase.
*/
String DT_GLOBE_COORDINATES = "http://wikiba.se/ontology#propertyTypeGlobeCoordinates";
String DT_GLOBE_COORDINATES = "http://wikiba.se/ontology#GlobeCoordinate";
/**
* IRI of the quantity datatype in Wikibase.
*/
String DT_QUANTITY = "http://wikiba.se/ontology#propertyTypeQuantity";
String DT_QUANTITY = "http://wikiba.se/ontology#Quantity";
/**
* IRI of the monolingual text datatype in Wikibase.
*/
String DT_MONOLINGUAL_TEXT = "http://wikiba.se/ontology#propertyTypeMonolingualText";
String DT_MONOLINGUAL_TEXT = "http://wikiba.se/ontology#Monolingualtext";
/**
* IRI of the external identifier datatype in Wikibase.
*/
String DT_EXTERNAL_ID = "http://wikiba.se/ontology#ExternalId";
/**
* IRI of the math datatype in Wikibase.
*/
String DT_MATH = "http://wikiba.se/ontology#Math";

}
Expand Up @@ -39,8 +39,7 @@ public class DatatypeIdImplTest {
@Before
public void setUp() {
d1 = new DatatypeIdImpl(DatatypeIdValue.DT_ITEM);
d2 = new DatatypeIdImpl(
"http://wikiba.se/ontology#propertyTypeItem");
d2 = new DatatypeIdImpl("http://wikiba.se/ontology#WikibaseItem");
d3 = new DatatypeIdImpl(DatatypeIdValue.DT_TIME);
}

Expand Down
Expand Up @@ -165,7 +165,7 @@ public void writePropertyDeclarations(RdfWriter rdfWriter,
propertyIdValue, PropertyContext.STATEMENT),
RdfWriter.RDF_TYPE, RdfWriter.OWL_OBJECT_PROPERTY);
rdfWriter.writeTripleValueObject(Vocabulary.getPropertyUri(
propertyIdValue, PropertyContext.SIMPLE_VALUE),
propertyIdValue, PropertyContext.VALUE_SIMPLE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_OBJECT_PROPERTY);
rdfWriter.writeTripleValueObject(Vocabulary.getPropertyUri(
propertyIdValue, PropertyContext.VALUE),
Expand All @@ -180,7 +180,7 @@ public void writePropertyDeclarations(RdfWriter rdfWriter,
propertyIdValue, PropertyContext.QUALIFIER_SIMPLE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_OBJECT_PROPERTY);
rdfWriter.writeTripleValueObject(Vocabulary.getPropertyUri(
propertyIdValue, PropertyContext.SIMPLE_REFERENCE),
propertyIdValue, PropertyContext.REFERENCE_SIMPLE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_OBJECT_PROPERTY);
}
if (simpleClaims) {
Expand Down Expand Up @@ -218,13 +218,13 @@ public void writePropertyDeclarations(RdfWriter rdfWriter,
propertyIdValue, PropertyContext.REFERENCE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_DATATYPE_PROPERTY);
rdfWriter.writeTripleValueObject(Vocabulary.getPropertyUri(
propertyIdValue, PropertyContext.SIMPLE_VALUE),
propertyIdValue, PropertyContext.VALUE_SIMPLE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_DATATYPE_PROPERTY);
rdfWriter.writeTripleValueObject(Vocabulary.getPropertyUri(
propertyIdValue, PropertyContext.QUALIFIER_SIMPLE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_DATATYPE_PROPERTY);
rdfWriter.writeTripleValueObject(Vocabulary.getPropertyUri(
propertyIdValue, PropertyContext.SIMPLE_REFERENCE),
propertyIdValue, PropertyContext.REFERENCE_SIMPLE),
RdfWriter.RDF_TYPE, RdfWriter.OWL_DATATYPE_PROPERTY);

}
Expand Down
Expand Up @@ -28,5 +28,5 @@
*
*/
public enum PropertyContext {
STATEMENT, VALUE, QUALIFIER, REFERENCE, SIMPLE_REFERENCE, DIRECT, SIMPLE_VALUE, QUALIFIER_SIMPLE, NO_VALUE, NO_QUALIFIER_VALUE
STATEMENT, VALUE, QUALIFIER, REFERENCE, REFERENCE_SIMPLE, DIRECT, VALUE_SIMPLE, QUALIFIER_SIMPLE, NO_VALUE, NO_QUALIFIER_VALUE
}
36 changes: 20 additions & 16 deletions wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/RdfConverter.java
Expand Up @@ -248,46 +248,50 @@ void writeInterPropertyLinks(PropertyDocument document)
Resource subject = this.rdfWriter.getUri(document.getEntityId()
.getIri());
this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_DIRECT_CLAIM), Vocabulary.getPropertyUri(
document.getPropertyId(), PropertyContext.DIRECT));
.getUri(Vocabulary.WB_DIRECT_CLAIM_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.DIRECT));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_CLAIM), Vocabulary.getPropertyUri(
.getUri(Vocabulary.WB_CLAIM_PROP), Vocabulary.getPropertyUri(
document.getPropertyId(), PropertyContext.STATEMENT));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_STATEMENT_PROPERTY), Vocabulary
.getUri(Vocabulary.WB_STATEMENT_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.SIMPLE_VALUE));
PropertyContext.VALUE_SIMPLE));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_STATEMENT_VALUE),
.getUri(Vocabulary.WB_STATEMENT_VALUE_PROP),
Vocabulary.getPropertyUri(document.getPropertyId(),
PropertyContext.VALUE));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_QUALIFIER), Vocabulary.getPropertyUri(
document.getPropertyId(), PropertyContext.QUALIFIER_SIMPLE));
.getUri(Vocabulary.WB_QUALIFIER_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.QUALIFIER_SIMPLE));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_QUALIFIER_VALUE), Vocabulary
.getUri(Vocabulary.WB_QUALIFIER_VALUE_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.QUALIFIER));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_REFERENCE), Vocabulary.getPropertyUri(
document.getPropertyId(), PropertyContext.SIMPLE_REFERENCE));
.getUri(Vocabulary.WB_REFERENCE_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.REFERENCE_SIMPLE));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_REFERENCE_VALUE), Vocabulary
.getUri(Vocabulary.WB_REFERENCE_VALUE_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.REFERENCE));

this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_NO_VALUE), Vocabulary.getPropertyUri(
document.getPropertyId(), PropertyContext.NO_VALUE));
.getUri(Vocabulary.WB_NO_VALUE_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.NO_VALUE));
this.rdfWriter.writeTripleUriObject(subject, this.rdfWriter
.getUri(Vocabulary.WB_NO_QUALIFIER_VALUE), Vocabulary
.getUri(Vocabulary.WB_NO_QUALIFIER_VALUE_PROP), Vocabulary
.getPropertyUri(document.getPropertyId(),
PropertyContext.NO_QUALIFIER_VALUE));
// TODO something more with NO_VALUE
Expand Down Expand Up @@ -540,7 +544,7 @@ void writeClaim(Resource claimResource, Claim claim) {
PropertyContext.VALUE);
claim.getMainSnak().accept(this.snakRdfConverter);
this.snakRdfConverter.setSnakContext(claimResource,
PropertyContext.SIMPLE_VALUE);
PropertyContext.VALUE_SIMPLE);
claim.getMainSnak().accept(this.snakRdfConverter);
// write qualifier
this.snakRdfConverter.setSnakContext(claimResource,
Expand Down
Expand Up @@ -142,9 +142,9 @@ public void setSnakContext(Resource subject, PropertyContext propertyContext) {
this.currentSubject = subject;
this.currentPropertyContext = propertyContext;
this.simple = (this.currentPropertyContext == PropertyContext.DIRECT)
|| (this.currentPropertyContext == PropertyContext.SIMPLE_VALUE)
|| (this.currentPropertyContext == PropertyContext.VALUE_SIMPLE)
|| (this.currentPropertyContext == PropertyContext.QUALIFIER_SIMPLE)
|| (this.currentPropertyContext == PropertyContext.SIMPLE_REFERENCE);
|| (this.currentPropertyContext == PropertyContext.REFERENCE_SIMPLE);

}

Expand Down
79 changes: 50 additions & 29 deletions wdtk-rdf/src/main/java/org/wikidata/wdtk/rdf/Vocabulary.java
Expand Up @@ -365,80 +365,101 @@ public class Vocabulary {
+ "DeprecatedRank";

/**
* Class for Wikibase direct claims.
* Property for connecting Wikibase property entities to their direct value
* properties (linking entities to their simplified statement's main
* values).
*/
public static final String WB_DIRECT_CLAIM = PREFIX_WBONTO + "directClaim";
public static final String WB_DIRECT_CLAIM_PROP = PREFIX_WBONTO
+ "directClaim";
static {
VOCABULARY_TYPES.put(WB_DIRECT_CLAIM, OWL_CLASS);
VOCABULARY_TYPES.put(WB_DIRECT_CLAIM_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Class for Wikibase claims.
* Property for connecting Wikibase property entities to their statement
* properties (linking entities to statements).
*/
public static final String WB_CLAIM = PREFIX_WBONTO + "claim";
public static final String WB_CLAIM_PROP = PREFIX_WBONTO + "claim";
static {
VOCABULARY_TYPES.put(WB_CLAIM, OWL_CLASS);
VOCABULARY_TYPES.put(WB_CLAIM_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Class for Wikibase direct statement properties.
* Property for connecting Wikibase property entities to their statement
* main value properties (linking to a statement's main value).
*/
public static final String WB_STATEMENT_PROPERTY = PREFIX_WBONTO
public static final String WB_STATEMENT_PROP = PREFIX_WBONTO
+ "statementProperty";
static {
VOCABULARY_TYPES.put(WB_STATEMENT_PROPERTY, OWL_CLASS);
VOCABULARY_TYPES.put(WB_STATEMENT_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Class for Wikibase statement values.
* Property for connecting Wikibase property entities to their statement
* main value properties, value version (linking to a statement's main
* value).
*/
public static final String WB_STATEMENT_VALUE = PREFIX_WBONTO
public static final String WB_STATEMENT_VALUE_PROP = PREFIX_WBONTO
+ "statementValue";
static {
VOCABULARY_TYPES.put(WB_STATEMENT_VALUE, OWL_CLASS);
VOCABULARY_TYPES.put(WB_STATEMENT_VALUE_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Class for Wikibase qualifiers.
* Property for connecting Wikibase property entities to their qualifier
* properties (linking to a statement's qualifier value).
*/
public static final String WB_QUALIFIER = PREFIX_WBONTO + "qualifier";
public static final String WB_QUALIFIER_PROP = PREFIX_WBONTO + "qualifier";
static {
VOCABULARY_TYPES.put(WB_QUALIFIER, OWL_CLASS);
VOCABULARY_TYPES.put(WB_QUALIFIER_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Class for Wikibase qualifier values.
* Property for connecting Wikibase property entities to their qualifier
* value properties (linking to a statement's qualifier value).
*/
public static final String WB_QUALIFIER_VALUE = PREFIX_WBONTO
public static final String WB_QUALIFIER_VALUE_PROP = PREFIX_WBONTO
+ "qualifierValue";
static {
VOCABULARY_TYPES.put(WB_QUALIFIER_VALUE, OWL_CLASS);
VOCABULARY_TYPES.put(WB_QUALIFIER_VALUE_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Class for Wikibase references values.
* Property for connecting Wikibase property entities to their reference
* properties.
*/
public static final String WB_REFERENCE_VALUE = PREFIX_WBONTO
public static final String WB_REFERENCE_PROP = PREFIX_WBONTO + "reference";
static {
VOCABULARY_TYPES.put(WB_REFERENCE_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Property for connecting Wikibase property entities to their reference
* value properties.
*/
public static final String WB_REFERENCE_VALUE_PROP = PREFIX_WBONTO
+ "referenceValue";
static {
VOCABULARY_TYPES.put(WB_REFERENCE_VALUE, OWL_CLASS);
VOCABULARY_TYPES.put(WB_REFERENCE_VALUE_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Property for Wikibase no values.
* Property for connecting Wikibase property entities to their main no-value
* classes.
*/
public static final String WB_NO_VALUE = PREFIX_WBONTO + "novalue";
public static final String WB_NO_VALUE_PROP = PREFIX_WBONTO + "novalue";
static {
VOCABULARY_TYPES.put(WB_NO_VALUE, OWL_OBJECT_PROPERTY);
VOCABULARY_TYPES.put(WB_NO_VALUE_PROP, OWL_OBJECT_PROPERTY);
}

/**
* Property for Wikibase no qualifier values.
* Property for connecting Wikibase property entities to their no-value
* classes for qualifiers.
*/
public static final String WB_NO_QUALIFIER_VALUE = PREFIX_WBONTO
public static final String WB_NO_QUALIFIER_VALUE_PROP = PREFIX_WBONTO
+ "noqualifiervalue";
static {
VOCABULARY_TYPES.put(WB_NO_QUALIFIER_VALUE, OWL_OBJECT_PROPERTY);
VOCABULARY_TYPES.put(WB_NO_QUALIFIER_VALUE_PROP, OWL_OBJECT_PROPERTY);
}

/**
Expand Down Expand Up @@ -480,7 +501,7 @@ public static String getPropertyUri(PropertyIdValue propertyIdValue,
return PREFIX_PROPERTY_DIRECT + propertyIdValue.getId();
case STATEMENT:
return PREFIX_PROPERTY + propertyIdValue.getId();
case SIMPLE_VALUE:
case VALUE_SIMPLE:
return PREFIX_PROPERTY_STATEMENT + propertyIdValue.getId();
case VALUE:
return PREFIX_PROPERTY_STATEMENT_VALUE + propertyIdValue.getId();
Expand All @@ -490,7 +511,7 @@ public static String getPropertyUri(PropertyIdValue propertyIdValue,
return PREFIX_PROPERTY_QUALIFIER + propertyIdValue.getId();
case REFERENCE:
return PREFIX_PROPERTY_REFERENCE_VALUE + propertyIdValue.getId();
case SIMPLE_REFERENCE:
case REFERENCE_SIMPLE:
return PREFIX_PROPERTY_REFERENCE + propertyIdValue.getId();
case NO_VALUE:
return PREFIX_WIKIDATA_NO_VALUE + propertyIdValue.getId();
Expand Down
Expand Up @@ -187,7 +187,7 @@ public void testSetPropertyTypeFromStringValue() {
dataObjectFactory.getPropertyIdValue("P434", this.siteIri),
dataObjectFactory
.getStringValue("http://musicbrainz.org/$1/artist")),
"http://wikiba.se/ontology#propertyTypeString");
"http://wikiba.se/ontology#String");
}

@Test
Expand All @@ -196,7 +196,7 @@ public void testSetMissingPropertyTypeFromStringValue() {
dataObjectFactory.getPropertyIdValue("P10", this.siteIri),
dataObjectFactory
.getStringValue("http://musicbrainz.org/$1/artist")),
"http://wikiba.se/ontology#propertyTypeString");
"http://wikiba.se/ontology#String");
}

@Test
Expand Down
16 changes: 9 additions & 7 deletions wdtk-rdf/src/test/resources/BasicDeclarations.rdf
Expand Up @@ -49,19 +49,21 @@

<http://wikiba.se/ontology#Property> a <http://www.w3.org/2002/07/owl#Class> .

<http://wikiba.se/ontology#directClaim> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#directClaim> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#statementValue> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#statementValue> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#statementProperty> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#statementProperty> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#claim> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#claim> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#qualifier> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#qualifier> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#qualifierValue> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#qualifierValue> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#referenceValue> a <http://www.w3.org/2002/07/owl#Class> .
<http://wikiba.se/ontology#reference> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#referenceValue> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

<http://wikiba.se/ontology#novalue> a <http://www.w3.org/2002/07/owl#ObjectProperty> .

Expand Down

0 comments on commit 38e2100

Please sign in to comment.