Search in sources :

Example 21 with JavaCodeGenContext

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;
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) JavaCodeGenContext(com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)

Example 22 with JavaCodeGenContext

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");
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) File(java.io.File) JavaCodeGenContext(com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)

Aggregations

JavaCodeGenContext (com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)22 Callable (java.util.concurrent.Callable)11 Progress (com.ctrip.platform.dal.daogen.entity.Progress)7 File (java.io.File)7 ExecuteResult (com.ctrip.platform.dal.daogen.entity.ExecuteResult)6 VelocityContext (org.apache.velocity.VelocityContext)6 AbstractParameterHost (com.ctrip.platform.dal.daogen.host.AbstractParameterHost)4 JavaMethodHost (com.ctrip.platform.dal.daogen.host.java.JavaMethodHost)4 ArrayList (java.util.ArrayList)4 FreeSqlHost (com.ctrip.platform.dal.daogen.host.java.FreeSqlHost)3 JavaTableHost (com.ctrip.platform.dal.daogen.host.java.JavaTableHost)3 CodeGenContext (com.ctrip.platform.dal.daogen.CodeGenContext)2 DalGenerator (com.ctrip.platform.dal.daogen.DalGenerator)2 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)2 CSharpCodeGenContext (com.ctrip.platform.dal.daogen.generator.csharp.CSharpCodeGenContext)2 CSharpDalGenerator (com.ctrip.platform.dal.daogen.generator.csharp.CSharpDalGenerator)2 JavaDalGenerator (com.ctrip.platform.dal.daogen.generator.java.JavaDalGenerator)2 DalConfigHost (com.ctrip.platform.dal.daogen.host.DalConfigHost)2 CSharpMethodHost (com.ctrip.platform.dal.daogen.host.csharp.CSharpMethodHost)2 EmailException (org.apache.commons.mail.EmailException)2