use of org.obeonetwork.dsl.database.reverse.utils.ProgressListener in project InformationSystem by ObeoNetwork.
the class AbstractDataBaseBuilder method initialize.
private void initialize(DataSource source, ProgressListener progressListener, Queries queries) throws SQLException {
connection = null;
try {
connection = source.getConnection();
} catch (DataSourceException e) {
throw new SQLException("Unable to connect to database", e.getCause());
}
if (connection != null) {
try {
this.metaData = connection.getMetaData();
} catch (SQLException e) {
JdbcUtils.closeConnection(connection);
throw e;
}
}
this.progressListener = progressListener;
if (this.progressListener == null) {
this.progressListener = new ProgressListener() {
@Override
public void start(int numberOfSteps) {
}
@Override
public void progressTo(int step, String message) {
}
@Override
public void end(String message) {
}
};
}
this.queries = queries;
dataBase = buildDataBase(source.getDatabaseName());
queries.registerDatabase(dataBase);
tableContainer = dataBase;
if (isSet(source.getSchemaName())) {
tableContainer = buildSchema(source.getSchemaName(), (DataBase) tableContainer);
}
setUsedLibraries();
}
use of org.obeonetwork.dsl.database.reverse.utils.ProgressListener in project InformationSystem by ObeoNetwork.
the class ImportRunnable method execute.
@Override
protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
ProgressListener progressListener = new ProgressListener() {
private int stepsToBeDone = 0;
public void start(int nbSteps) {
// +2 because there is one more step to save the file
monitor.beginTask("Importing database", nbSteps + 1);
}
public void progressTo(int stepsToBeDone, String message) {
if (this.stepsToBeDone != 0) {
monitor.worked(this.stepsToBeDone);
}
monitor.subTask(message);
this.stepsToBeDone = stepsToBeDone;
}
public void end(String message) {
if (this.stepsToBeDone != 0) {
monitor.worked(this.stepsToBeDone);
}
}
};
DataBase database = DatabaseReverser.reverse(dataSourceInfos, queries, progressListener);
if (database != null) {
// Store the model into a file
monitor.subTask("Saving model file");
try {
saveIntoFile(database, modelFilename);
result = true;
} catch (IOException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while saving database into model file", e));
}
monitor.worked(1);
} else {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while importing database : No database found."));
}
monitor.done();
}
Aggregations