use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable in project cayenne by apache.
the class FiltersConfigBuilderTest method testCompact_01.
@Test
public void testCompact_01() {
ReverseEngineering engineering = new ReverseEngineering();
engineering.addIncludeTable(new IncludeTable("table1"));
engineering.addIncludeTable(new IncludeTable("table2"));
engineering.addIncludeTable(new IncludeTable("table3"));
engineering.addIncludeColumn(new IncludeColumn("includeColumn"));
FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
builder.compact();
assertEquals("ReverseEngineering: \n" + " Catalog: null\n" + " Schema: null\n" + " IncludeTable: table1\n" + " IncludeColumn: includeColumn\n" + " IncludeTable: table2\n" + " IncludeColumn: includeColumn\n" + " IncludeTable: table3\n" + " IncludeColumn: includeColumn\n", engineering.toString());
}
use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable 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.IncludeTable in project cayenne by apache.
the class DbImporterMojoTest method testFilteringConfig.
@Test
public void testFilteringConfig() throws Exception {
DbImporterMojo cdbImport = getCdbImport("config/pom-01.xml");
assertEquals(2, cdbImport.getReverseEngineering().getCatalogs().size());
Iterator<Catalog> iterator = cdbImport.getReverseEngineering().getCatalogs().iterator();
assertEquals("catalog-name-01", iterator.next().getName());
Catalog catalog = iterator.next();
assertEquals("catalog-name-02", catalog.getName());
Iterator<Schema> schemaIterator = catalog.getSchemas().iterator();
assertEquals("schema-name-01", schemaIterator.next().getName());
Schema schema = schemaIterator.next();
assertEquals("schema-name-02", schema.getName());
Iterator<IncludeTable> includeTableIterator = schema.getIncludeTables().iterator();
assertEquals("incTable-01", includeTableIterator.next().getPattern());
IncludeTable includeTable = includeTableIterator.next();
assertEquals("incTable-02", includeTable.getPattern());
assertEquals("includeColumn-01", includeTable.getIncludeColumns().iterator().next().getPattern());
assertEquals("excludeColumn-01", includeTable.getExcludeColumns().iterator().next().getPattern());
assertEquals("includeColumn-02", schema.getIncludeColumns().iterator().next().getPattern());
assertEquals("excludeColumn-02", schema.getExcludeColumns().iterator().next().getPattern());
assertEquals("includeColumn-03", catalog.getIncludeColumns().iterator().next().getPattern());
assertEquals("excludeColumn-03", catalog.getExcludeColumns().iterator().next().getPattern());
schemaIterator = cdbImport.getReverseEngineering().getSchemas().iterator();
schema = schemaIterator.next();
assertEquals("schema-name-03", schema.getName());
schema = schemaIterator.next();
assertEquals("schema-name-04", schema.getName());
includeTableIterator = schema.getIncludeTables().iterator();
assertEquals("incTable-04", includeTableIterator.next().getPattern());
assertEquals("excTable-04", schema.getExcludeTables().iterator().next().getPattern());
includeTable = includeTableIterator.next();
assertEquals("incTable-05", includeTable.getPattern());
assertEquals("includeColumn-04", includeTable.getIncludeColumns().iterator().next().getPattern());
assertEquals("excludeColumn-04", includeTable.getExcludeColumns().iterator().next().getPattern());
assertEquals("includeColumn-04", schema.getIncludeColumns().iterator().next().getPattern());
assertEquals("excludeColumn-04", schema.getExcludeColumns().iterator().next().getPattern());
assertEquals("includeColumn-03", catalog.getIncludeColumns().iterator().next().getPattern());
assertEquals("excludeColumn-03", catalog.getExcludeColumns().iterator().next().getPattern());
}
Aggregations