org.mybatis.generator.api.ProgressCallback Java Examples

The following examples show how to use org.mybatis.generator.api.ProgressCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param warnings
 * @param progressCallback
 * @return true if an XML generator is required
 */
protected AbstractJavaClientGenerator calculateClientGenerators(List<String> warnings, ProgressCallback progressCallback) {
	if (!rules.generateJavaClient()) {
		return null;
	}

	AbstractJavaClientGenerator javaGenerator = createJavaClientGenerator();
	if (javaGenerator == null) {
		return null;
	}

	initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
	clientGenerators.add(javaGenerator);

	return javaGenerator;
}
 
Example #2
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
/**
 * Calculate client generators.
 *
 * @param warnings
 *            the warnings
 * @param progressCallback
 *            the progress callback
 * @return true if an XML generator is required
 */
protected AbstractJavaClientGenerator calculateClientGenerators(List<String> warnings,
        ProgressCallback progressCallback) {
    if (!rules.generateJavaClient()) {
        return null;
    }
    
    AbstractJavaClientGenerator javaGenerator = createJavaClientGenerator();
    if (javaGenerator == null) {
        return null;
    }

    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    clientGenerators.add(javaGenerator);
    
    return javaGenerator;
}
 
Example #3
Source File: IntrospectedTableMyBatis3Impl.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
protected AbstractJavaClientGenerator calculateClientGenerators(List<String> warnings,
        ProgressCallback progressCallback) {
    if (!rules.generateJavaClient()) {
        return null;
    }
    
    AbstractJavaClientGenerator javaGenerator = createJavaClientGenerator();
    if (javaGenerator == null) {
        return null;
    }

    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    javaGenerators.add(javaGenerator);

    return javaGenerator;
}
 
Example #4
Source File: IntrospectedTableMyBatis3DynamicSqlImpl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {

    AbstractJavaGenerator javaGenerator = new DynamicSqlModelGenerator(getModelProject());
    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    javaGenerators.add(javaGenerator);
}
 
Example #5
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected void initializeAbstractGenerator(AbstractGenerator abstractGenerator, List<String> warnings, ProgressCallback progressCallback) {
	if (abstractGenerator == null) {
		return;
	}

	abstractGenerator.setContext(context);
	abstractGenerator.setIntrospectedTable(this);
	abstractGenerator.setProgressCallback(progressCallback);
	abstractGenerator.setWarnings(warnings);
}
 
Example #6
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, List<String> warnings, ProgressCallback progressCallback) {
	if (javaClientGenerator == null) {
		if (context.getSqlMapGeneratorConfiguration() != null) {
			xmlMapperGenerator = new XMLMapperGenerator();
		}
	}
	else {
		xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
	}

	initializeAbstractGenerator(xmlMapperGenerator, warnings, progressCallback);
}
 
Example #7
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
public void calculateGenerators(List<String> warnings, ProgressCallback progressCallback) {
	calculateJavaModelGenerators(warnings, progressCallback);

	AbstractJavaClientGenerator javaClientGenerator = calculateClientGenerators(warnings, progressCallback);

	calculateXmlMapperGenerator(javaClientGenerator, warnings, progressCallback);
}
 
Example #8
Source File: IntrospectedTableMyBatis3SimpleImpl.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateJavaModelGenerators(List<String> warnings,
        ProgressCallback progressCallback) {

    AbstractJavaGenerator javaGenerator = new SimpleModelGenerator();
    initializeAbstractGenerator(javaGenerator, warnings,
            progressCallback);
    javaModelGenerators.add(javaGenerator);
}
 
Example #9
Source File: IntrospectedTableMyBatis3SimpleImpl.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, 
        List<String> warnings,
        ProgressCallback progressCallback) {
    if (javaClientGenerator == null) {
        if (context.getSqlMapGeneratorConfiguration() != null) {
            xmlMapperGenerator = new SimpleXMLMapperGenerator();
        }
    } else {
        xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
    }
    
    initializeAbstractGenerator(xmlMapperGenerator, warnings,
            progressCallback);
}
 
Example #10
Source File: Context.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public void generateFiles(ProgressCallback callback, List<GeneratedJavaFile> generatedJavaFiles, List<GeneratedXmlFile> generatedXmlFiles, List<String> warnings) throws InterruptedException {

		pluginAggregator = new PluginAggregator();
		for (PluginConfiguration pluginConfiguration : pluginConfigurations) {
			Plugin plugin = ObjectFactory.createPlugin(this, pluginConfiguration);
			if (plugin.validate(warnings)) {
				pluginAggregator.addPlugin(plugin);
			}
			else {
				warnings.add(getString("Warning.24", //$NON-NLS-1$
						pluginConfiguration.getConfigurationType(), id));
			}
		}

		if (introspectedTables != null) {
			for (IntrospectedTable introspectedTable : introspectedTables) {
				callback.checkCancel();

				introspectedTable.initialize();
				introspectedTable.calculateGenerators(warnings, callback);
				generatedJavaFiles.addAll(introspectedTable.getGeneratedJavaFiles());
				generatedXmlFiles.addAll(introspectedTable.getGeneratedXmlFiles());

				generatedJavaFiles.addAll(pluginAggregator.contextGenerateAdditionalJavaFiles(introspectedTable));
				generatedXmlFiles.addAll(pluginAggregator.contextGenerateAdditionalXmlFiles(introspectedTable));
			}
		}

		generatedJavaFiles.addAll(pluginAggregator.contextGenerateAdditionalJavaFiles());
		generatedXmlFiles.addAll(pluginAggregator.contextGenerateAdditionalXmlFiles());


		//每个表自定义包路径
		setJavaFilesCustomTargetPackage(generatedJavaFiles);
		setXmlFilesCustomTargetPackage(generatedJavaFiles);
	}
 
Example #11
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize abstract generator.
 *
 * @param abstractGenerator
 *            the abstract generator
 * @param warnings
 *            the warnings
 * @param progressCallback
 *            the progress callback
 */
protected void initializeAbstractGenerator(
        AbstractGenerator abstractGenerator, List<String> warnings,
        ProgressCallback progressCallback) {
    if (abstractGenerator == null) {
        return;
    }
    
    abstractGenerator.setContext(context);
    abstractGenerator.setIntrospectedTable(this);
    abstractGenerator.setProgressCallback(progressCallback);
    abstractGenerator.setWarnings(warnings);
}
 
Example #12
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
/**
 * Calculate xml mapper generator.
 *
 * @param javaClientGenerator
 *            the java client generator
 * @param warnings
 *            the warnings
 * @param progressCallback
 *            the progress callback
 */
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, 
        List<String> warnings,
        ProgressCallback progressCallback) {
    if (javaClientGenerator == null) {
        if (context.getSqlMapGeneratorConfiguration() != null) {
            xmlMapperGenerator = new XMLMapperGenerator();
        }
    } else {
        xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
    }
    
    initializeAbstractGenerator(xmlMapperGenerator, warnings,
            progressCallback);
}
 
Example #13
Source File: IntrospectedTableMyBatis3Impl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
public void calculateGenerators(List<String> warnings,
        ProgressCallback progressCallback) {
    calculateJavaModelGenerators(warnings, progressCallback);
    
    AbstractJavaClientGenerator javaClientGenerator =
        calculateClientGenerators(warnings, progressCallback);
        
    calculateXmlMapperGenerator(javaClientGenerator, warnings, progressCallback);
}
 
Example #14
Source File: IntrospectedTableMyBatis3SimpleImpl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateJavaModelGenerators(List<String> warnings,
        ProgressCallback progressCallback) {

    AbstractJavaGenerator javaGenerator = new SimpleModelGenerator();
    initializeAbstractGenerator(javaGenerator, warnings,
            progressCallback);
    javaModelGenerators.add(javaGenerator);
}
 
Example #15
Source File: IntrospectedTableMyBatis3SimpleImpl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, 
        List<String> warnings,
        ProgressCallback progressCallback) {
    if (javaClientGenerator == null) {
        if (context.getSqlMapGeneratorConfiguration() != null) {
            xmlMapperGenerator = new SimpleXMLMapperGenerator();
        }
    } else {
        xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
    }
    
    initializeAbstractGenerator(xmlMapperGenerator, warnings,
            progressCallback);
}
 
Example #16
Source File: IntrospectedTableIbatis2Java2Impl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
protected void initializeAbstractGenerator(
        AbstractGenerator abstractGenerator, List<String> warnings,
        ProgressCallback progressCallback) {
    abstractGenerator.setContext(context);
    abstractGenerator.setIntrospectedTable(this);
    abstractGenerator.setProgressCallback(progressCallback);
    abstractGenerator.setWarnings(warnings);
}
 
Example #17
Source File: IntrospectedTableIbatis2Java2Impl.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
public void calculateGenerators(List<String> warnings,
        ProgressCallback progressCallback) {
    calculateJavaModelGenerators(warnings, progressCallback);
    calculateDAOGenerators(warnings, progressCallback);
    calculateSqlMapGenerator(warnings, progressCallback);
}
 
Example #18
Source File: IntrospectedTableMyBatis3DynamicSqlImpl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, 
        List<String> warnings,
        ProgressCallback progressCallback) {
    // no XML with dynamic SQL support
    xmlMapperGenerator = null;
}
 
Example #19
Source File: Context.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
public void generateFiles(ProgressCallback callback,
        List<GeneratedJavaFile> generatedJavaFiles,
        List<GeneratedXmlFile> generatedXmlFiles, List<String> warnings)
        throws InterruptedException {

    pluginAggregator = new PluginAggregator();
    for (PluginConfiguration pluginConfiguration : pluginConfigurations) {
        Plugin plugin = ObjectFactory.createPlugin(this, pluginConfiguration);
        if (plugin.validate(warnings)) {
            pluginAggregator.addPlugin(plugin);
        } else {
            warnings.add(getString("Warning.24",
                    pluginConfiguration.getConfigurationType(), id));
        }
    }

    if (introspectedTables != null) {
        for (IntrospectedTable introspectedTable : introspectedTables) {
            callback.checkCancel();

            introspectedTable.initialize();
            introspectedTable.calculateGenerators(warnings, callback);
            generatedJavaFiles.addAll(introspectedTable.getGeneratedJavaFiles());
            generatedXmlFiles.addAll(introspectedTable.getGeneratedXmlFiles());

            generatedJavaFiles.addAll(pluginAggregator.contextGenerateAdditionalJavaFiles(introspectedTable));
            generatedXmlFiles.addAll(pluginAggregator.contextGenerateAdditionalXmlFiles(introspectedTable));
        }
    }

    generatedJavaFiles.addAll(pluginAggregator.contextGenerateAdditionalJavaFiles());
    generatedXmlFiles.addAll(pluginAggregator.contextGenerateAdditionalXmlFiles());
}
 
Example #20
Source File: IntrospectedTableMyBatis3Impl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
protected void initializeAbstractGenerator(
        AbstractGenerator abstractGenerator, List<String> warnings,
        ProgressCallback progressCallback) {
    if (abstractGenerator == null) {
        return;
    }

    abstractGenerator.setContext(context);
    abstractGenerator.setIntrospectedTable(this);
    abstractGenerator.setProgressCallback(progressCallback);
    abstractGenerator.setWarnings(warnings);
}
 
Example #21
Source File: IntrospectedTableMyBatis3Impl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, 
        List<String> warnings,
        ProgressCallback progressCallback) {
    if (javaClientGenerator == null) {
        if (context.getSqlMapGeneratorConfiguration() != null) {
            xmlMapperGenerator = new XMLMapperGenerator();
        }
    } else {
        xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
    }
    
    initializeAbstractGenerator(xmlMapperGenerator, warnings, progressCallback);
}
 
Example #22
Source File: IntrospectedTableMyBatis3Impl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
public void calculateGenerators(List<String> warnings, ProgressCallback progressCallback) {
    calculateJavaModelGenerators(warnings, progressCallback);
    
    AbstractJavaClientGenerator javaClientGenerator = calculateClientGenerators(warnings, progressCallback);
        
    calculateXmlMapperGenerator(javaClientGenerator, warnings, progressCallback);
}
 
Example #23
Source File: IntrospectedTableMyBatis3AlanImpl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator, 
        List<String> warnings,
        ProgressCallback progressCallback) {
    // no XML with dynamic SQL support
    xmlMapperGenerator = null;
}
 
Example #24
Source File: IntrospectedTableMyBatis3AlanImpl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {

    AbstractJavaGenerator javaGenerator = new DynamicSqlModelGenerator(getModelProject());
    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    javaGenerators.add(javaGenerator);
}
 
Example #25
Source File: IntrospectedTableMyBatis3SimpleImpl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateXmlMapperGenerator(AbstractJavaClientGenerator javaClientGenerator,
                                           List<String> warnings,
                                           ProgressCallback progressCallback) {
    if (javaClientGenerator == null) {
        if (context.getSqlMapGeneratorConfiguration() != null) {
            xmlMapperGenerator = new SimpleXMLMapperGenerator();
        }
    } else {
        xmlMapperGenerator = javaClientGenerator.getMatchedXMLGenerator();
    }

    initializeAbstractGenerator(xmlMapperGenerator, warnings, progressCallback);
}
 
Example #26
Source File: IntrospectedTableMyBatis3SimpleImpl.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
@Override
protected void calculateJavaModelGenerators(List<String> warnings, ProgressCallback progressCallback) {

    AbstractJavaGenerator javaGenerator = new SimpleModelGenerator(getModelProject());
    initializeAbstractGenerator(javaGenerator, warnings, progressCallback);
    javaGenerators.add(javaGenerator);
}
 
Example #27
Source File: AbstractGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
public void setProgressCallback(ProgressCallback progressCallback) {
    this.progressCallback = progressCallback;
}
 
Example #28
Source File: AbstractGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
public ProgressCallback getProgressCallback() {
    return progressCallback;
}
 
Example #29
Source File: Context.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
/**
 * Introspect tables based on the configuration specified in the
 * constructor. This method is long running.
 * 
 * @param callback
 *            a progress callback if progress information is desired, or
 *            <code>null</code>
 * @param warnings
 *            any warning generated from this method will be added to the
 *            List. Warnings are always Strings.
 * @param fullyQualifiedTableNames
 *            a set of table names to generate. The elements of the set must
 *            be Strings that exactly match what's specified in the
 *            configuration. For example, if table name = "foo" and schema =
 *            "bar", then the fully qualified table name is "foo.bar". If
 *            the Set is null or empty, then all tables in the configuration
 *            will be used for code generation.
 * 
 * @throws SQLException
 *             if some error arises while introspecting the specified
 *             database tables.
 * @throws InterruptedException
 *             if the progress callback reports a cancel
 */
public void introspectTables(ProgressCallback callback,
        List<String> warnings, Set<String> fullyQualifiedTableNames)
        throws SQLException, InterruptedException {

    introspectedTables = new ArrayList<>();
    JavaTypeResolver javaTypeResolver = ObjectFactory.createJavaTypeResolver(this, warnings);

    Connection connection = null;

    try {
        callback.startTask(getString("Progress.0"));
        connection = getConnection();

        DatabaseIntrospector databaseIntrospector = new DatabaseIntrospector(
                this, connection.getMetaData(), javaTypeResolver, warnings);

        for (TableConfiguration tc : tableConfigurations) {
            String tableName = composeFullyQualifiedTableName(tc.getCatalog(), tc.getSchema(), tc.getTableName(), '.');

            if (fullyQualifiedTableNames != null
                    && !fullyQualifiedTableNames.isEmpty()
                    && !fullyQualifiedTableNames.contains(tableName)) {
                continue;
            }

            if (!tc.areAnyStatementsEnabled()) {
                warnings.add(getString("Warning.0", tableName));
                continue;
            }

            callback.startTask(getString("Progress.1", tableName));
            List<IntrospectedTable> tables = databaseIntrospector.introspectTables(tc);

            if (tables != null) {
                introspectedTables.addAll(tables);
            }

            callback.checkCancel();
        }
    } finally {
        closeConnection(connection);
    }
}
 
Example #30
Source File: IntrospectedTableIbatis2Java2Impl.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
protected void initializeAbstractGenerator(AbstractGenerator abstractGenerator, List<String> warnings, ProgressCallback progressCallback) {
	abstractGenerator.setContext(context);
	abstractGenerator.setIntrospectedTable(this);
	abstractGenerator.setProgressCallback(progressCallback);
	abstractGenerator.setWarnings(warnings);
}