List of usage examples for com.mongodb QueryBuilder start
public static QueryBuilder start(final String key)
From source file:org.apache.rya.indexing.geotemporal.mongo.GeoTemporalMongoDBStorageStrategy.java
License:Apache License
private DBObject getTemporalObject(final TemporalInterval interval, final TemporalPolicy policy) { final DBObject temporalObj; switch (policy) { case INSTANT_AFTER_INTERVAL: temporalObj = QueryBuilder.start(INSTANT).greaterThan(interval.getHasEnd().getAsDateTime().toDate()) .get();//from www. j a v a 2s . co m break; case INSTANT_BEFORE_INTERVAL: temporalObj = QueryBuilder.start(INSTANT).lessThan(interval.getHasBeginning().getAsDateTime().toDate()) .get(); break; case INSTANT_END_INTERVAL: temporalObj = QueryBuilder.start(INSTANT).is(interval.getHasEnd().getAsDateTime().toDate()).get(); break; case INSTANT_IN_INTERVAL: temporalObj = QueryBuilder.start(INSTANT) .greaterThan(interval.getHasBeginning().getAsDateTime().toDate()) .lessThan(interval.getHasEnd().getAsDateTime().toDate()).get(); break; case INSTANT_START_INTERVAL: temporalObj = QueryBuilder.start(INSTANT).is(interval.getHasBeginning().getAsDateTime().toDate()).get(); break; case INTERVAL_AFTER: temporalObj = QueryBuilder.start(INTERVAL_START) .greaterThan(interval.getHasEnd().getAsDateTime().toDate()).get(); break; case INTERVAL_BEFORE: temporalObj = QueryBuilder.start(INTERVAL_END) .lessThan(interval.getHasBeginning().getAsDateTime().toDate()).get(); break; case INTERVAL_EQUALS: temporalObj = QueryBuilder.start(INTERVAL_START).is(interval.getHasBeginning().getAsDateTime().toDate()) .and(INTERVAL_END).is(interval.getHasEnd().getAsDateTime().toDate()).get(); break; default: temporalObj = new BasicDBObject(); } return temporalObj; }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryInstantEqualsInstant( final TemporalInstant queryInstant, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INSTANT).is(queryInstant.getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryInstantBeforeInstant( final TemporalInstant queryInstant, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INSTANT).lessThan(queryInstant.getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryInstantAfterInstant( final TemporalInstant queryInstant, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INSTANT).greaterThan(queryInstant.getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryInstantBeforeInterval( final TemporalInterval givenInterval, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INSTANT) .lessThan(givenInterval.getHasBeginning().getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryInstantInsideInterval( final TemporalInterval givenInterval, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INSTANT) .greaterThan(givenInterval.getHasBeginning().getAsDateTime().toDate()) .lessThan(givenInterval.getHasEnd().getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryIntervalEquals(final TemporalInterval query, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INTERVAL_START) .is(query.getHasBeginning().getAsDateTime().toDate()).and(INTERVAL_END) .is(query.getHasEnd().getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryIntervalBefore(final TemporalInterval query, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INTERVAL_END) .lessThan(query.getHasBeginning().getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer.java
License:Apache License
@Override public CloseableIteration<Statement, QueryEvaluationException> queryIntervalAfter(final TemporalInterval query, final StatementConstraints constraints) throws QueryEvaluationException { final QueryBuilder qb = QueryBuilder.start(INTERVAL_START) .greaterThan(query.getHasEnd().getAsDateTime().toDate()); return withConstraints(constraints, qb.get()); }
From source file:org.apache.sling.mongodb.impl.MongoDBResourceProvider.java
License:Apache License
/** * TODO - we should handle delete different and not put all child resources into the * deleted set.//from www. ja v a 2 s . c om * Instead when getting resources, the parents of the resource should be checked * first. * This minimizes concurrency issues. * @see org.apache.sling.api.resource.ModifyingResourceProvider#delete(org.apache.sling.api.resource.ResourceResolver, java.lang.String) */ public void delete(final ResourceResolver resolver, final String path) throws PersistenceException { final String[] info = this.extractResourceInfo(path); if (info != null) { boolean deletedResource = false; if (!deletedResources.contains(path)) { final Resource rsrc = this.getResource(resolver, path, info); if (rsrc instanceof MongoDBResource) { this.deletedResources.add(path); this.changedResources.remove(path); final DBCollection col = this.getCollection(info[0]); final String pattern = "^" + Pattern.quote(info[1]) + "/"; final DBObject query = QueryBuilder.start(getPROP_PATH()).regex(Pattern.compile(pattern)).get(); final DBCursor cur = col.find(query); while (cur.hasNext()) { final DBObject dbObj = cur.next(); final String childPath = info[0] + '/' + dbObj.get(getPROP_PATH()); this.deletedResources.add(childPath); this.changedResources.remove(childPath); } deletedResource = true; } } else { deletedResource = true; } if (deletedResource) { final String prefix = path + "/"; final Iterator<Map.Entry<String, MongoDBResource>> i = this.changedResources.entrySet().iterator(); while (i.hasNext()) { final Map.Entry<String, MongoDBResource> entry = i.next(); if (entry.getKey().startsWith(prefix)) { i.remove(); } } return; } } throw new PersistenceException("Unable to delete resource at {}" + path, null, path, null); }