use of org.apache.rya.indexing.entity.storage.mongo.DocumentConverter.DocumentConverterException in project incubator-rya by apache.
the class MongoEventStorage method search.
@Override
public Collection<Event> search(final Optional<RyaURI> subject, final Optional<Collection<IndexingExpr>> geoFilters, final Optional<Collection<IndexingExpr>> temporalFilters) throws EventStorageException {
requireNonNull(subject);
try {
final Collection<IndexingExpr> geos = (geoFilters.isPresent() ? geoFilters.get() : new ArrayList<>());
final Collection<IndexingExpr> tempos = (temporalFilters.isPresent() ? temporalFilters.get() : new ArrayList<>());
final DBObject filterObj = queryAdapter.getFilterQuery(geos, tempos);
final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start(filterObj.toMap());
if (subject.isPresent()) {
builder.append(EventDocumentConverter.SUBJECT, subject.get().getData());
}
final MongoCursor<Document> results = mongo.getDatabase(ryaInstanceName).getCollection(COLLECTION_NAME).find(BsonDocument.parse(builder.get().toString())).iterator();
final List<Event> events = new ArrayList<>();
while (results.hasNext()) {
events.add(EVENT_CONVERTER.fromDocument(results.next()));
}
return events;
} catch (final MongoException | DocumentConverterException | GeoTemporalIndexException e) {
throw new EventStorageException("Could not get the Event.", e);
}
}
Aggregations