Search in sources :

Example 6 with IncludeTable

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());
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) Test(org.junit.Test)

Example 7 with IncludeTable

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;
}
Also used : DbImportConfiguration(org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration) FiltersConfigBuilder(org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) DbLoaderDelegate(org.apache.cayenne.dbsync.reverse.dbload.DbLoaderDelegate) IncludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure) DBConnectionInfo(org.apache.cayenne.modeler.pref.DBConnectionInfo) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)

Example 8 with IncludeTable

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());
}
Also used : Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) Test(org.junit.Test)

Aggregations

IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)8 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)6 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)6 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)4 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)3 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)3 Test (org.junit.Test)3 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)2 DbImportConfiguration (org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration)1 ExcludeRelationship (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeRelationship)1 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)1 DbLoaderDelegate (org.apache.cayenne.dbsync.reverse.dbload.DbLoaderDelegate)1 FiltersConfigBuilder (org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder)1 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)1