Package org.wikidata.wdtk.rdf
Class PropertyRegister
java.lang.Object
org.wikidata.wdtk.rdf.PropertyRegister
This class helps to manage information about Properties that has to obtained
by a webservice.
- Author:
- Michael Guenther
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPropertyRegister
(String uriPatternPropertyId, ApiConnection apiConnection, String siteUri) Constructs a new property register. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
fetchPropertyInformation
(PropertyIdValue property) Fetches the information of the given property from the Web API.void
fetchUsingSPARQL
(URI endpoint) Fetches type information for all known properties from the given SPARQL endpoint, and adds it to the register.getPropertyType
(PropertyIdValue propertyIdValue) Returns the IRI of the primitive type of anPropertyIdValue
.getPropertyUriPattern
(PropertyIdValue propertyIdValue) Returns the URI Pattern of aPropertyIdValue
that should be used to create URIs of external resources from statement values for the property.Returns the URI prefix that is used on the site considered by this object.static PropertyRegister
Returns a singleton object that serves as a property register for Wikidata.void
setPropertyType
(PropertyIdValue propertyIdValue, String datatypeIri) Sets datatypeIri an IRI of the primitive type of an Property forPropertyIdValue
.setPropertyTypeFromEntityIdValue
(PropertyIdValue propertyIdValue, EntityIdValue value) Returns the IRI of the primitive Type of an Property forEntityIdValue
objects.setPropertyTypeFromGlobeCoordinatesValue
(PropertyIdValue propertyIdValue, GlobeCoordinatesValue value) Returns the IRI of the primitive Type of an Property forGlobeCoordinatesValue
objects.setPropertyTypeFromMonolingualTextValue
(PropertyIdValue propertyIdValue, MonolingualTextValue value) Returns the IRI of the primitive Type of an Property forMonolingualTextValue
objects.setPropertyTypeFromQuantityValue
(PropertyIdValue propertyIdValue, QuantityValue value) Returns the IRI of the primitive Type of an Property forQuantityValue
objects.setPropertyTypeFromStringValue
(PropertyIdValue propertyIdValue, StringValue value) Returns the IRI of the primitive Type of an Property forStringValue
objects.setPropertyTypeFromTimeValue
(PropertyIdValue propertyIdValue, TimeValue value) Returns the IRI of the primitive Type of an Property forTimeValue
objects.
-
Field Details
-
datatypes
Map that stores the datatype of properties. Properties are identified by their Pid; dataypes are identified by their datatype IRI. -
uriPatterns
Map that stores the URI patterns of properties. Properties are identified by their Pid; patterns are given as strings using $1 as placeholder for the escaped value.
-
-
Constructor Details
-
PropertyRegister
Constructs a new property register.- Parameters:
uriPatternPropertyId
- property id used for a URI Pattern property, e.g., P1921 on Wikidata; can be null if no such property should be usedapiConnection
- API connection object that defines how to connect to the online APIsiteUri
- the URI identifying the site that is accessed (usually the prefix of entity URIs), e.g., "http://www.wikidata.org/entity/"
-
-
Method Details
-
getWikidataPropertyRegister
Returns a singleton object that serves as a property register for Wikidata.- Returns:
- property register for Wikidata
-
getUriPrefix
Returns the URI prefix that is used on the site considered by this object. This string also identifies the site globally.- Returns:
- The URI prefix, e.g., "http://www.wikidata.org/entity/"
-
getPropertyType
Returns the IRI of the primitive type of anPropertyIdValue
.- Parameters:
propertyIdValue
- property whose datatype should be fetched- Returns:
- URI of the datatype of this property, or null if the type could not be determined
-
setPropertyType
Sets datatypeIri an IRI of the primitive type of an Property forPropertyIdValue
.- Parameters:
propertyIdValue
-datatypeIri
-
-
getPropertyUriPattern
Returns the URI Pattern of aPropertyIdValue
that should be used to create URIs of external resources from statement values for the property.- Parameters:
propertyIdValue
- property to fetch URI pattern for- Returns:
- string pattern using "$1" as a placeholder, or null if no pattern was found for the given property
-
setPropertyTypeFromEntityIdValue
public String setPropertyTypeFromEntityIdValue(PropertyIdValue propertyIdValue, EntityIdValue value) Returns the IRI of the primitive Type of an Property forEntityIdValue
objects. TODO: this really ought to be exposed by the wdtk-datamodel module and reused here. The same heuristic is implemented inEntityIdValueImpl
.- Parameters:
propertyIdValue
-value
-
-
setPropertyTypeFromGlobeCoordinatesValue
public String setPropertyTypeFromGlobeCoordinatesValue(PropertyIdValue propertyIdValue, GlobeCoordinatesValue value) Returns the IRI of the primitive Type of an Property forGlobeCoordinatesValue
objects.- Parameters:
propertyIdValue
-value
-
-
setPropertyTypeFromQuantityValue
public String setPropertyTypeFromQuantityValue(PropertyIdValue propertyIdValue, QuantityValue value) Returns the IRI of the primitive Type of an Property forQuantityValue
objects.- Parameters:
propertyIdValue
-value
-
-
setPropertyTypeFromStringValue
Returns the IRI of the primitive Type of an Property forStringValue
objects.- Parameters:
propertyIdValue
-value
-
-
setPropertyTypeFromTimeValue
Returns the IRI of the primitive Type of an Property forTimeValue
objects.- Parameters:
propertyIdValue
-value
-
-
setPropertyTypeFromMonolingualTextValue
public String setPropertyTypeFromMonolingualTextValue(PropertyIdValue propertyIdValue, MonolingualTextValue value) Returns the IRI of the primitive Type of an Property forMonolingualTextValue
objects.- Parameters:
propertyIdValue
-value
-
-
fetchPropertyInformation
Fetches the information of the given property from the Web API. Further properties are fetched in the same request and results cached so as to limit the total number of Web requests made until all properties are fetched.- Parameters:
property
-
-
fetchUsingSPARQL
Fetches type information for all known properties from the given SPARQL endpoint, and adds it to the register. The SPARQL endpoint must support the wikibase:propertyType predicate.- Parameters:
endpoint
- URI of the SPARQL service to use, for example "https://query.wikidata.org/sparql"
-