use of org.apache.cayenne.dbsync.reverse.filters.CatalogFilter in project cayenne by apache.
the class DefaultDbImportAction method newTargetDataMap.
protected DataMap newTargetDataMap(DbImportConfiguration config) throws IOException {
DataMap dataMap = new DataMap();
dataMap.setName(config.getDataMapName());
dataMap.setConfigurationSource(new URLResource(config.getTargetDataMap().toURI().toURL()));
dataMap.setNamespace(new EntityResolver(Collections.singleton(dataMap)));
// update map defaults
// do not override default package of existing DataMap unless it is
// explicitly requested by the plugin caller
String defaultPackage = config.getDefaultPackage();
if (defaultPackage != null && defaultPackage.length() > 0) {
dataMap.setDefaultPackage(defaultPackage);
}
CatalogFilter[] catalogs = config.getDbLoaderConfig().getFiltersConfig().getCatalogs();
if (catalogs.length > 0) {
// do not override default catalog of existing DataMap unless it is
// explicitly requested by the plugin caller, and the provided catalog is
// not a pattern
String catalog = catalogs[0].name;
if (catalog != null && catalog.length() > 0 && catalog.indexOf('%') < 0) {
dataMap.setDefaultCatalog(catalog);
}
// do not override default schema of existing DataMap unless it is
// explicitly requested by the plugin caller, and the provided schema is
// not a pattern
String schema = catalogs[0].schemas[0].name;
if (schema != null && schema.length() > 0 && schema.indexOf('%') < 0) {
dataMap.setDefaultSchema(schema);
}
}
return dataMap;
}
Aggregations