*/
public DataMap loadEOModel(String path, boolean generateClientClass) throws Exception {
EOModelHelper helper = makeHelper(path, generateClientClass);
// create empty map
DataMap dataMap = helper.getDataMap();
// process enitities ... throw out prototypes ... for now
List modelNames = new ArrayList(helper.modelNamesAsList());
CollectionUtils.filter(modelNames, PredicateUtils.notPredicate(prototypeChecker));
Iterator it = modelNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
// create and register entity
makeEntity(helper, name, generateClientClass);
}
// now sort following inheritance hierarchy
Collections.sort(modelNames, new InheritanceComparator(dataMap));
// after all entities are loaded, process attributes
it = modelNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
EOObjEntity e = (EOObjEntity) dataMap.getObjEntity(name);
// process entity attributes
makeAttributes(helper, e);
}
// after all entities are loaded, process relationships
it = modelNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
makeRelationships(helper, dataMap.getObjEntity(name));
}
// after all normal relationships are loaded, process flattened relationships
it = modelNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
makeFlatRelationships(helper, dataMap.getObjEntity(name));
}
// now create missing reverse DB (but not OBJ) relationships
// since Cayenne requires them
it = modelNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
DbEntity dbEntity = dataMap.getObjEntity(name).getDbEntity();
if (dbEntity != null) {
makeReverseDbRelationships(dbEntity);
}
}
// build SelectQueries out of EOFetchSpecifications...
it = modelNames.iterator();
while (it.hasNext()) {
String name = (String) it.next();
Iterator queries = helper.queryNames(name);
while (queries.hasNext()) {
String queryName = (String) queries.next();
EOObjEntity entity = (EOObjEntity) dataMap.getObjEntity(name);
makeQuery(helper, entity, queryName);
}
}
return dataMap;