use of org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder in project cayenne by apache.
the class DbImportTask method createConfig.
DbImportConfiguration createConfig() {
reverseEngineering = config.toReverseEngineering();
DbImportConfiguration config = new DbImportConfiguration();
config.setAdapter(adapter);
config.setDefaultPackage(reverseEngineering.getDefaultPackage());
config.setDriver(dataSource.getDriver());
config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
config.setForceDataMapCatalog(reverseEngineering.isForceDataMapCatalog());
config.setForceDataMapSchema(reverseEngineering.isForceDataMapSchema());
config.setLogger(getLogger());
config.setMeaningfulPkTables(reverseEngineering.getMeaningfulPkTables());
config.setNamingStrategy(reverseEngineering.getNamingStrategy());
config.setPassword(dataSource.getPassword());
config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
config.setStripFromTableNames(reverseEngineering.getStripFromTableNames());
config.setTableTypes(reverseEngineering.getTableTypes());
config.setTargetDataMap(getDataMapFile());
config.setUrl(dataSource.getUrl());
config.setUsername(dataSource.getUsername());
config.setUsePrimitives(reverseEngineering.isUsePrimitives());
config.setUseJava7Types(reverseEngineering.isUseJava7Types());
config.setCayenneProject(cayenneProject);
return config;
}
use of org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder in project cayenne by apache.
the class DbImporterTask method execute.
@Override
public void execute() {
config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
validateAttributes();
Logger logger = new AntLogger(this);
config.setLogger(logger);
config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
config.setTableTypes(reverseEngineering.getTableTypes());
Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
try {
validator.validate();
} catch (Exception ex) {
throw new BuildException(ex.getMessage(), ex);
}
try {
injector.getInstance(DbImportAction.class).execute(config);
} catch (Exception ex) {
Throwable th = Util.unwindException(ex);
String message = "Error importing database schema";
if (th.getLocalizedMessage() != null) {
message += ": " + th.getLocalizedMessage();
}
log(message, Project.MSG_ERR);
throw new BuildException(message, th);
} finally {
injector.shutdown();
}
}
use of org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder 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.filters.FiltersConfigBuilder in project cayenne by apache.
the class DbImporterMojo method createConfig.
DbImportConfiguration createConfig(Logger logger) {
DbImportConfiguration config = new DbImportConfiguration();
config.setAdapter(adapter);
config.setDefaultPackage(dbImportConfig.getDefaultPackage());
config.setDriver(dataSource.getDriver());
config.setFiltersConfig(new FiltersConfigBuilder(dbImportConfig).build());
config.setForceDataMapCatalog(dbImportConfig.isForceDataMapCatalog());
config.setForceDataMapSchema(dbImportConfig.isForceDataMapSchema());
config.setLogger(logger);
config.setMeaningfulPkTables(dbImportConfig.getMeaningfulPkTables());
config.setNamingStrategy(dbImportConfig.getNamingStrategy());
config.setPassword(dataSource.getPassword());
config.setSkipRelationshipsLoading(dbImportConfig.getSkipRelationshipsLoading());
config.setSkipPrimaryKeyLoading(dbImportConfig.getSkipPrimaryKeyLoading());
config.setStripFromTableNames(dbImportConfig.getStripFromTableNames());
config.setTableTypes(dbImportConfig.getTableTypes());
config.setTargetDataMap(map);
config.setCayenneProject(cayenneProject);
config.setUrl(dataSource.getUrl());
config.setUsername(dataSource.getUsername());
config.setUsePrimitives(dbImportConfig.isUsePrimitives());
config.setUseJava7Types(dbImportConfig.isUseJava7Types());
return config;
}
Aggregations