fix #5341 and fixing deletion of specimen
authorKatja Luther <k.luther@bgbm.org>
Thu, 5 Nov 2015 11:09:23 +0000 (12:09 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 5 Nov 2015 11:09:58 +0000 (12:09 +0100)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/FeatureNode.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/FeatureNodeServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/FeatureTreeServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IFeatureNodeService.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/TaxonNodeDeletionConfigurator.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/FeatureNodeServiceImplTest.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.java

index 778b15c8a62dca80bcdaba86e925f6cb38368633..372973b3730d1d814063a6328fc359a9d3e88420 100644 (file)
@@ -81,7 +81,7 @@ public class FeatureNode extends VersionableEntity implements ITreeNode<FeatureN
     @XmlIDREF
     @XmlSchemaType(name = "IDREF")
     @ManyToOne(fetch = FetchType.LAZY)
-    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE, CascadeType.DELETE_ORPHAN}) //TODO this usage is incorrect, needed only for OneToMany, check why it is here, can it be removed??
+    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE}) //TODO this usage is incorrect, needed only for OneToMany, check why it is here, can it be removed??
         //TODO Val #3379
 //    @NotNull
        private FeatureTree featureTree;
@@ -320,6 +320,7 @@ public class FeatureNode extends VersionableEntity implements ITreeNode<FeatureN
                if (child != null){
                        children.remove(index);
                        child.setParent(null);
+                       child.setFeatureTree(null);
                        //TODO workaround (see sortIndex doc)
                        for(int i = 0; i < children.size(); i++){
                                FeatureNode childAt = children.get(i);
index ed6799618956a5d55b036aa40049bb18c9f2ba91..780a95cadbf2e9942513dbcadd61141f71751bbb 100644 (file)
@@ -1,21 +1,31 @@
 // $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.
 */
 
 package eu.etaxonomy.cdm.api.service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureNode;
 import eu.etaxonomy.cdm.persistence.dao.description.IFeatureNodeDao;
 
@@ -28,10 +38,72 @@ import eu.etaxonomy.cdm.persistence.dao.description.IFeatureNodeDao;
 @Transactional(readOnly = false)
 public class FeatureNodeServiceImpl extends VersionableServiceBase<FeatureNode, IFeatureNodeDao> implements IFeatureNodeService {
        private static final Logger logger = Logger.getLogger(FeatureNodeServiceImpl.class);
-       
-       @Autowired
+
+       @Override
+    @Autowired
        protected void setDao(IFeatureNodeDao dao) {
                this.dao = dao;
        }
-       
+
+       @Autowired
+    private ITermService termService;
+
+        @Override
+        @Transactional(readOnly = false)
+        public DeleteResult deleteFeatureNode(UUID nodeUuid, NodeDeletionConfigurator config) {
+            DeleteResult result = new DeleteResult();
+            FeatureNode node = HibernateProxyHelper.deproxy(dao.load(nodeUuid), FeatureNode.class);
+            result = isDeletable(node, config);
+            Feature feature;
+            if (result.isOk()){
+
+                List<FeatureNode> children = new ArrayList(node.getChildNodes());
+
+                if (config.getChildHandling().equals(ChildHandling.DELETE)){
+
+                    for (FeatureNode child: children){
+                        node.removeChild(child);
+                        deleteFeatureNode(child.getUuid(), config);
+                    }
+                } else{
+                    FeatureNode parent = node.getParent();
+                    if (parent != null){
+                        parent.removeChild(node);
+                        for (FeatureNode child: children){
+                            node.removeChild(child);
+                            parent.addChild(child);
+                        }
+                    }else{
+                        result.setAbort();
+                        result.addException(new ReferencedObjectUndeletableException("The root node can not be deleted without its child nodes"));
+                        return result;
+                    }
+                }
+
+                dao.delete(node);
+                if (config.isDeleteElement()){
+                 feature = node.getFeature();
+                 termService.delete(feature.getUuid());
+             }
+            }
+
+
+            return result;
+        }
+
+        @Override
+        public DeleteResult isDeletable(FeatureNode node, NodeDeletionConfigurator config){
+            DeleteResult result = new DeleteResult();
+            Set<CdmBase> references = commonService.getReferencingObjectsForDeletion(node);
+            for (CdmBase ref:references){
+                if (ref instanceof FeatureNode){
+                    break;
+                }
+                result.setAbort();
+                result.addException(new ReferencedObjectUndeletableException("The featureNode is referenced ..."));
+
+            }
+            return result;
+        }
+
 }
index 6a7a1ce77af3c16c7c5021887665a85d835bf93a..03179f3cd6ec94cc2a47613c8da2093130f145f3 100644 (file)
@@ -21,7 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;\r
 import org.springframework.transaction.annotation.Transactional;\r
 \r
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator;\r
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;\r
 import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;\r
 import eu.etaxonomy.cdm.model.description.FeatureNode;\r
 import eu.etaxonomy.cdm.model.description.FeatureTree;\r
 import eu.etaxonomy.cdm.persistence.dao.description.IFeatureNodeDao;\r
@@ -37,6 +40,9 @@ public class FeatureTreeServiceImpl extends IdentifiableServiceBase<FeatureTree,
     @Autowired\r
     private IVocabularyService vocabularyService;\r
 \r
+    @Autowired\r
+    private IFeatureNodeService featureNodeService;\r
+\r
     @Override\r
     @Autowired\r
     protected void setDao(IFeatureTreeDao dao) {\r
@@ -137,6 +143,23 @@ public class FeatureTreeServiceImpl extends IdentifiableServiceBase<FeatureTree,
         return load(IFeatureTreeDao.DefaultFeatureTreeUuid);\r
     }\r
 \r
+    @Override\r
+    public DeleteResult delete(UUID featureTreeUuid){\r
+        DeleteResult result = new DeleteResult();\r
+        FeatureTree tree = dao.load(featureTreeUuid);\r
+\r
+        FeatureNode rootNode = HibernateProxyHelper.deproxy(tree.getRoot(), FeatureNode.class);\r
+        NodeDeletionConfigurator config = new NodeDeletionConfigurator();\r
+        config.setChildHandling(ChildHandling.DELETE);\r
+        result =featureNodeService.deleteFeatureNode(rootNode.getUuid(), config);\r
+        dao.delete(tree);\r
+\r
+\r
+\r
+        return result;\r
+\r
+    }\r
+\r
 \r
 \r
 }\r
index abba2f61b0418acc7717da7db8384265484365bb..16c4fa171d1e9938315e02013f6ae6381b8ab737 100644 (file)
@@ -1,15 +1,18 @@
 // $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.
 */
 
 package eu.etaxonomy.cdm.api.service;
 
+import java.util.UUID;
+
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator;
 import eu.etaxonomy.cdm.model.description.FeatureNode;
 
 /**
@@ -19,4 +22,18 @@ import eu.etaxonomy.cdm.model.description.FeatureNode;
  */
 public interface IFeatureNodeService extends IVersionableService<FeatureNode>{
 
+    /**
+     * @param node
+     * @param config
+     * @return
+     */
+    DeleteResult deleteFeatureNode(UUID nodeUuid, NodeDeletionConfigurator config);
+
+    /**
+     * @param node
+     * @param config
+     * @return
+     */
+    DeleteResult isDeletable(FeatureNode node, NodeDeletionConfigurator config);
+
 }
index f3190a29ca87692085a6de010fd10a6c312fb1ff..5bbdf0c8664af386c4ca01603724604265cfa6bd 100644 (file)
@@ -1275,7 +1275,7 @@ public class OccurrenceServiceImpl extends IdentifiableServiceBase<SpecimenOrObs
             Sequence sequence = HibernateProxyHelper.deproxy(from, Sequence.class);
             DnaSample dnaSample = sequence.getDnaSample();
             dnaSample.removeSequence(sequence);
-            deleteResult = sequenceService.delete(sequence);
+            deleteResult.includeResult(sequenceService.delete(sequence));
             deleteResult.addUpdatedObject(dnaSample);
         }
         else if(from instanceof SingleRead){
@@ -1289,7 +1289,7 @@ public class OccurrenceServiceImpl extends IdentifiableServiceBase<SpecimenOrObs
                     + "Single read may still be attached to a consensus sequence."));
         }
         else if(from.isInstanceOf(SpecimenOrObservationBase.class))  {
-            deleteResult = delete(HibernateProxyHelper.deproxy(from, SpecimenOrObservationBase.class), config);
+            deleteResult.includeResult(delete(HibernateProxyHelper.deproxy(from, SpecimenOrObservationBase.class), config));
         }
         return deleteResult;
     }
index b7f4a172f8de6015127c60e70332cfd57654d52d..0dd73bc67ab566c770c8f89088c7e4c5e6111f8a 100644 (file)
@@ -25,9 +25,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import eu.etaxonomy.cdm.api.service.UpdateResult.Status;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
@@ -243,7 +243,7 @@ public class TaxonNodeServiceImpl extends AnnotatableServiceBase<TaxonNode, ITax
         }else{
                result.setStatus(Status.OK);
                TaxonNodeDeletionConfigurator config = new TaxonNodeDeletionConfigurator();
-               config.setDeleteTaxon(false);
+               config.setDeleteElement(false);
                conf.setTaxonNodeConfig(config);
                result.includeResult(deleteTaxonNode(oldTaxonNode, conf));
         }
@@ -434,7 +434,7 @@ public class TaxonNodeServiceImpl extends AnnotatableServiceBase<TaxonNode, ITax
        }
        DeleteResult result = new DeleteResult();
 
-       if (config.getTaxonNodeConfig().getChildHandling().equals(TaxonNodeDeletionConfigurator.ChildHandling.MOVE_TO_PARENT)){
+       if (config.getTaxonNodeConfig().getChildHandling().equals(ChildHandling.MOVE_TO_PARENT)){
           Object[] children = node.getChildNodes().toArray();
           TaxonNode childNode;
           for (Object child: children){
@@ -468,7 +468,7 @@ public class TaxonNodeServiceImpl extends AnnotatableServiceBase<TaxonNode, ITax
                        if (index > -1){
                            parent.removeChild(index);
                        }
-               if (!dao.delete(node, config.getTaxonNodeConfig().getChildHandling().equals(TaxonNodeDeletionConfigurator.ChildHandling.DELETE)).equals(null)){
+               if (!dao.delete(node, config.getTaxonNodeConfig().getChildHandling().equals(ChildHandling.DELETE)).equals(null)){
                        return result;
                } else {
                        result.setError();
index 2915e90e66695ef1e58f3c8f77ad99677f5fb360..4d5d3e47fb5f5af091695c45b9bafb1221af90c6 100644 (file)
@@ -42,9 +42,9 @@ import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
 import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;\r
 import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator;\r
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;\r
 import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;\r
 import eu.etaxonomy.cdm.api.service.dto.FindByIdentifierDTO;\r
 import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;\r
 import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;\r
@@ -1092,7 +1092,7 @@ public class TaxonServiceImpl extends IdentifiableServiceBase<TaxonBase,ITaxonDa
                                     //taxon.removeTaxonNode(taxonNode);\r
                                 }\r
                             }\r
-                        config.getTaxonNodeConfig().setDeleteTaxon(false);\r
+                        config.getTaxonNodeConfig().setDeleteElement(false);\r
                         DeleteResult resultNodes = nodeService.deleteTaxonNodes(nodesList, config);\r
                         if (!resultNodes.isOk()){\r
                                result.addExceptions(resultNodes.getExceptions());\r
index 39ac431b37f50aafd092b1c36907bebc72cb3774..ebb2a883e35b9e91dcd8094419ce0932d7797640 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$\r
 /**\r
 * Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
 * http://www.e-taxonomy.eu\r
-* \r
+*\r
 * The contents of this file are subject to the Mozilla Public License Version 1.1\r
 * See LICENSE.TXT at the top of this package for the full license terms.\r
 */\r
@@ -15,53 +15,26 @@ import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 \r
 /**\r
  * This class is used to configure taxon node deletion.\r
- * \r
+ *\r
  * @see ITaxonNodeService#delete(eu.etaxonomy.cdm.model.taxon.TaxonNode)\r
- * \r
+ *\r
  * @author a.mueller\r
  * @date 09.11.2011\r
  *\r
  */\r
-public class TaxonNodeDeletionConfigurator extends DeleteConfiguratorBase {\r
+public class TaxonNodeDeletionConfigurator extends NodeDeletionConfigurator {\r
        @SuppressWarnings("unused")\r
        private static final Logger logger = Logger.getLogger(TaxonNodeDeletionConfigurator.class);\r
-       \r
-       /**\r
-        * \r
-        * \r
-        *\r
-        */\r
-       public enum ChildHandling{\r
-               DELETE,\r
-               MOVE_TO_PARENT\r
-       }\r
-       \r
 \r
-       private ChildHandling childHandling = ChildHandling.DELETE;\r
-       \r
-\r
-       public void setChildHandling(ChildHandling childHandling) {\r
-               this.childHandling = childHandling;\r
+       public boolean isDeleteTaxon() {\r
+               return isDeleteElement();\r
        }\r
 \r
-\r
-       public ChildHandling getChildHandling() {\r
-               return childHandling;\r
+       public void setDeleteTaxon(boolean deleteTaxon) {\r
+               this.deleteElement = deleteTaxon;\r
        }\r
-       \r
-       public boolean deleteTaxon = true;\r
 \r
 \r
-       public boolean isDeleteTaxon() {\r
-               return deleteTaxon;\r
-       }\r
 \r
 \r
-       public void setDeleteTaxon(boolean deleteTaxon) {\r
-               this.deleteTaxon = deleteTaxon;\r
-       }\r
-       \r
-       \r
-       \r
-       \r
 }\r
index 1bfe8572d3bcfc372066406c6418e2991ef6c2b7..5cf2930f91822418060a7b86bddc0bae913876e2 100644 (file)
@@ -10,6 +10,9 @@
 
 package eu.etaxonomy.cdm.api.service;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import java.io.FileNotFoundException;
 import java.util.UUID;
 
@@ -17,9 +20,10 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.unitils.dbunit.annotation.DataSet;
-import org.unitils.spring.annotation.SpringApplicationContext;
 import org.unitils.spring.annotation.SpringBeanByType;
 
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.model.common.ITreeNode;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureNode;
@@ -35,16 +39,16 @@ public class FeatureNodeServiceImplTest extends CdmTransactionalIntegrationTest{
 
        private static final String sep = ITreeNode.separator;
        private static final String pref = ITreeNode.treePrefix;
-       
+
        @SpringBeanByType
        private IFeatureNodeService featureNodeService;
 
        @SpringBeanByType
        private IFeatureTreeService featureTreeService;
-       
+
        @SpringBeanByType
        private ITermService termService;
-       
+
 
 //     private static final UUID t2Uuid = UUID.fromString("55c3e41a-c629-40e6-aa6a-ff274ac6ddb1");
 //     private static final UUID t3Uuid = UUID.fromString("2659a7e0-ff35-4ee4-8493-b453756ab955");
@@ -52,7 +56,7 @@ public class FeatureNodeServiceImplTest extends CdmTransactionalIntegrationTest{
        private static final UUID featureTree2Uuid = UUID.fromString("43d67247-936f-42a3-a739-bbcde372e334");
        private static final UUID node2Uuid= UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
        private static final UUID node3Uuid = UUID.fromString("2d41f0c2-b785-4f73-a436-cc2d5e93cc5b");
-//     private static final UUID node4Uuid = UUID.fromString("fdaec4bd-c78e-44df-ae87-28f18110968c");
+       private static final UUID node4Uuid = UUID.fromString("fdaec4bd-c78e-44df-ae87-28f18110968c");
        private static final UUID node5Uuid = UUID.fromString("c4d5170a-7967-4dac-ab76-ae2019eefde5");
        private static final UUID node6Uuid = UUID.fromString("b419ba5e-9c8b-449c-ad86-7abfca9a7340");
 
@@ -73,7 +77,7 @@ public class FeatureNodeServiceImplTest extends CdmTransactionalIntegrationTest{
        public final void testIndexCreatRoot() {
                FeatureTree featureTree = FeatureTree.NewInstance();
                featureTreeService.save(featureTree);
-               
+
                Feature feature = (Feature)termService.find(914);
                FeatureNode newNode = FeatureNode.NewInstance(feature);
                featureTree.getRoot().addChild(newNode);
@@ -81,31 +85,31 @@ public class FeatureNodeServiceImplTest extends CdmTransactionalIntegrationTest{
                featureTreeService.save(featureTree);
 
                featureNodeService.saveOrUpdate(newNode);
-               
+
                commitAndStartNewTransaction(new String[]{"FeatureNode"});
                newNode = featureNodeService.load(newNode.getUuid());
                Assert.assertEquals("", sep + pref+featureTree.getId()+sep + featureTree.getRoot().getId()+ sep  + newNode.getId() + sep, newNode.treeIndex());
        }
 
-       
+
        @Test
        @DataSet(value="FeatureNodeServiceImplTest-indexing.xml")
        public final void testIndexCreateNode() {
                Feature feature = (Feature)termService.find(914);
-               
+
                node2 = featureNodeService.load(node2Uuid);
                String oldTreeIndex = node2.treeIndex();
-               
+
                FeatureNode newNode = FeatureNode.NewInstance(feature);
                node2.addChild(newNode);
                featureNodeService.saveOrUpdate(node2);
-               
+
                commitAndStartNewTransaction(new String[]{"FeatureNode"});
                newNode = featureNodeService.load(newNode.getUuid());
                Assert.assertEquals("", oldTreeIndex + newNode.getId() + sep, newNode.treeIndex());
        }
 
-       
+
        @Test
        @DataSet(value="FeatureNodeServiceImplTest-indexing.xml")
        public final void testIndexMoveNode() {
@@ -144,15 +148,35 @@ public class FeatureNodeServiceImplTest extends CdmTransactionalIntegrationTest{
        @Test  //here we may have a test for testing delete of a node and attaching the children
        //to its parents, however this depends on the way delete is implemented and therefore needs
        //to wait until this is finally done
+       @DataSet(value="FeatureNodeServiceImplTest-indexing.xml")
        public final void testIndexDeleteNode() {
-//             node2 = taxonNodeService.load(node2Uuid);
-//             node2.getParent().deleteChildNode(node2);
-//             
-//             node5.addChildNode(node3, null, null);
-//             taxonNodeService.saveOrUpdate(node5);
-//             commitAndStartNewTransaction(new String[]{"TaxonNode"});
-//             node3 = taxonNodeService.load(node3Uuid);
-//             Assert.assertEquals("Node3 treeindex is not correct", "#t2#2#5#3#", node3.getTreeIndex());
+               node2 = featureNodeService.load(node2Uuid);
+               FeatureNode root = node2.getParent();
+               NodeDeletionConfigurator config = new NodeDeletionConfigurator();
+               config.setDeleteElement(false);
+        config.setChildHandling(ChildHandling.MOVE_TO_PARENT);
+        DeleteResult result = featureNodeService.deleteFeatureNode(node2Uuid, config);
+        commitAndStartNewTransaction(new String[]{"TaxonNode"});
+        FeatureTree tree1 = featureTreeService.load(featureTreeUuid);
+        assertNotNull(tree1);
+        node2 = featureNodeService.load(node2Uuid);
+        assertNull(node2);
+        node3 = featureNodeService.load(node3Uuid);
+        assertNotNull(node3);
+        FeatureNode node4 = featureNodeService.load(node4Uuid);
+        assertNotNull(node4);
+               config.setDeleteElement(false);
+               config.setChildHandling(ChildHandling.DELETE);
+               result = featureNodeService.deleteFeatureNode(node4Uuid, config);
+               commitAndStartNewTransaction(new String[]{"TaxonNode"});
+               tree1 = featureTreeService.load(featureTreeUuid);
+               assertNotNull(tree1);
+
+               node4 = featureNodeService.load(node4Uuid);
+               assertNull(node4);
+               FeatureNode node6 = featureNodeService.load(node6Uuid);
+               assertNull(node6);
+
        }
 
     /* (non-Javadoc)
@@ -160,11 +184,11 @@ public class FeatureNodeServiceImplTest extends CdmTransactionalIntegrationTest{
      */
     @Override
     public void createTestDataSet() throws FileNotFoundException {
-        // TODO Auto-generated method stub 
+        // TODO Auto-generated method stub
     }
-       
-       
-       
-       
+
+
+
+
 
 }
index bb105a06e64ecac16101a36318e8e5cb85ef4a73..6f58d040b1b9390497aa4d0a43ec675656843cd9 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
-* Copyright (C) 2014 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) 2014 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.cdm.api.service;
 
 import static org.junit.Assert.assertEquals;
@@ -95,28 +95,30 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     private IDescriptionService descriptionService;
 
     @Test
-    public void testGetNonCascadedAssociatedElements(){
-        //Collection
+    public void testGetNonCascadedAssociatedElements() {
+        // Collection
         Collection collection = Collection.NewInstance();
         Collection subCollection = Collection.NewInstance();
         subCollection.setSuperCollection(collection);
 
         Institution institution = Institution.NewInstance();
-        institution.addType(DefinedTerm.NewInstitutionTypeInstance("Research and teaching", "botanical garden", "BGBM"));
+        institution
+                .addType(DefinedTerm.NewInstitutionTypeInstance("Research and teaching", "botanical garden", "BGBM"));
         collection.setInstitute(institution);
 
-        //Source
-        Reference<?> article = ReferenceFactory.newArticle(getReference(), Person.NewInstance(), "title", "pages", "series", "volume", TimePeriod.NewInstance(2014));
+        // Source
+        Reference<?> article = ReferenceFactory.newArticle(getReference(), Person.NewInstance(), "title", "pages",
+                "series", "volume", TimePeriod.NewInstance(2014));
         IdentifiableSource source = IdentifiableSource.NewPrimarySourceInstance(article, "microCitation");
 
-        //FieldUnit
+        // FieldUnit
         FieldUnit fieldUnit = FieldUnit.NewInstance();
         Person primaryCollector = Person.NewInstance();
         primaryCollector.setLifespan(TimePeriod.NewInstance(2014));
         fieldUnit.setPrimaryCollector(primaryCollector);
         fieldUnit.addSource(source);
 
-        //GatheringEvent
+        // GatheringEvent
         GatheringEvent gatheringEvent = GatheringEvent.NewInstance();
         fieldUnit.setGatheringEvent(gatheringEvent);
         gatheringEvent.putLocality(Language.ENGLISH(), "locality");
@@ -125,72 +127,73 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         gatheringEvent.setCountry(Country.GERMANY());
         gatheringEvent.addCollectingArea(NamedArea.EUROPE());
 
-        //Derived Unit
+        // Derived Unit
         MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
         mediaSpecimen.setCollection(collection);
         BotanicalName storedUnder = BotanicalName.NewInstance(Rank.SPECIES());
         mediaSpecimen.setStoredUnder(storedUnder);
         PreservationMethod preservation = PreservationMethod.NewInstance(null, "My preservation");
-        preservation.setMedium(DefinedTerm.NewDnaMarkerInstance("medium", "medium", "medium"));//dummy defined term
+        preservation.setMedium(DefinedTerm.NewDnaMarkerInstance("medium", "medium", "medium"));// dummy
+                                                                                               // defined
+                                                                                               // term
         mediaSpecimen.setPreservation(preservation);
 
-        //DerivationEvent
+        // DerivationEvent
         DerivationEvent event = DerivationEvent.NewInstance(DerivationEventType.ACCESSIONING());
         event.addOriginal(fieldUnit);
         event.addDerivative(mediaSpecimen);
 
-        //SpecOrObservationBase
+        // SpecOrObservationBase
         fieldUnit.setSex(DefinedTerm.SEX_FEMALE());
         fieldUnit.setLifeStage(DefinedTerm.NewStageInstance("Live stage", "stage", null));
         fieldUnit.setKindOfUnit(DefinedTerm.NewKindOfUnitInstance("Kind of unit", "Kind of unit", null));
         fieldUnit.putDefinition(Language.ENGLISH(), "definition");
 
-        //Determination
+        // Determination
         DeterminationEvent determinationEvent = DeterminationEvent.NewInstance(getTaxon(), mediaSpecimen);
-        determinationEvent.setModifier(DefinedTerm.NewModifierInstance("modifierDescription", "modifierLabel", "mofifierLabelAbbrev"));
+        determinationEvent.setModifier(DefinedTerm.NewModifierInstance("modifierDescription", "modifierLabel",
+                "mofifierLabelAbbrev"));
         determinationEvent.setPreferredFlag(true);
         Reference<?> reference = getReference();
         determinationEvent.addReference(reference);
 
-        /*NonCascaded
-         * SOOB
-         *  - sex (FEMALE)
-         *  - stage (Live stage)
-         *  - kindOfUnit (Kind of unit)
-         * GatheringEvent
-         *  - country (GERMANY)
-         *  - collectingArea (EUROPE)
-         *  DerivedUnit
-         *  - storedUnder (botanical name)
-         *  DerivedUnit-> Collection -> institiute
-         *  - type (botanical garden)
-         *
-         * */
-
-        assertEquals("Incorrect number of non cascaded CDM entities", 9, occurrenceService.getNonCascadedAssociatedElements(fieldUnit).size());
-        assertEquals("Incorrect number of non cascaded CDM entities", 9, occurrenceService.getNonCascadedAssociatedElements(mediaSpecimen).size());
+        /*
+         * NonCascaded SOOB - sex (FEMALE) - stage (Live stage) - kindOfUnit
+         * (Kind of unit) GatheringEvent - country (GERMANY) - collectingArea
+         * (EUROPE) DerivedUnit - storedUnder (botanical name) DerivedUnit->
+         * Collection -> institiute - type (botanical garden)
+         */
+
+        assertEquals("Incorrect number of non cascaded CDM entities", 9, occurrenceService
+                .getNonCascadedAssociatedElements(fieldUnit).size());
+        assertEquals("Incorrect number of non cascaded CDM entities", 9, occurrenceService
+                .getNonCascadedAssociatedElements(mediaSpecimen).size());
 
     }
+
     private Reference<?> getReference() {
         Reference<?> result = ReferenceFactory.newGeneric();
         result.setTitle("some generic reference");
         return result;
-   }
-   private Taxon getTaxon() {
-       Reference<?> sec = getReference();
-       TaxonNameBase<?,?> name = BotanicalName.NewInstance(Rank.GENUS());
-       Taxon taxon = Taxon.NewInstance(name, sec);
-       return taxon;
+    }
 
-   }
+    private Taxon getTaxon() {
+        Reference<?> sec = getReference();
+        TaxonNameBase<?, ?> name = BotanicalName.NewInstance(Rank.GENUS());
+        Taxon taxon = Taxon.NewInstance(name, sec);
+        return taxon;
 
-    @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurenceServiceTest.move.xml")
-    public void testMoveDerivate(){
-        DerivedUnit specimenA = (DerivedUnit) occurrenceService.load(UUID.fromString("35cfb0b3-588d-4eee-9db6-ac9caa44e39a"));
-        DerivedUnit specimenB = (DerivedUnit) occurrenceService.load(UUID.fromString("09496534-efd0-44c8-b1ce-01a34a8a0229"));
-        DerivedUnit dnaSample = (DnaSample) occurrenceService.load(UUID.fromString("5995f852-0e78-405c-b849-d923bd6781d9"));
+    }
 
+    @Test
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurenceServiceTest.move.xml")
+    public void testMoveDerivate() {
+        DerivedUnit specimenA = (DerivedUnit) occurrenceService.load(UUID
+                .fromString("35cfb0b3-588d-4eee-9db6-ac9caa44e39a"));
+        DerivedUnit specimenB = (DerivedUnit) occurrenceService.load(UUID
+                .fromString("09496534-efd0-44c8-b1ce-01a34a8a0229"));
+        DerivedUnit dnaSample = (DnaSample) occurrenceService.load(UUID
+                .fromString("5995f852-0e78-405c-b849-d923bd6781d9"));
 
         occurrenceService.saveOrUpdate(specimenA);
         occurrenceService.saveOrUpdate(specimenB);
@@ -201,7 +204,8 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         Institution derivationInstitution = Institution.NewInstance();
         TimePeriod derivationTimePeriod = TimePeriod.NewInstance(2015);
 
-        DerivationEvent originalDerivedFromEvent = DerivationEvent.NewSimpleInstance(specimenA, dnaSample, DerivationEventType.DNA_EXTRACTION());
+        DerivationEvent originalDerivedFromEvent = DerivationEvent.NewSimpleInstance(specimenA, dnaSample,
+                DerivationEventType.DNA_EXTRACTION());
 
         originalDerivedFromEvent.setActor(derivationActor);
         originalDerivedFromEvent.setDescription(derivationDescription);
@@ -213,7 +217,8 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertEquals("DerivationEvent not moved to source!", 1, specimenB.getDerivationEvents().size());
 
         DerivationEvent derivationEvent = specimenB.getDerivationEvents().iterator().next();
-        assertEquals("Moved DerivationEvent not of same type!", DerivationEventType.DNA_EXTRACTION(), derivationEvent.getType());
+        assertEquals("Moved DerivationEvent not of same type!", DerivationEventType.DNA_EXTRACTION(),
+                derivationEvent.getType());
         assertEquals(derivationActor, derivationEvent.getActor());
         assertEquals(derivationDescription, derivationEvent.getDescription());
         assertEquals(derivationInstitution, derivationEvent.getInstitution());
@@ -226,14 +231,16 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertEquals("Wrong number of derivatives!", 1, derivationEvent.getDerivatives().size());
 
         DerivedUnit movedDerivate = derivationEvent.getDerivatives().iterator().next();
-        assertEquals("Moved derivate has wrong type", SpecimenOrObservationType.DnaSample, movedDerivate.getRecordBasis());
-        assertNotEquals("DerivationEvent 'derivedFrom' has not been changed after moving", originalDerivedFromEvent, movedDerivate.getDerivedFrom());
+        assertEquals("Moved derivate has wrong type", SpecimenOrObservationType.DnaSample,
+                movedDerivate.getRecordBasis());
+        assertNotEquals("DerivationEvent 'derivedFrom' has not been changed after moving", originalDerivedFromEvent,
+                movedDerivate.getDerivedFrom());
 
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="BlankDataSet.xml")
-    public void testMoveDerivateNoParent(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "BlankDataSet.xml")
+    public void testMoveDerivateNoParent() {
         DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
         FieldUnit fieldUnit = FieldUnit.NewInstance();
 
@@ -254,10 +261,12 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurenceServiceTest.move.xml")
-    public void testMoveSequence(){
-        DnaSample dnaSampleA = (DnaSample) occurrenceService.load(UUID.fromString("5995f852-0e78-405c-b849-d923bd6781d9"));
-        DnaSample dnaSampleB = (DnaSample) occurrenceService.load(UUID.fromString("85fccc2f-c796-46b3-b2fc-6c9a4d68cfda"));
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurenceServiceTest.move.xml")
+    public void testMoveSequence() {
+        DnaSample dnaSampleA = (DnaSample) occurrenceService.load(UUID
+                .fromString("5995f852-0e78-405c-b849-d923bd6781d9"));
+        DnaSample dnaSampleB = (DnaSample) occurrenceService.load(UUID
+                .fromString("85fccc2f-c796-46b3-b2fc-6c9a4d68cfda"));
         String consensusSequence = "ATTCG";
         Sequence sequence = sequenceService.load(UUID.fromString("6da4f378-9861-4338-861b-7b8073763e7a"));
 
@@ -276,106 +285,113 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testDeleteIndividualAssociatedAndTypeSpecimen.xml")
-    public void testDeleteIndividualAssociatedAndTypeSpecimen(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testDeleteIndividualAssociatedAndTypeSpecimen.xml")
+    public void testDeleteIndividualAssociatedAndTypeSpecimen() {
         final UUID taxonDEscriptionUuid = UUID.fromString("a87a893e-2ea8-427d-a26b-dbd2515d6b8a");
         final UUID botanicalNameUuid = UUID.fromString("a604774e-d66a-4d47-b9d1-d0e38a8c787a");
         final UUID fieldUnitUuid = UUID.fromString("67e81ca8-ff91-4df6-bf48-e4600c7f15a2");
         final UUID derivedUnitUuid = UUID.fromString("d229713b-0123-4f15-bffc-76ae45c37564");
 
-        //        //how the XML was generated
-//        FieldUnit fieldUnit = FieldUnit.NewInstance();
-//        fieldUnit.setUuid(fieldUnitUuid);
-//        //sub derivates (DerivedUnit, DnaSample)
-//        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//        derivedUnit.setUuid(derivedUnitUuid);
-//
-//        //derivation events
-//        DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.ACCESSIONING());
-//
-//        occurrenceService.save(fieldUnit);
-//        occurrenceService.save(derivedUnit);
-//
-//        //create name with type specimen
-//        BotanicalName name = BotanicalName.PARSED_NAME("Campanula patual sec L.");
-//        name.setUuid(BOTANICAL_NAME_UUID);
-//        SpecimenTypeDesignation typeDesignation = SpecimenTypeDesignation.NewInstance();
-//        typeDesignation.setTypeSpecimen(derivedUnit);
-//        //add type designation to name
-//        name.addTypeDesignation(typeDesignation, false);
-//
-//        // create taxon with name and two taxon descriptions (one with
-//        // IndividualsAssociations and a "described" voucher specimen, and an
-//        // empty one)
-//        Taxon taxon = Taxon.NewInstance(name, null);
-//        taxon.setUuid(taxonUuid);
-//        TaxonDescription taxonDescription = TaxonDescription.NewInstance();
-//        taxonDescription.setUuid(TAXON_DESCRIPTION_UUID);
-//        //add voucher
-//        taxonDescription.addElement(IndividualsAssociation.NewInstance(fieldUnit));
-//        taxon.addDescription(taxonDescription);
-//        //add another taxon description to taxon which is not associated with a specimen thus should not be taken into account
-//        taxon.addDescription(TaxonDescription.NewInstance());
-//        taxonService.saveOrUpdate(taxon);
-//
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "Sequence_SingleRead",
-//                    "SingleRead",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"
-//            }, "testDeleteIndividualAssociatedAndTypeSpecimen");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
+        // //how the XML was generated
+        // FieldUnit fieldUnit = FieldUnit.NewInstance();
+        // fieldUnit.setUuid(fieldUnitUuid);
+        // //sub derivates (DerivedUnit, DnaSample)
+        // DerivedUnit derivedUnit =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        // derivedUnit.setUuid(derivedUnitUuid);
+        //
+        // //derivation events
+        // DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit,
+        // DerivationEventType.ACCESSIONING());
+        //
+        // occurrenceService.save(fieldUnit);
+        // occurrenceService.save(derivedUnit);
+        //
+        // //create name with type specimen
+        // BotanicalName name =
+        // BotanicalName.PARSED_NAME("Campanula patual sec L.");
+        // name.setUuid(BOTANICAL_NAME_UUID);
+        // SpecimenTypeDesignation typeDesignation =
+        // SpecimenTypeDesignation.NewInstance();
+        // typeDesignation.setTypeSpecimen(derivedUnit);
+        // //add type designation to name
+        // name.addTypeDesignation(typeDesignation, false);
+        //
+        // // create taxon with name and two taxon descriptions (one with
+        // // IndividualsAssociations and a "described" voucher specimen, and an
+        // // empty one)
+        // Taxon taxon = Taxon.NewInstance(name, null);
+        // taxon.setUuid(taxonUuid);
+        // TaxonDescription taxonDescription = TaxonDescription.NewInstance();
+        // taxonDescription.setUuid(TAXON_DESCRIPTION_UUID);
+        // //add voucher
+        // taxonDescription.addElement(IndividualsAssociation.NewInstance(fieldUnit));
+        // taxon.addDescription(taxonDescription);
+        // //add another taxon description to taxon which is not associated with
+        // a specimen thus should not be taken into account
+        // taxon.addDescription(TaxonDescription.NewInstance());
+        // taxonService.saveOrUpdate(taxon);
+        //
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "Sequence_SingleRead",
+        // "SingleRead",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"
+        // }, "testDeleteIndividualAssociatedAndTypeSpecimen");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
 
         FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid);
         DerivedUnit typeSpecimen = (DerivedUnit) occurrenceService.load(derivedUnitUuid);
         BotanicalName name = (BotanicalName) nameService.load(botanicalNameUuid);
         TaxonDescription taxonDescription = (TaxonDescription) descriptionService.load(taxonDEscriptionUuid);
-        //check initial state (IndividualsAssociation)
+        // check initial state (IndividualsAssociation)
         DescriptionElementBase descriptionElement = taxonDescription.getElements().iterator().next();
         assertTrue("wrong type of description element", descriptionElement.isInstanceOf(IndividualsAssociation.class));
-        assertEquals("associated specimen is incorrect", associatedFieldUnit, ((IndividualsAssociation)descriptionElement).getAssociatedSpecimenOrObservation());
-        //check initial state (Type Designation)
+        assertEquals("associated specimen is incorrect", associatedFieldUnit,
+                ((IndividualsAssociation) descriptionElement).getAssociatedSpecimenOrObservation());
+        // check initial state (Type Designation)
         Set<TypeDesignationBase> typeDesignations = name.getTypeDesignations();
         TypeDesignationBase<?> typeDesignation = typeDesignations.iterator().next();
         assertTrue("wrong type of type designation", typeDesignation.isInstanceOf(SpecimenTypeDesignation.class));
-        assertEquals("type specimen is incorrect", typeSpecimen, ((SpecimenTypeDesignation)typeDesignation).getTypeSpecimen());
+        assertEquals("type specimen is incorrect", typeSpecimen,
+                ((SpecimenTypeDesignation) typeDesignation).getTypeSpecimen());
 
         SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
-        //delete type specimen from type designation
+        // delete type specimen from type designation
         config.setDeleteFromTypeDesignation(true);
         occurrenceService.delete(typeSpecimen, config);
-        assertTrue(((SpecimenTypeDesignation)typeDesignation).getTypeSpecimen()==null);
+        assertTrue(((SpecimenTypeDesignation) typeDesignation).getTypeSpecimen() == null);
 
-        //delete associated field unit from IndividualsAssociation
+        // delete associated field unit from IndividualsAssociation
         config.setDeleteFromIndividualsAssociation(true);
         occurrenceService.delete(associatedFieldUnit, config);
-        assertTrue(((IndividualsAssociation)descriptionElement).getAssociatedSpecimenOrObservation()==null);
+        assertTrue(((IndividualsAssociation) descriptionElement).getAssociatedSpecimenOrObservation() == null);
 
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceService.loadData.xml")
-    public void testLoadData(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceService.loadData.xml")
+    public void testLoadData() {
         String fieldUnitUuid = "5a31df5a-2e4d-40b1-8d4e-5754736ae7ef";
         String derivedUnitUuid = "18f70977-5d9c-400a-96c4-0cb7a2cd287e";
 
@@ -383,98 +399,106 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         DerivedUnit derivedUnit = (DerivedUnit) occurrenceService.load(UUID.fromString(derivedUnitUuid));
 
         assertFalse(fieldUnit.getDerivationEvents().iterator().next().getDerivatives().isEmpty());
-        assertTrue(derivedUnit.getDerivedFrom()!=null);
+        assertTrue(derivedUnit.getDerivedFrom() != null);
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testListAssociatedAndTypedTaxa.xml")
-    public void testListAssociatedAndTypedTaxa(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testListAssociatedAndTypedTaxa.xml")
+    public void testListAssociatedAndTypedTaxa() {
         UUID fieldUnitUuid = UUID.fromString("b359ff20-98de-46bf-aa43-3e10bb072cd4");
         UUID typeSpecimenUuid = UUID.fromString("0f8608c7-ffe7-40e6-828c-cb3382580878");
         UUID taxonDescriptionUuid = UUID.fromString("d77db2d4-45a1-4aa1-ab34-f33395f54965");
         UUID taxonUuid = UUID.fromString("b0de794c-8cb7-4369-8f83-870ca37abbe0");
-//        //how the XML was generated
-//        FieldUnit associatedFieldUnit = FieldUnit.NewInstance();
-//        associatedFieldUnit.setUuid(fieldUnitUuid);
-//        //sub derivates (DerivedUnit, DnaSample)
-//        DerivedUnit typeSpecimen = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//        typeSpecimen.setUuid(typeSpecimenUuid);
-//
-//        //derivation events
-//        DerivationEvent.NewSimpleInstance(associatedFieldUnit, typeSpecimen, DerivationEventType.ACCESSIONING());
-//
-//        occurrenceService.save(associatedFieldUnit);
-//        occurrenceService.save(typeSpecimen);
-//
-//        //create name with type specimen
-//        BotanicalName name = BotanicalName.PARSED_NAME("Campanula patual sec L.");
-//        SpecimenTypeDesignation typeDesignation = SpecimenTypeDesignation.NewInstance();
-//        typeDesignation.setTypeSpecimen(typeSpecimen);
-//
-//        // create taxon with name and two taxon descriptions (one with
-//        // IndividualsAssociations and a "described" voucher specimen, and an
-//        // empty one)
-//        Taxon taxon = Taxon.NewInstance(name, null);
-//        taxon.setUuid(taxonUuid);
-//        TaxonDescription taxonDescription = TaxonDescription.NewInstance();
-//        taxonDescription.setUuid(taxonDescriptionUuid);
-//        //add voucher
-//        taxonDescription.addElement(IndividualsAssociation.NewInstance(associatedFieldUnit));
-//        taxon.addDescription(taxonDescription);
-//        //add type designation to name
-//        name.addTypeDesignation(typeDesignation, false);
-//        //add another taxon description to taxon which is not associated with a specimen thus should not be taken into account
-//        taxon.addDescription(TaxonDescription.NewInstance());
-//        taxonService.saveOrUpdate(taxon);
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[]{
-//                                   "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "Sequence_SingleRead",
-//                    "SingleRead",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"}, "testListAssociatedAndTypedTaxa");
-//        } catch (FileNotFoundException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
-//
-//        System.out.println("associatedFieldUnit.getUuid() " + associatedFieldUnit.getUuid());
-//        System.out.println("typeSpecimen.getUuid() "+typeSpecimen.getUuid());
-//        System.out.println("taxonDescription.getUuid() "+taxonDescription.getUuid());
-//        System.out.println("taxon.getUuid() "+taxon.getUuid());
-
+        // //how the XML was generated
+        // FieldUnit associatedFieldUnit = FieldUnit.NewInstance();
+        // associatedFieldUnit.setUuid(fieldUnitUuid);
+        // //sub derivates (DerivedUnit, DnaSample)
+        // DerivedUnit typeSpecimen =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        // typeSpecimen.setUuid(typeSpecimenUuid);
+        //
+        // //derivation events
+        // DerivationEvent.NewSimpleInstance(associatedFieldUnit, typeSpecimen,
+        // DerivationEventType.ACCESSIONING());
+        //
+        // occurrenceService.save(associatedFieldUnit);
+        // occurrenceService.save(typeSpecimen);
+        //
+        // //create name with type specimen
+        // BotanicalName name =
+        // BotanicalName.PARSED_NAME("Campanula patual sec L.");
+        // SpecimenTypeDesignation typeDesignation =
+        // SpecimenTypeDesignation.NewInstance();
+        // typeDesignation.setTypeSpecimen(typeSpecimen);
+        //
+        // // create taxon with name and two taxon descriptions (one with
+        // // IndividualsAssociations and a "described" voucher specimen, and an
+        // // empty one)
+        // Taxon taxon = Taxon.NewInstance(name, null);
+        // taxon.setUuid(taxonUuid);
+        // TaxonDescription taxonDescription = TaxonDescription.NewInstance();
+        // taxonDescription.setUuid(taxonDescriptionUuid);
+        // //add voucher
+        // taxonDescription.addElement(IndividualsAssociation.NewInstance(associatedFieldUnit));
+        // taxon.addDescription(taxonDescription);
+        // //add type designation to name
+        // name.addTypeDesignation(typeDesignation, false);
+        // //add another taxon description to taxon which is not associated with
+        // a specimen thus should not be taken into account
+        // taxon.addDescription(TaxonDescription.NewInstance());
+        // taxonService.saveOrUpdate(taxon);
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[]{
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "Sequence_SingleRead",
+        // "SingleRead",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"}, "testListAssociatedAndTypedTaxa");
+        // } catch (FileNotFoundException e) {
+        // // TODO Auto-generated catch block
+        // e.printStackTrace();
+        // }
+        //
+        // System.out.println("associatedFieldUnit.getUuid() " +
+        // associatedFieldUnit.getUuid());
+        // System.out.println("typeSpecimen.getUuid() "+typeSpecimen.getUuid());
+        // System.out.println("taxonDescription.getUuid() "+taxonDescription.getUuid());
+        // System.out.println("taxon.getUuid() "+taxon.getUuid());
 
         FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid);
         DerivedUnit typeSpecimen = (DerivedUnit) occurrenceService.load(typeSpecimenUuid);
         Taxon taxon = (Taxon) taxonService.load(taxonUuid);
         TaxonDescription taxonDescription = (TaxonDescription) descriptionService.load(taxonDescriptionUuid);
-        //check for FieldUnit (IndividualsAssociation)
-        java.util.Collection<IndividualsAssociation> individualsAssociations = occurrenceService.listIndividualsAssociations(associatedFieldUnit, null, null, null,null);
+        // check for FieldUnit (IndividualsAssociation)
+        java.util.Collection<IndividualsAssociation> individualsAssociations = occurrenceService
+                .listIndividualsAssociations(associatedFieldUnit, null, null, null, null);
         assertEquals("Number of individuals associations is incorrect", 1, individualsAssociations.size());
         IndividualsAssociation individualsAssociation = individualsAssociations.iterator().next();
-        assertTrue("association has wrong type", individualsAssociation.getInDescription().isInstanceOf(TaxonDescription.class));
-        TaxonDescription retrievedTaxonDescription = HibernateProxyHelper.deproxy(individualsAssociation.getInDescription(), TaxonDescription.class);
+        assertTrue("association has wrong type",
+                individualsAssociation.getInDescription().isInstanceOf(TaxonDescription.class));
+        TaxonDescription retrievedTaxonDescription = HibernateProxyHelper.deproxy(
+                individualsAssociation.getInDescription(), TaxonDescription.class);
         assertEquals(taxonDescription, retrievedTaxonDescription);
         assertEquals("Associated taxon is incorrect", taxon, retrievedTaxonDescription.getTaxon());
 
-
-        //check for DerivedUnit (Type Designation should exist)
-        java.util.Collection<SpecimenTypeDesignation> typeDesignations = occurrenceService.listTypeDesignations(typeSpecimen, null, null, null,null);
+        // check for DerivedUnit (Type Designation should exist)
+        java.util.Collection<SpecimenTypeDesignation> typeDesignations = occurrenceService.listTypeDesignations(
+                typeSpecimen, null, null, null, null);
         assertEquals("Number of type designations is incorrect", 1, typeDesignations.size());
         SpecimenTypeDesignation specimenTypeDesignation = typeDesignations.iterator().next();
         Set<TaxonNameBase> typifiedNames = specimenTypeDesignation.getTypifiedNames();
@@ -482,132 +506,140 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         Set<?> taxonBases = typifiedNames.iterator().next().getTaxonBases();
         assertEquals("number of taxa incorrect", 1, taxonBases.size());
         Object next = taxonBases.iterator().next();
-        assertTrue(next instanceof CdmBase && ((CdmBase)next).isInstanceOf(Taxon.class));
+        assertTrue(next instanceof CdmBase && ((CdmBase) next).isInstanceOf(Taxon.class));
         assertEquals("Typed taxon is incorrect", taxon, next);
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testIsDeletableWithSpecimenDescription.xml")
-    public void testIsDeletableWithSpecimenDescription(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithSpecimenDescription.xml")
+    public void testIsDeletableWithSpecimenDescription() {
         UUID derivedUnitUuid = UUID.fromString("68095c8e-025d-49f0-8bb2-ed36378b75c3");
         UUID specimenDescriptionUuid = UUID.fromString("4094f947-ce84-47b1-bad5-e57e33239d3c");
-//        //how the XML was generated
-//        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//        derivedUnit.setUuid(derivedUnitUuid);
-//        SpecimenDescription specimenDescription = SpecimenDescription.NewInstance();
-//        specimenDescription.setUuid(specimenDescriptionUuid);
-//        derivedUnit.addDescription(specimenDescription);
-//        occurrenceService.save(derivedUnit);
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "Sequence_SingleRead",
-//                    "SingleRead",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"
-//            }, "testIsDeletableWithSpecimenDescription");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
-
+        // //how the XML was generated
+        // DerivedUnit derivedUnit =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        // derivedUnit.setUuid(derivedUnitUuid);
+        // SpecimenDescription specimenDescription =
+        // SpecimenDescription.NewInstance();
+        // specimenDescription.setUuid(specimenDescriptionUuid);
+        // derivedUnit.addDescription(specimenDescription);
+        // occurrenceService.save(derivedUnit);
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "Sequence_SingleRead",
+        // "SingleRead",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"
+        // }, "testIsDeletableWithSpecimenDescription");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
 
         DerivedUnit derivedUnit = (DerivedUnit) occurrenceService.load(derivedUnitUuid);
-        SpecimenDescription specimenDescription = (SpecimenDescription) descriptionService.load(specimenDescriptionUuid);
+        SpecimenDescription specimenDescription = (SpecimenDescription) descriptionService
+                .load(specimenDescriptionUuid);
 
         SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
         DeleteResult deleteResult = null;
-        //delete derivedUnit1
+        // delete derivedUnit1
         deleteResult = occurrenceService.isDeletable(derivedUnit, config);
         assertFalse(deleteResult.toString(), deleteResult.isOk());
 
-        //allow deletion from Descriptions
+        // allow deletion from Descriptions
         config.setDeleteFromDescription(true);
         deleteResult = occurrenceService.isDeletable(derivedUnit, config);
         assertTrue(deleteResult.toString(), deleteResult.isOk());
         occurrenceService.delete(derivedUnit, config);
-        specimenDescription =  (SpecimenDescription) descriptionService.find(specimenDescriptionUuid);
+        specimenDescription = (SpecimenDescription) descriptionService.find(specimenDescriptionUuid);
 
         assertNull(specimenDescription);
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testIsDeletableWithDescribedSpecimenInTaxonDescription.xml")
-    public void testIsDeletableWithDescribedSpecimenInTaxonDescription(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithDescribedSpecimenInTaxonDescription.xml")
+    public void testIsDeletableWithDescribedSpecimenInTaxonDescription() {
         UUID fieldUnitUuid = UUID.fromString("d656a004-38ee-404c-810a-87ffb0ab16c2");
-//        //how the XML was generated
-//        FieldUnit fieldUnit = FieldUnit.NewInstance();
-//        fieldUnit.setUuid(fieldUnitUuid);
-//        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//
-//        //derivation events
-//        DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.ACCESSIONING());
-//
-//        occurrenceService.save(fieldUnit);
-//        occurrenceService.save(derivedUnit);
-//
-//        // create taxon with name and two taxon descriptions
-//        //(one with a "described" voucher specimen, and an empty one)
-//        Taxon taxon = Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual sec L."), null);
-//        taxonDescription.setUuid(taxonDescriptionUuid);
-//        //add voucher
-//        taxonDescription.setDescribedSpecimenOrObservation(derivedUnit);
-//        taxon.addDescription(taxonDescription);
-//        //add another taxon description to taxon which is not associated with a specimen thus should not be taken into account
-//        taxon.addDescription(TaxonDescription.NewInstance());
-//        taxonService.saveOrUpdate(taxon);
-//
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "Sequence_SingleRead",
-//                    "SingleRead",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"
-//            }, "testIsDeletableWithDescribedSpecimenInTaxonDescription");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
+        // //how the XML was generated
+        // FieldUnit fieldUnit = FieldUnit.NewInstance();
+        // fieldUnit.setUuid(fieldUnitUuid);
+        // DerivedUnit derivedUnit =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        //
+        // //derivation events
+        // DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit,
+        // DerivationEventType.ACCESSIONING());
+        //
+        // occurrenceService.save(fieldUnit);
+        // occurrenceService.save(derivedUnit);
+        //
+        // // create taxon with name and two taxon descriptions
+        // //(one with a "described" voucher specimen, and an empty one)
+        // Taxon taxon =
+        // Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual sec L."),
+        // null);
+        // taxonDescription.setUuid(taxonDescriptionUuid);
+        // //add voucher
+        // taxonDescription.setDescribedSpecimenOrObservation(derivedUnit);
+        // taxon.addDescription(taxonDescription);
+        // //add another taxon description to taxon which is not associated with
+        // a specimen thus should not be taken into account
+        // taxon.addDescription(TaxonDescription.NewInstance());
+        // taxonService.saveOrUpdate(taxon);
+        //
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "Sequence_SingleRead",
+        // "SingleRead",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"
+        // }, "testIsDeletableWithDescribedSpecimenInTaxonDescription");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
 
         FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid);
 
         SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
         DeleteResult deleteResult = null;
-        //check deletion of field unit -> should fail because of voucher specimen (describedSpecimen) in TaxonDescription
+        // check deletion of field unit -> should fail because of voucher
+        // specimen (describedSpecimen) in TaxonDescription
         deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config);
         assertFalse(deleteResult.toString(), deleteResult.isOk());
 
-        //allow deletion from TaxonDescription and deletion of child derivates
+        // allow deletion from TaxonDescription and deletion of child derivates
         config.setDeleteFromDescription(true);
         config.setDeleteChildren(true);
         deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config);
@@ -615,69 +647,74 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testIsDeletableWithIndividualsAssociationTaxonDescription.xml")
-    public void testIsDeletableWithIndividualsAssociationTaxonDescription(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithIndividualsAssociationTaxonDescription.xml")
+    public void testIsDeletableWithIndividualsAssociationTaxonDescription() {
         UUID fieldUnitUuid = UUID.fromString("7978b978-5100-4c7a-82ef-3a23e0f3c723");
         UUID taxonDescriptionUuid = UUID.fromString("d4b0d561-6e7e-4fd8-bf3c-925530f949eb");
-//        //how the XML was generated
-//        FieldUnit fieldUnit = FieldUnit.NewInstance();
-//        fieldUnit.setUuid(fieldUnitUuid);
-//
-//        occurrenceService.save(fieldUnit);
-//
-//        // create taxon with name and two taxon descriptions (one with
-//        // IndividualsAssociations and a "described" voucher specimen, and an
-//        // empty one)
-//        Taxon taxon = Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual sec L."), null);
-//        TaxonDescription taxonDescription = TaxonDescription.NewInstance();
-//        taxonDescription.setUuid(taxonDescriptionUuid);
-//        //add voucher
-//        taxonDescription.addElement(IndividualsAssociation.NewInstance(fieldUnit));
-//        taxon.addDescription(taxonDescription);
-//        //add another taxon description to taxon which is not associated with a specimen thus should not be taken into account
-//        taxon.addDescription(TaxonDescription.NewInstance());
-//        taxonService.saveOrUpdate(taxon);
-//
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "Sequence_SingleRead",
-//                    "SingleRead",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"
-//            }, "testIsDeletableWithIndividualsAssociationTaxonDescription");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
+        // //how the XML was generated
+        // FieldUnit fieldUnit = FieldUnit.NewInstance();
+        // fieldUnit.setUuid(fieldUnitUuid);
+        //
+        // occurrenceService.save(fieldUnit);
+        //
+        // // create taxon with name and two taxon descriptions (one with
+        // // IndividualsAssociations and a "described" voucher specimen, and an
+        // // empty one)
+        // Taxon taxon =
+        // Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual sec L."),
+        // null);
+        // TaxonDescription taxonDescription = TaxonDescription.NewInstance();
+        // taxonDescription.setUuid(taxonDescriptionUuid);
+        // //add voucher
+        // taxonDescription.addElement(IndividualsAssociation.NewInstance(fieldUnit));
+        // taxon.addDescription(taxonDescription);
+        // //add another taxon description to taxon which is not associated with
+        // a specimen thus should not be taken into account
+        // taxon.addDescription(TaxonDescription.NewInstance());
+        // taxonService.saveOrUpdate(taxon);
+        //
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "Sequence_SingleRead",
+        // "SingleRead",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"
+        // }, "testIsDeletableWithIndividualsAssociationTaxonDescription");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
 
         FieldUnit associatedFieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid);
         TaxonDescription taxonDescription = (TaxonDescription) descriptionService.load(taxonDescriptionUuid);
-        IndividualsAssociation individualsAssociation = (IndividualsAssociation) taxonDescription.getElements().iterator().next();
+        IndividualsAssociation individualsAssociation = (IndividualsAssociation) taxonDescription.getElements()
+                .iterator().next();
 
         SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
         DeleteResult deleteResult = null;
-        //check deletion of field unit -> should fail because of IndividualAssociation
+        // check deletion of field unit -> should fail because of
+        // IndividualAssociation
         deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config);
         assertFalse(deleteResult.toString(), deleteResult.isOk());
         assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(individualsAssociation));
 
-        //allow deletion of individuals association
+        // allow deletion of individuals association
         config.setDeleteFromIndividualsAssociation(true);
         deleteResult = occurrenceService.isDeletable(associatedFieldUnit, config);
         assertTrue(deleteResult.toString(), deleteResult.isOk());
@@ -685,72 +722,74 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testIsDeletableWithTypeDesignation.xml")
-    public void testIsDeletableWithTypeDesignation(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithTypeDesignation.xml")
+    public void testIsDeletableWithTypeDesignation() {
         UUID derivedUnitUuid = UUID.fromString("f7fd1dc1-3c93-42a7-8279-cde5bfe37ea0");
         UUID botanicalNameUuid = UUID.fromString("7396430c-c932-4dd3-a45a-40c2808b132e");
-//        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//        derivedUnit.setUuid(derivedUnitUuid);
-//
-//        occurrenceService.save(derivedUnit);
-//
-//        //create name with type specimen
-//        BotanicalName name = BotanicalName.PARSED_NAME("Campanula patual sec L.");
-//        name.setUuid(botanicalNameUuid);
-//        SpecimenTypeDesignation typeDesignation = SpecimenTypeDesignation.NewInstance();
-//        typeDesignation.setTypeSpecimen(derivedUnit);
-//        //add type designation to name
-//        name.addTypeDesignation(typeDesignation, false);
-//
-//        nameService.saveOrUpdate(name);
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "Sequence_SingleRead",
-//                    "SingleRead",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"
-//            }, "testIsDeletableWithTypeDesignation");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
-
-
+        // DerivedUnit derivedUnit =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        // derivedUnit.setUuid(derivedUnitUuid);
+        //
+        // occurrenceService.save(derivedUnit);
+        //
+        // //create name with type specimen
+        // BotanicalName name =
+        // BotanicalName.PARSED_NAME("Campanula patual sec L.");
+        // name.setUuid(botanicalNameUuid);
+        // SpecimenTypeDesignation typeDesignation =
+        // SpecimenTypeDesignation.NewInstance();
+        // typeDesignation.setTypeSpecimen(derivedUnit);
+        // //add type designation to name
+        // name.addTypeDesignation(typeDesignation, false);
+        //
+        // nameService.saveOrUpdate(name);
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "Sequence_SingleRead",
+        // "SingleRead",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"
+        // }, "testIsDeletableWithTypeDesignation");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
 
         DerivedUnit typeSpecimen = (DerivedUnit) occurrenceService.load(derivedUnitUuid);
 
-        //create name with type specimen
+        // create name with type specimen
         BotanicalName name = (BotanicalName) nameService.load(botanicalNameUuid);
-        SpecimenTypeDesignation typeDesignation = (SpecimenTypeDesignation) name.getTypeDesignations().iterator().next();
+        SpecimenTypeDesignation typeDesignation = (SpecimenTypeDesignation) name.getTypeDesignations().iterator()
+                .next();
 
-        //add type designation to name
+        // add type designation to name
         name.addTypeDesignation(typeDesignation, false);
 
         SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
         DeleteResult deleteResult = null;
 
-        //check deletion of specimen
+        // check deletion of specimen
         deleteResult = occurrenceService.isDeletable(typeSpecimen, config);
         assertFalse(deleteResult.toString(), deleteResult.isOk());
         assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(typeDesignation));
 
-        //allow deletion of type designation
+        // allow deletion of type designation
         config.setDeleteFromTypeDesignation(true);
 
         deleteResult = occurrenceService.isDeletable(typeSpecimen, config);
@@ -758,93 +797,94 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testIsDeletableWithChildren.xml")
-
-    public void testIsDeletableWithChildren(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testIsDeletableWithChildren.xml")
+    public void testIsDeletableWithChildren() {
         UUID fieldUnitUuid = UUID.fromString("92ada058-4c14-4131-8ecd-b82dc1dd2882");
         UUID derivedUnitUuid = UUID.fromString("896dffdc-6809-4914-8950-5501fee1c0fd");
         UUID dnaSampleUuid = UUID.fromString("7efd1d66-ac7f-4202-acdf-a72cbb9c3a21");
-        //if this test fails be sure to check if there are left-over elements in the DB
-        //e.g. clear by adding "<AMPLIFICATIONRESULT/>" to the data set XML
-
-//        //how the XML was generated
-//        FieldUnit fieldUnit = FieldUnit.NewInstance();
-//        fieldUnit.setUuid(fieldUnitUuid);
-//        //sub derivates (DerivedUnit, DnaSample)
-//        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//        derivedUnit.setUuid(derivedUnitUuid);
-//        DnaSample dnaSample = DnaSample.NewInstance();
-//        dnaSample.setUuid(dnaSampleUuid);
-//
-//        //derivation events
-//        DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.ACCESSIONING());
-//        DerivationEvent.NewSimpleInstance(derivedUnit, dnaSample, DerivationEventType.DNA_EXTRACTION());
-//
-//        occurrenceService.save(fieldUnit);
-//        occurrenceService.save(derivedUnit);
-//        occurrenceService.save(dnaSample);
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "Sequence",
-//                    "SingleRead",
-//                    "SingleReadAlignment",
-//                    "Amplification",
-//                    "AmplificationResult",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup"
-//            }, "testIsDeletableWithChildren");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
+        // if this test fails be sure to check if there are left-over elements
+        // in the DB
+        // e.g. clear by adding "<AMPLIFICATIONRESULT/>" to the data set XML
+
+        // //how the XML was generated
+        // FieldUnit fieldUnit = FieldUnit.NewInstance();
+        // fieldUnit.setUuid(fieldUnitUuid);
+        // //sub derivates (DerivedUnit, DnaSample)
+        // DerivedUnit derivedUnit =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        // derivedUnit.setUuid(derivedUnitUuid);
+        // DnaSample dnaSample = DnaSample.NewInstance();
+        // dnaSample.setUuid(dnaSampleUuid);
+        //
+        // //derivation events
+        // DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit,
+        // DerivationEventType.ACCESSIONING());
+        // DerivationEvent.NewSimpleInstance(derivedUnit, dnaSample,
+        // DerivationEventType.DNA_EXTRACTION());
+        //
+        // occurrenceService.save(fieldUnit);
+        // occurrenceService.save(derivedUnit);
+        // occurrenceService.save(dnaSample);
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "Sequence",
+        // "SingleRead",
+        // "SingleReadAlignment",
+        // "Amplification",
+        // "AmplificationResult",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup"
+        // }, "testIsDeletableWithChildren");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
         FieldUnit fieldUnit = (FieldUnit) occurrenceService.load(fieldUnitUuid);
-        //sub derivates (DerivedUnit, DnaSample)
+        // sub derivates (DerivedUnit, DnaSample)
         DerivedUnit derivedUnit = (DerivedUnit) occurrenceService.load(derivedUnitUuid);
         DnaSample dnaSample = (DnaSample) occurrenceService.load(dnaSampleUuid);
 
-        //derivation events
+        // derivation events
         DerivationEvent fieldUnitToDerivedUnitEvent = fieldUnit.getDerivationEvents().iterator().next();
         DerivationEvent derivedUnitToDnaSampleEvent = derivedUnit.getDerivationEvents().iterator().next();
 
         SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
 
         DeleteResult deleteResult = null;
-        //check deletion of DnaSample
+        // check deletion of DnaSample
         deleteResult = occurrenceService.isDeletable(dnaSample, config);
         assertTrue(deleteResult.toString(), deleteResult.isOk());
 
-        //check deletion of Specimen
+        // check deletion of Specimen
         deleteResult = occurrenceService.isDeletable(derivedUnit, config);
         assertFalse(deleteResult.toString(), deleteResult.isOk());
         assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(derivedUnitToDnaSampleEvent));
 
-        //check deletion of fieldUnit
+        // check deletion of fieldUnit
         deleteResult = occurrenceService.isDeletable(fieldUnit, config);
         assertFalse(deleteResult.toString(), deleteResult.isOk());
         assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(fieldUnitToDerivedUnitEvent));
 
-
-
-        //check deletion of Specimen
+        // check deletion of Specimen
         config.setDeleteChildren(true);
         deleteResult = occurrenceService.isDeletable(derivedUnit, config);
         assertTrue(deleteResult.toString(), deleteResult.isOk());
         assertTrue(deleteResult.toString(), deleteResult.getRelatedObjects().contains(derivedUnitToDnaSampleEvent));
 
-        //check deletion of fieldUnit
+        // check deletion of fieldUnit
         config.setDeleteFromDescription(true);
         deleteResult = occurrenceService.isDeletable(fieldUnit, config);
         assertTrue(deleteResult.toString(), deleteResult.isOk());
@@ -852,8 +892,8 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
     }
 
     @Test
-    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="OccurrenceServiceTest.testFindOcurrences.xml")
-    public void testFindOccurrences(){
+    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testFindOcurrences.xml")
+    public void testFindOccurrences() {
         UUID derivedUnit1Uuid = UUID.fromString("843bc8c9-c0fe-4735-bf40-82f1996dcefb");
         UUID derivedUnit2Uuid = UUID.fromString("40cd9cb1-7c74-4e7d-a1f8-8a1e0314e940");
         UUID dnaSampleUuid = UUID.fromString("364969a6-2457-4e2e-ae1e-29a6fcaa741a");
@@ -861,63 +901,70 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
 
         UUID taxonUuid = UUID.fromString("dfca7629-8a60-4d51-998d-371897f725e9");
 
-//        DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
-//        derivedUnit.setTitleCache("testUnit1");
-//        derivedUnit.setAccessionNumber("ACC1");
-//        DerivedUnit derivedUnit2 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
-//        derivedUnit2.setTitleCache("testUnit2");
-//        derivedUnit2.setBarcode("ACC2");
-//        DerivedUnit dnaSample = DerivedUnit.NewInstance(SpecimenOrObservationType.DnaSample);
-//        dnaSample.setTitleCache("dna");
-//        dnaSample.setCatalogNumber("ACC1");
-//        DerivedUnit tissue = DerivedUnit.NewInstance(SpecimenOrObservationType.TissueSample);
-//        tissue.setTitleCache("tissue");
-//
-//        DerivationEvent.NewSimpleInstance(derivedUnit, dnaSample, DerivationEventType.DNA_EXTRACTION());
-//
-//        derivedUnit.setUuid(derivedUnit1Uuid);
-//        derivedUnit2.setUuid(derivedUnit2Uuid);
-//        dnaSample.setUuid(dnaSampleUuid);
-//        tissue.setUuid(tissueUuid);
-//
-//        occurrenceService.save(derivedUnit);
-//        occurrenceService.save(derivedUnit2);
-//        occurrenceService.save(dnaSample);
-//        occurrenceService.save(tissue);
-//
-//        Taxon taxon = Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual"), null);
-//        taxon.setUuid(taxonUuid);
-//        TaxonDescription taxonDescription = TaxonDescription.NewInstance();
-//        taxonDescription.setUuid(UUID.fromString("272d4d28-662c-468e-94d8-16993fab91ba"));
-//        //add voucher
-//        taxonDescription.addElement(IndividualsAssociation.NewInstance(derivedUnit));
-//        taxonDescription.addElement(IndividualsAssociation.NewInstance(tissue));
-//        taxon.addDescription(taxonDescription);
-//        taxonService.saveOrUpdate(taxon);
-//
-//        commitAndStartNewTransaction(null);
-//
-//        setComplete();
-//        endTransaction();
-//
-//
-//        try {
-//            writeDbUnitDataSetFile(new String[] {
-//                    "SpecimenOrObservationBase",
-//                    "SpecimenOrObservationBase_DerivationEvent",
-//                    "DerivationEvent",
-//                    "DescriptionElementBase",
-//                    "DescriptionBase",
-//                    "TaxonBase",
-//                    "TypeDesignationBase",
-//                    "TaxonNameBase",
-//                    "TaxonNameBase_TypeDesignationBase",
-//                    "HomotypicalGroup",
-//                    "TeamOrPersonBase"
-//            }, "testFindOcurrences");
-//        } catch (FileNotFoundException e) {
-//            e.printStackTrace();
-//        }
+        // DerivedUnit derivedUnit =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.Fossil);
+        // derivedUnit.setTitleCache("testUnit1");
+        // derivedUnit.setAccessionNumber("ACC1");
+        // DerivedUnit derivedUnit2 =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+        // derivedUnit2.setTitleCache("testUnit2");
+        // derivedUnit2.setBarcode("ACC2");
+        // DerivedUnit dnaSample =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.DnaSample);
+        // dnaSample.setTitleCache("dna");
+        // dnaSample.setCatalogNumber("ACC1");
+        // DerivedUnit tissue =
+        // DerivedUnit.NewInstance(SpecimenOrObservationType.TissueSample);
+        // tissue.setTitleCache("tissue");
+        //
+        // DerivationEvent.NewSimpleInstance(derivedUnit, dnaSample,
+        // DerivationEventType.DNA_EXTRACTION());
+        //
+        // derivedUnit.setUuid(derivedUnit1Uuid);
+        // derivedUnit2.setUuid(derivedUnit2Uuid);
+        // dnaSample.setUuid(dnaSampleUuid);
+        // tissue.setUuid(tissueUuid);
+        //
+        // occurrenceService.save(derivedUnit);
+        // occurrenceService.save(derivedUnit2);
+        // occurrenceService.save(dnaSample);
+        // occurrenceService.save(tissue);
+        //
+        // Taxon taxon =
+        // Taxon.NewInstance(BotanicalName.PARSED_NAME("Campanula patual"),
+        // null);
+        // taxon.setUuid(taxonUuid);
+        // TaxonDescription taxonDescription = TaxonDescription.NewInstance();
+        // taxonDescription.setUuid(UUID.fromString("272d4d28-662c-468e-94d8-16993fab91ba"));
+        // //add voucher
+        // taxonDescription.addElement(IndividualsAssociation.NewInstance(derivedUnit));
+        // taxonDescription.addElement(IndividualsAssociation.NewInstance(tissue));
+        // taxon.addDescription(taxonDescription);
+        // taxonService.saveOrUpdate(taxon);
+        //
+        // commitAndStartNewTransaction(null);
+        //
+        // setComplete();
+        // endTransaction();
+        //
+        //
+        // try {
+        // writeDbUnitDataSetFile(new String[] {
+        // "SpecimenOrObservationBase",
+        // "SpecimenOrObservationBase_DerivationEvent",
+        // "DerivationEvent",
+        // "DescriptionElementBase",
+        // "DescriptionBase",
+        // "TaxonBase",
+        // "TypeDesignationBase",
+        // "TaxonNameBase",
+        // "TaxonNameBase_TypeDesignationBase",
+        // "HomotypicalGroup",
+        // "TeamOrPersonBase"
+        // }, "testFindOcurrences");
+        // } catch (FileNotFoundException e) {
+        // e.printStackTrace();
+        // }
 
         SpecimenOrObservationBase derivedUnit1 = occurrenceService.load(derivedUnit1Uuid);
         SpecimenOrObservationBase derivedUnit2 = occurrenceService.load(derivedUnit2Uuid);
@@ -931,7 +978,7 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertNotNull(dnaSample);
         assertNotNull(taxon);
 
-        //wildcard search => all derivates
+        // wildcard search => all derivates
         FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
         config.setTitleSearchString("*");
         assertEquals(4, occurrenceService.countOccurrences(config));
@@ -942,24 +989,24 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertTrue(allDerivates.contains(tissue));
         assertTrue(allDerivates.contains(dnaSample));
 
-        //queryString search => 2 derivates
+        // queryString search => 2 derivates
         config = new FindOccurrencesConfigurator();
         config.setTitleSearchString("test*");
-//        config.setClazz(SpecimenOrObservationBase.class);
+        // config.setClazz(SpecimenOrObservationBase.class);
         assertEquals(2, occurrenceService.countOccurrences(config));
         List<SpecimenOrObservationBase> queryStringDerivates = occurrenceService.findByTitle(config).getRecords();
         assertEquals(2, queryStringDerivates.size());
         assertTrue(queryStringDerivates.contains(derivedUnit1));
         assertTrue(queryStringDerivates.contains(derivedUnit2));
 
-        //class search => 0 results
+        // class search => 0 results
         config = new FindOccurrencesConfigurator();
         config.setClazz(FieldUnit.class);
         assertEquals(0, occurrenceService.countOccurrences(config));
         List<SpecimenOrObservationBase> fieldUnits = occurrenceService.findByTitle(config).getRecords();
         assertEquals(0, fieldUnits.size());
 
-        //class search => 4 results
+        // class search => 4 results
         config = new FindOccurrencesConfigurator();
         config.setClazz(DerivedUnit.class);
         assertEquals(4, occurrenceService.countOccurrences(config));
@@ -970,7 +1017,7 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertTrue(derivedUnits.contains(tissue));
         assertTrue(derivedUnits.contains(dnaSample));
 
-        //significant identifier search
+        // significant identifier search
         config = new FindOccurrencesConfigurator();
         config.setClazz(DerivedUnit.class);
         config.setSignificantIdentifier("ACC1");
@@ -993,8 +1040,7 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertFalse(barcodedUnits.contains(tissue));
         assertFalse(barcodedUnits.contains(dnaSample));
 
-
-        //recordBasis search => 1 Fossil
+        // recordBasis search => 1 Fossil
         config = new FindOccurrencesConfigurator();
         config.setSpecimenType(SpecimenOrObservationType.Fossil);
         assertEquals(1, occurrenceService.countOccurrences(config));
@@ -1002,7 +1048,7 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertEquals(1, fossils.size());
         assertTrue(fossils.contains(derivedUnit1));
 
-        //taxon determination search => 2 associated specimens
+        // taxon determination search => 2 associated specimens
         config = new FindOccurrencesConfigurator();
         config.setClazz(DerivedUnit.class);
         config.setAssociatedTaxonUuid(taxon.getUuid());
@@ -1012,19 +1058,23 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         assertTrue(associatedSpecimens.contains(derivedUnit1));
         assertTrue(associatedSpecimens.contains(tissue));
 
-        //taxon determination search (indirectly associated) => 3 associated specimens
+        // taxon determination search (indirectly associated) => 3 associated
+        // specimens
         config = new FindOccurrencesConfigurator();
         config.setClazz(DerivedUnit.class);
         config.setAssociatedTaxonUuid(taxon.getUuid());
         config.setRetrieveIndirectlyAssociatedSpecimens(true);
         assertEquals(3, occurrenceService.countOccurrences(config));
-        List<SpecimenOrObservationBase> indirectlyAssociatedSpecimens = occurrenceService.findByTitle(config).getRecords();
+        List<SpecimenOrObservationBase> indirectlyAssociatedSpecimens = occurrenceService.findByTitle(config)
+                .getRecords();
         assertEquals(3, indirectlyAssociatedSpecimens.size());
         assertTrue(indirectlyAssociatedSpecimens.contains(derivedUnit1));
         assertTrue(indirectlyAssociatedSpecimens.contains(dnaSample));
         assertTrue(indirectlyAssociatedSpecimens.contains(tissue));
 
-        //using the super class will lead to 0 results because listByAssociatedTaxon does type matching which obviously does not understand inheritance
+        // using the super class will lead to 0 results because
+        // listByAssociatedTaxon does type matching which obviously does not
+        // understand inheritance
         config = new FindOccurrencesConfigurator();
         config.setClazz(SpecimenOrObservationBase.class);
         config.setAssociatedTaxonUuid(taxon.getUuid());
@@ -1034,11 +1084,14 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
 
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
      */
     @Override
-//    @Test
+    // @Test
     public void createTestDataSet() throws FileNotFoundException {
         UUID derivedUnit1Uuid = UUID.fromString("843bc8c9-c0fe-4735-bf40-82f1996dcefb");
         UUID derivedUnit2Uuid = UUID.fromString("40cd9cb1-7c74-4e7d-a1f8-8a1e0314e940");
@@ -1075,7 +1128,7 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         taxon.setUuid(taxonUuid);
         TaxonDescription taxonDescription = TaxonDescription.NewInstance();
         taxonDescription.setUuid(UUID.fromString("272d4d28-662c-468e-94d8-16993fab91ba"));
-        //add voucher
+        // add voucher
         taxonDescription.addElement(IndividualsAssociation.NewInstance(derivedUnit));
         taxonDescription.addElement(IndividualsAssociation.NewInstance(tissue));
         taxon.addDescription(taxonDescription);
@@ -1086,21 +1139,11 @@ public class OccurrenceServiceTest extends CdmTransactionalIntegrationTest {
         setComplete();
         endTransaction();
 
-
         try {
-            writeDbUnitDataSetFile(new String[] {
-                    "SpecimenOrObservationBase",
-                    "SpecimenOrObservationBase_DerivationEvent",
-                    "DerivationEvent",
-                    "DescriptionElementBase",
-                    "DescriptionBase",
-                    "TaxonBase",
-                    "TypeDesignationBase",
-                    "TaxonNameBase",
-                    "TaxonNameBase_TypeDesignationBase",
-                    "HomotypicalGroup",
-                    "TeamOrPersonBase"
-            }, "testFindOcurrences");
+            writeDbUnitDataSetFile(new String[] { "SpecimenOrObservationBase",
+                    "SpecimenOrObservationBase_DerivationEvent", "DerivationEvent", "DescriptionElementBase",
+                    "DescriptionBase", "TaxonBase", "TypeDesignationBase", "TaxonNameBase",
+                    "TaxonNameBase_TypeDesignationBase", "HomotypicalGroup", "TeamOrPersonBase" }, "testFindOcurrences");
         } catch (FileNotFoundException e) {
             e.printStackTrace();
         }
index d4a8e49b65dd8d9af62a0f324f92a0e1fe9f79ba..e71ffbc29caacd660225e8d15c94cb0307ad7171 100644 (file)
@@ -29,9 +29,9 @@ import org.unitils.spring.annotation.SpringBeanByType;
 \r
 import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;\r
 import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;\r
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;\r
 import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;\r
 import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;\r
 import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;\r
 import eu.etaxonomy.cdm.datagenerator.TaxonGenerator;\r