@Test public void equalsInstantAfterInterval_onlyTemporal() throws Exception { final String query = "PREFIX time: <http: + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n" + "SELECT ?event ?time " + "WHERE { " + " ?event time:atTime ?time . " + " FILTER(tempo:before(?time, \"2015-12-30T12:00:00Z\")) . " + " FILTER(tempo:insideInterval(?time, \"[1969-12-31T19:00:00-05:00,1969-12-31T19:00:01-05:00]\")) . " + "}"; final List<IndexingExpr> geoFilters = new ArrayList<>(); final List<IndexingExpr> temporalFilters = new ArrayList<>(); final List<StatementPattern> sps = getSps(query); final List<FunctionCall> filters = getFilters(query); for(final FunctionCall filter : filters) { final Var objVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(VF.createIRI(filter.getURI()), filter.getArgs()); final Value[] arguments = extractArguments(objVar.getName(), filter); final IndexingExpr expr = new IndexingExpr(VF.createIRI(filter.getURI()), sps.get(0), Arrays.stream(arguments).toArray()); temporalFilters.add(expr); } final Document actual = adapter.getFilterQuery(geoFilters, temporalFilters); final String expectedString = "{ " + "\"$and\" : [{" + "\"instant\" : {" + "\"$gt\" : {" + "\"$date\" : \"1970-01-01T00:00:00.000Z\"" + "}," + "\"$lt\" : {" + "\"$date\" : \"1970-01-01T00:00:01.000Z\"" + "}," + "}}, {" + "\"instant\" : {" + "\"$lt\" : {" + "\"$date\" : \"2015-12-30T12:00:00.000Z\"" + "}" + "}" + "}]" + "}"; final Document expected = Document.parse(expectedString); assertEqualMongo(expected, actual); }
public Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters) throws GeoTemporalIndexException { final QueryBuilder builder = QueryBuilder.start(); if(!geoFilters.isEmpty()) { final Document[] geo = getGeoObjs(geoFilters); if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); builder.and(oneOrAnd(geo), oneOrAnd(temporal)); return builder.get(); } else { return oneOrAnd(geo); } } else if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); return oneOrAnd(temporal); } else { return builder.get(); } }
GeoTemporalMongoDBStorageStrategy extends IndexingMongoDBStorageStrategy { public Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters) throws GeoTemporalIndexException { final QueryBuilder builder = QueryBuilder.start(); if(!geoFilters.isEmpty()) { final Document[] geo = getGeoObjs(geoFilters); if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); builder.and(oneOrAnd(geo), oneOrAnd(temporal)); return builder.get(); } else { return oneOrAnd(geo); } } else if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); return oneOrAnd(temporal); } else { return builder.get(); } } }
GeoTemporalMongoDBStorageStrategy extends IndexingMongoDBStorageStrategy { public Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters) throws GeoTemporalIndexException { final QueryBuilder builder = QueryBuilder.start(); if(!geoFilters.isEmpty()) { final Document[] geo = getGeoObjs(geoFilters); if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); builder.and(oneOrAnd(geo), oneOrAnd(temporal)); return builder.get(); } else { return oneOrAnd(geo); } } else if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); return oneOrAnd(temporal); } else { return builder.get(); } } GeoTemporalMongoDBStorageStrategy(); }
GeoTemporalMongoDBStorageStrategy extends IndexingMongoDBStorageStrategy { public Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters) throws GeoTemporalIndexException { final QueryBuilder builder = QueryBuilder.start(); if(!geoFilters.isEmpty()) { final Document[] geo = getGeoObjs(geoFilters); if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); builder.and(oneOrAnd(geo), oneOrAnd(temporal)); return builder.get(); } else { return oneOrAnd(geo); } } else if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); return oneOrAnd(temporal); } else { return builder.get(); } } GeoTemporalMongoDBStorageStrategy(); @Override void createIndices(final MongoCollection<Document> coll); Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters); @Override Document serialize(final RyaStatement ryaStatement); }
GeoTemporalMongoDBStorageStrategy extends IndexingMongoDBStorageStrategy { public Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters) throws GeoTemporalIndexException { final QueryBuilder builder = QueryBuilder.start(); if(!geoFilters.isEmpty()) { final Document[] geo = getGeoObjs(geoFilters); if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); builder.and(oneOrAnd(geo), oneOrAnd(temporal)); return builder.get(); } else { return oneOrAnd(geo); } } else if(!temporalFilters.isEmpty()) { final Document[] temporal = getTemporalObjs(temporalFilters); return oneOrAnd(temporal); } else { return builder.get(); } } GeoTemporalMongoDBStorageStrategy(); @Override void createIndices(final MongoCollection<Document> coll); Document getFilterQuery(final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters); @Override Document serialize(final RyaStatement ryaStatement);  }