Search in sources :

Example 6 with FilterContainer

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

the class DatabaseSchemaLoader method packTable.

private void packTable(String tableName, String catalogName, String schemaName, String columnName) {
    IncludeTable table = new IncludeTable();
    table.setPattern(tableName);
    if (catalogName == null && schemaName == null) {
        if (!databaseReverseEngineering.getIncludeTables().contains(table)) {
            databaseReverseEngineering.addIncludeTable(table);
        }
        addColumn(null, table, columnName);
        return;
    }
    FilterContainer filterContainer = packFilterContainer(catalogName, schemaName);
    addTable(filterContainer, table);
    addColumn(filterContainer, table, columnName);
}
Also used : IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)

Example 7 with FilterContainer

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

the class ColumnNode method getStatus.

@Override
public Status getStatus(ReverseEngineering config) {
    Status parentStatus = getParent().getStatus(config);
    if (parentStatus != Status.INCLUDE) {
        return parentStatus;
    }
    List<FilterContainer> containers = getParent().getContainers(config);
    List<IncludeColumn> includeColumns = new ArrayList<>();
    List<ExcludeColumn> excludeColumns = new ArrayList<>();
    for (FilterContainer container : containers) {
        if (container == null) {
            continue;
        }
        IncludeTable table = getParent().getIncludeTable(container.getIncludeTables());
        if (table != null) {
            includeColumns.addAll(table.getIncludeColumns());
            excludeColumns.addAll(table.getExcludeColumns());
        }
        includeColumns.addAll(container.getIncludeColumns());
        excludeColumns.addAll(container.getExcludeColumns());
    }
    return includesColumn(includeColumns, excludeColumns);
}
Also used : FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) ArrayList(java.util.ArrayList) ExcludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)

Example 8 with FilterContainer

use of org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer 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 9 with FilterContainer

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

the class AddIncludeTableAction method performAction.

@Override
public void performAction(ActionEvent e) {
    ReverseEngineering reverseEngineeringOldCopy = prepareElements();
    if (reverseEngineeringIsEmpty()) {
        tree.getRootNode().removeAllChildren();
    }
    IncludeTable newTable = new IncludeTable(name);
    if (canBeInserted(selectedElement)) {
        ((FilterContainer) selectedElement.getUserObject()).addIncludeTable(newTable);
        selectedElement.add(new DbImportTreeNode(newTable));
        updateSelected = true;
    } else {
        if (parentElement == null) {
            parentElement = tree.getRootNode();
        }
        ((FilterContainer) parentElement.getUserObject()).addIncludeTable(newTable);
        parentElement.add(new DbImportTreeNode(newTable));
        updateSelected = false;
    }
    completeInserting(reverseEngineeringOldCopy);
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)

Example 10 with FilterContainer

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

the class AddPatternParamAction method performAction.

@Override
public void performAction(ActionEvent e) {
    ReverseEngineering reverseEngineeringOldCopy = prepareElements();
    Object selectedObject;
    if (reverseEngineeringIsEmpty()) {
        tree.getRootNode().removeAllChildren();
    }
    if (canBeInserted(selectedElement)) {
        selectedObject = selectedElement.getUserObject();
        if (selectedObject instanceof FilterContainer) {
            addPatternParamToContainer(paramClass, selectedObject, name, selectedElement);
        } else if (selectedObject instanceof IncludeTable) {
            addPatternParamToIncludeTable(paramClass, selectedObject, name, selectedElement);
        }
        updateSelected = true;
    } else {
        if (parentElement == null) {
            parentElement = tree.getRootNode();
        }
        selectedObject = parentElement.getUserObject();
        if (selectedObject instanceof FilterContainer) {
            addPatternParamToContainer(paramClass, selectedObject, name, parentElement);
        } else if (selectedObject instanceof IncludeTable) {
            addPatternParamToIncludeTable(paramClass, selectedObject, name, parentElement);
        }
        updateSelected = false;
    }
    completeInserting(reverseEngineeringOldCopy);
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)

Aggregations

FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)11 ArrayList (java.util.ArrayList)6 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)6 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)4 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)3 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)3 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)3 PatternParam (org.apache.cayenne.dbsync.reverse.dbimport.PatternParam)3 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)3 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)2 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)2 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 BiFunction (java.util.function.BiFunction)1 JTree (javax.swing.JTree)1 TreeExpansionEvent (javax.swing.event.TreeExpansionEvent)1 TreeExpansionListener (javax.swing.event.TreeExpansionListener)1 TreeNode (javax.swing.tree.TreeNode)1 TreePath (javax.swing.tree.TreePath)1