// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
public IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(getConnectionMessage(), 10);
-
+
// check if database is up and running
checkDatabaseReachable(monitor);
Thread.currentThread().setPriority(oldPriority);
}
}
-
-
+
+
if (!monitor.isCanceled()) {
CdmStore.setInstance(applicationController, cdmSource);
display.asyncExec(new Runnable() {
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Runnable#run()
*/
@Override
display.asyncExec(new Runnable() {
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Runnable#run()
*/
@Override
private ICdmApplicationConfiguration getApplicationController(ICdmSource cdmSource, CdmProgressMonitorAdapter subprogressMonitor) {
if(cdmSource instanceof ICdmDataSource) {
- return CdmApplicationController.NewInstance(applicationContextBean,
- (ICdmDataSource)cdmSource,
+ return CdmApplicationController.NewInstance(applicationContextBean,
+ (ICdmDataSource)cdmSource,
dbSchemaValidation,
- false,
+ false,
subprogressMonitor);
} else if(cdmSource instanceof ICdmRemoteSource) {
- return CdmApplicationRemoteController.NewInstance((ICdmRemoteSource)cdmSource,
- false,
+ return CdmApplicationRemoteController.NewInstance((ICdmRemoteSource)cdmSource,
+ false,
subprogressMonitor,
null);
} else {
private void checkDbSchemaVersionCompatibility(IProgressMonitor monitor) {
monitor.subTask("Checking if datasource is compatible with this editor.");
String dbSchemaVersion;
- boolean result = false;
+
+ String message = null;
try {
dbSchemaVersion = cdmSource.getDbSchemaVersion();
// we assume that empty dbSchemaVersion means an empty database and
// skip version checking
- result = dbSchemaVersion == null ? true : CdmMetaData
- .isDbSchemaVersionCompatible(dbSchemaVersion);
+
+ if(dbSchemaVersion != null) {
+ int compareVersion = CdmMetaData.compareVersion(dbSchemaVersion, CdmMetaData.getDbSchemaVersion(), 3, null);
+ // if the datasource version is greater than the taxeditor compatible version then the taxeditor needs to
+ // be updated else the datasource needs to be updated
+ if(compareVersion > 0) {
+ message = "Please update the Taxonomic Editor (Help->Check for Updates) or choose a compatible datasource";
+ } else if (compareVersion < 0) {
+ message = "Please update the chosen datasource or choose a new data source to connect to in the Datasource View.";
+ }
+ }
monitor.worked(1);
} catch (CdmSourceException e) {
//
}
- if (!result) {
+ if (message != null) {
// Show an error message
MessagingUtils
.messageDialog(
- "DatabaseCompatibilityCheck failed",
+ "Datasource Compatibility Check failed",
this,
"The database schema for the chosen "
+ "datasource '"
+ cdmSource
- + "' \n is not valid for this version of the taxonomic editor. \n"
- + "Please update the chosen datasource or choose a new data source to connect to in the Datasource View.",
+ + "' \n is not compatible for this version of the taxonomic editor. \n\n"
+ + message,
null);
monitor.setCanceled(true);
return causeIsCancelationExceptionRecursive(throwable.getCause());
}
}
-
+
private void checkDatabaseReachable(IProgressMonitor monitor) {
try {
monitor.subTask("Checking if datasource is reachable.");
MessagingUtils.messageDialog("Could not connect to chosen datasource",
this, "Reason: " + e.getMessage(), e);
monitor.setCanceled(true);
- }
+ }
}
}