use of org.apache.gora.mongodb.utils.BSONDecorator in project gora by apache.
the class MongoStore method fromMongoRecord.
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object fromMongoRecord(final Schema fieldSchema, final String docf, final DBObject rec) {
Object result;
BSONDecorator innerBson = new BSONDecorator(rec);
Class<?> clazz = null;
try {
clazz = ClassLoadingUtils.loadClass(fieldSchema.getFullName());
} catch (ClassNotFoundException e) {
}
PersistentBase record = (PersistentBase) new BeanFactoryImpl(keyClass, clazz).newPersistent();
for (Field recField : fieldSchema.getFields()) {
Schema innerSchema = recField.schema();
DocumentFieldType innerStoreType = mapping.getDocumentFieldType(innerSchema.getName());
String innerDocField = mapping.getDocumentField(recField.name()) != null ? mapping.getDocumentField(recField.name()) : recField.name();
String fieldPath = docf + "." + innerDocField;
LOG.debug("Load from DBObject (RECORD), field:{}, schemaType:{}, docField:{}, storeType:{}", new Object[] { recField.name(), innerSchema.getType(), fieldPath, innerStoreType });
record.put(recField.pos(), fromDBObject(innerSchema, innerStoreType, recField, innerDocField, innerBson));
}
result = record;
return result;
}
use of org.apache.gora.mongodb.utils.BSONDecorator in project gora by apache.
the class TestMongoStore method testFromMongoMap_empty.
@Test
public void testFromMongoMap_empty() throws Exception {
MongoStore store = new MongoStore();
String field = "myField";
BasicDBObject emptyField = new BasicDBObject(field, new BasicDBObject());
Object item = store.fromMongoMap(field, null, new BSONDecorator(emptyField), null);
assertNotNull(item);
}
use of org.apache.gora.mongodb.utils.BSONDecorator in project gora by apache.
the class TestMongoStore method testFromMongoMap_null.
@Test
public void testFromMongoMap_null() throws Exception {
MongoStore store = new MongoStore();
BasicDBObject noField = new BasicDBObject();
String field = "myField";
Object item = store.fromMongoMap(field, null, new BSONDecorator(noField), null);
assertNotNull(item);
}
Aggregations