use of org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering in project cayenne by apache.
the class FiltersConfigBuilderTest method testCompact_03.
@Test
public void testCompact_03() {
ReverseEngineering engineering = new ReverseEngineering();
engineering.addCatalog(new Catalog("APP1"));
engineering.addCatalog(new Catalog("APP2"));
engineering.addExcludeTable(new ExcludeTable("SYS_.*"));
engineering.addExcludeColumn(new ExcludeColumn("calculated_.*"));
FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
builder.compact();
assertEquals("ReverseEngineering: \n" + " Catalog: APP1\n" + " Schema: null\n" + " IncludeTable: null\n" + " ExcludeColumn: calculated_.*\n" + " ExcludeTable: SYS_.*\n" + " Catalog: APP2\n" + " Schema: null\n" + " IncludeTable: null\n" + " ExcludeColumn: calculated_.*\n" + " ExcludeTable: SYS_.*\n", engineering.toString());
}
use of org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering in project cayenne by apache.
the class FiltersConfigBuilderTest method testCompact_04.
@Test
public void testCompact_04() {
ReverseEngineering engineering = new ReverseEngineering();
engineering.addSchema(new Schema("s"));
FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
builder.compact();
assertEquals("ReverseEngineering: \n" + " Catalog: null\n" + " Schema: s\n" + " IncludeTable: null\n", engineering.toString());
}
use of org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering in project cayenne by apache.
the class DbImportConfigTest method toReverseEngineering.
@Test
public void toReverseEngineering() throws Exception {
DbImportConfig config = new DbImportConfig();
config.catalog("catalog1");
config.schema("schema1");
config.setDefaultPackage("com.example.package");
config.setMeaningfulPkTables("pk_tables");
config.setNamingStrategy("com.example.naming");
config.setSkipPrimaryKeyLoading(true);
config.setSkipRelationshipsLoading(true);
config.setStripFromTableNames("strip");
config.tableType("table");
config.tableTypes("view", "alias");
config.setForceDataMapCatalog(true);
config.setForceDataMapSchema(true);
config.setUseJava7Types(true);
config.setUsePrimitives(false);
ReverseEngineering rr = config.toReverseEngineering();
assertNotNull(rr);
assertEquals(1, rr.getCatalogs().size());
assertEquals("catalog1", rr.getCatalogs().iterator().next().getName());
assertEquals(1, rr.getSchemas().size());
assertEquals("schema1", rr.getSchemas().iterator().next().getName());
assertEquals(0, rr.getIncludeTables().size());
assertEquals(0, rr.getExcludeTables().size());
assertEquals(0, rr.getIncludeColumns().size());
assertEquals(0, rr.getExcludeColumns().size());
assertEquals(0, rr.getIncludeProcedures().size());
assertEquals(0, rr.getExcludeProcedures().size());
assertEquals("com.example.package", rr.getDefaultPackage());
assertEquals("pk_tables", rr.getMeaningfulPkTables());
assertEquals("com.example.naming", rr.getNamingStrategy());
assertTrue(rr.getSkipPrimaryKeyLoading());
assertTrue(rr.getSkipRelationshipsLoading());
assertEquals("strip", rr.getStripFromTableNames());
assertArrayEquals(new String[] { "table", "view", "alias" }, rr.getTableTypes());
assertTrue(rr.isForceDataMapCatalog());
assertTrue(rr.isForceDataMapSchema());
assertTrue(rr.isUseJava7Types());
assertFalse(rr.isUsePrimitives());
}
use of org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering 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