use of org.mybatis.generator.api.dom.java.CompilationUnit in project generator by mybatis.
the class DAOGenerator method getCompilationUnits.
@Override
public List<CompilationUnit> getCompilationUnits() {
FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
progressCallback.startTask(getString("Progress.14", //$NON-NLS-1$
table.toString()));
TopLevelClass topLevelClass = getTopLevelClassShell();
Interface interfaze = getInterfaceShell();
addCountByExampleMethod(topLevelClass, interfaze);
addDeleteByExampleMethod(topLevelClass, interfaze);
addDeleteByPrimaryKeyMethod(topLevelClass, interfaze);
addInsertMethod(topLevelClass, interfaze);
addInsertSelectiveMethod(topLevelClass, interfaze);
addSelectByExampleWithBLOBsMethod(topLevelClass, interfaze);
addSelectByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
addSelectByPrimaryKeyMethod(topLevelClass, interfaze);
addUpdateByExampleParmsInnerclass(topLevelClass, interfaze);
addUpdateByExampleSelectiveMethod(topLevelClass, interfaze);
addUpdateByExampleWithBLOBsMethod(topLevelClass, interfaze);
addUpdateByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
addUpdateByPrimaryKeySelectiveMethod(topLevelClass, interfaze);
addUpdateByPrimaryKeyWithBLOBsMethod(topLevelClass, interfaze);
addUpdateByPrimaryKeyWithoutBLOBsMethod(topLevelClass, interfaze);
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
if (context.getPlugins().clientGenerated(interfaze, topLevelClass, introspectedTable)) {
answer.add(topLevelClass);
answer.add(interfaze);
}
return answer;
}
use of org.mybatis.generator.api.dom.java.CompilationUnit in project generator by mybatis.
the class PrimaryKeyGenerator method getCompilationUnits.
@Override
public List<CompilationUnit> getCompilationUnits() {
FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
progressCallback.startTask(getString("Progress.7", //$NON-NLS-1$
table.toString()));
Plugin plugins = context.getPlugins();
CommentGenerator commentGenerator = context.getCommentGenerator();
TopLevelClass topLevelClass = new TopLevelClass(introspectedTable.getPrimaryKeyType());
topLevelClass.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addJavaFileComment(topLevelClass);
String rootClass = getRootClass();
if (rootClass != null) {
topLevelClass.setSuperClass(new FullyQualifiedJavaType(rootClass));
topLevelClass.addImportedType(topLevelClass.getSuperClass());
}
for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
if (RootClassInfo.getInstance(rootClass, warnings).containsProperty(introspectedColumn)) {
continue;
}
Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
if (plugins.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.PRIMARY_KEY)) {
topLevelClass.addField(field);
topLevelClass.addImportedType(field.getType());
}
Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
if (plugins.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.PRIMARY_KEY)) {
topLevelClass.addMethod(method);
}
method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
if (plugins.modelSetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.PRIMARY_KEY)) {
topLevelClass.addMethod(method);
}
}
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
if (context.getPlugins().modelPrimaryKeyClassGenerated(topLevelClass, introspectedTable)) {
answer.add(topLevelClass);
}
return answer;
}
use of org.mybatis.generator.api.dom.java.CompilationUnit in project generator by mybatis.
the class IntrospectedTableMyBatis3Impl method getGeneratedJavaFiles.
/* (non-Javadoc)
* @see org.mybatis.generator.api.IntrospectedTable#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 : clientGenerators) {
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;
}
use of org.mybatis.generator.api.dom.java.CompilationUnit in project generator by mybatis.
the class BaseRecordGenerator method getCompilationUnits.
@Override
public List<CompilationUnit> getCompilationUnits() {
FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
progressCallback.startTask(getString("Progress.8", //$NON-NLS-1$
table.toString()));
Plugin plugins = context.getPlugins();
CommentGenerator commentGenerator = context.getCommentGenerator();
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
TopLevelClass topLevelClass = new TopLevelClass(type);
topLevelClass.setVisibility(JavaVisibility.PUBLIC);
commentGenerator.addJavaFileComment(topLevelClass);
FullyQualifiedJavaType superClass = getSuperClass();
if (superClass != null) {
topLevelClass.setSuperClass(superClass);
topLevelClass.addImportedType(superClass);
}
commentGenerator.addModelClassComment(topLevelClass, introspectedTable);
List<IntrospectedColumn> introspectedColumns = getColumnsInThisClass();
if (introspectedTable.isConstructorBased()) {
addParameterizedConstructor(topLevelClass);
if (!introspectedTable.isImmutable()) {
addDefaultConstructor(topLevelClass);
}
}
String rootClass = getRootClass();
for (IntrospectedColumn introspectedColumn : introspectedColumns) {
if (RootClassInfo.getInstance(rootClass, warnings).containsProperty(introspectedColumn)) {
continue;
}
Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
if (plugins.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) {
topLevelClass.addField(field);
topLevelClass.addImportedType(field.getType());
}
Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
if (plugins.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) {
topLevelClass.addMethod(method);
}
if (!introspectedTable.isImmutable()) {
method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
if (plugins.modelSetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable, Plugin.ModelClassType.BASE_RECORD)) {
topLevelClass.addMethod(method);
}
}
}
List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass, introspectedTable)) {
answer.add(topLevelClass);
}
return answer;
}
Aggregations