Search in sources :

Example 1 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class TemporalIntervalTest method constructorTest.

@Test
public void constructorTest() throws Exception {
    TemporalInterval ti = new // 
    TemporalInterval(// 
    new TemporalInstantRfc3339(2014, 12, 30, 12, 59, 59), // 
    new TemporalInstantRfc3339(2014, 12, 30, 13, 00, 00));
    Assert.assertNotNull(ti.getAsKeyBeginning());
    Assert.assertNotNull(ti.getHasEnd());
}
Also used : TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Example 2 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class AccumuloTemporalIndexer method deleteStatement.

private void deleteStatement(final Statement statement) throws IOException, IllegalArgumentException {
    Objects.requireNonNull(temporalIndexBatchWriter, "This is not initialized for writing.  Must call setMultiTableBatchWriter() and init().");
    // if the predicate list is empty, accept all predicates.
    // Otherwise, make sure the predicate is on the "valid" list
    final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
    if (!isValidPredicate || !(statement.getObject() instanceof Literal)) {
        return;
    }
    // 0 begin, 1 end of interval
    final DateTime[] indexDateTimes = new DateTime[2];
    extractDateTime(statement, indexDateTimes);
    if (indexDateTimes[0] == null) {
        return;
    }
    // Remove this as an instant, or interval.
    try {
        if (indexDateTimes[1] != null) {
            final TemporalInterval interval = new TemporalInterval(new TemporalInstantRfc3339(indexDateTimes[0]), new TemporalInstantRfc3339(indexDateTimes[1]));
            removeInterval(temporalIndexBatchWriter, interval, statement);
        } else {
            final TemporalInstant instant = new TemporalInstantRfc3339(indexDateTimes[0]);
            removeInstant(temporalIndexBatchWriter, instant, statement);
        }
    } catch (final MutationsRejectedException e) {
        throw new IOException("While adding interval/instant for statement =" + statement, e);
    }
}
Also used : Literal(org.openrdf.model.Literal) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) IOException(java.io.IOException) TemporalInstant(org.apache.rya.indexing.TemporalInstant) TemporalInterval(org.apache.rya.indexing.TemporalInterval) DateTime(org.joda.time.DateTime) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 3 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class GeoTemporalProviderTest method twoPatternsTwoFiltersNotValid_test.

@Test
public void twoPatternsTwoFiltersNotValid_test() throws Exception {
    final ValueFactory vf = new ValueFactoryImpl();
    final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
    final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
    final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
    // Only handles geo and temporal filters
    final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX text: <http://rdf.useekm.com/fts#text>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ." + "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + " FILTER(text:equals(?time, " + temp + ")) . " + "}";
    final QuerySegment<EventQueryNode> node = getQueryNode(query);
    final List<EventQueryNode> nodes = provider.getExternalSets(node);
    assertEquals(0, nodes.size());
}
Also used : ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) Value(org.openrdf.model.Value) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) ValueFactory(org.openrdf.model.ValueFactory) EventQueryNode(org.apache.rya.indexing.geotemporal.model.EventQueryNode) URI(org.openrdf.model.URI) Test(org.junit.Test)

Example 4 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class GeoTemporalProviderTest method twoNode_test.

@Test
public void twoNode_test() throws Exception {
    final ValueFactory vf = new ValueFactoryImpl();
    final Value geo = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
    final Value temp = vf.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString());
    final URI tempPred = vf.createURI(URI_PROPERTY_AT_TIME);
    final String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geos: <http://www.opengis.net/def/function/geosparql/>" + "PREFIX time: <tag:rya-rdf.org,2015:temporal#>" + "SELECT * WHERE { " + "?subj <" + tempPred + "> ?time ." + "?subj <" + GeoConstants.GEO_AS_WKT + "> ?loc . " + "?subj2 <" + tempPred + "> ?time2 ." + "?subj2 <" + GeoConstants.GEO_AS_WKT + "> ?loc2 . " + " FILTER(geos:sfContains(?loc, " + geo + ")) . " + " FILTER(time:equals(?time, " + temp + ")) . " + " FILTER(geos:sfContains(?loc2, " + geo + ")) . " + " FILTER(time:equals(?time2, " + temp + ")) . " + "}";
    final QuerySegment<EventQueryNode> node = getQueryNode(query);
    final List<EventQueryNode> nodes = provider.getExternalSets(node);
    assertEquals(2, nodes.size());
}
Also used : ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) Value(org.openrdf.model.Value) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) ValueFactory(org.openrdf.model.ValueFactory) EventQueryNode(org.apache.rya.indexing.geotemporal.model.EventQueryNode) URI(org.openrdf.model.URI) Test(org.junit.Test)

Example 5 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class EventQueryNode2IT method evaluate_variableSubject.

@Test
public void evaluate_variableSubject() throws Exception {
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), "testDB");
    RyaURI subject = new RyaURI("urn:event-1111");
    Geometry geo = GF.createPoint(new Coordinate(1, 1));
    final TemporalInstant temp = new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0);
    final Event event = Event.builder().setSubject(subject).setGeometry(geo).setTemporalInstant(temp).build();
    subject = new RyaURI("urn:event-2222");
    geo = GF.createPoint(new Coordinate(-1, -1));
    final Event otherEvent = Event.builder().setSubject(subject).setGeometry(geo).setTemporalInstant(temp).build();
    storage.create(event);
    storage.create(otherEvent);
    final String query = "PREFIX time: <http://www.w3.org/2006/time#> \n" + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n" + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>" + "SELECT ?event ?time ?point ?wkt " + "WHERE { " + "  ?event time:atTime ?time . " + "  ?event geo:asWKT ?wkt . " + "  FILTER(geof:sfWithin(?wkt, \"POLYGON((-3 -2, -3 2, 1 2, 1 -2, -3 -2))\"^^geo:wktLiteral)) " + "  FILTER(tempo:equals(?time, \"2015-12-30T12:00:00Z\")) " + "}";
    final EventQueryNode node = buildNode(storage, query);
    final CloseableIteration<BindingSet, QueryEvaluationException> rez = node.evaluate(new MapBindingSet());
    final MapBindingSet expected1 = new MapBindingSet();
    expected1.addBinding("wkt", VF.createLiteral("POINT (1 1)"));
    expected1.addBinding("time", VF.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString()));
    final MapBindingSet expected2 = new MapBindingSet();
    expected2.addBinding("wkt", VF.createLiteral("POINT (-1 -1)"));
    expected2.addBinding("time", VF.createLiteral(new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 0).toString()));
    final List<BindingSet> actual = new ArrayList<>();
    while (rez.hasNext()) {
        actual.add(rez.next());
    }
    assertEquals(expected1, actual.get(0));
    assertEquals(expected2, actual.get(1));
    assertEquals(2, actual.size());
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) ArrayList(java.util.ArrayList) TemporalInstant(org.apache.rya.indexing.TemporalInstant) Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) Coordinate(com.vividsolutions.jts.geom.Coordinate) MapBindingSet(org.openrdf.query.impl.MapBindingSet) MongoEventStorage(org.apache.rya.indexing.geotemporal.mongo.MongoEventStorage) MongoEventStorage(org.apache.rya.indexing.geotemporal.mongo.MongoEventStorage) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Aggregations

TemporalInstantRfc3339 (org.apache.rya.indexing.TemporalInstantRfc3339)34 Test (org.junit.Test)26 TemporalInstant (org.apache.rya.indexing.TemporalInstant)21 RyaURI (org.apache.rya.api.domain.RyaURI)15 Geometry (com.vividsolutions.jts.geom.Geometry)13 Coordinate (com.vividsolutions.jts.geom.Coordinate)12 TemporalInterval (org.apache.rya.indexing.TemporalInterval)12 EventStorage (org.apache.rya.indexing.geotemporal.storage.EventStorage)11 URI (org.openrdf.model.URI)11 Event (org.apache.rya.indexing.geotemporal.model.Event)9 Value (org.openrdf.model.Value)9 ValueFactory (org.openrdf.model.ValueFactory)9 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)9 EventQueryNode (org.apache.rya.indexing.geotemporal.model.EventQueryNode)7 DateTime (org.joda.time.DateTime)5 MongoEventStorage (org.apache.rya.indexing.geotemporal.mongo.MongoEventStorage)4 BindingSet (org.openrdf.query.BindingSet)4 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)4 MapBindingSet (org.openrdf.query.impl.MapBindingSet)4 IOException (java.io.IOException)3