Search in sources :

Example 86 with ValueFactory

use of org.openrdf.model.ValueFactory in project incubator-rya by apache.

the class MongoIndexerDeleteIT method statement.

private static RyaStatement statement(final Geometry geo) {
    final ValueFactory vf = new ValueFactoryImpl();
    final Resource subject = vf.createURI("urn:geo");
    final URI predicate = GeoConstants.GEO_AS_WKT;
    final WKTWriter w = new WKTWriter();
    final Value object = vf.createLiteral(w.write(geo), GeoConstants.XMLSCHEMA_OGC_WKT);
    return RdfToRyaConversions.convertStatement(new StatementImpl(subject, predicate, object));
}
Also used : WKTWriter(com.vividsolutions.jts.io.WKTWriter) StatementImpl(org.openrdf.model.impl.StatementImpl) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) ValueFactory(org.openrdf.model.ValueFactory) URI(org.openrdf.model.URI)

Example 87 with ValueFactory

use of org.openrdf.model.ValueFactory in project incubator-rya by apache.

the class MongoIndexerDeleteIT method populateRya.

private void populateRya(final SailRepositoryConnection conn) throws Exception {
    final ValueFactory VF = new ValueFactoryImpl();
    // geo 2x2 points
    final GeometryFactory GF = new GeometryFactory();
    for (int x = 0; x <= 1; x++) {
        for (int y = 0; y <= 1; y++) {
            final Geometry geo = GF.createPoint(new Coordinate(x + .5, y + .5));
            final RyaStatement stmnt = statement(geo);
            final Statement statement = RyaToRdfConversions.convertStatement(stmnt);
            conn.add(statement);
        }
    }
    // freetext
    final URI person = VF.createURI("http://example.org/ontology/Person");
    String uuid;
    uuid = "urn:people";
    conn.add(VF.createURI(uuid), RDF.TYPE, person);
    conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Alice Palace Hose", VF.createURI("http://www.w3.org/2001/XMLSchema#string")));
    conn.add(VF.createURI(uuid), RDFS.LABEL, VF.createLiteral("Bob Snob Hose", "en"));
    // temporal
    final TemporalInstant instant = new TemporalInstantRfc3339(1, 2, 3, 4, 5, 6);
    conn.add(VF.createURI("foo:time"), VF.createURI("Property:atTime"), VF.createLiteral(instant.toString()));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactory(org.openrdf.model.ValueFactory) TemporalInstant(org.apache.rya.indexing.TemporalInstant) URI(org.openrdf.model.URI)

Example 88 with ValueFactory

use of org.openrdf.model.ValueFactory in project incubator-rya by apache.

the class StatementSerializerTest method testSimpleStatementObjectUri.

@Test
public void testSimpleStatementObjectUri() throws Exception {
    ValueFactory vf = new ValueFactoryImpl();
    Statement s;
    s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createURI("foo:object"));
    Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
    s = new ContextStatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createURI("foo:object"), vf.createURI("foo:context"));
    Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
}
Also used : ContextStatementImpl(org.openrdf.model.impl.ContextStatementImpl) Statement(org.openrdf.model.Statement) ContextStatementImpl(org.openrdf.model.impl.ContextStatementImpl) StatementImpl(org.openrdf.model.impl.StatementImpl) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) ValueFactory(org.openrdf.model.ValueFactory) Test(org.junit.Test)

Example 89 with ValueFactory

use of org.openrdf.model.ValueFactory in project incubator-rya by apache.

the class StatementSerializerTest method testObjectLiteralWithDataTypeGarbage.

@Test
public void testObjectLiteralWithDataTypeGarbage() throws Exception {
    // test with some garbage in the literal that may throw off the parser
    ValueFactory vf = new ValueFactoryImpl();
    Statement s;
    String str;
    str = "Alice ^^<Palace>\"";
    s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str));
    Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
    s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, "en"));
    Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
    s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, vf.createURI("xsd:string")));
    Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
}
Also used : Statement(org.openrdf.model.Statement) ContextStatementImpl(org.openrdf.model.impl.ContextStatementImpl) StatementImpl(org.openrdf.model.impl.StatementImpl) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) ValueFactory(org.openrdf.model.ValueFactory) Test(org.junit.Test)

Example 90 with ValueFactory

use of org.openrdf.model.ValueFactory in project incubator-rya by apache.

the class EntityQueryNodeIT method evaluate_constantObject.

@Test
public void evaluate_constantObject() throws Exception {
    final EntityStorage storage = new MongoEntityStorage(super.getMongoClient(), "testDB");
    final ValueFactory vf = ValueFactoryImpl.getInstance();
    final RyaURI subject = new RyaURI("urn:SSN:111-11-1111");
    final Entity entity = Entity.builder().setSubject(subject).setExplicitType(PERSON_TYPE.getId()).setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:age"), RdfToRyaConversions.convertLiteral(vf.createLiteral(20)))).setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:eye"), RdfToRyaConversions.convertLiteral(vf.createLiteral("blue")))).setProperty(PERSON_TYPE.getId(), new Property(new RyaURI("urn:name"), RdfToRyaConversions.convertLiteral(vf.createLiteral("Bob")))).build();
    storage.create(entity);
    // A set of patterns that match a sepecific Entity subject.
    final List<StatementPattern> patterns = getSPs("SELECT * WHERE { " + "<urn:SSN:111-11-1111> <" + RDF.TYPE + "> <urn:person> ." + "<urn:SSN:111-11-1111> <urn:age> ?age . " + "<urn:SSN:111-11-1111> <urn:eye> \"blue\" . " + "<urn:SSN:111-11-1111> <urn:name> ?name . " + "}");
    final EntityQueryNode node = new EntityQueryNode(PERSON_TYPE, patterns, storage);
    final CloseableIteration<BindingSet, QueryEvaluationException> rez = node.evaluate(new MapBindingSet());
    final MapBindingSet expected = new MapBindingSet();
    expected.addBinding("age", vf.createLiteral("20"));
    expected.addBinding("-const-blue", vf.createLiteral("blue"));
    expected.addBinding("name", vf.createLiteral("Bob"));
    while (rez.hasNext()) {
        assertEquals(expected, rez.next());
        break;
    }
}
Also used : Entity(org.apache.rya.indexing.entity.model.Entity) MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) MongoEntityStorage(org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage) EntityStorage(org.apache.rya.indexing.entity.storage.EntityStorage) MongoEntityStorage(org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage) ValueFactory(org.openrdf.model.ValueFactory) RyaURI(org.apache.rya.api.domain.RyaURI) StatementPattern(org.openrdf.query.algebra.StatementPattern) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Property(org.apache.rya.indexing.entity.model.Property) Test(org.junit.Test)

Aggregations

ValueFactory (org.openrdf.model.ValueFactory)230 Test (org.junit.Test)195 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)187 Statement (org.openrdf.model.Statement)114 MapBindingSet (org.openrdf.query.impl.MapBindingSet)99 URI (org.openrdf.model.URI)83 HashSet (java.util.HashSet)72 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)66 Value (org.openrdf.model.Value)57 BindingSet (org.openrdf.query.BindingSet)51 Resource (org.openrdf.model.Resource)39 ArrayList (java.util.ArrayList)35 VisibilityStatement (org.apache.rya.api.model.VisibilityStatement)35 RdfToRyaConversions.convertStatement (org.apache.rya.api.resolver.RdfToRyaConversions.convertStatement)34 ContextStatementImpl (org.openrdf.model.impl.ContextStatementImpl)33 UUID (java.util.UUID)29 StatementImpl (org.openrdf.model.impl.StatementImpl)27 TopologyFactory (org.apache.rya.streams.kafka.topology.TopologyFactory)25 LinearRing (com.vividsolutions.jts.geom.LinearRing)24 Polygon (com.vividsolutions.jts.geom.Polygon)24