}
}
@Override
public ClosableIterator<Tuple> executeBackendQuery(BackendCustomQuery customQuery, QueryParameters queryParameters) {
MongoDBQueryDescriptor query = null;
// query already given in DBObject-representation (created by JP-QL parser)
if ( customQuery.getQueryObject() != null ) {
query = (MongoDBQueryDescriptor) customQuery.getQueryObject();
}
// a string-based native query; need to create the DBObject from that
else {
// TODO OGM-414 This should actually be cached in the native query plan
NativeQueryParser parser = Parboiled.createParser( NativeQueryParser.class );
ParsingResult<MongoDBQueryDescriptorBuilder> parseResult = new RecoveringParseRunner<MongoDBQueryDescriptorBuilder>( parser.Query() ).run( customQuery.getQueryString() );
if (parseResult.hasErrors() ) {
throw new IllegalArgumentException( "Unsupported native query: " + ErrorUtils.printParseErrors( parseResult.parseErrors ) );
}
query = parseResult.resultValue.build();
}
EntityKeyMetadata entityKeyMetadata = customQuery.getSingleEntityKeyMetadataOrNull();
String collectionName = getCollectionName( customQuery, query, entityKeyMetadata );
DBCollection collection = provider.getDatabase().getCollection( collectionName );
switch( query.getOperation() ) {
case FIND:
return doFind( query, queryParameters, collection, entityKeyMetadata );
case COUNT:
return doCount( query, collection );
default: