apache/cayenne — pull request #15 by AlexKolonitsky (2014-09-24 17:22:06+00:00)
Title: cdbmport: Add advanced filtering into cdbimport

Solution description:
1) Package "/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config" is responsible for loading configuration from different sources (ant, maven, external reversengineering file) and transform(see FiltersConfigBuilder) into convenient format for DbLoader (see FiltersConfig). It is mean that FiltersConfig is a key interface in interaction between tools and server modules.

2) FiltersConfig is a map (DbPath -> EntityFilter)
DbPath = Catalog/Schema/Table
EntityFilter = Table/Column/Procedure Filters

3) DbLoader builds DbPath for each object, takes filter for this path (filter can aggregate a number of defined in config filters, see FiltersConfig.filter(DbPath)), call isInclude in order to figure out should we include this object or not. DbLoader should interact only with DbPath, FiltersConfig, EntityFilter and Filter interface.

4) Filter interface was designed in order to encapsulate all filtering logic for each specific entity and provide flexibility extend/override this mechanism. For each db object we are calling "isInclude" once and only in one place where filtering applied.
Here I have 2 key classes: Filter interface and FiltersFactory.