Search in sources :

Example 6 with ExcludeTable

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

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

the class TableNode method getStatus.

@Override
public Status getStatus(ReverseEngineering config) {
    T parent = getParent();
    if (parent != null) {
        Status parentStatus = parent.getStatus(config);
        if (parentStatus != Status.INCLUDE) {
            return parentStatus;
        }
    }
    List<IncludeTable> includeTables = new ArrayList<>();
    List<ExcludeTable> excludeTables = new ArrayList<>();
    for (FilterContainer container : getContainers(config)) {
        if (container == null) {
            continue;
        }
        includeTables.addAll(container.getIncludeTables());
        excludeTables.addAll(container.getExcludeTables());
    }
    return includesTable(includeTables, excludeTables);
}
Also used : IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) ArrayList(java.util.ArrayList) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)

Example 8 with ExcludeTable

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

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

the class AddPatternParamAction method addPatternParamToContainer.

private void addPatternParamToContainer(Class paramClass, Object selectedObject, String name, DbImportTreeNode node) {
    FilterContainer container = (FilterContainer) selectedObject;
    PatternParam element = null;
    if (paramClass == ExcludeTable.class) {
        element = new ExcludeTable(name);
        container.addExcludeTable((ExcludeTable) element);
    } else if (paramClass == IncludeColumn.class) {
        element = new IncludeColumn(name);
        container.addIncludeColumn((IncludeColumn) element);
    } else if (paramClass == ExcludeColumn.class) {
        element = new ExcludeColumn(name);
        container.addExcludeColumn((ExcludeColumn) element);
    } else if (paramClass == IncludeProcedure.class) {
        element = new IncludeProcedure(name);
        container.addIncludeProcedure((IncludeProcedure) element);
    } else if (paramClass == ExcludeProcedure.class) {
        element = new ExcludeProcedure(name);
        container.addExcludeProcedure((ExcludeProcedure) element);
    }
    node.add(new DbImportTreeNode(element));
}
Also used : PatternParam(org.apache.cayenne.dbsync.reverse.dbimport.PatternParam) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) 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 10 with ExcludeTable

use of org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable 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\n" + "  Use primitives", engineering.toString());
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) ExcludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable) Test(org.junit.Test)

Aggregations

ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)11 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)6 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)6 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)5 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)4 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)4 IncludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure)4 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)4 Test (org.junit.Test)4 ExcludeProcedure (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure)3 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)2 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)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 DBConnectionInfo (org.apache.cayenne.modeler.pref.DBConnectionInfo)1