Search in sources :

Example 1 with PropertyType

use of org.wikidata.query.rdf.common.uri.WikibaseUris.PropertyType in project wikidata-query-rdf by wikimedia.

the class AbstractRandomizedBlazegraphTestBase method convert.

/**
 * Convert any object into an RDF value.
 */
protected Value convert(Object o) {
    if (o instanceof Value) {
        return (Value) o;
    }
    if (o instanceof String) {
        String s = (String) o;
        s = s.replaceFirst("^ontology:", Ontology.NAMESPACE);
        s = s.replaceFirst("^wdata:", uris.entityData());
        s = s.replaceFirst("^wd:", uris.entity());
        s = s.replaceFirst("^wds:", uris.statement());
        s = s.replaceFirst("^wdv:", uris.value());
        s = s.replaceFirst("^wdref:", uris.reference());
        for (PropertyType p : PropertyType.values()) {
            s = s.replaceFirst("^" + p.prefix() + ":", uris.property(p));
        }
        return new URIImpl(s);
    }
    if (o instanceof Integer) {
        return new IntegerLiteralImpl(BigInteger.valueOf((int) o));
    }
    throw new RuntimeException("No idea how to convert " + o + " to a value.  Its a " + o.getClass() + ".");
}
Also used : BigInteger(java.math.BigInteger) Value(org.openrdf.model.Value) IntegerLiteralImpl(org.openrdf.model.impl.IntegerLiteralImpl) URIImpl(org.openrdf.model.impl.URIImpl) PropertyType(org.wikidata.query.rdf.common.uri.WikibaseUris.PropertyType)

Example 2 with PropertyType

use of org.wikidata.query.rdf.common.uri.WikibaseUris.PropertyType in project wikidata-query-rdf by wikimedia.

the class WikibaseContextListener method addPrefixes.

/**
 * Add standard prefixes to the system.
 * @param uris Wikidata URIs to use
 */
private static void addPrefixes(final WikibaseUris uris) {
    final Map<String, String> defaultDecls = PrefixDeclProcessor.defaultDecls;
    for (PropertyType p : PropertyType.values()) {
        defaultDecls.put(p.prefix(), uris.property(p));
    }
    defaultDecls.put("wikibase", Ontology.NAMESPACE);
    defaultDecls.put("wd", uris.entity());
    defaultDecls.put("wds", uris.statement());
    defaultDecls.put("wdv", uris.value());
    defaultDecls.put("wdref", uris.reference());
    defaultDecls.put("wdata", uris.entityData());
    // External schemata
    defaultDecls.put("schema", SchemaDotOrg.NAMESPACE);
    defaultDecls.put("prov", Provenance.NAMESPACE);
    defaultDecls.put("skos", SKOS.NAMESPACE);
    defaultDecls.put("owl", OWL.NAMESPACE);
    defaultDecls.put("geo", GeoSparql.NAMESPACE);
    defaultDecls.put("geof", GeoSparql.FUNCTION_NAMESPACE);
    defaultDecls.put("mediawiki", Mediawiki.NAMESPACE);
    defaultDecls.put("mwapi", Mediawiki.API);
    defaultDecls.put("gas", GASService.Options.NAMESPACE);
}
Also used : PropertyType(org.wikidata.query.rdf.common.uri.WikibaseUris.PropertyType)

Aggregations

PropertyType (org.wikidata.query.rdf.common.uri.WikibaseUris.PropertyType)2 BigInteger (java.math.BigInteger)1 Value (org.openrdf.model.Value)1 IntegerLiteralImpl (org.openrdf.model.impl.IntegerLiteralImpl)1 URIImpl (org.openrdf.model.impl.URIImpl)1