From: n.hoffmann Date: Tue, 12 Apr 2011 08:29:41 +0000 (+0000) Subject: Added a missing feature to plugin dependencies X-Git-Tag: rcp.ss-first-working-version~122 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/c9a67492d75497b3cf3e99fc3cb23c0f4c5a116d?ds=inline Added a missing feature to plugin dependencies --- diff --git a/eu.etaxonomy.taxeditor.feature.platform/feature.xml b/eu.etaxonomy.taxeditor.feature.platform/feature.xml index 74ad0fef6..20d6fa9d9 100644 --- a/eu.etaxonomy.taxeditor.feature.platform/feature.xml +++ b/eu.etaxonomy.taxeditor.feature.platform/feature.xml @@ -853,4 +853,10 @@ Software distributed under the License is distributed on an "AS IS" ba fragment="true" unpack="false"/> + + diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java index 853dbe42c..8e560cf54 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java @@ -1,12 +1,12 @@ // $Id$ /** -* Copyright (C) 2007 EDIT -* 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. -*/ + * Copyright (C) 2007 EDIT + * 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. + */ package eu.etaxonomy.taxeditor.store; @@ -34,11 +34,11 @@ import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart; * @created Dec 8, 2010 * @version 1.0 */ -class CdmStoreConnector extends Job{ - private Display display; - private ICdmDataSource dataSource; +class CdmStoreConnector extends Job { + private final Display display; + private final ICdmDataSource dataSource; private DbSchemaValidation dbSchemaValidation; - private Resource applicationContextBean; + private final Resource applicationContextBean; /** * @param datasource @@ -55,66 +55,75 @@ class CdmStoreConnector extends Job{ this.applicationContextBean = applicationContextBean; } - + @Override public IStatus run(final IProgressMonitor monitor) { monitor.beginTask(getConnectionMessage(), 10); - + // check if database is up and running checkDatabaseReachable(monitor); - - if(! monitor.isCanceled()){ + + if (!monitor.isCanceled()) { // check if the datasource actually holds data checkIsNonEmptyCdmDatabase(monitor); } - - if(dbSchemaValidation != DbSchemaValidation.CREATE && ! monitor.isCanceled()){ - // if we do not create the datasource, we want to check if the datasource is compatible with this editor + + if (dbSchemaValidation != DbSchemaValidation.CREATE + && !monitor.isCanceled()) { + // if we do not create the datasource, we want to check if the + // datasource is compatible with this editor checkDbSchemaVersionCompatibility(monitor); } - + // we are done with our low level checking and will free resources now dataSource.closeOpenConnections(); - - if(! monitor.isCanceled()){ + + if (!monitor.isCanceled()) { CdmStore.close(monitor); } - + CdmApplicationController applicationController = null; - - if(! monitor.isCanceled()){ - CdmProgressMonitorAdapter subprogressMonitor = CdmProgressMonitorAdapter.CreateSubMonitor(monitor, 5); + + if (!monitor.isCanceled()) { + CdmProgressMonitorAdapter subprogressMonitor = CdmProgressMonitorAdapter + .CreateSubMonitor(monitor, IProgressMonitor.UNKNOWN); // This is where we instantiate the application controller - try{ - applicationController = CdmApplicationController.NewInstance(applicationContextBean, dataSource, dbSchemaValidation, false, subprogressMonitor); - }catch(Exception e){ + try { + applicationController = CdmApplicationController.NewInstance( + applicationContextBean, dataSource, dbSchemaValidation, + false, subprogressMonitor); + } catch (Exception e) { StoreUtil.error(this.getClass(), e.getMessage(), e); } } - + monitor.done(); - - if(! monitor.isCanceled()){ + + if (!monitor.isCanceled()) { CdmStore.setInstance(applicationController, dataSource); - - display.asyncExec(new Runnable(){ - /* (non-Javadoc) + + display.asyncExec(new Runnable() { + /* + * (non-Javadoc) + * * @see java.lang.Runnable#run() */ @Override public void run() { authenticate(); - + startContext(); } }); - - StoreUtil.info("Application context initialized."); + + StoreUtil.info("Application context initialized."); return Status.OK_STATUS; - }else{ + } else { // Show datasource view if not shown yet - display.asyncExec(new Runnable(){ - /* (non-Javadoc) + display.asyncExec(new Runnable() { + /* + * (non-Javadoc) + * * @see java.lang.Runnable#run() */ @Override @@ -124,86 +133,99 @@ class CdmStoreConnector extends Job{ }); return Status.CANCEL_STATUS; } - - + } - - private void authenticate(){ + + private void authenticate() { LoginDialog loginDialog = new LoginDialog(StoreUtil.getShell()); - loginDialog.open(); + loginDialog.open(); } - - private void startContext(){ + + private void startContext() { CdmStore.getContextManager().notifyContextStart(); } - + /** * @return */ private String getConnectionMessage() { String message = ""; - if(dataSource.getDatabaseType().equals(DatabaseTypeEnum.H2)){ + if (dataSource.getDatabaseType().equals(DatabaseTypeEnum.H2)) { message = " local CDM Store "; - }else{ + } else { message = " CDM Community Store "; } message += "'" + dataSource.getName() + "'"; - + message = "Connecting to" + message + "."; - + return message; } - + /** * @return - * @throws SQLException + * @throws SQLException */ private void checkDbSchemaVersionCompatibility(IProgressMonitor monitor) { monitor.subTask("Checking if datasource is compatible with this editor."); String dbSchemaVersion; boolean result = false; try { - dbSchemaVersion = (String) dataSource.getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery()); - // we assume that empty dbSchemaVersion means an empty database and skip version checking - result = dbSchemaVersion == null ? true : CdmMetaData.isDbSchemaVersionCompatible(dbSchemaVersion); + dbSchemaVersion = (String) dataSource + .getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION + .getSqlQuery()); + // we assume that empty dbSchemaVersion means an empty database and + // skip version checking + result = dbSchemaVersion == null ? true : CdmMetaData + .isDbSchemaVersionCompatible(dbSchemaVersion); monitor.worked(1); } catch (SQLException e) { // } - - if(!result){ + + if (!result) { // Show an error message - StoreUtil.errorDialog("DatabaseCompatibilityCheck failed", this, "The database schema for the chosen " + - "datasource '" + dataSource + "' \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.", null); - + StoreUtil + .errorDialog( + "DatabaseCompatibilityCheck failed", + this, + "The database schema for the chosen " + + "datasource '" + + dataSource + + "' \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.", + null); + monitor.setCanceled(true); - } - + } + } - + private void checkIsNonEmptyCdmDatabase(IProgressMonitor monitor) { monitor.subTask("Checking if datasource is a non empty CDM database."); - + try { - dataSource.getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION.getSqlQuery()); + dataSource.getSingleValue(MetaDataPropertyName.DB_SCHEMA_VERSION + .getSqlQuery()); } catch (SQLException e1) { dbSchemaValidation = DbSchemaValidation.CREATE; } } - - private void checkDatabaseReachable(IProgressMonitor monitor){ + + private void checkDatabaseReachable(IProgressMonitor monitor) { try { monitor.subTask("Checking if datasource is reachable."); dataSource.testConnection(); monitor.worked(1); } catch (ClassNotFoundException e) { - StoreUtil.errorDialog("Could not connect to chosen datasource", this, "Reason: " + e.getMessage(), e); + StoreUtil.errorDialog("Could not connect to chosen datasource", + this, "Reason: " + e.getMessage(), e); monitor.setCanceled(true); } catch (SQLException e) { - StoreUtil.errorDialog("Could not connect to chosen datasource", this, "Reason: " + e.getMessage(), e); + StoreUtil.errorDialog("Could not connect to chosen datasource", + this, "Reason: " + e.getMessage(), e); monitor.setCanceled(true); } - + } }