From: Cherian Mathew Date: Wed, 3 Jun 2015 11:56:16 +0000 (+0200) Subject: eu.etaxonomy.taxeditor.cdmlib/.classpath, eu.etaxonomy.taxeditor.cdmlib/META-INF... X-Git-Tag: remoting-3.9.0~173 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/93b0eb6b9106c8f08e3ef503022ed3bd9e01d329 eu.etaxonomy.taxeditor.cdmlib/.classpath, eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF, eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF : moved test jars to test project eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF : added packages required by test project to exported package list ContextManager.java : adding check to make sure the workbench is created before initialisation eu.etaxonomy.taxeditor.test/.classpath : moved resource from src/main/resources to src/test/resourcesto be maven comliant eu.etaxonomy.taxeditor.test/pom.xml : added tycho-surefire-plugin config to run tests TaxonNameEditorTest : removed logger setting BaseRemotingTest : removed unused call to disk cache CdmPersistentRemoteSourceTest, AbstractLazyInitializerTest, RemoteLazyLoadingTest : changed assert calls to be compatible with junit 4.8.2 OperationTestBase, BaseRemotingTest : changed to abstract to not be included in test run eu.etaxonomy.taxeditor/pom.xml : made the building of products as optional (separate profile) pom.xml : added unitils version property eu.etaxonomy.taxeditor.test/lib : added test dependency jars --- diff --git a/eu.etaxonomy.taxeditor.cdmlib/.classpath b/eu.etaxonomy.taxeditor.cdmlib/.classpath index 433df8079..59e3bedb4 100644 --- a/eu.etaxonomy.taxeditor.cdmlib/.classpath +++ b/eu.etaxonomy.taxeditor.cdmlib/.classpath @@ -1,11 +1,5 @@ - - - - - - @@ -210,5 +204,6 @@ + diff --git a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF index 4c4c417d4..9409f9883 100644 --- a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF +++ b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Eclipse-BundleShape: dir Export-Package: com.google.api, com.google.api.detect, com.google.api.translate, + eu.etaxonomy.cdm, eu.etaxonomy.cdm.api.application, eu.etaxonomy.cdm.api.cache, eu.etaxonomy.cdm.api.conversation, @@ -191,6 +192,7 @@ Export-Package: com.google.api, eu.etaxonomy.taxeditor.remoting.cache, eu.etaxonomy.taxeditor.remoting.server, eu.etaxonomy.taxeditor.remoting.source, + eu.etaxonomy.taxeditor.service, eu.etaxonomy.taxeditor.session, eu.etaxonomy.taxeditor.session.mock, javassist.util.proxy, @@ -201,9 +203,13 @@ Export-Package: com.google.api, net.sf.ehcache.statistics, net.sf.ehcache.store, net.sf.json;uses:="net.sf.json.processors,net.sf.json.util,org.apache.commons.lang.exception", + org.aopalliance.aop, org.apache.commons.collections;uses:="org.apache.commons.collections.keyvalue,new org.apache.commons.collections", + org.apache.commons.dbcp, org.apache.commons.io;uses:="org.apache.commons.io.filefilter", org.apache.commons.lang;uses:="org.apache.commons.lang.exception", + org.apache.commons.lang.text, + org.apache.commons.logging, org.apache.fop.apps, org.apache.http, org.apache.http.client, @@ -335,6 +341,9 @@ Export-Package: com.google.api, org.odftoolkit.odfdom.dom.element, org.odftoolkit.odfdom.dom.element.style, org.odftoolkit.odfdom.dom.style, + org.slf4j, + org.springframework.aop, + org.springframework.aop.framework, org.springframework.beans, org.springframework.beans.factory, org.springframework.beans.factory.annotation; @@ -356,6 +365,7 @@ Export-Package: com.google.api, org.springframework.core.io.support, org.springframework.beans.factory.config, org.springframework.beans.factory", + org.springframework.context.config, org.springframework.context.event; uses:="org.springframework.core, org.aopalliance.intercept, @@ -367,6 +377,7 @@ Export-Package: com.google.api, org.springframework.core.io;uses:="org.jboss.virtual", org.springframework.core.io.support, org.springframework.core.type.classreading, + org.springframework.jdbc.datasource, org.springframework.orm.hibernate3; uses:="org.apache.commons.logging, org.aopalliance.intercept, @@ -398,7 +409,10 @@ Export-Package: com.google.api, org.springframework.remoting.support, org.springframework.security.access, org.springframework.security.authentication, + org.springframework.security.authentication.dao, + org.springframework.security.authentication.encoding, org.springframework.security.authentication.event, + org.springframework.security.config, org.springframework.security.core, org.springframework.security.core.context, org.springframework.security.core.userdetails, @@ -448,13 +462,7 @@ Export-Package: com.google.api, org.springframework.context.event, javax.servlet, org.springframework.ui, - javax.servlet.http", - org.unitils, - org.unitils.database, - org.unitils.database.annotations, - org.unitils.database.util, - org.unitils.dbunit.annotation, - org.unitils.spring.annotation + javax.servlet.http" Bundle-Vendor: EDIT Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.eclipse.osgi, @@ -661,10 +669,5 @@ Bundle-ClassPath: ., lib/xmlbeans-2.3.0.jar, lib/poi-ooxml-schemas-3.10-FINAL.jar, lib/swagger-annotations-1.3.5.jar, - lib/unitils-core-3.4.2.jar, - lib/unitils-database-3.4.2.jar, - lib/unitils-dbmaintainer-3.4.2.jar, - lib/unitils-dbunit-3.4.2.jar, - lib/unitils-spring-3.4.2.jar, lib/cdm-server-3.5.2-SNAPSHOT.jar Import-Package: org.apache.commons.httpclient.methods diff --git a/eu.etaxonomy.taxeditor.cdmlib/build.properties b/eu.etaxonomy.taxeditor.cdmlib/build.properties index 1cad966b4..e5a0e4b4c 100644 --- a/eu.etaxonomy.taxeditor.cdmlib/build.properties +++ b/eu.etaxonomy.taxeditor.cdmlib/build.properties @@ -183,7 +183,7 @@ bin.includes = META-INF/,\ lib/poi-3.10-FINAL.jar,\ lib/poi-ooxml-3.10-FINAL.jar,\ lib/poi-ooxml-schemas-3.10-FINAL.jar,\ - lib/xmlbeans-2.3.0.jar,\ + lib/xmlbeans-2.3.0.jar,\ lib/cdmlib-commons-3.5.2-SNAPSHOT-sources.jar,\ lib/cdmlib-commons-3.5.2-SNAPSHOT.jar,\ lib/cdmlib-ext-3.5.2-SNAPSHOT-sources.jar,\ @@ -200,7 +200,7 @@ bin.includes = META-INF/,\ lib/cdmlib-remote-3.5.2-SNAPSHOT.jar,\ lib/cdmlib-services-3.5.2-SNAPSHOT-sources.jar,\ lib/cdmlib-services-3.5.2-SNAPSHOT.jar,\ - lib/swagger-annotations-1.3.5.jar + lib/swagger-annotations-1.3.5.jar jars.compile.order = . output.. = bin/ diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/ContextManager.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/ContextManager.java index d7ca5a0d0..3e9c8460f 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/ContextManager.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/ContextManager.java @@ -1,9 +1,9 @@ // $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. */ @@ -24,6 +24,7 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchListener; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.XMLMemento; +import org.eclipse.ui.internal.Workbench; import eu.etaxonomy.taxeditor.model.IContextListener; import eu.etaxonomy.taxeditor.model.MementoHelper; @@ -38,18 +39,20 @@ import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; * @version 1.0 */ public class ContextManager implements IWorkbenchListener{ - - private ListenerList contextListeners = new ListenerList(); + + private final ListenerList contextListeners = new ListenerList(); private IMemento memento; - + /** *

Constructor for ContextManager.

*/ protected ContextManager() { - PlatformUI.getWorkbench().addWorkbenchListener(this); + if(Workbench.getInstance() != null) { + PlatformUI.getWorkbench().addWorkbenchListener(this); + } } - + /** *

addContextListener

* @@ -58,7 +61,7 @@ public class ContextManager implements IWorkbenchListener{ public void addContextListener(IContextListener listener){ contextListeners.add(listener); } - + /** *

removeContextListener

* @@ -67,14 +70,14 @@ public class ContextManager implements IWorkbenchListener{ public void removeContextListener(IContextListener listener) { contextListeners.remove(listener); } - + /** *

notifyContextStart

*/ public void notifyContextStart() { MessagingUtils.info("Notifying context listeners, that the context has started."); ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell()); - + try { dialog.run(false, false, new IRunnableWithProgress() { /* (non-Javadoc) @@ -84,10 +87,10 @@ public class ContextManager implements IWorkbenchListener{ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Starting context", contextListeners.size()); - - - readMemento(); - + + + readMemento(); + for(final Object listener : contextListeners.getListeners()){ ((IContextListener) listener).contextStart(memento, monitor); monitor.worked(1); @@ -101,15 +104,15 @@ public class ContextManager implements IWorkbenchListener{ MessagingUtils.error(getClass(), e); } } - + /** - * + * */ public void notifyContextRefresh() { MessagingUtils.info("Notifying context listeners, that the context needs to be refreshed."); ProgressMonitorDialog dialog = new ProgressMonitorDialog(StoreUtil.getShell()); - + try { dialog.run(false, false, new IRunnableWithProgress() { /* (non-Javadoc) @@ -118,8 +121,8 @@ public class ContextManager implements IWorkbenchListener{ @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - monitor.beginTask("Refreshing context", contextListeners.size()); - + monitor.beginTask("Refreshing context", contextListeners.size()); + for(final Object listener : contextListeners.getListeners()){ ((IContextListener) listener).contextRefresh(monitor); monitor.worked(1); @@ -133,7 +136,7 @@ public class ContextManager implements IWorkbenchListener{ MessagingUtils.error(getClass(), e); } } - + /** *

notifyContextAboutToStop

* @@ -146,36 +149,36 @@ public class ContextManager implements IWorkbenchListener{ subMonitor.beginTask("Stoping context", contextListeners.size()); // we are creating the memento here; even if the context is not stopped createMemento(); - + for(final Object listener : contextListeners.getListeners()){ ((IContextListener) listener).contextAboutToStop(memento, subMonitor); subMonitor.worked(1); - } - + } + subMonitor.done(); } - + /** *

notifyContextStop

* * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object. */ public void notifyContextStop(IProgressMonitor monitor) { - + IProgressMonitor subMonitor = StoreUtil.getSubProgressMonitor(monitor, 1); subMonitor.beginTask("Stoping context", contextListeners.size()); MessagingUtils.info("Notifying context listeners, that the context has stopped."); - + for(Object listener : contextListeners.getListeners()){ ((IContextListener) listener).contextStop(memento, subMonitor); subMonitor.worked(1); - } + } saveMemento(); subMonitor.done(); } - + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchListener#preShutdown(org.eclipse.ui.IWorkbench, boolean) */ @@ -184,15 +187,15 @@ public class ContextManager implements IWorkbenchListener{ public boolean preShutdown(IWorkbench workbench, boolean forced) { createMemento(); - + IProgressMonitor monitor = null; - + for(Object listener : contextListeners.getListeners()){ ((IContextListener) listener).workbenchShutdown(memento, monitor); - } - + } + saveMemento(); - + // return true in any case, otherwise the application will not stop return true; } @@ -203,11 +206,11 @@ public class ContextManager implements IWorkbenchListener{ /** {@inheritDoc} */ @Override public void postShutdown(IWorkbench workbench) { - - + + } - - + + private void readMemento(){ try { memento = MementoHelper.readMementoFromFile(getStateFileForCurrentDatabase()); @@ -216,17 +219,17 @@ public class ContextManager implements IWorkbenchListener{ MessagingUtils.info("No state file for datasource"); } } - + private void createMemento(){ - + if (CdmStore.getActiveCdmSource() != null) { - + try { String name = CdmStore.getActiveCdmSource().getName(); name = name.trim(); name = name.replace(" ", "_"); memento = XMLMemento.createWriteRoot(name); - + MessagingUtils.info("DataSource found. Memento created."); } catch (Exception e) { // The memento could not be created, but a not closable editor is avoided for this case. @@ -235,13 +238,13 @@ public class ContextManager implements IWorkbenchListener{ } else { MessagingUtils.info("Not storing state data, because no DataSource present."); } - + } - + private boolean saveMemento(){ return MementoHelper.saveMementoToFile(memento, getStateFileForCurrentDatabase()) != null; } - + /** *

getStateFileForCurrentDatabase

* @@ -251,7 +254,7 @@ public class ContextManager implements IWorkbenchListener{ if(CdmStore.getActiveCdmSource() == null){ return null; } - + IPath path = TaxeditorStorePlugin.getDefault().getStateLocation(); if (path == null) { return null; diff --git a/eu.etaxonomy.taxeditor.test/.classpath b/eu.etaxonomy.taxeditor.test/.classpath index 3f3206ecc..c4629743d 100644 --- a/eu.etaxonomy.taxeditor.test/.classpath +++ b/eu.etaxonomy.taxeditor.test/.classpath @@ -1,10 +1,16 @@ + + + + + + - + + - diff --git a/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF index 5078e840d..2b3022603 100644 --- a/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF +++ b/eu.etaxonomy.taxeditor.test/META-INF/MANIFEST.MF @@ -6,20 +6,25 @@ Bundle-Version: 3.5.2.qualifier Bundle-ActivationPolicy: lazy Bundle-Vendor: EDIT Bundle-RequiredExecutionEnvironment: JavaSE-1.6 -Require-Bundle: org.apache.log4j, - org.eclipse.ui, +Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.swtbot.eclipse.core, - org.eclipse.swtbot.eclipse.finder, org.eclipse.ui.ide, - eu.etaxonomy.taxeditor.bulkeditor, + org.junit;bundle-version="4.8.2", eu.etaxonomy.taxeditor.cdmlib, + eu.etaxonomy.taxeditor.bulkeditor, eu.etaxonomy.taxeditor.editor, eu.etaxonomy.taxeditor.help, eu.etaxonomy.taxeditor.navigation, eu.etaxonomy.taxeditor.printpublisher, - eu.etaxonomy.taxeditor.store + eu.etaxonomy.taxeditor.store, + org.apache.log4j Eclipse-RegisterBuddy: org.apache.log4j Bundle-ClassPath: ., - lib/byte-buddy-0.5.1.jar -Import-Package: org.apache.http.impl.client + lib/byte-buddy-0.5.1.jar, + lib/org.springframework.context-3.2.2.RELEASE.jar, + lib/unitils-core-3.4.2.jar, + lib/unitils-database-3.4.2.jar, + lib/unitils-dbmaintainer-3.4.2.jar, + lib/unitils-dbunit-3.4.2.jar, + lib/unitils-spring-3.4.2.jar, + lib/dbunit-2.4.9.jar diff --git a/eu.etaxonomy.taxeditor.test/build.properties b/eu.etaxonomy.taxeditor.test/build.properties index 95673643b..0e7e33b0f 100644 --- a/eu.etaxonomy.taxeditor.test/build.properties +++ b/eu.etaxonomy.taxeditor.test/build.properties @@ -1,4 +1,14 @@ -source.. = src/test/java/ +source.. = src/test/java/,\ + src/test/resources/ bin.includes = META-INF/,\ .,\ - lib/byte-buddy-0.5.1.jar + lib/byte-buddy-0.5.1.jar,\ + src/,\ + lib/org.springframework.context-3.2.2.RELEASE.jar,\ + lib/unitils-core-3.4.2.jar,\ + lib/unitils-database-3.4.2.jar,\ + lib/unitils-dbmaintainer-3.4.2.jar,\ + lib/unitils-dbunit-3.4.2.jar,\ + lib/unitils-spring-3.4.2.jar,\ + lib/dbunit-2.4.9.jar +output.. = bin/ diff --git a/eu.etaxonomy.taxeditor.test/lib/dbunit-2.4.9.jar b/eu.etaxonomy.taxeditor.test/lib/dbunit-2.4.9.jar new file mode 100644 index 000000000..130921b78 Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/dbunit-2.4.9.jar differ diff --git a/eu.etaxonomy.taxeditor.test/lib/org.springframework.context-3.2.2.RELEASE.jar b/eu.etaxonomy.taxeditor.test/lib/org.springframework.context-3.2.2.RELEASE.jar new file mode 100644 index 000000000..e285a2104 Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/org.springframework.context-3.2.2.RELEASE.jar differ diff --git a/eu.etaxonomy.taxeditor.test/lib/unitils-core-3.4.2.jar b/eu.etaxonomy.taxeditor.test/lib/unitils-core-3.4.2.jar new file mode 100644 index 000000000..ab4c22e78 Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/unitils-core-3.4.2.jar differ diff --git a/eu.etaxonomy.taxeditor.test/lib/unitils-database-3.4.2.jar b/eu.etaxonomy.taxeditor.test/lib/unitils-database-3.4.2.jar new file mode 100644 index 000000000..dfcb6ae7c Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/unitils-database-3.4.2.jar differ diff --git a/eu.etaxonomy.taxeditor.test/lib/unitils-dbmaintainer-3.4.2.jar b/eu.etaxonomy.taxeditor.test/lib/unitils-dbmaintainer-3.4.2.jar new file mode 100644 index 000000000..01f8994f6 Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/unitils-dbmaintainer-3.4.2.jar differ diff --git a/eu.etaxonomy.taxeditor.test/lib/unitils-dbunit-3.4.2.jar b/eu.etaxonomy.taxeditor.test/lib/unitils-dbunit-3.4.2.jar new file mode 100644 index 000000000..778274e8d Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/unitils-dbunit-3.4.2.jar differ diff --git a/eu.etaxonomy.taxeditor.test/lib/unitils-spring-3.4.2.jar b/eu.etaxonomy.taxeditor.test/lib/unitils-spring-3.4.2.jar new file mode 100644 index 000000000..f30810b72 Binary files /dev/null and b/eu.etaxonomy.taxeditor.test/lib/unitils-spring-3.4.2.jar differ diff --git a/eu.etaxonomy.taxeditor.test/pom.xml b/eu.etaxonomy.taxeditor.test/pom.xml index 835df5791..b87c33a93 100644 --- a/eu.etaxonomy.taxeditor.test/pom.xml +++ b/eu.etaxonomy.taxeditor.test/pom.xml @@ -1,58 +1,69 @@ - - eu.etaxonomy - taxeditor-parent - 3.5.2-SNAPSHOT - - 4.0.0 - eu.etaxonomy.taxeditor.test - eclipse-test-plugin - UI Test Bundle - Holds all UI tests for the Taxonomic Editor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - junit - junit - 4.11 - test - - + + eu.etaxonomy + taxeditor-parent + 3.5.2-SNAPSHOT + + 4.0.0 + eu.etaxonomy.taxeditor.test + eclipse-test-plugin + UI Test Bundle + Holds all UI tests for the Taxonomic Editor + + + + + + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho.version} + + + + + + p2-installable-unit + org.eclipse.equinox.servletbridge.extensionbundle + + + + + + + + + + + + + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho.version} + + + + + + + eclipse-feature + eu.etaxonomy.taxeditor.feature + + 1.0.0 + + + + + + + \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/util/H2DbSupport.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/util/H2DbSupport.java new file mode 100644 index 000000000..2dddbf52e --- /dev/null +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/util/H2DbSupport.java @@ -0,0 +1,166 @@ +package eu.etaxonomy.taxeditor.util; + +/** + * based on from http://code.google.com/p/java-tester/source/browse/trunk/src/main/java/org/jtester/unitils/database/H2DbSupport.java + */ + + +import java.util.Set; + +import org.unitils.core.dbsupport.DbSupport; + +public class H2DbSupport extends DbSupport { + /** + * Creates support for HsqlDb databases. + */ + public H2DbSupport() { + super("h2"); + } + + @Override + public Set getColumnNames(String tableName) { + return getSQLHandler().getItemsAsStringSet( + "select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" + tableName + + "' AND TABLE_SCHEMA = '" + getSchemaName() + "'"); + } + + @Override + public Set getTableNames() { + return getSQLHandler().getItemsAsStringSet( + "select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'TABLE' AND TABLE_SCHEMA = '" + + getSchemaName() + "'"); + } + + @Override + public Set getViewNames() { + return getSQLHandler().getItemsAsStringSet( + "select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '" + + getSchemaName() + "'"); + } + + @Override + public Set getSequenceNames() { + return getSQLHandler().getItemsAsStringSet( + "select SEQUENCE_NAME from INFORMATION_SCHEMA.SEQUENCES where SEQUENCE_SCHEMA = '" + + getSchemaName() + "'"); + } + + @Override + public Set getTriggerNames() { + return getSQLHandler().getItemsAsStringSet( + "select TRIGGER_NAME from INFORMATION_SCHEMA.TRIGGERS where TRIGGER_SCHEMA = '" + getSchemaName() + + "'"); + } + + @Override + public long getSequenceValue(String sequenceName) { + return getSQLHandler().getItemAsLong( + "select CURRENT_VALUE from INFORMATION_SCHEMA.SEQUENCES where SEQUENCE_SCHEMA = '" + + getSchemaName() + "' and SEQUENCE_NAME = '" + sequenceName + "'"); + } + + @Override + public boolean supportsSequences() { + return true; + } + + @Override + public boolean supportsTriggers() { + return true; + } + + @Override + public boolean supportsIdentityColumns() { + return true; + } + + @Override + public void incrementSequenceToValue(String sequenceName, long newSequenceValue) { + getSQLHandler().executeUpdate( + "alter sequence " + qualified(sequenceName) + " restart with " + newSequenceValue); + } + + @Override + public void incrementIdentityColumnToValue(String tableName, String identityColumnName, long identityValue) { + getSQLHandler().executeUpdate( + "alter table " + qualified(tableName) + " alter column " + quoted(identityColumnName) + + " RESTART WITH " + identityValue); + } + + @Override + public void disableReferentialConstraints() { + Set tableNames = getTableNames(); + for (String tableName : tableNames) { + disableReferentialConstraints(tableName); + } + } + + @Override + public void disableValueConstraints() { + Set tableNames = getTableNames(); + for (String tableName : tableNames) { + disableValueConstraints(tableName); + } + } + + private void disableReferentialConstraints(String tableName) { + Set constraintNames = this.getForeignKeyConstraintNames(tableName); + for (String constraintName : constraintNames) { + this.removeForeignKeyConstraint(tableName, constraintName); + } + } + + private void disableValueConstraints(String tableName) { + Set primaryKeyColumnNames = this.getPrimaryKeyColumnNames(tableName); + + Set notNullColumnNames = this.getNotNullColummnNames(tableName); + for (String notNullColumnName : notNullColumnNames) { + if (primaryKeyColumnNames.contains(notNullColumnName)) { + continue; + } + this.removeNotNullConstraint(tableName, notNullColumnName); + } + } + + /** + * Gets the names of all identity columns of the given table. + *

+ * todo check, at this moment the PK columns are returned + * + * @param tableName The table, not null + * @return The names of the identity columns of the table with the given name + */ + @Override + public Set getIdentityColumnNames(String tableName) { + return getPrimaryKeyColumnNames(tableName); + } + + private Set getPrimaryKeyColumnNames(String tableName) { + return getSQLHandler().getItemsAsStringSet( + "select COLUMN_NAME from INFORMATION_SCHEMA.INDEXES where PRIMARY_KEY=TRUE AND TABLE_NAME = '" + + tableName + "' AND TABLE_SCHEMA = '" + getSchemaName() + "'"); + } + + private Set getNotNullColummnNames(String tableName) { + return getSQLHandler().getItemsAsStringSet( + "select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where IS_NULLABLE = 'NO' AND TABLE_NAME = '" + + tableName + "' AND TABLE_SCHEMA = '" + getSchemaName() + "'"); + } + + private Set getForeignKeyConstraintNames(String tableName) { + return getSQLHandler().getItemsAsStringSet( + "select CONSTRAINT_NAME from INFORMATION_SCHEMA.CONSTRAINTS " + + "where CONSTRAINT_TYPE = 'REFERENTIAL' AND TABLE_NAME = '" + tableName + + "' AND CONSTRAINT_SCHEMA = '" + getSchemaName() + "'"); + } + + private void removeForeignKeyConstraint(String tableName, String constraintName) { + getSQLHandler().executeUpdate( + "alter table " + qualified(tableName) + " drop constraint " + quoted(constraintName)); + } + + private void removeNotNullConstraint(String tableName, String columnName) { + getSQLHandler().executeUpdate( + "alter table " + qualified(tableName) + " alter column " + quoted(columnName) + " set null"); + } +} diff --git a/eu.etaxonomy.taxeditor.test/src/test/resources/unitils.properties b/eu.etaxonomy.taxeditor.test/src/test/resources/unitils.properties index 47c604db9..daea61b65 100644 --- a/eu.etaxonomy.taxeditor.test/src/test/resources/unitils.properties +++ b/eu.etaxonomy.taxeditor.test/src/test/resources/unitils.properties @@ -1,69 +1,69 @@ -# -# NOTE: this is the unitils.properties file for the cdmlib-persistence module -# a separate unitils.properties exists for cdmlib-io and for cdmlib-services -# -# -# the list of all properties is found in -# http://unitils.org/unitils-default.properties -# - -### Unitils Modules ### -# List of modules that is loaded. Overloading this list is normally not useful, unless you want to add a custom -# module. Disabling a module can be performed by setting unitils.module..enabled to false. -# If a module's specific dependencies are not found (e.g. hibernate is not in you classpath), this module is not loaded, -# even if it is in this list and the enabled property is set to true. It's therefore not strictly necessary to disable -# any of these modules. -#DEFAULT: unitils.modules=database,dbunit,hibernate,mock,easymock,inject,spring,jpa -unitils.module.easymock.enabled=false -unitils.module.mock.enabled=false - - -### Database ### -# -# Name or path of the user specific properties file. This file should contain the necessary parameters to connect to the -# developer's own unit test schema. It is recommended to override the name of this file in the project specific properties -# file, to include the name of the project. The system will try to find this file in the classpath, the user home folder -# (recommended) or the local filesystem. -# -unitils.configuration.localFileName=unitils-cdmlib-local.properties - -# H2 # -# -database.driverClassName=org.h2.Driver -#database.url=jdbc:h2:file:./src/main/resources/h2/cdmTest;AUTO_SERVER=TRUE -database.url=jdbc:h2:file:./target/classes/h2/cdmTest;AUTO_SERVER=TRUE -database.dialect=h2 -database.userName=sa -database.password= -database.schemaNames=PUBLIC -org.dbunit.dataset.datatype.IDataTypeFactory.implClassName.h2=org.dbunit.ext.h2.H2DataTypeFactory -org.unitils.core.dbsupport.DbSupport.implClassName.h2=eu.etaxonomy.cdm.database.H2DbSupport -database.storedIndentifierCase.h2=auto -database.identifierQuoteString.h2=auto - - -#### Transaction mode ### -# -# If set to commit or rollback, each test is run in a transaction, -# which is committed or rolled back after the test is finished. -# Since we have many tests with incomplete data these tests would be -# failing during commit so it is better use rollback as default -# and set commit for individual test where necessary -DatabaseModule.Transactional.value.default=rollback - -# org.unitils.database.transaction.impl.DefaultUnitilsTransactionManager is used by default: -# -# Implements transactions for unit tests, by delegating to a spring PlatformTransactionManager. -# The concrete implementation of PlatformTransactionManager that is used depends on the test class. -# If a custom PlatformTransactionManager was configured in a spring ApplicationContext, this one is used. -# If not, a suitable subclass of PlatformTransactionManager is created, depending on the configuration -# of a test. E.g. if some ORM persistence unit was configured on the test, a PlatformTransactionManager -# that can offer transactional behavior for such a persistence unit is used. -# If no such configuration is found, a DataSourceTransactionManager is used. -# -# org.unitils.database.transaction.UnitilsTransactionManager.implClassName=org.unitils.database.transaction.impl.SpringTransactionManager - -### Hibernate ### -# -HibernateModule.configuration.implClassName=org.hibernate.cfg.Configuration - +# +# NOTE: this is the unitils.properties file for the cdmlib-persistence module +# a separate unitils.properties exists for cdmlib-io and for cdmlib-services +# +# +# the list of all properties is found in +# http://unitils.org/unitils-default.properties +# + +### Unitils Modules ### +# List of modules that is loaded. Overloading this list is normally not useful, unless you want to add a custom +# module. Disabling a module can be performed by setting unitils.module..enabled to false. +# If a module's specific dependencies are not found (e.g. hibernate is not in you classpath), this module is not loaded, +# even if it is in this list and the enabled property is set to true. It's therefore not strictly necessary to disable +# any of these modules. +#DEFAULT: unitils.modules=database,dbunit,hibernate,mock,easymock,inject,spring,jpa +unitils.module.easymock.enabled=false +unitils.module.mock.enabled=false + + +### Database ### +# +# Name or path of the user specific properties file. This file should contain the necessary parameters to connect to the +# developer's own unit test schema. It is recommended to override the name of this file in the project specific properties +# file, to include the name of the project. The system will try to find this file in the classpath, the user home folder +# (recommended) or the local filesystem. +# +unitils.configuration.localFileName=unitils-cdmlib-local.properties + +# H2 # +# +database.driverClassName=org.h2.Driver +#database.url=jdbc:h2:file:./src/main/resources/h2/cdmTest;AUTO_SERVER=TRUE +database.url=jdbc:h2:file:./target/classes/h2/cdmTest;AUTO_SERVER=TRUE +database.dialect=h2 +database.userName=sa +database.password= +database.schemaNames=PUBLIC +org.dbunit.dataset.datatype.IDataTypeFactory.implClassName.h2=org.dbunit.ext.h2.H2DataTypeFactory +org.unitils.core.dbsupport.DbSupport.implClassName.h2=eu.etaxonomy.taxeditor.util.H2DbSupport +database.storedIndentifierCase.h2=auto +database.identifierQuoteString.h2=auto + + +#### Transaction mode ### +# +# If set to commit or rollback, each test is run in a transaction, +# which is committed or rolled back after the test is finished. +# Since we have many tests with incomplete data these tests would be +# failing during commit so it is better use rollback as default +# and set commit for individual test where necessary +DatabaseModule.Transactional.value.default=rollback + +# org.unitils.database.transaction.impl.DefaultUnitilsTransactionManager is used by default: +# +# Implements transactions for unit tests, by delegating to a spring PlatformTransactionManager. +# The concrete implementation of PlatformTransactionManager that is used depends on the test class. +# If a custom PlatformTransactionManager was configured in a spring ApplicationContext, this one is used. +# If not, a suitable subclass of PlatformTransactionManager is created, depending on the configuration +# of a test. E.g. if some ORM persistence unit was configured on the test, a PlatformTransactionManager +# that can offer transactional behavior for such a persistence unit is used. +# If no such configuration is found, a DataSourceTransactionManager is used. +# +# org.unitils.database.transaction.UnitilsTransactionManager.implClassName=org.unitils.database.transaction.impl.SpringTransactionManager + +### Hibernate ### +# +HibernateModule.configuration.implClassName=org.hibernate.cfg.Configuration + diff --git a/eu.etaxonomy.taxeditor/pom.xml b/eu.etaxonomy.taxeditor/pom.xml index 62fcda0de..37a197abd 100644 --- a/eu.etaxonomy.taxeditor/pom.xml +++ b/eu.etaxonomy.taxeditor/pom.xml @@ -13,41 +13,45 @@ EDIT Taxonomic Editor Product The EDIT Taxonomic Desktop Editor http://wp5.e-taxonomy.eu/taxeditor - + eu.etaxonomy.taxeditor.product - - - - org.eclipse.tycho - tycho-p2-director-plugin - ${tycho.version} - - - materialize-products - - materialize-products - - - - archive-products - - archive-products - - - - - - - ${product.id} - EDIT Taxonomic Editor - - - - - - + + + buildProducts + + + + org.eclipse.tycho + tycho-p2-director-plugin + ${tycho.version} + + + materialize-products + + materialize-products + + + + archive-products + + archive-products + + + + + + + ${product.id} + EDIT Taxonomic Editor + + + + + + + signJars diff --git a/pom.xml b/pom.xml index 013d4a79e..1667aea57 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,7 @@ 0.22.0 3.5.2-SNAPSHOT snapshot + 3.4.2 eu.etaxonomy.taxeditor.cdmlib