for(Field field: fieldMap.keySet()){
Map<Key, Entity> entities = ds.get(fieldMap.get(field));
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(Field field: fieldMap.keySet()){
Object objVal = field.get(model);
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 model;
} catch(IllegalAccessException ex){
throw new SienaException(ex);
}
}