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);
}
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);
}
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);
}
}
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);
}
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);
}
Aggregations