use of com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext in project dal by ctripcorp.
the class JavaDirectoryPreparerProcessor method process.
public void process(CodeGenContext codeGenCtx) throws Exception {
JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
File dir = new File(String.format("%s/%s/java", ctx.getGeneratePath(), ctx.getProjectId()));
try {
if (dir.exists() && ctx.isRegenerate())
FileUtils.forceDelete(dir);
File daoDir = new File(dir, "Dao");
File entityDir = new File(dir, "Entity");
File testDir = new File(dir, "Test");
if (!daoDir.exists()) {
FileUtils.forceMkdir(daoDir);
}
if (!entityDir.exists()) {
FileUtils.forceMkdir(entityDir);
}
if (!testDir.exists()) {
FileUtils.forceMkdir(testDir);
}
} catch (IOException e) {
throw e;
}
}
use of com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext in project dal by ctripcorp.
the class JavaCodeGeneratorOfOthersProcessor method process.
@Override
public void process(CodeGenContext context) throws Exception {
JavaCodeGenContext ctx = (JavaCodeGenContext) context;
int projectId = ctx.getProjectId();
File dir = new File(String.format("%s/%s/java", ctx.getGeneratePath(), projectId));
VelocityContext vltCcontext = GenUtils.buildDefaultVelocityContext();
vltCcontext.put("host", ctx.getDalConfigHost());
GenUtils.mergeVelocityContext(vltCcontext, String.format("%s/dal.xml", dir.getAbsolutePath()), "templates/java/Dal.config.java.tpl");
vltCcontext.put("host", ctx.getContextHost());
GenUtils.mergeVelocityContext(vltCcontext, String.format("%s/datasource.xml", dir.getAbsolutePath()), "templates/java/DataSource.java.tpl");
}
Aggregations