use of com.ctrip.platform.dal.daogen.host.csharp.CSharpFreeSqlPojoHost in project dal by ctripcorp.
the class CSharpCodeGeneratorOfFreeSqlProcessor method generateFreeSqlDao.
private List<Callable<ExecuteResult>> generateFreeSqlDao(CodeGenContext codeGenCtx, final File mavenLikeDir) {
final CSharpCodeGenContext ctx = (CSharpCodeGenContext) codeGenCtx;
final Progress progress = ctx.getProgress();
List<Callable<ExecuteResult>> results = new ArrayList<>();
Map<String, CSharpFreeSqlPojoHost> _freeSqlPojoHosts = ctx.getFreeSqlPojoHosts();
for (final CSharpFreeSqlPojoHost host : _freeSqlPojoHosts.values()) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() {
//progress.setOtherMessage("正在生成 " + host.getClassName());
ExecuteResult result = new ExecuteResult("Generate Free SQL[" + host.getClassName() + "] Pojo");
progress.setOtherMessage(result.getTaskName());
try {
VelocityContext context = GenUtils.buildDefaultVelocityContext();
context.put("host", host);
GenUtils.mergeVelocityContext(context, String.format("%s/Entity/%s.cs", mavenLikeDir.getAbsolutePath(), CommonUtils.normalizeVariable(host.getClassName())), ctx.isNewPojo() ? "templates/csharp/PojoNew.cs.tpl" : "templates/csharp/Pojo.cs.tpl");
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + "exception", e);
}
return result;
}
};
results.add(worker);
}
ProgressResource.addDoneFiles(progress, _freeSqlPojoHosts.size());
Queue<CSharpFreeSqlHost> _freeSqlHosts = ctx.getFreeSqlHosts();
for (final CSharpFreeSqlHost host : _freeSqlHosts) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() {
//progress.setOtherMessage("正在生成 " + host.getClassName());
ExecuteResult result = new ExecuteResult("Generate Free SQL[" + host.getClassName() + "] Dap, Test");
progress.setOtherMessage(result.getTaskName());
try {
VelocityContext context = GenUtils.buildDefaultVelocityContext();
context.put("host", host);
GenUtils.mergeVelocityContext(context, String.format("%s/Dao/%sDao.cs", mavenLikeDir.getAbsolutePath(), CommonUtils.normalizeVariable(host.getClassName())), "templates/csharp/dao/freesql/FreeSqlDAO.cs.tpl");
GenUtils.mergeVelocityContext(context, String.format("%s/Test/%sTest.cs", mavenLikeDir.getAbsolutePath(), CommonUtils.normalizeVariable(host.getClassName())), "templates/csharp/test/FreeSqlTest.cs.tpl");
GenUtils.mergeVelocityContext(context, String.format("%s/Test/%sUnitTest.cs", mavenLikeDir.getAbsolutePath(), CommonUtils.normalizeVariable(host.getClassName())), "templates/csharp/test/FreeSqlUnitTest.cs.tpl");
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + "exception", e);
}
return result;
}
};
results.add(worker);
}
return results;
}
Aggregations