use of com.ctrip.platform.dal.daogen.entity.Progress 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 (Exception e) {
log.error(result.getTaskName() + " exception", e);
}
return result;
}
};
results.add(worker);
}
return results;
}
use of com.ctrip.platform.dal.daogen.entity.Progress in project dal by ctripcorp.
the class JavaDataPreparerOfSqlBuilderProcessor method prepareSqlBuilder.
private List<Callable<ExecuteResult>> prepareSqlBuilder(CodeGenContext codeGenCtx) {
final JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
final Progress progress = ctx.getProgress();
List<Callable<ExecuteResult>> results = new ArrayList<>();
Queue<GenTaskBySqlBuilder> _sqlBuilders = ctx.getSqlBuilders();
final Queue<JavaTableHost> _tableHosts = ctx.getTableHosts();
if (_sqlBuilders.size() > 0) {
//按照DbName和TableName进行分组
Map<String, GenTaskBySqlBuilder> _TempSqlBuildres = sqlBuilderBroupBy(_sqlBuilders);
for (final Map.Entry<String, GenTaskBySqlBuilder> _table : _TempSqlBuildres.entrySet()) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() throws Exception {
/*progress.setOtherMessage("正在整理表 "
+ _table.getValue().getClass_name());*/
ExecuteResult result = new ExecuteResult("Build Extral SQL[" + _table.getValue().getAllInOneName() + "." + _table.getKey() + "] Host");
progress.setOtherMessage(result.getTaskName());
try {
JavaTableHost extraTableHost = buildExtraSqlBuilderHost(ctx, _table.getValue());
if (null != extraTableHost) {
_tableHosts.add(extraTableHost);
}
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + " exception.", e);
progress.setOtherMessage(e.getMessage());
}
return result;
}
};
results.add(worker);
}
}
return results;
}
use of com.ctrip.platform.dal.daogen.entity.Progress in project dal by ctripcorp.
the class JavaCodeGeneratorOfFreeSqlProcessor method generateFreeSqlDao.
private List<Callable<ExecuteResult>> generateFreeSqlDao(CodeGenContext codeGenCtx, final File mavenLikeDir) {
JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
final Progress progress = ctx.getProgress();
List<Callable<ExecuteResult>> results = new ArrayList<>();
Map<String, JavaMethodHost> _freeSqlPojoHosts = ctx.get_freeSqlPojoHosts();
for (final JavaMethodHost host : _freeSqlPojoHosts.values()) {
if (host.isSampleType())
continue;
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() throws Exception {
ExecuteResult result = new ExecuteResult("Generate Free SQL[" + host.getPojoClassName() + "] Pojo");
progress.setOtherMessage(result.getTaskName());
try {
VelocityContext context = GenUtils.buildDefaultVelocityContext();
context.put("host", host);
GenUtils.mergeVelocityContext(context, String.format("%s/Entity/%s.java", mavenLikeDir.getAbsolutePath(), host.getPojoClassName()), "templates/java/Pojo.java.tpl");
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + " exception", e);
}
return result;
}
};
results.add(worker);
}
Queue<FreeSqlHost> _freeSqlHosts = ctx.getFreeSqlHosts();
for (final FreeSqlHost host : _freeSqlHosts) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() throws Exception {
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.java", mavenLikeDir.getAbsolutePath(), host.getClassName()), "templates/java/dao/freesql/FreeSqlDAO.java.tpl");
GenUtils.mergeVelocityContext(context, String.format("%s/Test/%sDaoUnitTest.java", mavenLikeDir.getAbsolutePath(), host.getClassName()), "templates/java/test/FreeSqlDaoUnitTest.java.tpl");
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + " exception", e);
}
return result;
}
};
results.add(worker);
}
return results;
}
use of com.ctrip.platform.dal.daogen.entity.Progress in project dal by ctripcorp.
the class JavaCodeGeneratorOfSpProcessor method generateSpDao.
private List<Callable<ExecuteResult>> generateSpDao(CodeGenContext codeGenCtx, final File mavenLikeDir) {
JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
final Progress progress = ctx.getProgress();
Map<String, SpDbHost> _spHostMaps = ctx.getSpHostMaps();
List<Callable<ExecuteResult>> results = new ArrayList<Callable<ExecuteResult>>();
for (final SpDbHost host : _spHostMaps.values()) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() throws Exception {
ExecuteResult result = new ExecuteResult("Generate SP[" + host.getDbSetName() + "] Dao, Pojo, Test");
progress.setOtherMessage(result.getTaskName());
try {
VelocityContext context = GenUtils.buildDefaultVelocityContext();
context.put("host", host);
GenUtils.mergeVelocityContext(context, String.format("%s/Dao/%sSpDao.java", mavenLikeDir.getAbsolutePath(), host.getDbSetName()), "templates/java/DAOBySp.java.tpl");
GenUtils.mergeVelocityContext(context, String.format("%s/Test/%sSpDaoUnitTest.java", mavenLikeDir.getAbsolutePath(), host.getDbSetName()), "templates/java/test/DAOBySpUnitTest.java.tpl");
for (SpHost sp : host.getSpHosts()) {
sp.setDbSetName(host.getDbSetName());
context.put("host", sp);
GenUtils.mergeVelocityContext(context, String.format("%s/Entity/%s.java", mavenLikeDir.getAbsolutePath(), sp.getPojoClassName()), "templates/java/Pojo.java.tpl");
}
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + " exception", e);
}
return result;
}
};
results.add(worker);
}
return results;
}
use of com.ctrip.platform.dal.daogen.entity.Progress in project dal by ctripcorp.
the class JavaCodeGeneratorOfTableProcessor method generateTableDao.
private List<Callable<ExecuteResult>> generateTableDao(CodeGenContext codeGenCtx, final File mavenLikeDir) {
JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
final Progress progress = ctx.getProgress();
Queue<JavaTableHost> _tableHosts = ctx.getTableHosts();
List<Callable<ExecuteResult>> results = new ArrayList<>();
for (final JavaTableHost host : _tableHosts) {
Callable<ExecuteResult> worker = new Callable<ExecuteResult>() {
@Override
public ExecuteResult call() throws Exception {
ExecuteResult result = new ExecuteResult("Generate Table[" + host.getDbSetName() + "." + host.getTableName() + "] Dao, Pojo, Test");
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/dao/standard/DAO.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/DaoUnitTests.java.tpl");
result.setSuccessal(true);
} catch (Exception e) {
log.error(result.getTaskName() + " exception", e);
}
return result;
}
};
results.add(worker);
}
return results;
}
Aggregations