Search in sources :

Example 21 with IncludeTable

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

the class PrintTablesBiFunction method apply.

@Override
public Void apply(FilterContainer filterContainer, DbImportTreeNode root) {
    DbImportModel model = (DbImportModel) dbImportTree.getModel();
    boolean isTransferable = dbImportTree.isTransferable();
    if (root.getChildCount() != 0) {
        root.removeAllChildren();
    }
    Collection<IncludeTable> includeTables = filterContainer.getIncludeTables();
    for (IncludeTable includeTable : includeTables) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(includeTable) : new TransferableNode(includeTable);
        if (isTransferable && includeTable.getIncludeColumns().isEmpty() && includeTable.getExcludeColumns().isEmpty()) {
            dbImportTree.printParams(Collections.singletonList(new IncludeColumn("Loading...")), node);
        }
        root.add(node);
        dbImportTree.packColumns(includeTable, node);
    }
    model.reload(root);
    return null;
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode)

Example 22 with IncludeTable

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

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

the class DbImportTree method printIncludeTables.

private void printIncludeTables(Collection<IncludeTable> collection, DbImportTreeNode parent) {
    for (IncludeTable includeTable : collection) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(includeTable) : new TransferableNode(includeTable);
        if (!node.getSimpleNodeName().equals("")) {
            if (isTransferable && includeTable.getIncludeColumns().isEmpty() && includeTable.getExcludeColumns().isEmpty()) {
                printParams(Collections.singletonList(new IncludeColumn("Loading...")), node);
            }
            printParams(includeTable.getIncludeColumns(), node);
            printParams(includeTable.getExcludeColumns(), node);
            parent.add(node);
        }
    }
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode)

Example 24 with IncludeTable

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

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

IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)26 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)10 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)10 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)10 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)9 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)6 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)6 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)5 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)5 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)2 DbImportView (org.apache.cayenne.modeler.editor.dbimport.DbImportView)2 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)2 SQLException (java.sql.SQLException)1 TreePath (javax.swing.tree.TreePath)1 DbImportConfiguration (org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration)1 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)1 ExcludeRelationship (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeRelationship)1