Search in sources :

Example 6 with DbLoader

use of org.apache.cayenne.dbsync.reverse.dbload.DbLoader 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

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