use of com.ctrip.platform.dal.daogen.host.java.ViewHost in project dal by ctripcorp.
the class JavaCodeGeneratorOfViewProcessor method generateViewDao.
private List<Callable<ExecuteResult>> generateViewDao(CodeGenContext codeGenCtx, final File mavenLikeDir) {
JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
final Progress progress = ctx.getProgress();
Queue<ViewHost> _viewHosts = ctx.getViewHosts();
List<Callable<ExecuteResult>> results = new ArrayList<>();
for (final ViewHost host : _viewHosts) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() throws Exception {
ExecuteResult result = new ExecuteResult("Generate View[" + host.getDbSetName() + "." + host.getViewName() + "] Dao");
progress.setOtherMessage(result.getTaskName());
try {
VelocityContext context = GenUtils.buildDefaultVelocityContext();
context.put("host", host);
GenUtils.mergeVelocityContext(context, String.format("%s/Dao/%sDao.java", mavenLikeDir.getAbsolutePath(), host.getPojoClassName()), "templates/java/ViewDAO.java.tpl");
GenUtils.mergeVelocityContext(context, String.format("%s/Entity/%s.java", mavenLikeDir.getAbsolutePath(), host.getPojoClassName()), "templates/java/Pojo.java.tpl");
GenUtils.mergeVelocityContext(context, String.format("%s/Test/%sDaoUnitTest.java", mavenLikeDir.getAbsolutePath(), host.getPojoClassName()), "templates/java/test/DAOByViewUnitTest.java.tpl");
result.setSuccessal(true);
} catch (Throwable e) {
throw e;
}
return result;
}
};
results.add(worker);
}
return results;
}
Aggregations