Search in sources :

Example 6 with DbLoaderConfiguration

use of org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration in project cayenne by apache.

the class MergeCase method createMergeTokens.

protected List<MergerToken> createMergeTokens(String tableFilterInclude) {
    FiltersConfig filters = FiltersConfig.create(null, null, TableFilter.include(tableFilterInclude), PatternFilter.INCLUDE_NOTHING);
    DbLoaderConfiguration loaderConfiguration = new DbLoaderConfiguration();
    loaderConfiguration.setFiltersConfig(filters);
    DataMap dbImport;
    try (Connection conn = node.getDataSource().getConnection()) {
        dbImport = new DbLoader(node.getAdapter(), conn, loaderConfiguration, new LoggingDbLoaderDelegate(LoggerFactory.getLogger(DbLoader.class)), new DefaultObjectNameGenerator(NoStemStemmer.getInstance())).load();
    } catch (SQLException e) {
        throw new CayenneRuntimeException("Can't doLoad dataMap from db.", e);
    }
    List<MergerToken> tokens = merger().filters(filters).build().createMergeTokens(map, dbImport);
    return filter(tokens);
}
Also used : LoggingDbLoaderDelegate(org.apache.cayenne.dbsync.reverse.dbload.LoggingDbLoaderDelegate) DefaultObjectNameGenerator(org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator) SQLException(java.sql.SQLException) FiltersConfig(org.apache.cayenne.dbsync.reverse.filters.FiltersConfig) Connection(java.sql.Connection) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) MergerToken(org.apache.cayenne.dbsync.merge.token.MergerToken) DbLoader(org.apache.cayenne.dbsync.reverse.dbload.DbLoader) DbLoaderConfiguration(org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration) DataMap(org.apache.cayenne.map.DataMap)

Aggregations

DbLoaderConfiguration (org.apache.cayenne.dbsync.reverse.dbload.DbLoaderConfiguration)6 DataMap (org.apache.cayenne.map.DataMap)6 DbLoader (org.apache.cayenne.dbsync.reverse.dbload.DbLoader)5 DefaultObjectNameGenerator (org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator)4 Connection (java.sql.Connection)3 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)3 DataMapBuilder (org.apache.cayenne.dbsync.merge.builders.DataMapBuilder)3 DefaultModelMergeDelegate (org.apache.cayenne.dbsync.reverse.dbload.DefaultModelMergeDelegate)3 FileProjectSaver (org.apache.cayenne.project.FileProjectSaver)3 Project (org.apache.cayenne.project.Project)3 Test (org.junit.Test)3 SQLException (java.sql.SQLException)2 DataSource (javax.sql.DataSource)2 DataMapLoader (org.apache.cayenne.configuration.DataMapLoader)2 MergerTokenFactory (org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory)2 MergerToken (org.apache.cayenne.dbsync.merge.token.MergerToken)2 LoggingDbLoaderDelegate (org.apache.cayenne.dbsync.reverse.dbload.LoggingDbLoaderDelegate)2 FiltersConfig (org.apache.cayenne.dbsync.reverse.filters.FiltersConfig)2 Resource (org.apache.cayenne.resource.Resource)2 URLResource (org.apache.cayenne.resource.URLResource)2