use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class SchemaProcedureNode method getContainers.
@Override
List<FilterContainer> getContainers(ReverseEngineering config) {
List<FilterContainer> containers = new ArrayList<>();
if (getParent() != null && getParent().getParent() != null) {
Catalog catalog = getParent().getParent().getCatalog(config);
if (catalog != null) {
containers.add(getParent().getSchema(catalog));
containers.add(catalog);
}
containers.add(getParent().getSchema(config));
}
containers.add(config);
return containers;
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class FiltersConfigBuilder method clearGlobalFilters.
private void clearGlobalFilters() {
for (Catalog catalog : engineering.getCatalogs()) {
catalog.clearIncludeTables();
catalog.clearExcludeTables();
catalog.clearIncludeProcedures();
catalog.clearExcludeProcedures();
catalog.clearIncludeColumns();
catalog.clearExcludeColumns();
catalog.clearExcludeRelationships();
for (Schema schema : catalog.getSchemas()) {
schema.clearIncludeColumns();
schema.clearExcludeColumns();
schema.clearExcludeRelationships();
}
}
engineering.clearIncludeTables();
engineering.clearExcludeTables();
engineering.clearIncludeProcedures();
engineering.clearExcludeProcedures();
engineering.clearIncludeColumns();
engineering.clearExcludeColumns();
engineering.clearExcludeRelationships();
engineering.getSchemas().clear();
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class DbLoaderContext method buildConfig.
public boolean buildConfig(DataSourceWizard connectionWizard, DbLoaderOptionsDialog dialog) {
if (dialog == null || connectionWizard == null) {
return false;
}
// Build filters
ReverseEngineering reverseEngineering = new ReverseEngineering();
reverseEngineering.addCatalog(new Catalog(dialog.getSelectedCatalog()));
reverseEngineering.addSchema(new Schema(dialog.getSelectedSchema()));
reverseEngineering.addIncludeTable(new IncludeTable(dialog.getTableIncludePattern()));
if (dialog.getTableExcludePattern() != null) {
reverseEngineering.addExcludeTable(new ExcludeTable(dialog.getTableExcludePattern()));
}
// Add here auto_pk_support table
reverseEngineering.addExcludeTable(new ExcludeTable("auto_pk_support|AUTO_PK_SUPPORT"));
reverseEngineering.addIncludeProcedure(new IncludeProcedure(dialog.getProcedureNamePattern()));
FiltersConfigBuilder filtersConfigBuilder = new FiltersConfigBuilder(reverseEngineering);
DbImportConfiguration config = new DbImportConfiguration() {
@Override
public DbLoaderDelegate createLoaderDelegate() {
return new LoaderDelegate(DbLoaderContext.this);
}
};
// Build config
DBConnectionInfo connectionInfo = connectionWizard.getConnectionInfo();
config.setAdapter(connectionWizard.getAdapter().getClass().getName());
config.setUsername(connectionInfo.getUserName());
config.setPassword(connectionInfo.getPassword());
config.setDriver(connectionInfo.getJdbcDriver());
config.setUrl(connectionInfo.getUrl());
config.getDbLoaderConfig().setFiltersConfig(filtersConfigBuilder.build());
config.setMeaningfulPkTables(dialog.getMeaningfulPk());
config.setNamingStrategy(dialog.getNamingStrategy());
config.setUsePrimitives(dialog.isUsePrimitives());
config.setUseJava7Types(dialog.isUseJava7Typed());
setConfig(config);
prepareDataMap();
return true;
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class FiltersConfigBuilder method processCatalogs.
private void processCatalogs(DatabaseMetaData databaseMetaData, DbAdapter dbAdapter) throws SQLException {
try (ResultSet catalogRs = databaseMetaData.getCatalogs()) {
List<String> systemCatalogs = dbAdapter.getSystemCatalogs();
List<String> systemSchemas = dbAdapter.getSystemSchemas();
boolean hasCatalogs = false;
while (catalogRs.next()) {
hasCatalogs = true;
String catalogName = catalogRs.getString("TABLE_CAT");
if (!systemCatalogs.contains(catalogName)) {
Catalog catalog = new Catalog(catalogName);
List<Schema> schemas = processSchemas(databaseMetaData, catalogName, systemSchemas);
catalog.getSchemas().addAll(schemas);
engineering.addCatalog(catalog);
}
}
if (!hasCatalogs) {
List<Schema> schemas = processSchemas(databaseMetaData, null, systemSchemas);
engineering.getSchemas().addAll(schemas);
}
}
}
use of org.apache.cayenne.dbsync.reverse.dbimport.Catalog in project cayenne by apache.
the class FiltersConfigBuilder method compactProcedureFilter.
private void compactProcedureFilter() {
Collection<IncludeProcedure> engIncludeProcedures = engineering.getIncludeProcedures();
Collection<ExcludeProcedure> engExcludeProcedures = engineering.getExcludeProcedures();
for (Catalog catalog : engineering.getCatalogs()) {
Collection<IncludeProcedure> catalogIncludeProcedures = catalog.getIncludeProcedures();
Collection<ExcludeProcedure> catalogExcludeProcedures = catalog.getExcludeProcedures();
for (Schema schema : catalog.getSchemas()) {
schema.getIncludeProcedures().addAll(engIncludeProcedures);
schema.getIncludeProcedures().addAll(catalogIncludeProcedures);
schema.getExcludeProcedures().addAll(engExcludeProcedures);
schema.getExcludeProcedures().addAll(catalogExcludeProcedures);
}
}
for (Schema schema : engineering.getSchemas()) {
schema.getIncludeProcedures().addAll(engIncludeProcedures);
schema.getExcludeProcedures().addAll(engExcludeProcedures);
}
}
Aggregations