Search in sources :

Example 1 with AbstractJavaGenerator

use of org.mybatis.generator.codegen.AbstractJavaGenerator in project generator by mybatis.

the class IntrospectedTableMyBatis3Impl method calculateJavaModelGenerators.

/**
     * Calculate java model generators.
     *
     * @param warnings
     *            the warnings
     * @param progressCallback
     *            the progress callback
     */
protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {
    if (getRules().generateExampleClass()) {
        AbstractJavaGenerator javaGenerator = new ExampleGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
    if (getRules().generatePrimaryKeyClass()) {
        AbstractJavaGenerator javaGenerator = new PrimaryKeyGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
    if (getRules().generateBaseRecordClass()) {
        AbstractJavaGenerator javaGenerator = new BaseRecordGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
    if (getRules().generateRecordWithBLOBsClass()) {
        AbstractJavaGenerator javaGenerator = new RecordWithBLOBsGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
}
Also used : AbstractJavaGenerator(org.mybatis.generator.codegen.AbstractJavaGenerator) RecordWithBLOBsGenerator(org.mybatis.generator.codegen.mybatis3.model.RecordWithBLOBsGenerator) PrimaryKeyGenerator(org.mybatis.generator.codegen.mybatis3.model.PrimaryKeyGenerator) ExampleGenerator(org.mybatis.generator.codegen.mybatis3.model.ExampleGenerator) BaseRecordGenerator(org.mybatis.generator.codegen.mybatis3.model.BaseRecordGenerator)

Example 2 with AbstractJavaGenerator

use of org.mybatis.generator.codegen.AbstractJavaGenerator in project generator by mybatis.

the class IntrospectedTableMyBatis3SimpleImpl method calculateJavaModelGenerators.

@Override
protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {
    AbstractJavaGenerator javaGenerator = new SimpleModelGenerator();
    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    javaModelGenerators.add(javaGenerator);
}
Also used : AbstractJavaGenerator(org.mybatis.generator.codegen.AbstractJavaGenerator) SimpleModelGenerator(org.mybatis.generator.codegen.mybatis3.model.SimpleModelGenerator)

Example 3 with AbstractJavaGenerator

use of org.mybatis.generator.codegen.AbstractJavaGenerator in project generator by mybatis.

the class IntrospectedTableIbatis2Java2Impl method getGeneratedJavaFiles.

@Override
public List<GeneratedJavaFile> getGeneratedJavaFiles() {
    List<GeneratedJavaFile> answer = new ArrayList<GeneratedJavaFile>();
    for (AbstractJavaGenerator javaGenerator : javaModelGenerators) {
        List<CompilationUnit> compilationUnits = javaGenerator.getCompilationUnits();
        for (CompilationUnit compilationUnit : compilationUnits) {
            GeneratedJavaFile gjf = new GeneratedJavaFile(compilationUnit, context.getJavaModelGeneratorConfiguration().getTargetProject(), context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING), context.getJavaFormatter());
            answer.add(gjf);
        }
    }
    for (AbstractJavaGenerator javaGenerator : daoGenerators) {
        List<CompilationUnit> compilationUnits = javaGenerator.getCompilationUnits();
        for (CompilationUnit compilationUnit : compilationUnits) {
            GeneratedJavaFile gjf = new GeneratedJavaFile(compilationUnit, context.getJavaClientGeneratorConfiguration().getTargetProject(), context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING), context.getJavaFormatter());
            answer.add(gjf);
        }
    }
    return answer;
}
Also used : CompilationUnit(org.mybatis.generator.api.dom.java.CompilationUnit) AbstractJavaGenerator(org.mybatis.generator.codegen.AbstractJavaGenerator) ArrayList(java.util.ArrayList) GeneratedJavaFile(org.mybatis.generator.api.GeneratedJavaFile)

Example 4 with AbstractJavaGenerator

use of org.mybatis.generator.codegen.AbstractJavaGenerator in project generator by mybatis.

the class IntrospectedTableIbatis2Java2Impl method calculateDAOGenerators.

protected void calculateDAOGenerators(List<String> warnings, ProgressCallback progressCallback) {
    if (context.getJavaClientGeneratorConfiguration() == null) {
        return;
    }
    String type = context.getJavaClientGeneratorConfiguration().getConfigurationType();
    AbstractJavaGenerator javaGenerator;
    if ("IBATIS".equalsIgnoreCase(type)) {
        //$NON-NLS-1$
        javaGenerator = new DAOGenerator(new IbatisDAOTemplate(), isJava5Targeted());
    } else if ("SPRING".equalsIgnoreCase(type)) {
        //$NON-NLS-1$
        javaGenerator = new DAOGenerator(new SpringDAOTemplate(), isJava5Targeted());
    } else if ("GENERIC-CI".equalsIgnoreCase(type)) {
        //$NON-NLS-1$
        javaGenerator = new DAOGenerator(new GenericCIDAOTemplate(), isJava5Targeted());
    } else if ("GENERIC-SI".equalsIgnoreCase(type)) {
        //$NON-NLS-1$
        javaGenerator = new DAOGenerator(new GenericSIDAOTemplate(), isJava5Targeted());
    } else {
        javaGenerator = (AbstractJavaGenerator) ObjectFactory.createInternalObject(type);
    }
    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    daoGenerators.add(javaGenerator);
}
Also used : AbstractJavaGenerator(org.mybatis.generator.codegen.AbstractJavaGenerator) DAOGenerator(org.mybatis.generator.codegen.ibatis2.dao.DAOGenerator) IbatisDAOTemplate(org.mybatis.generator.codegen.ibatis2.dao.templates.IbatisDAOTemplate) GenericSIDAOTemplate(org.mybatis.generator.codegen.ibatis2.dao.templates.GenericSIDAOTemplate) GenericCIDAOTemplate(org.mybatis.generator.codegen.ibatis2.dao.templates.GenericCIDAOTemplate) SpringDAOTemplate(org.mybatis.generator.codegen.ibatis2.dao.templates.SpringDAOTemplate)

Example 5 with AbstractJavaGenerator

use of org.mybatis.generator.codegen.AbstractJavaGenerator in project generator by mybatis.

the class IntrospectedTableIbatis2Java2Impl method calculateJavaModelGenerators.

protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {
    if (getRules().generateExampleClass()) {
        AbstractJavaGenerator javaGenerator = new ExampleGenerator(isJava5Targeted());
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
    if (getRules().generatePrimaryKeyClass()) {
        AbstractJavaGenerator javaGenerator = new PrimaryKeyGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
    if (getRules().generateBaseRecordClass()) {
        AbstractJavaGenerator javaGenerator = new BaseRecordGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
    if (getRules().generateRecordWithBLOBsClass()) {
        AbstractJavaGenerator javaGenerator = new RecordWithBLOBsGenerator();
        initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
        javaModelGenerators.add(javaGenerator);
    }
}
Also used : AbstractJavaGenerator(org.mybatis.generator.codegen.AbstractJavaGenerator) RecordWithBLOBsGenerator(org.mybatis.generator.codegen.ibatis2.model.RecordWithBLOBsGenerator) PrimaryKeyGenerator(org.mybatis.generator.codegen.ibatis2.model.PrimaryKeyGenerator) ExampleGenerator(org.mybatis.generator.codegen.ibatis2.model.ExampleGenerator) BaseRecordGenerator(org.mybatis.generator.codegen.ibatis2.model.BaseRecordGenerator)

Aggregations

AbstractJavaGenerator (org.mybatis.generator.codegen.AbstractJavaGenerator)6 ArrayList (java.util.ArrayList)2 GeneratedJavaFile (org.mybatis.generator.api.GeneratedJavaFile)2 CompilationUnit (org.mybatis.generator.api.dom.java.CompilationUnit)2 DAOGenerator (org.mybatis.generator.codegen.ibatis2.dao.DAOGenerator)1 GenericCIDAOTemplate (org.mybatis.generator.codegen.ibatis2.dao.templates.GenericCIDAOTemplate)1 GenericSIDAOTemplate (org.mybatis.generator.codegen.ibatis2.dao.templates.GenericSIDAOTemplate)1 IbatisDAOTemplate (org.mybatis.generator.codegen.ibatis2.dao.templates.IbatisDAOTemplate)1 SpringDAOTemplate (org.mybatis.generator.codegen.ibatis2.dao.templates.SpringDAOTemplate)1 BaseRecordGenerator (org.mybatis.generator.codegen.ibatis2.model.BaseRecordGenerator)1 ExampleGenerator (org.mybatis.generator.codegen.ibatis2.model.ExampleGenerator)1 PrimaryKeyGenerator (org.mybatis.generator.codegen.ibatis2.model.PrimaryKeyGenerator)1 RecordWithBLOBsGenerator (org.mybatis.generator.codegen.ibatis2.model.RecordWithBLOBsGenerator)1 BaseRecordGenerator (org.mybatis.generator.codegen.mybatis3.model.BaseRecordGenerator)1 ExampleGenerator (org.mybatis.generator.codegen.mybatis3.model.ExampleGenerator)1 PrimaryKeyGenerator (org.mybatis.generator.codegen.mybatis3.model.PrimaryKeyGenerator)1 RecordWithBLOBsGenerator (org.mybatis.generator.codegen.mybatis3.model.RecordWithBLOBsGenerator)1 SimpleModelGenerator (org.mybatis.generator.codegen.mybatis3.model.SimpleModelGenerator)1