use of org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule in project cayenne by apache.
the class DbImportTask method runImport.
@TaskAction
public void runImport() {
dataSource.validate();
DbImportConfiguration config = createConfig();
Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(getLogger()), new DbImportModule());
DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
try {
validator.validate();
} catch (Exception ex) {
throw new TaskExecutionException(this, ex);
}
try {
injector.getInstance(DbImportAction.class).execute(config);
} catch (Exception ex) {
Throwable th = Util.unwindException(ex);
String message = "Error importing database schema";
if (th.getLocalizedMessage() != null) {
message += ": " + th.getLocalizedMessage();
}
getLogger().error(message);
throw new TaskExecutionException(this, th);
}
}
use of org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule in project cayenne by apache.
the class DbImporterTask method execute.
@Override
public void execute() {
config.setFiltersConfig(new FiltersConfigBuilder(reverseEngineering).build());
validateAttributes();
Logger logger = new AntLogger(this);
config.setLogger(logger);
config.setSkipRelationshipsLoading(reverseEngineering.getSkipRelationshipsLoading());
config.setSkipPrimaryKeyLoading(reverseEngineering.getSkipPrimaryKeyLoading());
config.setTableTypes(reverseEngineering.getTableTypes());
Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
DbImportConfigurationValidator validator = new DbImportConfigurationValidator(reverseEngineering, config, injector);
try {
validator.validate();
} catch (Exception ex) {
throw new BuildException(ex.getMessage(), ex);
}
try {
injector.getInstance(DbImportAction.class).execute(config);
} catch (Exception ex) {
Throwable th = Util.unwindException(ex);
String message = "Error importing database schema";
if (th.getLocalizedMessage() != null) {
message += ": " + th.getLocalizedMessage();
}
log(message, Project.MSG_ERR);
throw new BuildException(message, th);
} finally {
injector.shutdown();
}
}
use of org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule in project cayenne by apache.
the class DbImporterMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
Logger logger = new MavenLogger(this);
// check missing data source parameters
dataSource.validate();
DbImportConfiguration config = createConfig(logger);
Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
DbImportConfigurationValidator validator = new DbImportConfigurationValidator(dbImportConfig, config, injector);
try {
validator.validate();
} catch (Exception ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
try {
injector.getInstance(DbImportAction.class).execute(config);
} catch (Exception ex) {
Throwable th = Util.unwindException(ex);
String message = "Error importing database schema";
if (th.getLocalizedMessage() != null) {
message += ": " + th.getLocalizedMessage();
}
getLog().error(message);
throw new MojoExecutionException(message, th);
}
}
Aggregations