Search in sources :

Example 1 with ValidationResultBrowser

use of org.apache.cayenne.modeler.dialog.ValidationResultBrowser 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

ArrayList (java.util.ArrayList)1 DbGenerator (org.apache.cayenne.access.DbGenerator)1 ValidationResultBrowser (org.apache.cayenne.modeler.dialog.ValidationResultBrowser)1 DataSourceWizard (org.apache.cayenne.modeler.dialog.db.DataSourceWizard)1 ValidationResult (org.apache.cayenne.validation.ValidationResult)1