Search in sources :

Example 1 with IncludeProcedure

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure in project cayenne by apache.

the class FiltersConfigBuilderTest method testCompact_full.

@Test
public void testCompact_full() {
    ReverseEngineering engineering = new ReverseEngineering();
    Catalog cat01 = new Catalog("cat_01");
    Schema sch01 = new Schema("sch_01");
    sch01.addIncludeTable(includeTable("t1", "c11", "c12"));
    sch01.addExcludeTable(new ExcludeTable("t2"));
    sch01.addIncludeProcedure(new IncludeProcedure("p1"));
    sch01.addExcludeProcedure(new ExcludeProcedure("p2"));
    sch01.addIncludeColumn(new IncludeColumn("c_x1"));
    sch01.addExcludeColumn(new ExcludeColumn("c_x2"));
    cat01.addSchema(sch01);
    cat01.addIncludeTable(includeTable("t3", "c31", "c32"));
    cat01.addExcludeTable(new ExcludeTable("t4"));
    cat01.addIncludeProcedure(new IncludeProcedure("p3"));
    cat01.addExcludeProcedure(new ExcludeProcedure("p4"));
    cat01.addIncludeColumn(new IncludeColumn("c_xx1"));
    cat01.addExcludeColumn(new ExcludeColumn("c_xx2"));
    engineering.addCatalog(cat01);
    Schema sch02 = new Schema("sch_02");
    sch02.addIncludeTable(includeTable("t5", "c51", "c52"));
    sch02.addExcludeTable(new ExcludeTable("t6"));
    sch02.addIncludeProcedure(new IncludeProcedure("p5"));
    sch02.addExcludeProcedure(new ExcludeProcedure("p6"));
    sch02.addIncludeColumn(new IncludeColumn("c2_x1"));
    sch02.addExcludeColumn(new ExcludeColumn("c2_x2"));
    engineering.addSchema(sch02);
    engineering.addIncludeTable(includeTable("t7", "c71", "c72"));
    engineering.addExcludeTable(new ExcludeTable("t8"));
    engineering.addIncludeProcedure(new IncludeProcedure("p7"));
    engineering.addExcludeProcedure(new ExcludeProcedure("p8"));
    engineering.addIncludeColumn(new IncludeColumn("c_xxx1"));
    engineering.addExcludeColumn(new ExcludeColumn("c_xxx2"));
    FiltersConfigBuilder builder = new FiltersConfigBuilder(engineering);
    assertEquals("Original ReverseEngineering should be", "ReverseEngineering: \n" + "  Catalog: cat_01\n" + "    Schema: sch_01\n" + "      IncludeTable: t1\n" + "        IncludeColumn: c11\n" + "        ExcludeColumn: c12\n" + "      ExcludeTable: t2\n" + "      IncludeColumn: c_x1\n" + "      ExcludeColumn: c_x2\n" + "      IncludeProcedure: p1\n" + "      ExcludeProcedure: p2\n" + "      IncludeTable: t3\n" + "        IncludeColumn: c31\n" + "        ExcludeColumn: c32\n" + "      ExcludeTable: t4\n" + "      IncludeColumn: c_xx1\n" + "      ExcludeColumn: c_xx2\n" + "      IncludeProcedure: p3\n" + "      ExcludeProcedure: p4\n" + "  Schema: sch_02\n" + "    IncludeTable: t5\n" + "      IncludeColumn: c51\n" + "      ExcludeColumn: c52\n" + "    ExcludeTable: t6\n" + "    IncludeColumn: c2_x1\n" + "    ExcludeColumn: c2_x2\n" + "    IncludeProcedure: p5\n" + "    ExcludeProcedure: p6\n" + "    IncludeTable: t7\n" + "      IncludeColumn: c71\n" + "      ExcludeColumn: c72\n" + "    ExcludeTable: t8\n" + "    IncludeColumn: c_xxx1\n" + "    ExcludeColumn: c_xxx2\n" + "    IncludeProcedure: p7\n" + "    ExcludeProcedure: p8\n\n" + "  Use primitives", engineering.toString());
    builder.compact();
    assertEquals("ReverseEngineering: \n" + "  Catalog: cat_01\n" + "    Schema: sch_01\n" + "      IncludeTable: t1\n" + "        IncludeColumn: c11\n" + "        IncludeColumn: c_xxx1\n" + "        IncludeColumn: c_xx1\n" + "        IncludeColumn: c_x1\n" + "        ExcludeColumn: c12\n" + "        ExcludeColumn: c_xxx2\n" + "        ExcludeColumn: c_xx2\n" + "        ExcludeColumn: c_x2\n" + "      IncludeTable: t7\n" + "        IncludeColumn: c71\n" + "        IncludeColumn: c_xxx1\n" + "        ExcludeColumn: c72\n" + "        ExcludeColumn: c_xxx2\n" + "      IncludeTable: t3\n" + "        IncludeColumn: c31\n" + "        IncludeColumn: c_xxx1\n" + "        IncludeColumn: c_xx1\n" + "        ExcludeColumn: c32\n" + "        ExcludeColumn: c_xxx2\n" + "        ExcludeColumn: c_xx2\n" + "      ExcludeTable: t2\n" + "      ExcludeTable: t8\n" + "      ExcludeTable: t4\n" + "      IncludeProcedure: p1\n" + "      IncludeProcedure: p7\n" + "      IncludeProcedure: p3\n" + "      ExcludeProcedure: p2\n" + "      ExcludeProcedure: p8\n" + "      ExcludeProcedure: p4\n" + "    Schema: sch_02\n" + "      IncludeTable: t5\n" + "        IncludeColumn: c51\n" + "        IncludeColumn: c_xxx1\n" + "        IncludeColumn: c2_x1\n" + "        ExcludeColumn: c52\n" + "        ExcludeColumn: c_xxx2\n" + "        ExcludeColumn: c2_x2\n" + "      IncludeTable: t7\n" + "        IncludeColumn: c71\n" + "        IncludeColumn: c_xxx1\n" + "        ExcludeColumn: c72\n" + "        ExcludeColumn: c_xxx2\n" + "      ExcludeTable: t6\n" + "      ExcludeTable: t8\n" + "      IncludeProcedure: p5\n" + "      IncludeProcedure: p7\n" + "      ExcludeProcedure: p6\n" + "      ExcludeProcedure: p8\n\n" + "  Use primitives", engineering.toString());
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) ExcludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn) ExcludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) IncludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable) Test(org.junit.Test)

Example 2 with IncludeProcedure

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure in project cayenne by apache.

the class PatternParam method toIncludeProcedure.

IncludeProcedure toIncludeProcedure() {
    IncludeProcedure procedure = new IncludeProcedure();
    procedure.setPattern(pattern);
    return procedure;
}
Also used : IncludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)

Example 3 with IncludeProcedure

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure in project cayenne by apache.

the class ColorTreeRenderer method mergeAsFilterContainer.

private boolean mergeAsFilterContainer(FilterContainer container, Object object) {
    if (object instanceof IncludeTable) {
        container.addIncludeTable((IncludeTable) object);
        container.addIncludeProcedure(new IncludeProcedure("tmp include to disable include all behaviour"));
        return true;
    } else if (object instanceof ExcludeTable) {
        container.addExcludeTable((ExcludeTable) object);
        container.addIncludeProcedure(new IncludeProcedure("tmp include to disable include all behaviour"));
        container.addIncludeTable(new IncludeTable("tmp include to disable include all behaviour"));
        return true;
    } else if (object instanceof IncludeProcedure) {
        container.addIncludeProcedure((IncludeProcedure) object);
        return true;
    } else if (object instanceof ExcludeProcedure) {
        container.addExcludeProcedure((ExcludeProcedure) object);
        container.addIncludeProcedure(new IncludeProcedure("tmp include to disable include all behaviour"));
        return true;
    } else if (object instanceof IncludeColumn) {
        container.addIncludeColumn((IncludeColumn) object);
        return true;
    } else if (object instanceof ExcludeColumn) {
        container.addExcludeColumn((ExcludeColumn) object);
        return true;
    }
    return false;
}
Also used : IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) ExcludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn) ExcludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) IncludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)

Example 4 with IncludeProcedure

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure 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 5 with IncludeProcedure

use of org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure in project cayenne by apache.

the class FiltersConfigBuilder method compactProcedureFilter.

private void compactProcedureFilter() {
    Collection<IncludeProcedure> engIncludeProcedures = engineering.getIncludeProcedures();
    Collection<ExcludeProcedure> engExcludeProcedures = engineering.getExcludeProcedures();
    for (Catalog catalog : engineering.getCatalogs()) {
        Collection<IncludeProcedure> catalogIncludeProcedures = catalog.getIncludeProcedures();
        Collection<ExcludeProcedure> catalogExcludeProcedures = catalog.getExcludeProcedures();
        for (Schema schema : catalog.getSchemas()) {
            schema.getIncludeProcedures().addAll(engIncludeProcedures);
            schema.getIncludeProcedures().addAll(catalogIncludeProcedures);
            schema.getExcludeProcedures().addAll(engExcludeProcedures);
            schema.getExcludeProcedures().addAll(catalogExcludeProcedures);
        }
    }
    for (Schema schema : engineering.getSchemas()) {
        schema.getIncludeProcedures().addAll(engIncludeProcedures);
        schema.getExcludeProcedures().addAll(engExcludeProcedures);
    }
}
Also used : Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) ExcludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure) IncludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Aggregations

IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)8 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)5 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)4 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)3 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)3 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)3 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)3 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)2 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)2 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 DbImportConfiguration (org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration)1 PatternParam (org.apache.cayenne.dbsync.reverse.dbimport.PatternParam)1 DbLoaderDelegate (org.apache.cayenne.dbsync.reverse.dbload.DbLoaderDelegate)1 FiltersConfigBuilder (org.apache.cayenne.dbsync.reverse.filters.FiltersConfigBuilder)1 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)1 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)1