use of org.apache.gora.mongodb.store.MongoMapping in project gora by apache.
the class DefaultFactory method transformFieldFilter.
protected DBObject transformFieldFilter(final SingleFieldValueFilter<K, T> fieldFilter, final MongoStore<K, T> store) {
MongoMapping mapping = store.getMapping();
String dbFieldName = mapping.getDocumentField(fieldFilter.getFieldName());
FilterOp filterOp = fieldFilter.getFilterOp();
List<Object> operands = fieldFilter.getOperands();
QueryBuilder builder = QueryBuilder.start(dbFieldName);
builder = appendToBuilder(builder, filterOp, operands);
if (!fieldFilter.isFilterIfMissing()) {
// If false, the find query will pass if the column is not found.
DBObject notExist = QueryBuilder.start(dbFieldName).exists(false).get();
builder = QueryBuilder.start().or(notExist, builder.get());
}
return builder.get();
}
use of org.apache.gora.mongodb.store.MongoMapping in project gora by apache.
the class DefaultFactory method transformMapFilter.
protected DBObject transformMapFilter(final MapFieldValueFilter<K, T> mapFilter, final MongoStore<K, T> store) {
MongoMapping mapping = store.getMapping();
String dbFieldName = mapping.getDocumentField(mapFilter.getFieldName()) + "." + store.encodeFieldKey(mapFilter.getMapKey().toString());
FilterOp filterOp = mapFilter.getFilterOp();
List<Object> operands = mapFilter.getOperands();
QueryBuilder builder = QueryBuilder.start(dbFieldName);
builder = appendToBuilder(builder, filterOp, operands);
if (!mapFilter.isFilterIfMissing()) {
// If false, the find query will pass if the column is not found.
DBObject notExist = QueryBuilder.start(dbFieldName).exists(false).get();
builder = QueryBuilder.start().or(notExist, builder.get());
}
return builder.get();
}
Aggregations