Search in sources :

Example 1 with SchemaContainer

use of org.apache.cayenne.dbsync.reverse.dbimport.SchemaContainer in project cayenne by apache.

the class AddSchemaAction method performAction.

@Override
public void performAction(ActionEvent e) {
    ReverseEngineering reverseEngineeringOldCopy = prepareElements();
    Schema newSchema = new Schema(name);
    if (canBeInserted(selectedElement)) {
        ((SchemaContainer) selectedElement.getUserObject()).addSchema(newSchema);
        selectedElement.add(new DbImportTreeNode(newSchema));
        updateSelected = true;
    } else if (canInsert()) {
        if (parentElement.isReverseEngineering()) {
            ((ReverseEngineering) parentElement.getUserObject()).addSchema(newSchema);
        } else {
            ((Catalog) parentElement.getUserObject()).addSchema(newSchema);
        }
        parentElement.add(new DbImportTreeNode(newSchema));
        updateSelected = false;
    }
    completeInserting(reverseEngineeringOldCopy);
}
Also used : SchemaContainer(org.apache.cayenne.dbsync.reverse.dbimport.SchemaContainer) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema)

Example 2 with SchemaContainer

use of org.apache.cayenne.dbsync.reverse.dbimport.SchemaContainer in project cayenne by apache.

the class DatabaseSchemaLoader method packFilterContainer.

private FilterContainer packFilterContainer(String catalogName, String schemaName) {
    SchemaContainer parentCatalog;
    if (catalogName == null) {
        parentCatalog = databaseReverseEngineering;
    } else {
        parentCatalog = getCatalogByName(databaseReverseEngineering.getCatalogs(), catalogName);
        if (parentCatalog == null) {
            parentCatalog = new Catalog();
            parentCatalog.setName(catalogName);
            databaseReverseEngineering.addCatalog((Catalog) parentCatalog);
        }
    }
    Schema parentSchema = null;
    if (schemaName != null) {
        parentSchema = getSchemaByName(parentCatalog.getSchemas(), schemaName);
        if (parentSchema == null) {
            parentSchema = new Schema();
            parentSchema.setName(schemaName);
            parentCatalog.addSchema(parentSchema);
        }
    }
    return parentSchema == null ? parentCatalog : parentSchema;
}
Also used : SchemaContainer(org.apache.cayenne.dbsync.reverse.dbimport.SchemaContainer) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Aggregations

Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)2 SchemaContainer (org.apache.cayenne.dbsync.reverse.dbimport.SchemaContainer)2 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)1 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)1 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)1