UtilTimer utilTimer = new UtilTimer();
Iterator rhIter = entityResourceHandlers.iterator();
while (rhIter.hasNext()) {
ResourceHandler entityResourceHandler = (ResourceHandler) rhIter.next();
// utilTimer.timerString("Before getDocument in file " + entityFileName);
Document document = null;
try {
document = entityResourceHandler.getDocument();
} catch (GenericConfigException e) {
throw new GenericEntityConfException("Error getting document from resource handler", e);
}
if (document == null) {
throw new GenericEntityConfException("Could not get document for " + entityResourceHandler.toString());
}
// utilTimer.timerString("Before getDocumentElement in " + entityResourceHandler.toString());
Element docElement = document.getDocumentElement();
if (docElement == null) {
entityCache = null;
return null;
}
docElement.normalize();
Node curChild = docElement.getFirstChild();
ModelInfo def = new ModelInfo();
def.populateFromElements(docElement);
int i = 0;
if (curChild != null) {
utilTimer.timerString("Before start of entity loop in " + entityResourceHandler.toString());
do {
boolean isEntity = "entity".equals(curChild.getNodeName());
boolean isViewEntity = "view-entity".equals(curChild.getNodeName());
boolean isExtendEntity = "extend-entity".equals(curChild.getNodeName());
if ((isEntity || isViewEntity) && curChild.getNodeType() == Node.ELEMENT_NODE) {
i++;
Element curEntityElement = (Element) curChild;
String entityName = UtilXml.checkEmpty(curEntityElement.getAttribute("entity-name"));
// add entityName to appropriate resourceHandlerEntities collection
Collection resourceHandlerEntityNames = (Collection) resourceHandlerEntities.get(entityResourceHandler);
if (resourceHandlerEntityNames == null) {
resourceHandlerEntityNames = FastList.newInstance();
resourceHandlerEntities.put(entityResourceHandler, resourceHandlerEntityNames);
}
resourceHandlerEntityNames.add(entityName);
// check to see if entity with same name has already been read
if (entityCache.containsKey(entityName)) {
Debug.logWarning("WARNING: Entity " + entityName +
" is defined more than once, most recent will over-write " +
"previous definition(s)", module);
Debug.logWarning("WARNING: Entity " + entityName + " was found in " +
entityResourceHandler + ", but was already defined in " +
entityResourceHandlerMap.get(entityName).toString(), module);
}
// add entityName, entityFileName pair to entityResourceHandlerMap map
entityResourceHandlerMap.put(entityName, entityResourceHandler);
// utilTimer.timerString(" After entityEntityName -- " + i + " --");
// ModelEntity entity = createModelEntity(curEntity, utilTimer);
ModelEntity modelEntity = null;
if (isEntity) {
modelEntity = createModelEntity(curEntityElement, null, def);
} else {
modelEntity = createModelViewEntity(curEntityElement, null, def);
// put the view entity in a list to get ready for the second pass to populate fields...
tempViewEntityList.add(modelEntity);
}
// utilTimer.timerString(" After createModelEntity -- " + i + " --");
if (modelEntity != null) {
entityCache.put(entityName, modelEntity);
// utilTimer.timerString(" After entityCache.put -- " + i + " --");
if (isEntity) {
if (Debug.verboseOn()) Debug.logVerbose("-- [Entity]: #" + i + ": " + entityName, module);
} else {
if (Debug.verboseOn()) Debug.logVerbose("-- [ViewEntity]: #" + i + ": " + entityName, module);
}
} else {
Debug.logWarning("-- -- ENTITYGEN ERROR:getModelEntity: Could not create " +
"entity for entityName: " + entityName, module);
}
} else if (isExtendEntity && curChild.getNodeType() == Node.ELEMENT_NODE) {
tempExtendEntityElementList.add(curChild);
}
} while ((curChild = curChild.getNextSibling()) != null);
} else {
Debug.logWarning("No child nodes found.", module);
}
utilTimer.timerString("Finished " + entityResourceHandler.toString() + " - Total Entities: " + i + " FINISHED");
}
// all entity elements in, now go through extend-entity elements and add their stuff
Iterator tempExtendEntityElementIter = tempExtendEntityElementList.iterator();
while (tempExtendEntityElementIter.hasNext()) {