Search in sources :

Example 26 with Catalog

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

the class DatabaseSchemaLoader method loadColumns.

public ReverseEngineering loadColumns(DBConnectionInfo connectionInfo, ClassLoadingService loadingService, TreePath path) throws SQLException {
    int pathIndex = 1;
    String catalogName = null, schemaName = null;
    Object userObject = getUserObjectOrNull(path, pathIndex);
    if (userObject instanceof Catalog) {
        catalogName = ((Catalog) userObject).getName();
        userObject = getUserObjectOrNull(path, ++pathIndex);
    }
    if (userObject instanceof Schema) {
        schemaName = ((Schema) userObject).getName();
        userObject = getUserObjectOrNull(path, ++pathIndex);
    }
    String tableName = processTable(userObject);
    try (Connection connection = connectionInfo.makeDataSource(loadingService).getConnection()) {
        try (ResultSet rs = connection.getMetaData().getColumns(catalogName, schemaName, tableName, null)) {
            while (rs.next()) {
                String column = rs.getString("COLUMN_NAME");
                packTable(tableName, catalogName, schemaName, column);
            }
        }
    }
    sort();
    return databaseReverseEngineering;
}
Also used : Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 27 with Catalog

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

the class DbImportTree method printCatalogs.

private void printCatalogs(Collection<Catalog> catalogs, DbImportTreeNode parent) {
    for (Catalog catalog : catalogs) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(catalog) : new TransferableNode(catalog);
        if (!"".equals(node.getSimpleNodeName())) {
            if (isTransferable && catalog.getSchemas().isEmpty() && catalog.getIncludeTables().isEmpty() && catalog.getExcludeTables().isEmpty()) {
                printParams(Collections.singletonList(new IncludeTable("Loading...")), node);
            }
            printSchemas(catalog.getSchemas(), node);
            printChildren(catalog, node);
            parent.add(node);
        }
    }
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 28 with Catalog

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

the class DbImportTree method update.

public void update(ReverseEngineering reverseEngineering, BiFunction<FilterContainer, DbImportTreeNode, Void> processor) {
    DbImportModel model = (DbImportModel) this.getModel();
    DbImportTreeNode root = (DbImportTreeNode) model.getRoot();
    Collection<Catalog> catalogs = reverseEngineering.getCatalogs();
    if (!catalogs.isEmpty()) {
        catalogs.forEach(catalog -> {
            Collection<Schema> schemas = catalog.getSchemas();
            if (!schemas.isEmpty()) {
                DbImportTreeNode currentRoot = findNodeInParent(root, catalog);
                schemas.forEach(schema -> packNextFilter(schema, currentRoot, processor));
            } else {
                packNextFilter(catalog, root, processor);
            }
        });
    } else if (!reverseEngineering.getSchemas().isEmpty()) {
        reverseEngineering.getSchemas().forEach(schema -> packNextFilter(schema, root, processor));
    } else if (!reverseEngineering.getIncludeTables().isEmpty()) {
        Schema schema = new Schema();
        schema.getIncludeTables().addAll(reverseEngineering.getIncludeTables());
        packNextFilter(schema, root, processor);
    }
}
Also used : TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) Collection(java.util.Collection) BiFunction(java.util.function.BiFunction) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) LoadDbSchemaAction(org.apache.cayenne.modeler.action.LoadDbSchemaAction) JTree(javax.swing.JTree) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) ArrayList(java.util.ArrayList) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) PatternParam(org.apache.cayenne.dbsync.reverse.dbimport.PatternParam) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) TreeExpansionListener(javax.swing.event.TreeExpansionListener) Collections(java.util.Collections) Application(org.apache.cayenne.modeler.Application) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 29 with Catalog

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

the class SchemaNode method getStatus.

@Override
public Status getStatus(ReverseEngineering config) {
    // check via parent path
    if (getParent() != null) {
        Status parentStatus = getParent().getStatus(config);
        if (parentStatus != Status.INCLUDE) {
            return parentStatus;
        }
        Catalog parentCatalog = getParent().getCatalog(config);
        if (parentCatalog != null && includesSchema(parentCatalog) == Status.INCLUDE) {
            return Status.INCLUDE;
        }
    }
    // check root
    return includesSchema(config);
}
Also used : Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 30 with Catalog

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

the class CatalogHandler method createCatalog.

private void createCatalog() {
    catalog = new Catalog();
    configuration.addCatalog(catalog);
}
Also used : Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Aggregations

Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)30 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)18 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)11 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)7 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)7 Test (org.junit.Test)7 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)6 ResultSet (java.sql.ResultSet)4 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)4 ArrayList (java.util.ArrayList)3 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)3 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)3 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)3 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 TreePath (javax.swing.tree.TreePath)2 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)2 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)2 DbImportView (org.apache.cayenne.modeler.editor.dbimport.DbImportView)2