Search in sources :

Example 1 with BigdataURI

use of com.bigdata.rdf.model.BigdataURI in project wikidata-query-rdf by wikimedia.

the class IsSomeValueUnitTest method testReturnFalseOnConcreteValue.

@Test
public void testReturnFalseOnConcreteValue() throws QueryEvaluationException {
    switchToBlank();
    BigdataURI uri = store().getValueFactory().createURI("http://unittest.local/testReturnFalseOnConcreteValue");
    add(uri, uri, uri);
    add(uri, uri, store().getValueFactory().createLiteral("foo"));
    TupleQueryResult tqr = query("select ?s where { ?s <" + uri + "> ?o FILTER wikibase:isSomeValue(?o) }");
    assertThat(tqr.hasNext()).isFalse();
}
Also used : TupleQueryResult(org.openrdf.query.TupleQueryResult) BigdataURI(com.bigdata.rdf.model.BigdataURI) Test(org.junit.Test)

Example 2 with BigdataURI

use of com.bigdata.rdf.model.BigdataURI in project wikidata-query-rdf by wikimedia.

the class IsSomeValueUnitTest method testReturnTrueOnBNode.

@Test
public void testReturnTrueOnBNode() throws QueryEvaluationException {
    switchToBlank();
    BigdataURI uri = store().getValueFactory().createURI("http://unittest.local/testReturnTrueOnBNode");
    add(uri, uri, store().getValueFactory().createBNode());
    TupleQueryResult tqr = query("select ?s where { ?s <" + uri + "> ?o FILTER wikibase:isSomeValue(?o) }");
    assertThat(tqr.hasNext()).isTrue();
    BindingSet result = tqr.next();
    assertThat(result).matches((e) -> binds("s", uri).matches(e));
}
Also used : BindingSet(org.openrdf.query.BindingSet) TupleQueryResult(org.openrdf.query.TupleQueryResult) BigdataURI(com.bigdata.rdf.model.BigdataURI) Test(org.junit.Test)

Example 3 with BigdataURI

use of com.bigdata.rdf.model.BigdataURI in project wikidata-query-rdf by wikimedia.

the class IsSomeValueUnitTest method testReturnTrueOnSkolemPrefix.

@Test
public void testReturnTrueOnSkolemPrefix() throws QueryEvaluationException {
    switchToSkolem();
    BigdataURI uri = store().getValueFactory().createURI("http://unittest.local/testReturnTrueOnSkolemPrefix");
    BigdataURI skolem = store().getValueFactory().createURI(scheme.wellKnownBNodeIRIPrefix(), "91212dc3fcc8b65607d27f92b36e5761");
    add(uri, uri, skolem);
    TupleQueryResult tqr = query("select ?s where { ?s <" + uri + "> ?o FILTER wikibase:isSomeValue(?o) }");
    assertThat(tqr.hasNext()).isTrue();
    BindingSet result = tqr.next();
    assertThat(result).matches((e) -> binds("s", uri).matches(e));
}
Also used : BindingSet(org.openrdf.query.BindingSet) TupleQueryResult(org.openrdf.query.TupleQueryResult) BigdataURI(com.bigdata.rdf.model.BigdataURI) Test(org.junit.Test)

Example 4 with BigdataURI

use of com.bigdata.rdf.model.BigdataURI in project wikidata-query-rdf by wikimedia.

the class AbstractMultiTypeExtension method resolveDataType.

/**
 * Convert the literal into a uri as resolved by the resolve this extension
 * received on construction.
 */
@SuppressWarnings("rawtypes")
protected BigdataURI resolveDataType(LiteralExtensionIV literal) {
    IV extensionIV = literal.getExtensionIV();
    BigdataURI dt = dataTypes.get(extensionIV);
    if (dt == null) {
        throw new IllegalArgumentException("Unrecognized datatype:  " + extensionIV);
    }
    return dt;
}
Also used : IV(com.bigdata.rdf.internal.IV) AbstractLiteralIV(com.bigdata.rdf.internal.impl.literal.AbstractLiteralIV) LiteralExtensionIV(com.bigdata.rdf.internal.impl.literal.LiteralExtensionIV) BigdataURI(com.bigdata.rdf.model.BigdataURI)

Example 5 with BigdataURI

use of com.bigdata.rdf.model.BigdataURI in project wikidata-query-rdf by wikimedia.

the class GeoService method getGlobeNode.

/**
 * Create globe node with appropriate value for coordSystem.
 */
protected TermNode getGlobeNode(BigdataValueFactory vf, ServiceParams serviceParams) {
    final TermNode globeNode = serviceParams.get(GLOBE_PARAM, null);
    if (globeNode == null) {
        return new DummyConstantNode(vf.createLiteral(WKTSerializer.NO_GLOBE));
    }
    if (!globeNode.isConstant()) {
        // FIXME: add support for this
        throw new IllegalArgumentException("Non-constant globe value is not supported yet.");
    }
    BigdataValue v = globeNode.getValue();
    if (v instanceof BigdataURI) {
        WKTSerializer ser = new WKTSerializer();
        try {
            return new DummyConstantNode(vf.createLiteral(ser.trimCoordURI(v.stringValue())));
        } catch (GeoSpatialSearchException e) {
            // Unexpectedly wrong URI - still pass it along
            return globeNode;
        }
    }
    return globeNode;
}
Also used : BigdataValue(com.bigdata.rdf.model.BigdataValue) DummyConstantNode(com.bigdata.rdf.sparql.ast.DummyConstantNode) WKTSerializer(org.wikidata.query.rdf.blazegraph.inline.literal.WKTSerializer) GeoSpatialSearchException(com.bigdata.service.geospatial.GeoSpatialSearchException) TermNode(com.bigdata.rdf.sparql.ast.TermNode) BigdataURI(com.bigdata.rdf.model.BigdataURI)

Aggregations

BigdataURI (com.bigdata.rdf.model.BigdataURI)7 Test (org.junit.Test)5 TupleQueryResult (org.openrdf.query.TupleQueryResult)5 BindingSet (org.openrdf.query.BindingSet)2 IV (com.bigdata.rdf.internal.IV)1 AbstractLiteralIV (com.bigdata.rdf.internal.impl.literal.AbstractLiteralIV)1 LiteralExtensionIV (com.bigdata.rdf.internal.impl.literal.LiteralExtensionIV)1 BigdataValue (com.bigdata.rdf.model.BigdataValue)1 DummyConstantNode (com.bigdata.rdf.sparql.ast.DummyConstantNode)1 TermNode (com.bigdata.rdf.sparql.ast.TermNode)1 GeoSpatialSearchException (com.bigdata.service.geospatial.GeoSpatialSearchException)1 WKTSerializer (org.wikidata.query.rdf.blazegraph.inline.literal.WKTSerializer)1