use of org.apache.cayenne.dbsync.reverse.dbload.DbLoaderDelegate 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;
}
Aggregations