public void setObjEntityClassName(String n) {
objEntityClassName = n;
}
public void execute(MergerContext mergerContext) {
DataMap map = mergerContext.getDataMap();
map.addDbEntity(getEntity());
// create a ObjEntity
String objEntityName = NameConverter.underscoredToJava(getEntity().getName(), true);
// this loop will terminate even if no valid name is found
// to prevent loader from looping forever (though such case is very unlikely)
String baseName = objEntityName;
for (int i = 1; i < 1000 && map.getObjEntity(objEntityName) != null; i++) {
objEntityName = baseName + i;
}
ObjEntity objEntity = new ObjEntity(objEntityName);
objEntity.setDbEntity(getEntity());
// try to find a class name for the ObjEntity
String className = objEntityClassName;
if (className == null) {
// we should generate a className based on the objEntityName
String packageName = map.getDefaultPackage();
if (Util.isEmptyString(packageName)) {
packageName = "";
}
else if (!packageName.endsWith(".")) {
packageName = packageName + ".";
}
className = packageName + objEntityName;
}
objEntity.setClassName(className);
map.addObjEntity(objEntity);
synchronizeWithObjEntity(getEntity());
}