use of org.apache.cayenne.gen.ClassGenerationAction in project cayenne by apache.
the class CgenTask method createGenerator.
ClassGenerationAction createGenerator() {
ClassGenerationAction action = newGeneratorInstance();
action.setDestDir(getDestDirFile());
action.setEncoding(encoding);
action.setMakePairs(makePairs);
action.setArtifactsGenerationMode(mode);
action.setOutputPattern(outputPattern);
action.setOverwrite(overwrite);
action.setSuperPkg(superPkg);
action.setSuperTemplate(superTemplate);
action.setTemplate(template);
action.setEmbeddableSuperTemplate(embeddableSuperTemplate);
action.setEmbeddableTemplate(embeddableTemplate);
action.setUsePkgPath(usePkgPath);
action.setCreatePropertyNames(createPropertyNames);
return action;
}
use of org.apache.cayenne.gen.ClassGenerationAction in project cayenne by apache.
the class CayenneGeneratorMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
// compilation resource for maven.
if (!destDir.exists()) {
destDir.mkdirs();
}
injector = DIBootstrap.createInjector(new ToolsModule(LoggerFactory.getLogger(CayenneGeneratorMojo.class)));
Logger logger = new MavenLogger(this);
CayenneGeneratorMapLoaderAction loaderAction = new CayenneGeneratorMapLoaderAction(injector);
loaderAction.setMainDataMapFile(map);
CayenneGeneratorEntityFilterAction filterAction = new CayenneGeneratorEntityFilterAction();
filterAction.setClient(client);
filterAction.setNameFilter(NamePatternMatcher.build(logger, includeEntities, excludeEntities));
try {
loaderAction.setAdditionalDataMapFiles(convertAdditionalDataMaps());
DataMap dataMap = loaderAction.getMainDataMap();
ClassGenerationAction generator = createGenerator();
generator.setLogger(logger);
if (force) {
// will (re-)generate all files
generator.setForce(true);
}
generator.setTimestamp(map.lastModified());
generator.setDataMap(dataMap);
generator.addEntities(filterAction.getFilteredEntities(dataMap));
generator.addEmbeddables(dataMap.getEmbeddables());
generator.addQueries(dataMap.getQueryDescriptors());
generator.execute();
} catch (Exception e) {
throw new MojoExecutionException("Error generating classes: ", e);
}
}
use of org.apache.cayenne.gen.ClassGenerationAction in project cayenne by apache.
the class CodeGeneratorController method generateAction.
public void generateAction() {
Collection<ClassGenerationAction> generators = generatorSelector.getGenerator();
if (generators != null) {
try {
for (ClassGenerationAction generator : generators) {
generator.execute();
}
JOptionPane.showMessageDialog(this.getView(), "Class generation finished");
} catch (Exception e) {
logObj.error("Error generating classes", e);
JOptionPane.showMessageDialog(this.getView(), "Error generating classes - " + e.getMessage());
}
}
view.dispose();
}
use of org.apache.cayenne.gen.ClassGenerationAction in project cayenne by apache.
the class CustomModeController method createGenerator.
public Collection<ClassGenerationAction> createGenerator() {
mode = modesByLabel.get(view.getGenerationMode().getSelectedItem()).toString();
Collection<ClassGenerationAction> generators = super.createGenerator();
String superKey = view.getSuperclassTemplate().getSelectedItem().toString();
String superTemplate = templateManager.getTemplatePath(superKey);
String subKey = view.getSubclassTemplate().getSelectedItem().toString();
String subTemplate = templateManager.getTemplatePath(subKey);
for (ClassGenerationAction generator : generators) {
generator.setSuperTemplate(superTemplate);
generator.setTemplate(subTemplate);
generator.setOverwrite(view.getOverwrite().isSelected());
generator.setUsePkgPath(view.getUsePackagePath().isSelected());
generator.setMakePairs(view.getPairs().isSelected());
generator.setCreatePropertyNames(view.getCreatePropertyNames().isSelected());
if (!Util.isEmptyString(view.getOutputPattern().getText())) {
generator.setOutputPattern(view.getOutputPattern().getText());
}
}
return generators;
}
use of org.apache.cayenne.gen.ClassGenerationAction in project cayenne by apache.
the class CayenneGeneratorTask method createGeneratorAction.
protected ClassGenerationAction createGeneratorAction() {
ClassGenerationAction action = client ? new ClientClassGenerationAction() : new ClassGenerationAction();
action.setContext(getVppContext());
action.setDestDir(destDir);
action.setEncoding(encoding);
action.setMakePairs(makepairs);
action.setArtifactsGenerationMode(mode);
action.setOutputPattern(outputPattern);
action.setOverwrite(overwrite);
action.setSuperPkg(superpkg);
action.setSuperTemplate(supertemplate);
action.setTemplate(template);
action.setEmbeddableSuperTemplate(embeddablesupertemplate);
action.setEmbeddableTemplate(embeddabletemplate);
action.setQueryTemplate(querytemplate);
action.setQuerySuperTemplate(querysupertemplate);
action.setUsePkgPath(usepkgpath);
action.setCreatePropertyNames(createpropertynames);
return action;
}
Aggregations