Map<Key, Entity> entities = ds.get(fieldMap.get(field));
// gets the future here because we need it so we wait for it
entityMap.put(field, entities);
}
}catch(Exception ex){
throw new SienaException(ex);
}
// associates linked models to their models
// linkedModels is just a map to contain entities already mapped
Map<Key, Object> linkedModels = new HashMap<Key, Object>();
Object linkedObj;
Entity entity;
for (final T model : models) {
for(Field field: fieldMap.keySet()){
Object objVal = Util.readField(model, field);
// our object is not linked to another object...so it doesn't have any key
if(objVal == null) {
continue;
}
Key key = GaeMappingUtils.getKey(objVal);
linkedObj = linkedModels.get(key);
if(linkedObj==null){
entity = entityMap.get(field).get(key);
linkedObj = objVal;
GaeMappingUtils.fillModel(linkedObj, entity);
linkedModels.put(key, linkedObj);
}
field.set(model, linkedObj);
}
}
return models;
} catch(IllegalAccessException ex){
throw new SienaException(ex);
}
}