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