Search in sources :

Example 11 with DbGenerator

use of org.apache.cayenne.access.DbGenerator in project cayenne by apache.

the class DBGeneratorOptions method generateSchemaAction.

/**
 * Performs configured schema operations via DbGenerator.
 */
public void generateSchemaAction() {
    DataSourceWizard connectWizard = new DataSourceWizard(this.getParent(), "Generate DB Schema: Connect to Database");
    if (!connectWizard.startupAction()) {
        return;
    }
    this.connectionInfo = connectWizard.getConnectionInfo();
    refreshGeneratorAction();
    Collection<ValidationResult> failures = new ArrayList<ValidationResult>();
    // sanity check...
    for (DbGenerator generator : generators) {
        if (generator.isEmpty(true)) {
            JOptionPane.showMessageDialog(getView(), "Nothing to generate.");
            return;
        }
        try {
            generator.runGenerator(connectWizard.getDataSource());
            failures.add(generator.getFailures());
        } catch (Throwable th) {
            reportError("Schema Generation Error", th);
        }
    }
    if (failures.size() == 0) {
        JOptionPane.showMessageDialog(getView(), "Schema Generation Complete.");
    } else {
        new ValidationResultBrowser(this).startupAction("Schema Generation Complete", "Schema generation finished. The following problem(s) were ignored.", failures);
    }
}
Also used : DataSourceWizard(org.apache.cayenne.modeler.dialog.db.DataSourceWizard) ArrayList(java.util.ArrayList) ValidationResultBrowser(org.apache.cayenne.modeler.dialog.ValidationResultBrowser) ValidationResult(org.apache.cayenne.validation.ValidationResult) DbGenerator(org.apache.cayenne.access.DbGenerator)

Aggregations

DbGenerator (org.apache.cayenne.access.DbGenerator)11 DataMap (org.apache.cayenne.map.DataMap)5 DbAdapter (org.apache.cayenne.dba.DbAdapter)4 DbSyncModule (org.apache.cayenne.dbsync.DbSyncModule)3 ToolsModule (org.apache.cayenne.dbsync.reverse.configuration.ToolsModule)3 Injector (org.apache.cayenne.di.Injector)3 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)2 DriverDataSource (org.apache.cayenne.datasource.DriverDataSource)2 NoopJdbcEventLogger (org.apache.cayenne.log.NoopJdbcEventLogger)2 Logger (org.slf4j.Logger)2 IOException (java.io.IOException)1 AdhocObjectFactory (org.apache.cayenne.di.AdhocObjectFactory)1 DbEntity (org.apache.cayenne.map.DbEntity)1 ValidationResultBrowser (org.apache.cayenne.modeler.dialog.ValidationResultBrowser)1 DataSourceWizard (org.apache.cayenne.modeler.dialog.db.DataSourceWizard)1 UnitDbAdapter (org.apache.cayenne.unit.UnitDbAdapter)1 ValidationResult (org.apache.cayenne.validation.ValidationResult)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1