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
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="lib/cdm-server-3.5.2-SNAPSHOT.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/unitils-spring-3.4.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/unitils-core-3.4.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/unitils-database-3.4.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/unitils-dbmaintainer-3.4.2.jar"/>
- <classpathentry exported="true" kind="lib" path="lib/unitils-dbunit-3.4.2.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry exported="true" kind="lib" path="lib/xmlbeans-2.3.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/poi-ooxml-schemas-3.10-FINAL.jar"/>
<classpathentry exported="true" kind="lib" path="lib/swagger-annotations-1.3.5.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/cdm-server-3.5.2-SNAPSHOT.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
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,
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,
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,
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;
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,
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,
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,
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,
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
lib/poi-3.10-FINAL.jar,\\r
lib/poi-ooxml-3.10-FINAL.jar,\\r
lib/poi-ooxml-schemas-3.10-FINAL.jar,\\r
- lib/xmlbeans-2.3.0.jar,\
+ lib/xmlbeans-2.3.0.jar,\\r
lib/cdmlib-commons-3.5.2-SNAPSHOT-sources.jar,\\r
lib/cdmlib-commons-3.5.2-SNAPSHOT.jar,\\r
lib/cdmlib-ext-3.5.2-SNAPSHOT-sources.jar,\\r
lib/cdmlib-remote-3.5.2-SNAPSHOT.jar,\\r
lib/cdmlib-services-3.5.2-SNAPSHOT-sources.jar,\\r
lib/cdmlib-services-3.5.2-SNAPSHOT.jar,\\r
- lib/swagger-annotations-1.3.5.jar
+ lib/swagger-annotations-1.3.5.jar\r
\r
jars.compile.order = .\r
output.. = bin/\r
// $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.
*/
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;
* @version 1.0
*/
public class ContextManager implements IWorkbenchListener{
-
- private ListenerList contextListeners = new ListenerList();
+
+ private final ListenerList contextListeners = new ListenerList();
private IMemento memento;
-
+
/**
* <p>Constructor for ContextManager.</p>
*/
protected ContextManager() {
- PlatformUI.getWorkbench().addWorkbenchListener(this);
+ if(Workbench.getInstance() != null) {
+ PlatformUI.getWorkbench().addWorkbenchListener(this);
+ }
}
-
+
/**
* <p>addContextListener</p>
*
public void addContextListener(IContextListener listener){
contextListeners.add(listener);
}
-
+
/**
* <p>removeContextListener</p>
*
public void removeContextListener(IContextListener listener) {
contextListeners.remove(listener);
}
-
+
/**
* <p>notifyContextStart</p>
*/
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)
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);
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)
@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);
MessagingUtils.error(getClass(), e);
}
}
-
+
/**
* <p>notifyContextAboutToStop</p>
*
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();
}
-
+
/**
* <p>notifyContextStop</p>
*
* @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)
*/
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;
}
/** {@inheritDoc} */
@Override
public void postShutdown(IWorkbench workbench) {
-
-
+
+
}
-
-
+
+
private void readMemento(){
try {
memento = MementoHelper.readMementoFromFile(getStateFileForCurrentDatabase());
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.
} else {
MessagingUtils.info("Not storing state data, because no DataSource present.");
}
-
+
}
-
+
private boolean saveMemento(){
return MementoHelper.saveMementoToFile(memento, getStateFileForCurrentDatabase()) != null;
}
-
+
/**
* <p>getStateFileForCurrentDatabase</p>
*
if(CdmStore.getActiveCdmSource() == null){
return null;
}
-
+
IPath path = TaxeditorStorePlugin.getDefault().getStateLocation();
if (path == null) {
return null;
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry exported="true" kind="lib" path="lib/dbunit-2.4.9.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/unitils-core-3.4.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/unitils-database-3.4.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/unitils-dbmaintainer-3.4.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/unitils-dbunit-3.4.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/unitils-spring-3.4.2.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry including="**/*.java" kind="src" path="src/test/java"/>
- <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry excluding="**/*.java" kind="src" path="src/test/resources"/>
+ <classpathentry exported="true" kind="lib" path="lib/org.springframework.context-3.2.2.RELEASE.jar"/>
<classpathentry exported="true" kind="lib" path="lib/byte-buddy-0.5.1.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
-
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
-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/
<?xml version="1.0" encoding="UTF-8"?>\r
<project>\r
\r
- <parent>\r
- <groupId>eu.etaxonomy</groupId>\r
- <artifactId>taxeditor-parent</artifactId>\r
- <version>3.5.2-SNAPSHOT</version>\r
- </parent>\r
- <modelVersion>4.0.0</modelVersion>\r
- <artifactId>eu.etaxonomy.taxeditor.test</artifactId>\r
- <packaging>eclipse-test-plugin</packaging>\r
- <name>UI Test Bundle</name>\r
- <description>Holds all UI tests for the Taxonomic Editor</description>\r
-<!-- <build> -->\r
-<!-- <plugins> -->\r
-<!-- <plugin> -->\r
-<!-- <groupId>org.eclipse.tycho</groupId> -->\r
-<!-- <artifactId>tycho-maven-plugin</artifactId> -->\r
-<!-- <version>${tycho.version}</version> -->\r
-<!-- <extensions>true</extensions> -->\r
-<!-- </plugin> -->\r
-<!-- <plugin> -->\r
-<!-- <groupId>org.eclipse.tycho</groupId> -->\r
-<!-- <artifactId>target-platform-configuration</artifactId> -->\r
-<!-- <version>${tycho.version}</version> -->\r
-<!-- <configuration> -->\r
-<!-- <resolver>p2</resolver> -->\r
-<!-- </configuration> -->\r
-<!-- </plugin> -->\r
-<!-- <plugin> -->\r
-<!-- <groupId>org.eclipse.tycho</groupId> -->\r
-<!-- <artifactId>tycho-surefire-plugin</artifactId> -->\r
-<!-- <version>${tycho.version}</version> -->\r
-<!-- <configuration> -->\r
-<!-- <useUIHarness>true</useUIHarness> -->\r
-<!-- <useUIThread>false</useUIThread> -->\r
-<!-- <includes> -->\r
-<!-- <include>**/*Test.java</include> -->\r
-<!-- </includes> -->\r
-<!-- <product>eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product -->\r
-<!-- </product> -->\r
-<!-- <application>eu.etaxonomy.taxeditor.application.application -->\r
-<!-- </application> -->\r
-<!-- <dependency> <type>p2-installable-unit</type> <artifactId>eu.etaxonomy.taxeditor.product</artifactId> -->\r
-<!-- <version>0.0.0</version> </dependency> --> \r
-<!-- </configuration> -->\r
-<!-- </plugin> -->\r
-<!-- </plugins> -->\r
-<!-- </build> -->\r
- <dependencies>\r
- <dependency>\r
- <groupId>junit</groupId>\r
- <artifactId>junit</artifactId>\r
- <version>4.11</version>\r
- <scope>test</scope>\r
- </dependency>\r
- </dependencies>\r
+ <parent>\r
+ <groupId>eu.etaxonomy</groupId>\r
+ <artifactId>taxeditor-parent</artifactId>\r
+ <version>3.5.2-SNAPSHOT</version>\r
+ </parent>\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>eu.etaxonomy.taxeditor.test</artifactId>\r
+ <packaging>eclipse-test-plugin</packaging>\r
+ <name>UI Test Bundle</name>\r
+ <description>Holds all UI tests for the Taxonomic Editor</description>\r
+ <build>\r
+ <plugins>\r
+ <!-- <plugin> -->\r
+ <!-- <groupId>org.eclipse.tycho</groupId> -->\r
+ <!-- <artifactId>tycho-maven-plugin</artifactId> -->\r
+ <!-- <version>${tycho.version}</version> -->\r
+ <!-- <extensions>true</extensions> -->\r
+ <!-- </plugin> -->\r
+ <plugin>\r
+ <groupId>org.eclipse.tycho</groupId>\r
+ <artifactId>target-platform-configuration</artifactId>\r
+ <version>${tycho.version}</version>\r
+ <configuration>\r
+ <filters>\r
+ <!-- Work around for https://bugs.eclipse.org/bugs/show_bug.cgi?id=348045 -->\r
+ <!-- taken from https://wiki.eclipse.org/index.php?title=Tycho/Target_Platform#Filtering -->\r
+ <filter>\r
+ <type>p2-installable-unit</type>\r
+ <id>org.eclipse.equinox.servletbridge.extensionbundle</id>\r
+ <removeAll />\r
+ </filter>\r
+ </filters>\r
+ <!-- <dependency-resolution> -->\r
+ <!-- <extraRequirements> -->\r
+ <!-- product IU under test -->\r
+ <!-- <requirement> -->\r
+ <!-- <type>p2-installable-unit</type> -->\r
+ <!-- <id>eu.etaxonomy.taxeditor.product</id> -->\r
+ <!-- <versionRange>3.5.2.qualifier</versionRange> -->\r
+ <!-- </requirement> -->\r
+ <!-- </extraRequirements> -->\r
+ <!-- </dependency-resolution> -->\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.eclipse.tycho</groupId>\r
+ <artifactId>tycho-surefire-plugin</artifactId>\r
+ <version>${tycho.version}</version>\r
+ <configuration>\r
+ <!-- <testRuntime>p2-installed</testRuntime> -->\r
+ <!-- <useUIHarness>true</useUIHarness> -->\r
+ <!-- <providerHint>junit4</providerHint> -->\r
+ <dependencies>\r
+ <dependency>\r
+ <type>eclipse-feature</type>\r
+ <artifactId>eu.etaxonomy.taxeditor.feature</artifactId>\r
+ <!-- This is the minimum required version -->\r
+ <version>1.0.0</version>\r
+ </dependency>\r
+ </dependencies>\r
+\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
</project>
\ No newline at end of file
--- /dev/null
+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<String> getColumnNames(String tableName) {
+ return getSQLHandler().getItemsAsStringSet(
+ "select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '" + tableName
+ + "' AND TABLE_SCHEMA = '" + getSchemaName() + "'");
+ }
+
+ @Override
+ public Set<String> getTableNames() {
+ return getSQLHandler().getItemsAsStringSet(
+ "select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'TABLE' AND TABLE_SCHEMA = '"
+ + getSchemaName() + "'");
+ }
+
+ @Override
+ public Set<String> getViewNames() {
+ return getSQLHandler().getItemsAsStringSet(
+ "select TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '"
+ + getSchemaName() + "'");
+ }
+
+ @Override
+ public Set<String> getSequenceNames() {
+ return getSQLHandler().getItemsAsStringSet(
+ "select SEQUENCE_NAME from INFORMATION_SCHEMA.SEQUENCES where SEQUENCE_SCHEMA = '"
+ + getSchemaName() + "'");
+ }
+
+ @Override
+ public Set<String> 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<String> tableNames = getTableNames();
+ for (String tableName : tableNames) {
+ disableReferentialConstraints(tableName);
+ }
+ }
+
+ @Override
+ public void disableValueConstraints() {
+ Set<String> tableNames = getTableNames();
+ for (String tableName : tableNames) {
+ disableValueConstraints(tableName);
+ }
+ }
+
+ private void disableReferentialConstraints(String tableName) {
+ Set<String> constraintNames = this.getForeignKeyConstraintNames(tableName);
+ for (String constraintName : constraintNames) {
+ this.removeForeignKeyConstraint(tableName, constraintName);
+ }
+ }
+
+ private void disableValueConstraints(String tableName) {
+ Set<String> primaryKeyColumnNames = this.getPrimaryKeyColumnNames(tableName);
+
+ Set<String> 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.
+ * <p/>
+ * 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<String> getIdentityColumnNames(String tableName) {
+ return getPrimaryKeyColumnNames(tableName);
+ }
+
+ private Set<String> 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<String> 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<String> 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");
+ }
+}
-#\r
-# NOTE: this is the unitils.properties file for the cdmlib-persistence module\r
-# a separate unitils.properties exists for cdmlib-io and for cdmlib-services\r
-#\r
-#\r
-# the list of all properties is found in\r
-# http://unitils.org/unitils-default.properties\r
-#\r
-\r
-### Unitils Modules ###\r
-# List of modules that is loaded. Overloading this list is normally not useful, unless you want to add a custom\r
-# module. Disabling a module can be performed by setting unitils.module.<modulename>.enabled to false.\r
-# If a module's specific dependencies are not found (e.g. hibernate is not in you classpath), this module is not loaded,\r
-# even if it is in this list and the enabled property is set to true. It's therefore not strictly necessary to disable\r
-# any of these modules.\r
-#DEFAULT: unitils.modules=database,dbunit,hibernate,mock,easymock,inject,spring,jpa\r
-unitils.module.easymock.enabled=false\r
-unitils.module.mock.enabled=false\r
-\r
-\r
-### Database ###\r
-#\r
-# Name or path of the user specific properties file. This file should contain the necessary parameters to connect to the\r
-# developer's own unit test schema. It is recommended to override the name of this file in the project specific properties\r
-# file, to include the name of the project. The system will try to find this file in the classpath, the user home folder\r
-# (recommended) or the local filesystem.\r
-#\r
-unitils.configuration.localFileName=unitils-cdmlib-local.properties\r
-\r
-# H2 #\r
-#\r
-database.driverClassName=org.h2.Driver\r
-#database.url=jdbc:h2:file:./src/main/resources/h2/cdmTest;AUTO_SERVER=TRUE\r
-database.url=jdbc:h2:file:./target/classes/h2/cdmTest;AUTO_SERVER=TRUE\r
-database.dialect=h2\r
-database.userName=sa\r
-database.password=\r
-database.schemaNames=PUBLIC\r
-org.dbunit.dataset.datatype.IDataTypeFactory.implClassName.h2=org.dbunit.ext.h2.H2DataTypeFactory\r
-org.unitils.core.dbsupport.DbSupport.implClassName.h2=eu.etaxonomy.cdm.database.H2DbSupport\r
-database.storedIndentifierCase.h2=auto\r
-database.identifierQuoteString.h2=auto\r
-\r
-\r
-#### Transaction mode ###\r
-#\r
-# If set to commit or rollback, each test is run in a transaction,\r
-# which is committed or rolled back after the test is finished.\r
-# Since we have many tests with incomplete data these tests would be\r
-# failing during commit so it is better use rollback as default\r
-# and set commit for individual test where necessary\r
-DatabaseModule.Transactional.value.default=rollback\r
-\r
-# org.unitils.database.transaction.impl.DefaultUnitilsTransactionManager is used by default:\r
-#\r
-# Implements transactions for unit tests, by delegating to a spring PlatformTransactionManager.\r
-# The concrete implementation of PlatformTransactionManager that is used depends on the test class.\r
-# If a custom PlatformTransactionManager was configured in a spring ApplicationContext, this one is used.\r
-# If not, a suitable subclass of PlatformTransactionManager is created, depending on the configuration\r
-# of a test. E.g. if some ORM persistence unit was configured on the test, a PlatformTransactionManager\r
-# that can offer transactional behavior for such a persistence unit is used.\r
-# If no such configuration is found, a DataSourceTransactionManager is used.\r
-#\r
-# org.unitils.database.transaction.UnitilsTransactionManager.implClassName=org.unitils.database.transaction.impl.SpringTransactionManager\r
-\r
-### Hibernate ###\r
-#\r
-HibernateModule.configuration.implClassName=org.hibernate.cfg.Configuration\r
-\r
+#
+# 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.<modulename>.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
+
<name>EDIT Taxonomic Editor Product</name>
<description>The EDIT Taxonomic Desktop Editor</description>
<url>http://wp5.e-taxonomy.eu/taxeditor</url>
- <properties>
+ <properties>
<product.id>eu.etaxonomy.taxeditor.product</product.id>
</properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.eclipse.tycho</groupId>
- <artifactId>tycho-p2-director-plugin</artifactId>
- <version>${tycho.version}</version>
- <executions>
- <execution>
- <id>materialize-products</id>
- <goals>
- <goal>materialize-products</goal>
- </goals>
- </execution>
- <execution>
- <id>archive-products</id>
- <goals>
- <goal>archive-products</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <products>
- <product>
- <id>${product.id}</id>
- <rootFolder>EDIT Taxonomic Editor</rootFolder>
- </product>
- </products>
- </configuration>
- </plugin>
- </plugins>
- </build>
+
<profiles>
+ <profile>
+ <id>buildProducts</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-director-plugin</artifactId>
+ <version>${tycho.version}</version>
+ <executions>
+ <execution>
+ <id>materialize-products</id>
+ <goals>
+ <goal>materialize-products</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>archive-products</id>
+ <goals>
+ <goal>archive-products</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <products>
+ <product>
+ <id>${product.id}</id>
+ <rootFolder>EDIT Taxonomic Editor</rootFolder>
+ </product>
+ </products>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>signJars</id>
<build>
<tycho.version>0.22.0</tycho.version>
<taxeditor.version>3.5.2-SNAPSHOT</taxeditor.version>
<update.dir>snapshot</update.dir>
+ <unitils.version>3.4.2</unitils.version>
</properties>
<modules>
<module>eu.etaxonomy.taxeditor.cdmlib</module>