Class PropertyRegister

java.lang.Object
org.wikidata.wdtk.rdf.PropertyRegister

public class PropertyRegister extends Object
This class helps to manage information about Properties that has to obtained by a webservice.
Author:
Michael Guenther
  • Field Details

    • datatypes

      protected final Map<String,String> datatypes
      Map that stores the datatype of properties. Properties are identified by their Pid; dataypes are identified by their datatype IRI.
    • uriPatterns

      protected final Map<String,String> 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

      public PropertyRegister(String uriPatternPropertyId, ApiConnection apiConnection, String siteUri)
      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 used
      apiConnection - API connection object that defines how to connect to the online API
      siteUri - the URI identifying the site that is accessed (usually the prefix of entity URIs), e.g., "http://www.wikidata.org/entity/"
  • Method Details

    • getWikidataPropertyRegister

      public static PropertyRegister getWikidataPropertyRegister()
      Returns a singleton object that serves as a property register for Wikidata.
      Returns:
      property register for Wikidata
    • getUriPrefix

      public String 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

      public String getPropertyType(PropertyIdValue propertyIdValue)
      Returns the IRI of the primitive type of an PropertyIdValue.
      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

      public void setPropertyType(PropertyIdValue propertyIdValue, String datatypeIri)
      Sets datatypeIri an IRI of the primitive type of an Property for PropertyIdValue.
      Parameters:
      propertyIdValue -
      datatypeIri -
    • getPropertyUriPattern

      public String getPropertyUriPattern(PropertyIdValue propertyIdValue)
      Returns the URI Pattern of a PropertyIdValue 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 for EntityIdValue objects. TODO: this really ought to be exposed by the wdtk-datamodel module and reused here. The same heuristic is implemented in EntityIdValueImpl.
      Parameters:
      propertyIdValue -
      value -
    • setPropertyTypeFromGlobeCoordinatesValue

      public String setPropertyTypeFromGlobeCoordinatesValue(PropertyIdValue propertyIdValue, GlobeCoordinatesValue value)
      Returns the IRI of the primitive Type of an Property for GlobeCoordinatesValue objects.
      Parameters:
      propertyIdValue -
      value -
    • setPropertyTypeFromQuantityValue

      public String setPropertyTypeFromQuantityValue(PropertyIdValue propertyIdValue, QuantityValue value)
      Returns the IRI of the primitive Type of an Property for QuantityValue objects.
      Parameters:
      propertyIdValue -
      value -
    • setPropertyTypeFromStringValue

      public String setPropertyTypeFromStringValue(PropertyIdValue propertyIdValue, StringValue value)
      Returns the IRI of the primitive Type of an Property for StringValue objects.
      Parameters:
      propertyIdValue -
      value -
    • setPropertyTypeFromTimeValue

      public String setPropertyTypeFromTimeValue(PropertyIdValue propertyIdValue, TimeValue value)
      Returns the IRI of the primitive Type of an Property for TimeValue objects.
      Parameters:
      propertyIdValue -
      value -
    • setPropertyTypeFromMonolingualTextValue

      public String setPropertyTypeFromMonolingualTextValue(PropertyIdValue propertyIdValue, MonolingualTextValue value)
      Returns the IRI of the primitive Type of an Property for MonolingualTextValue objects.
      Parameters:
      propertyIdValue -
      value -
    • fetchPropertyInformation

      protected void fetchPropertyInformation(PropertyIdValue property)
      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

      public void fetchUsingSPARQL(URI endpoint)
      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"