URL modelURL = getModelURL(eogeneratorModel, eomodelReference);
IEOModelGroupFactory.Utility.loadModelGroup(modelURL, generatingModelGroup, failures, true, modelURL, monitor);
if (monitor.isCanceled()) {
throw new OperationCanceledException("EOGenerator canceled.");
}
EOModel generatingModel = generatingModelGroup.getEditingModel();
models.add(generatingModel);
for (EOModel model : generatingModelGroup.getModels()) {
if (!modelGroup.containsModelNamed(model.getName())) {
modelGroup.addModel(model);
}
}
}
} else {
loadModels(eogeneratorModel, modelGroup, eogeneratorModel.getModels(), models, monitor);
loadModels(eogeneratorModel, modelGroup, eogeneratorModel.getRefModels(), new LinkedList<EOModel>(), monitor);
modelGroup.resolve(failures);
modelGroup.verify(failures);
}
for (EOModelVerificationFailure failure : failures) {
if (!failure.isWarning()) {
results.append("Error: " + failure.getMessage() + "\n");
showResults = true;
}
}
} else {
modelGroup = preloadedModelGroup;
for (EOModelReference modelRef : eogeneratorModel.getModels()) {
String modelName = modelRef.getName();
EOModel model = modelGroup.getModelNamed(modelName);
if (model == null) {
throw new RuntimeException("There was no model named '" + modelName + "' in this model group.");
}
models.add(model);
}
}
File superclassDestination = new File(eogeneratorModel.getDestination());
if (!superclassDestination.isAbsolute()) {
IPath projectPath = eogeneratorModel.getProjectPath();
if (projectPath != null) {
superclassDestination = new File(projectPath.toFile(), eogeneratorModel.getDestination());
}
}
if (!superclassDestination.exists()) {
if (!superclassDestination.mkdirs()) {
throw new IOException("Failed to create destination '" + superclassDestination + "'.");
}
}
File subclassDestination = new File(eogeneratorModel.getSubclassDestination());
if (!subclassDestination.isAbsolute()) {
IPath projectPath = eogeneratorModel.getProjectPath();
if (projectPath != null) {
subclassDestination = new File(projectPath.toFile(), eogeneratorModel.getSubclassDestination());
}
}
if (!subclassDestination.exists()) {
if (!subclassDestination.mkdirs()) {
throw new IOException("Failed to create subclass destination '" + subclassDestination + "'.");
}
}
// String filePathTemplate = eogeneratorModel.getFilenameTemplate();
// if (filePathTemplate == null || filePathTemplate.trim().length()
// == 0) {
// }
String extension = eogeneratorModel.getExtension();
Set<String> entitySet = new HashSet<String>();
if (entityList != null) {
entitySet.addAll(entityList);
}
Date date = new Date();
for (EOModel model : models) {
if (monitor.isCanceled()) {
throw new OperationCanceledException("EOGenerator canceled.");
}
// System.out.println("Generating " + model.getName() + " ...");
for (EOEntity entity : model.getEntities()) {
VelocityContext context = new VelocityContext();
context.put("eogeneratorModel", eogeneratorModel);
context.put("date", date);
context.put("calendar", Calendar.getInstance());
for (Define define : eogeneratorModel.getDefines()) {