Project

General

Profile

Revision 08a698af

ID08a698afd5a98944fb4558599fc04dc24282a51a
Parent 88b1995d
Child 7ae6b88e

Added by Katja Luther about 5 years ago

ref #6099: removing cascading to child nodes and adapting the service and persistence layer

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Classification.java
252 252
        if(!rootNode.getChildNodes().contains(node)){
253 253
            throw new IllegalArgumentException("TaxonNode is a not a root node of this classification");
254 254
        }
255

  
255
        rootNode = HibernateProxyHelper.deproxy(rootNode, TaxonNode.class);
256 256
        result = rootNode.removeChildNode(node);
257 257

  
258 258
        node.setParent(null);
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNode.java
127 127
    @OrderColumn(name="sortIndex")
128 128
    @OrderBy("sortIndex")
129 129
    @OneToMany(mappedBy="parent", fetch=FetchType.LAZY)
130
    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
130
    //@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
131 131
    private List<TaxonNode> childNodes = new ArrayList<TaxonNode>();
132 132

  
133 133
    //see https://dev.e-taxonomy.eu/trac/ticket/3722
......
441 441
    @Override
442 442
    public boolean deleteChildNode(TaxonNode node) {
443 443
        boolean result = removeChildNode(node);
444
        Taxon taxon = node.getTaxon();
444
        Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
445
        node = HibernateProxyHelper.deproxy(node, TaxonNode.class);
445 446
        node.setTaxon(null);
446
        taxon.removeTaxonNode(node);
447

  
447 448

  
448 449
        ArrayList<TaxonNode> childNodes = new ArrayList<TaxonNode>(node.getChildNodes());
449 450
        for(TaxonNode childNode : childNodes){
451
            HibernateProxyHelper.deproxy(childNode, TaxonNode.class);
450 452
            node.deleteChildNode(childNode);
451 453
        }
452

  
454
        taxon.removeTaxonNode(node);
453 455
        return result;
454 456
    }
455 457

  
......
617 619
        //FIXME also set the tree index here for performance reasons
618 620
        classification = HibernateProxyHelper.deproxy(classification, Classification.class);
619 621
        setClassificationRecursively(classification);
620

  
621 622
        // add this node to the parent's child nodes
622 623
        parent = HibernateProxyHelper.deproxy(parent, TaxonNode.class);
623 624
        List<TaxonNode> parentChildren = parent.getChildNodes();
624 625
       //TODO: Only as a workaround. We have to find out why merge creates null entries.
625 626

  
626
        HHH_9751_Util.removeAllNull(parentChildren);
627
        parent.updateSortIndex(0);
627
//        HHH_9751_Util.removeAllNull(parentChildren);
628
//        parent.updateSortIndex(0);
628 629
        if (index > parent.getChildNodes().size()){
629 630
            index = parent.getChildNodes().size();
630 631
        }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TaxonNameDaoHibernateImpl.java
20 20
import org.hibernate.Query;
21 21
import org.hibernate.SQLQuery;
22 22
import org.hibernate.criterion.Criterion;
23
import org.hibernate.criterion.LogicalExpression;
23 24
import org.hibernate.criterion.Order;
24 25
import org.hibernate.criterion.Projections;
25 26
import org.hibernate.criterion.Restrictions;
......
29 30
import org.springframework.beans.factory.annotation.Qualifier;
30 31
import org.springframework.stereotype.Repository;
31 32

  
33
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
32 34
import eu.etaxonomy.cdm.model.common.CdmBase;
33 35
import eu.etaxonomy.cdm.model.common.RelationshipBase;
34 36
import eu.etaxonomy.cdm.model.name.BacterialName;
......
533 535
            MatchMode matchmode, Integer pageSize, Integer pageNumber, List<Criterion> criteria, List<String> propertyPaths) {
534 536

  
535 537
        Criteria crit = getSession().createCriteria(type);
538
        Criterion nameCacheLike;
536 539
        if (matchmode == MatchMode.EXACT) {
537
            crit.add(Restrictions.eq("nameCache", matchmode.queryStringFrom(queryString)));
540
            nameCacheLike = Restrictions.eq("nameCache", matchmode.queryStringFrom(queryString));
538 541
        } else {
539
            crit.add(Restrictions.ilike("nameCache", matchmode.queryStringFrom(queryString)));
542
            nameCacheLike =Restrictions.ilike("nameCache", matchmode.queryStringFrom(queryString));
540 543
        }
544
        Criterion notNull = Restrictions.isNotNull("nameCache");
545
        LogicalExpression locExpression = Restrictions.and(notNull, nameCacheLike);
546
        Criterion titleCacheLike;
547
        if (matchmode == MatchMode.EXACT) {
548
            titleCacheLike = Restrictions.eq("titleCache", matchmode.queryStringFrom(queryString));
549
        } else {
550
            titleCacheLike =Restrictions.ilike("titleCache", matchmode.queryStringFrom(queryString));
551
        }
552
        Criterion isNull = Restrictions.isNull("nameCache");
553
        LogicalExpression locExpression2 = Restrictions.and(isNull, titleCacheLike);
554
        LogicalExpression orExpression = Restrictions.or(locExpression2, locExpression);
555
        crit.add(orExpression);
541 556
        if(criteria != null){
542 557
            for (Criterion criterion : criteria) {
543 558
                crit.add(criterion);
......
740 755
        }
741 756
        getSession().saveOrUpdate(persistentObject);
742 757
        UUID persUuid = persistentObject.getUuid();
743
        persistentObject = this.load(persUuid);
758
       // persistentObject = this.load(persUuid);
744 759
        UUID homotypicalGroupUUID = persistentObject.getHomotypicalGroup().getUuid();
745 760

  
746 761

  
......
748 763
            taxonDao.delete(taxonBase);
749 764
        }
750 765
        HomotypicalGroup homotypicalGroup = homotypicalGroupDao.load(homotypicalGroupUUID);
766
        homotypicalGroup = HibernateProxyHelper.deproxy(homotypicalGroup, HomotypicalGroup.class);
751 767

  
752 768
        if (homotypicalGroup != null){
753 769
            if (homotypicalGroup.getTypifiedNames().contains(persistentObject)){
754 770
                homotypicalGroup.getTypifiedNames().remove(persistentObject);
755 771
                homotypicalGroupDao.saveOrUpdate(homotypicalGroup);
756 772
            }
757
            if (homotypicalGroup.getTypifiedNames().isEmpty()){
758
        		homotypicalGroupDao.delete(homotypicalGroup);
759
        	}
773

  
760 774
        }
761 775

  
762 776
        getSession().delete(persistentObject);
777
        if (homotypicalGroup.getTypifiedNames().isEmpty()){
778
            homotypicalGroupDao.delete(homotypicalGroup);
779
        }
763 780
        return persistentObject.getUuid();
764 781
    }
765 782

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/ClassificationDaoHibernateImpl.java
260 260
//        Iterator<TaxonNode> nodesIterator = nodes.iterator();
261 261
        for(TaxonNode node : nodesTmp){
262 262
            persistentObject.deleteChildNode(node, true);
263

  
263 264
            taxonNodeDao.delete(node, true);
264 265
        }
265 266

  
266 267
        TaxonNode rootNode = persistentObject.getRootNode();
267 268
        persistentObject.removeRootNode();
268 269
        taxonNodeDao.delete(rootNode);
269
        super.delete(persistentObject);
270
        UUID uuid =super.delete(persistentObject);
271

  
270 272

  
271 273
        return persistentObject.getUuid();
272 274
    }
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
901 901
        // I think this is preferable to catching lazy initialization errors
902 902
        // as that solution only swallows and hides the exception, but doesn't
903 903
        // actually solve it.
904
        getSession().merge(taxonBase);
904
        taxonBase = (TaxonBase)getSession().merge(taxonBase);
905 905

  
906 906
        taxonBase.removeSources();
907

  
908
        if (taxonBase instanceof Taxon){ //	is Taxon
909
            for (Iterator<TaxonRelationship> iterator = ((Taxon)taxonBase).getRelationsFromThisTaxon().iterator(); iterator.hasNext();){
910
                TaxonRelationship relationFromThisTaxon = iterator.next();
911

  
912
            }
913
        }
914

  
915
       return super.delete(taxonBase);
907
        return super.delete(taxonBase);
916 908

  
917 909
    }
918 910

  
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
11 11
package eu.etaxonomy.cdm.persistence.dao.hibernate.taxon;
12 12

  
13 13
import java.math.BigInteger;
14
import java.util.ArrayList;
14 15
import java.util.HashMap;
16
import java.util.Iterator;
15 17
import java.util.List;
16 18
import java.util.Map;
17 19
import java.util.Set;
......
19 21

  
20 22
import org.apache.log4j.Logger;
21 23
import org.hibernate.Criteria;
24
import org.hibernate.Hibernate;
22 25
import org.hibernate.Query;
23 26
import org.hibernate.criterion.Projections;
24 27
import org.hibernate.criterion.Restrictions;
......
66 69
		query.setParameter("taxon", taxon);
67 70
		List result = query.list();*/
68 71
		if (taxon != null){
72
		    Hibernate.initialize(taxon);
73
		    Hibernate.initialize(taxon.getTaxonNodes());
69 74
			Set<TaxonNode> nodes = taxon.getTaxonNodes();
70

  
71
			if (nodes.size()==1){
72

  
73
				TaxonNode node = nodes.iterator().next();
74
				node = HibernateProxyHelper.deproxy(node, TaxonNode.class);
75

  
76
				taxon.removeTaxonNode(node, deleteChildren);
77
				taxonDao.delete(taxon);
75
			//Hibernate.initialize(taxon.getTaxonNodes());
76
			for (TaxonNode node:nodes) {
77
			    System.out.println("Number of nodes: " + nodes.size());
78
                node = HibernateProxyHelper.deproxy(node, TaxonNode.class);
79

  
80
			    if (node.equals(persistentObject)){
81
			        if (node.hasChildNodes()){
82
			            Iterator<TaxonNode> childNodes = node.getChildNodes().iterator();
83
			            TaxonNode childNode;
84
			            List<TaxonNode> listForDeletion = new ArrayList<TaxonNode>();
85
	                    while (childNodes.hasNext()){
86
	                        childNode = childNodes.next();
87
	                        listForDeletion.add(childNode);
88
	                        childNodes.remove();
89

  
90
	                    }
91
	                    for (TaxonNode deleteNode:listForDeletion){
92
	                        delete(deleteNode, deleteChildren);
93
	                    }
94
	                }
95

  
96
			        taxon.removeTaxonNode(node, deleteChildren);
97
			        taxonDao.saveOrUpdate(taxon);
98
    				taxon = HibernateProxyHelper.deproxy(taxonDao.findByUuid(taxon.getUuid()), Taxon.class);
99
    				taxonDao.delete(taxon);
100

  
101
			    }
78 102
			}
79 103
		}
80
		//persistentObject.delete();
81

  
82
		super.delete(persistentObject);
83

  
84 104

  
105
		UUID result = super.delete(persistentObject);
85 106

  
86
		//taxon = (Taxon)taxonDao.findByUuid(taxon.getUuid());
87
		return persistentObject.getUuid();
107
		return result;
88 108
	}
89 109

  
90 110
	@Override
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/CdmGenericDaoImplTest.java
31 31
import org.junit.Before;
32 32
import org.junit.Test;
33 33
import org.unitils.dbunit.annotation.DataSet;
34
import org.unitils.dbunit.annotation.DataSets;
34 35
import org.unitils.spring.annotation.SpringBeanByType;
35 36

  
36 37
import eu.etaxonomy.cdm.model.agent.Address;
......
168 169
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy;
169 170
import eu.etaxonomy.cdm.strategy.merge.MergeException;
170 171
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
172
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
171 173

  
172 174
/**
173 175
 * @author a.mueller
......
200 202
// ***************** TESTS **************************************************
201 203

  
202 204
	@Test
205
	@DataSets({
206
     @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
207
     @DataSet("/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")})
203 208
	public void testDelete(){
204 209
		Reference ref1 = ReferenceFactory.newBook();
205 210
		Reference ref2 = ReferenceFactory.newBook();
206 211
		Annotation annotation = Annotation.NewInstance("Anno1", null);
207 212
		ref1.addAnnotation(annotation);
208
		cdmGenericDao.saveOrUpdate(ref1);
209
		cdmGenericDao.saveOrUpdate(ref2);
210
		taxonDao.flush();
213
		UUID ref1Uuid = cdmGenericDao.saveOrUpdate(ref1);
214
		UUID ref2Uuid = cdmGenericDao.saveOrUpdate(ref2);
215
		List<Reference> list = cdmGenericDao.list(Reference.class, 10, 0, null, null);
216
        System.out.println("ref1: " + ref1Uuid + " ref2: " + ref2Uuid);
217
        for (Reference ref: list){
218
            System.out.println("reference: " + ref.getUuid());
219
        }
211 220
		try {
212 221
			cdmGenericDao.merge(ref2, ref1, null);
213
			taxonDao.flush();
222

  
214 223
		} catch (MergeException e) {
215 224
			Assert.fail();
216 225
		}
217
		cdmGenericDao.delete(ref1);
218
		taxonDao.flush();
226
		commitAndStartNewTransaction(null);
227
		list = cdmGenericDao.list(Reference.class, 10, 0, null, null);
228
		System.out.println("ref1: " + ref1Uuid + " ref2: " + ref2Uuid);
229
        for (Reference ref: list){
230
            System.out.println("reference: " + ref.getUuid());
231
        }
232
		Assert.assertEquals(1, list.size());
233

  
219 234
	}
220 235

  
221 236

  
......
394 409
	 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmGenericDaoImpl#getReferencingObjects(CdmBase)}.
395 410
	 */
396 411
	@Test
412
	@DataSets({
413
	     @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
414
	     @DataSet("/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")})
397 415
	public void testGetReferencingObjectsCdmBase() {
398 416
		BotanicalName name = BotanicalName.NewInstance(Rank.SPECIES());
399 417
		name.setTitleCache("A name", true);
......
410 428
		taxonDao.save(taxon);
411 429
//		UUID uuid = UUID.fromString("613980ac-9bd5-43b9-a374-d71e1794688f");
412 430
//		Reference ref1 = referenceService.findByUuid(uuid);
413

  
431
		commitAndStartNewTransaction(null);
414 432

  
415 433
		Set<CdmBase> referencedObjects = cdmGenericDao.getReferencingObjects(ref1);
416 434
		String debug = "############## RESULT ###################";
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/DefinedTermDaoImplTest.java
311 311
         Assert.assertEquals("There should be exactly 1 more term now", nExistingTerms + 1 , nTermsNow);
312 312

  
313 313

  
314
         List<DefinedTerm> languages = this.dao.listByTermType(TermType.Language, null, null, null, null);
315
         Assert.assertNotNull(languages);
316
         Assert.assertEquals(485, languages.size());
314 317
	 }
315 318

  
316 319

  
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TaxonNameDaoHibernateImplTest.java
28 28

  
29 29
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
30 30
import eu.etaxonomy.cdm.model.name.BotanicalName;
31
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
31 32
import eu.etaxonomy.cdm.model.name.HybridRelationship;
32 33
import eu.etaxonomy.cdm.model.name.NameRelationship;
33 34
import eu.etaxonomy.cdm.model.name.Rank;
......
36 37
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
37 38
import eu.etaxonomy.cdm.model.name.ZoologicalName;
38 39
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
40
import eu.etaxonomy.cdm.persistence.dao.name.IHomotypicalGroupDao;
39 41
import eu.etaxonomy.cdm.persistence.dao.name.ITaxonNameDao;
40 42
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
41 43
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
......
50 52
    @SpringBeanByType
51 53
    ITaxonDao taxonDao;
52 54

  
55
    @SpringBeanByType
56
    IHomotypicalGroupDao homotypicalGroupDao;
57

  
53 58
    private UUID cryptocoryneGriffithiiUuid;
54 59
    private UUID acherontiaUuid;
55 60
    private UUID acherontiaLachesisUuid;
......
212 217
        TaxonNameBase acherontiaLachesis = taxonNameDao.findByUuid(UUID.fromString("497a9955-5c5a-4f2b-b08c-2135d336d633"));
213 218
        HibernateProxyHelper.deproxy(acherontiaLachesis, TaxonNameBase.class);
214 219
        Set<TaxonBase> taxonBases = acherontiaLachesis.getTaxonBases();
220
        HomotypicalGroup group = acherontiaLachesis.getHomotypicalGroup();
221
        UUID groupUuid = group.getUuid();
215 222
        taxonNameDao.delete(acherontiaLachesis);
223

  
216 224
        Iterator<TaxonBase> taxa= taxonBases.iterator();
217 225
        TaxonBase taxon = taxa.next();
218 226
        UUID taxonUuid = taxon.getUuid();
219
        //acherontiaLachesis.removeTaxonBase(taxon);
220
        //taxonDao.save(taxon);
221
        taxonDao.flush();
227
        
222 228
        //int numbOfTaxa = taxonDao.count(TaxonBase.class);
223 229
        List<TaxonBase> taxaList = taxonDao.getAllTaxonBases(100, 0);
224
        taxonNameDao.flush();
230
      
225 231
        acherontiaLachesis = taxonNameDao.findByUuid(UUID.fromString("497a9955-5c5a-4f2b-b08c-2135d336d633"));
226 232
        taxon = taxonDao.findByUuid(taxonUuid);
233
        group = homotypicalGroupDao.findByUuid(groupUuid);
234
        group = HibernateProxyHelper.deproxy(group, HomotypicalGroup.class);
227 235
        assertNull("There should be no taxonName with the deleted uuid", acherontiaLachesis);
228 236
        assertNull("There should be no taxon with the deleted uuid", taxon);
237
        assertNull("There should be no homotypicalGroup with the deleted uuid", group);
229 238

  
230 239
    }
231 240

  
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/name/TypeDesignationDaoHibernateImplTest.java
301 301
			this.endTransaction();
302 302
			Assert.fail("desig1 should not be deletable as it is still connected to name2");
303 303
		}catch (Exception e){
304
			//OK
304
		    //this.setComplete();
305
            this.endTransaction();
305 306
			this.startNewTransaction();
306 307
		}
307 308
		name2 = (BotanicalName)nameDao.load(name2.getUuid());
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/statistics/StatisticsDaoHibernateImplTest.java
179 179
		for (Classification classification : classifications) {
180 180
			TaxonNode root;
181 181
			root= createTaxTree(classification);
182

  
182 183
			result=statisticsDao.getAllChildNodeIds(root.getUuid());
183 184
			System.out.println("classification "+ classification.getName()+": ");
184 185
			System.out.println("result: "+result.toString());
......
513 514
		Random rand = new Random();
514 515

  
515 516
			Set<TaxonNode> nodes = classification.getAllNodes();
516
			ArrayList<TaxonNode> children = new ArrayList<TaxonNode>();
517
			ArrayList<TaxonNode> children = new ArrayList<>();
517 518
			TaxonNode parent = nodes.iterator().next();
518 519

  
519 520
			TaxonNode root = parent;
......
522 523
				int n = rand.nextInt(2) + 1;
523 524
				for (int i = 1; i <= n && !(nodes.isEmpty()); i++) {
524 525
					TaxonNode nextNode = nodes.iterator().next();
525
					parent.getChildNodes().add(nextNode);
526
					nextNode = parent.addChildNode(nextNode, null, null);
526 527
					children.add(nextNode);
527 528
					nodes.remove(nextNode);
528 529
				}
529
				taxonNodeDao.save(parent);
530

  
530 531
				parent = children.get(0);
531 532
				children.remove(0);
532 533
			}
534

  
533 535
		return root;
534 536
	}
535 537

  
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java
11 11

  
12 12
import static org.junit.Assert.assertEquals;
13 13
import static org.junit.Assert.assertNotNull;
14
import static org.junit.Assert.assertNull;
14 15

  
15 16
import java.io.FileNotFoundException;
16 17
import java.util.Arrays;
......
127 128
        taxNode = HibernateProxyHelper.deproxy(taxNode, TaxonNode.class);
128 129
        taxNode2 = HibernateProxyHelper.deproxy(taxNode2, TaxonNode.class);
129 130
        TaxonNode rootNode = HibernateProxyHelper.deproxy(classification.getRootNode(), TaxonNode.class);
130
        rootNode.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null), null, null);
131
        TaxonNode newNode = rootNode.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null), null, null);
132
        taxonNodeDao.saveOrUpdate(newNode);
131 133
        taxonNodeDao.delete(taxNode3, true);
134

  
135
        assertNull(taxonNodeDao.findByUuid(taxNode3.getUuid()));
132 136
        classification = classificationDao.findByUuid(ClassificationUuid);
133 137

  
134 138
        taxa = taxonDao.getAllTaxonBases(10, 0);
135
        assertEquals("there should be 7 taxa left", 7, taxa.size());
136
        taxonNodeDao.flush();
139
        // There should be 4 taxonBases: at the beginning 6 in the classification + 1 orphan taxon; 1 new created taxon -> 8: delete node3 deleted 4 taxa -> 4 taxa left.
140
        assertEquals("there should be 4 taxa left", 4, taxa.size());
141

  
137 142
        classificationDao.delete(classification);
138 143
        classification = null;
139 144

  
140
        classificationDao.flush();
145
       // classificationDao.flush();
141 146
        classification = classificationDao.findByUuid(ClassificationUuid);
142 147
        assertEquals("The tree should be null", null, classification);
143 148

  
......
186 191
        Taxon taxon = Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null);
187 192
        Taxon taxon1 = Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null);
188 193
        Taxon taxon2 = Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null);
189
        taxNode.addChildTaxon(taxon, null, null);
190
        taxNode2.addChildTaxon(taxon1, null, null);
191
        taxNode3.addChildTaxon(taxon2, null, null);
194
        TaxonNode child = taxNode.addChildTaxon(taxon, null, null);
195
        UUID childUuid = taxonNodeDao.saveOrUpdate(child);
196
        child = taxonNodeDao.load(childUuid);
197
        assertNotNull(child);
198
        child = taxNode2.addChildTaxon(taxon1, null, null);
199
        taxonNodeDao.saveOrUpdate(child);
200
        child = taxNode3.addChildTaxon(taxon2, null, null);
201
        taxonNodeDao.saveOrUpdate(child);
192 202

  
193 203
        List<TaxonNode> taxas = taxonNodeDao.getTaxonOfAcceptedTaxaByClassification(classification, null, null);
194 204
        assertEquals("there should be 7 taxa left", 7, taxas.size());
195

  
205
        commitAndStartNewTransaction(null);
196 206

  
197 207
        taxas = taxonNodeDao.getTaxonOfAcceptedTaxaByClassification(classification, 0, 10);
198 208
        logger.info(taxas.size());
......
214 224
    	Assert.assertTrue("Parent node must be proxy, otherwise test does not work", parent instanceof Proxy);
215 225
    	Taxon firstTopLevelTaxon = (Taxon)taxonDao.findByUuid(UUID.fromString("7b8b5cb3-37ba-4dba-91ac-4c6ffd6ac331"));
216 226
    	Classification classification = classificationDao.findByUuid(ClassificationUuid);
217
    	classification.addParentChild(taxonWithLazyLoadedParentNodeOnTopLevel, firstTopLevelTaxon, null, null);
227
    	TaxonNode childNode = classification.addParentChild(taxonWithLazyLoadedParentNodeOnTopLevel, firstTopLevelTaxon, null, null);
228
    	this.taxonNodeDao.saveOrUpdate(childNode);
218 229
    	commitAndStartNewTransaction( new String[]{"TaxonNode"});
219 230
    }
220 231

  
......
230 241
    	Classification classification = classificationDao.findByUuid(ClassificationUuid);
231 242
    	TaxonNode newNode = classification.addChildTaxon(newTaxon, 0, null, null);
232 243
    	newNode.setUuid(UUID.fromString("58728644-1155-4520-98f7-309fdb62abd7"));
244
    	this.taxonNodeDao.saveOrUpdate(newNode);
233 245
    	commitAndStartNewTransaction( new String[]{"TaxonNode"});
234 246
    }
235 247

  
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/tmp/TaxonNodeFilterDaoHibernateImplTest.java
63 63
		Taxon taxon4 = Taxon.NewInstance(null, null);
64 64
		Taxon taxon5 = Taxon.NewInstance(null, null);
65 65
		node1 = classification1.addChildTaxon(taxon1, citation, microCitation);
66
		node1= taxonNodeDao.save(node1);
67

  
66 68
		node2 = classification1.addChildTaxon(taxon2, citation, microCitation);
69
		node2 = taxonNodeDao.save(node2);
67 70
		node3 = node1.addChildTaxon(taxon3, citation, microCitation);
71
		taxonNodeDao.save(node3);
68 72
		node4 = node3.addChildTaxon(taxon4, citation, microCitation);
73
		taxonNodeDao.save(node4);
69 74
		node5 = node3.addChildTaxon(taxon5, citation, microCitation);
75
		node5 = taxonNodeDao.save(node5);
76
		//MergeResult result = taxonNodeDao.merge(node5, true);
77
		//node5 = (TaxonNode) result.getMergedEntity();
78

  
79
		//taxonNodeDao.save(node5);
80

  
81

  
82

  
70 83
		classificationDao.save(classification1);
71 84

  
85

  
72 86
	}
73 87

  
74 88
	/**
......
79 93
		Classification classification = classificationDao.findByUuid(classification1.getUuid());
80 94
		TaxonNodeFilter filter = new TaxonNodeFilter(node1);
81 95
		List<UUID> listUuid = filterDao.listUuids(filter);
96
		List<TaxonNode> children = taxonNodeDao.listChildrenOf(node1, null, null, null, true);
82 97
		Assert.assertEquals("All 4 children should be returned", 4, listUuid.size());
83 98
		Assert.assertTrue(listUuid.contains(node4.getUuid()));
84 99
		Assert.assertFalse(listUuid.contains(node2.getUuid()));
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/SaveOrUpdateEntityListenerTest.java
9 9
import org.junit.Assert;
10 10
import org.junit.Before;
11 11
import org.junit.Test;
12
import org.unitils.dbunit.annotation.DataSet;
12 13
import org.unitils.spring.annotation.SpringBeanByType;
13 14

  
14 15
import eu.etaxonomy.cdm.model.name.BotanicalName;
......
19 20
import eu.etaxonomy.cdm.model.taxon.Taxon;
20 21
import eu.etaxonomy.cdm.persistence.dao.hibernate.occurrence.OccurrenceDaoHibernateImpl;
21 22
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
23
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
22 24

  
23 25
/**
24 26
 * @author a.mueller
......
43 45
	 * Test if save or update event correctly handleds
44 46
	 */
45 47
	@Test
48
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDBDataSet.xml")
46 49
	public void testOnSaveOrUpdateDeterminationTaxonName() {
47 50
		DerivedUnit unit = DerivedUnit.NewInstance(SpecimenOrObservationType.DerivedUnit);
48 51
		Taxon taxon = Taxon.NewInstance(null, null);
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/replace/ReferringObjectMetadataFactoryTest.java
18 18
import org.junit.Before;
19 19
import org.junit.Test;
20 20
import org.unitils.dbunit.annotation.DataSet;
21
import org.unitils.dbunit.annotation.DataSets;
21 22
import org.unitils.dbunit.annotation.ExpectedDataSet;
22 23
import org.unitils.spring.annotation.SpringBeanByType;
23 24

  
......
26 27
import eu.etaxonomy.cdm.model.name.BotanicalName;
27 28
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao;
28 29
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
30
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
29 31

  
30 32
/**
31 33
 * @author ben.clark
......
85 87
	}
86 88

  
87 89
	@Test
88
	@DataSet
90
	 @DataSets({
91
	        @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
92
	        @DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml"),
93
	        @DataSet(value="ReferringObjectMetadataFactoryTest.xml")
94
	    })
89 95
	@ExpectedDataSet
90 96
	public void testReplaceToOneProperty() throws Exception {
91 97
		Person x = (Person)agentDao.findByUuid(person1);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java
338 338
    }
339 339

  
340 340
    @Override
341
    public UUID saveClassification(Classification classification) {
342

  
343
       taxonNodeDao.saveOrUpdateAll(classification.getAllNodes());
344
       UUID result =dao.saveOrUpdate(classification);
345
       return result;
346
    }
347

  
348
    @Override
341 349
    public UUID saveTreeNode(ITaxonTreeNode treeNode) {
342 350
        if(treeNode instanceof Classification){
343 351
            return dao.save((Classification) treeNode).getUuid();
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IClassificationService.java
350 350
            Boolean doChildren, Boolean doSynonyms, List<UUID> ancestorMarkers,
351 351
            NodeSortMode sortMode);
352 352

  
353
    /**
354
     * @param classification
355
     * @return
356
     */
357
    UUID saveClassification(Classification classification);
358

  
353 359

  
354 360
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
169 169

  
170 170
        Classification classification = oldTaxonNode.getClassification();
171 171
        Taxon oldTaxon = HibernateProxyHelper.deproxy(oldTaxonNode.getTaxon());
172
        Taxon newAcceptedTaxon = (Taxon)this.taxonService.load(newAcceptedTaxonNode.getTaxon().getUuid());
172
        Taxon newAcceptedTaxon = (Taxon)this.taxonService.find(newAcceptedTaxonNode.getTaxon().getUuid());
173
        newAcceptedTaxon = HibernateProxyHelper.deproxy(newAcceptedTaxon, Taxon.class);
173 174
        // Move oldTaxon to newTaxon
174 175
        //TaxonNameBase<?,?> synonymName = oldTaxon.getName();
175 176
        TaxonNameBase<?,?> synonymName = HibernateProxyHelper.deproxy(oldTaxon.getName());
......
187 188
        HomotypicalGroup newAcceptedTaxonHomotypicalgroup = newAcceptedTaxon.getHomotypicGroup();
188 189
        newAcceptedTaxonHomotypicalgroup = HibernateProxyHelper.deproxy(newAcceptedTaxonHomotypicalgroup, HomotypicalGroup.class);
189 190
        TaxonNameBase newAcceptedTaxonName = HibernateProxyHelper.deproxy(newAcceptedTaxon.getName(), TaxonNameBase.class);
191
        newAcceptedTaxon.setName(newAcceptedTaxonName);
190 192
        // Move Synonym Relations to new Taxon
191 193
        SynonymRelationship synonmyRelationship = newAcceptedTaxon.addSynonymName(synonymName,
192 194
                synonymRelationshipType, citation, citationMicroReference);
193
         HomotypicalGroup homotypicalGroupAcceptedTaxon = synonmyRelationship.getSynonym().getHomotypicGroup();
195
         HomotypicalGroup homotypicalGroupOldAcceptedTaxon = synonmyRelationship.getSynonym().getHomotypicGroup();
194 196
        // Move Synonym Relations to new Taxon
195 197
        // From ticket 3163 we can move taxon with accepted name having homotypic synonyms
196 198
        List<Synonym> synonymsInHomotypicalGroup = null;
......
212 214
            		srt = SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF();
213 215
            	}
214 216
            } else {
215
                srt = synRelation.getType();
217
                if (synonymsInHomotypicalGroup != null && synonymsInHomotypicalGroup.contains(synRelation.getSynonym())){
218
                    srt = SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF();
219
                }else{
220
                    srt = synRelation.getType();
221
                }
216 222

  
217 223
            }
218 224

  
......
279 285
        }
280 286
        oldTaxon.clearDescriptions();
281 287

  
282
        taxonService.update(newAcceptedTaxon);
288
        taxonService.saveOrUpdate(newAcceptedTaxon);
283 289

  
284
        taxonService.update(oldTaxon);
290
        taxonService.saveOrUpdate(oldTaxon);
291
        taxonService.getSession().flush();
285 292

  
286 293
        TaxonDeletionConfigurator conf = new TaxonDeletionConfigurator();
287 294
        conf.setDeleteSynonymsIfPossible(false);
288
        DeleteResult result = taxonService.isDeletable(oldTaxon, conf);
289 295
        conf.setDeleteNameIfPossible(false);
296
        DeleteResult result = taxonService.isDeletable(oldTaxon, conf);
297

  
290 298

  
291 299
        if (result.isOk()){
292 300
        	 result = taxonService.deleteTaxon(oldTaxon.getUuid(), conf, classification.getUuid());
301

  
293 302
        }else{
294 303
        	result.setStatus(Status.OK);
295 304
        	TaxonNodeDeletionConfigurator config = new TaxonNodeDeletionConfigurator();
......
297 306
        	conf.setTaxonNodeConfig(config);
298 307
        	result.includeResult(deleteTaxonNode(oldTaxonNode, conf));
299 308
        }
309

  
300 310
        result.addUpdatedObject(newAcceptedTaxon);
301
        result.addUpdatedObject(oldTaxon);
311

  
302 312

  
303 313
        //oldTaxonNode.delete();
304 314
        return result;
......
522 532
    	}
523 533
    	result.setCdmEntity(node);
524 534
    	boolean success = taxon.removeTaxonNode(node);
525
    	dao.save(parent);
535
    	dao.saveOrUpdate(parent);
526 536
    	taxonService.saveOrUpdate(taxon);
527 537
    	result.addUpdatedObject(parent);
528 538

  
......
678 688
        }
679 689
//        child = dao.save(child);
680 690

  
681
        dao.saveOrUpdate(parent);
691
        dao.saveOrUpdate(child);
682 692
        result.addUpdatedObject(parent);
683 693
        if (child != null){
684 694
            result.setCdmEntity(child);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
935 935
    }
936 936

  
937 937
    @Override
938
    @Transactional(readOnly = false)
938
    @Transactional(readOnly=false)
939 939
    public DeleteResult deleteTaxon(UUID taxonUUID, TaxonDeletionConfigurator config, UUID classificationUuid)  {
940 940

  
941 941
    	if (config == null){
......
1042 1042

  
1043 1043

  
1044 1044
         if (! config.isDeleteTaxonNodes() || (!config.isDeleteInAllClassifications() && classification == null && taxon.getTaxonNodes().size() > 1)){
1045
                //if (taxon.getTaxonNodes().size() > 0){
1046
                 result.addException(new Exception( "Taxon can't be deleted as it is used in more than one classification."));
1047
                   // throw new ReferencedObjectUndeletableException(message);
1048
                //}
1045
             result.addException(new Exception( "Taxon can't be deleted as it is used in more than one classification."));
1049 1046
         }else{
1050
                if (taxon.getTaxonNodes().size() != 0){
1051
                    Set<TaxonNode> nodes = taxon.getTaxonNodes();
1052
                    Iterator<TaxonNode> iterator = nodes.iterator();
1053
                    TaxonNode node = null;
1054
                    boolean deleteChildren;
1055
                    if (config.getTaxonNodeConfig().getChildHandling().equals(ChildHandling.DELETE)){
1056
                        deleteChildren = true;
1057
                    }else {
1058
                        deleteChildren = false;
1059
                    }
1060
                    boolean success = true;
1061
                    if (!config.isDeleteInAllClassifications() && !(classification == null)){
1062
                        while (iterator.hasNext()){
1063
                            node = iterator.next();
1064
                            if (node.getClassification().equals(classification)){
1065
                                break;
1066
                            }
1067
                            node = null;
1068
                        }
1069
                        if (node != null){
1070
                            HibernateProxyHelper.deproxy(node, TaxonNode.class);
1071
                            success =taxon.removeTaxonNode(node, deleteChildren);
1072
                            nodeService.delete(node);
1073
                        } else {
1074
                        	result.setError();
1075
                        	result.addException(new Exception("The taxon can not be deleted because it is not used in defined classification."));
1047
             if (taxon.getTaxonNodes().size() != 0){
1048
                Set<TaxonNode> nodes = taxon.getTaxonNodes();
1049
                Iterator<TaxonNode> iterator = nodes.iterator();
1050
                TaxonNode node = null;
1051
                boolean deleteChildren;
1052
                if (config.getTaxonNodeConfig().getChildHandling().equals(ChildHandling.DELETE)){
1053
                    deleteChildren = true;
1054
                }else {
1055
                    deleteChildren = false;
1056
                }
1057
                boolean success = true;
1058
                if (!config.isDeleteInAllClassifications() && !(classification == null)){
1059
                    while (iterator.hasNext()){
1060
                        node = iterator.next();
1061
                        if (node.getClassification().equals(classification)){
1062
                            break;
1076 1063
                        }
1077
                    } else if (config.isDeleteInAllClassifications()){
1078
                        List<TaxonNode> nodesList = new ArrayList<TaxonNode>();
1079
                        nodesList.addAll(taxon.getTaxonNodes());
1080

  
1081
                            for (ITaxonTreeNode treeNode: nodesList){
1082
                                TaxonNode taxonNode = (TaxonNode) treeNode;
1083
                                if(!deleteChildren){
1084
                                    Object[] childNodes = taxonNode.getChildNodes().toArray();
1085
                                    for (Object childNode: childNodes){
1086
                                        TaxonNode childNodeCast = (TaxonNode) childNode;
1087
                                        taxonNode.getParent().addChildNode(childNodeCast, childNodeCast.getReference(), childNodeCast.getMicroReference());
1088
                                    }
1089

  
1090
                                    //taxon.removeTaxonNode(taxonNode);
1091
                                }
1064
                        node = null;
1065
                    }
1066
                    if (node != null){
1067
                        HibernateProxyHelper.deproxy(node, TaxonNode.class);
1068
                        success =taxon.removeTaxonNode(node, deleteChildren);
1069
                        nodeService.delete(node);
1070
                    } else {
1071
                    	result.setError();
1072
                    	result.addException(new Exception("The taxon can not be deleted because it is not used in defined classification."));
1073
                    }
1074
                } else if (config.isDeleteInAllClassifications()){
1075
                    List<TaxonNode> nodesList = new ArrayList<TaxonNode>();
1076
                    nodesList.addAll(taxon.getTaxonNodes());
1077
                    for (ITaxonTreeNode treeNode: nodesList){
1078
                        TaxonNode taxonNode = (TaxonNode) treeNode;
1079
                        if(!deleteChildren){
1080
                            Object[] childNodes = taxonNode.getChildNodes().toArray();
1081
                            for (Object childNode: childNodes){
1082
                                TaxonNode childNodeCast = (TaxonNode) childNode;
1083
                                taxonNode.getParent().addChildNode(childNodeCast, childNodeCast.getReference(), childNodeCast.getMicroReference());
1092 1084
                            }
1093
                        config.getTaxonNodeConfig().setDeleteElement(false);
1094
                        DeleteResult resultNodes = nodeService.deleteTaxonNodes(nodesList, config);
1095
                        if (!resultNodes.isOk()){
1096
                        	result.addExceptions(resultNodes.getExceptions());
1097
                        	result.setStatus(resultNodes.getStatus());
1098
                        } else {
1099
                            result.addUpdatedObjects(resultNodes.getUpdatedObjects());
1100 1085
                        }
1101 1086
                    }
1102
                    if (!success){
1103
                        result.setError();
1104
                        result.addException(new Exception("The taxon can not be deleted because the taxon node can not be removed."));
1087
                    config.getTaxonNodeConfig().setDeleteElement(false);
1088
                    DeleteResult resultNodes = nodeService.deleteTaxonNodes(nodesList, config);
1089
                    if (!resultNodes.isOk()){
1090
                    	result.addExceptions(resultNodes.getExceptions());
1091
                    	result.setStatus(resultNodes.getStatus());
1092
                    } else {
1093
                        result.addUpdatedObjects(resultNodes.getUpdatedObjects());
1105 1094
                    }
1106 1095
                }
1096
                if (!success){
1097
                    result.setError();
1098
                    result.addException(new Exception("The taxon can not be deleted because the taxon node can not be removed."));
1099
                }
1107 1100
            }
1108

  
1101
         }
1102
         TaxonNameBase name = taxon.getName();
1103
         taxon.setName(null);
1104
         this.saveOrUpdate(taxon);
1105

  
1106
         if ((taxon.getTaxonNodes() == null || taxon.getTaxonNodes().size()== 0)  && result.isOk()){
1107
             try{
1108
                 //taxon.setName(null);
1109
                 UUID uuid = dao.delete(taxon);
1110

  
1111
             }catch(Exception e){
1112
                 result.addException(e);
1113
                 result.setError();
1114

  
1115
             }
1116
         } else {
1117
             result.setError();
1118
             result.addException(new Exception("The Taxon can't be deleted because it is used in a classification."));
1119

  
1120
         }
1109 1121
            //TaxonNameBase
1110
            if (config.isDeleteNameIfPossible() && result.isOk()){
1111

  
1112

  
1113
                    //TaxonNameBase name = nameService.find(taxon.getName().getUuid());
1114
                    TaxonNameBase name = HibernateProxyHelper.deproxy(taxon.getName());
1115
                    //check whether taxon will be deleted or not
1122
        if (config.isDeleteNameIfPossible() && result.isOk()){
1123
           // name = HibernateProxyHelper.deproxy(name);
1116 1124

  
1117
                    if ((taxon.getTaxonNodes() == null || taxon.getTaxonNodes().size()== 0) && name != null ){
1118

  
1119
                        //name.removeTaxonBase(taxon);
1120
                        //nameService.saveOrUpdate(name);
1121
                        taxon.setName(null);
1122
                        //dao.delete(taxon);
1123
                        DeleteResult nameResult = new DeleteResult();
1124

  
1125
                        //remove name if possible (and required)
1126
                        if (name != null && config.isDeleteNameIfPossible()){
1127
                        	nameResult = nameService.delete(name.getUuid(), config.getNameDeletionConfig());
1128
                        }
1129

  
1130
                        if (nameResult.isError() || nameResult.isAbort()){
1131
                        	//result.setError();
1132
                        	result.addRelatedObject(name);
1133
                        	result.addExceptions(nameResult.getExceptions());
1134
                        }
1125
            DeleteResult nameResult = new DeleteResult();
1126
            //remove name if possible (and required)
1127
            if (name != null ){
1128
                nameResult = nameService.delete(name.getUuid(), config.getNameDeletionConfig());
1129
            }
1130
            if (nameResult.isError() || nameResult.isAbort()){
1131
                result.addRelatedObject(name);
1132
                result.addExceptions(nameResult.getExceptions());
1133
            }
1135 1134

  
1136
                    }
1137 1135

  
1138
            }else {
1139
                taxon.setName(null);
1140 1136
            }
1141 1137

  
1142 1138

  
1143
            if ((taxon.getTaxonNodes() == null || taxon.getTaxonNodes().size()== 0)  && result.isOk()){
1144
            	try{
1145
            		UUID uuid = dao.delete(taxon);
1146 1139

  
1147
            	}catch(Exception e){
1148
            		result.addException(e);
1149
            		result.setError();
1150 1140

  
1151
            	}
1152
            } else {
1153
            	result.setError();
1154
            	result.addException(new Exception("The Taxon can't be deleted because it is used in a classification."));
1155 1141

  
1156
            }
1157 1142
        }
1158 1143

  
1159 1144
        return result;
......
1228 1213

  
1229 1214
    }
1230 1215

  
1231
    @Transactional(readOnly = false)
1216

  
1232 1217
    @Override
1218
    @Transactional(readOnly = false)
1233 1219
    public DeleteResult deleteSynonym(Synonym synonym, Taxon taxon, SynonymDeletionConfigurator config) {
1234 1220
        DeleteResult result = new DeleteResult();
1235 1221
    	if (synonym == null){
......
3290 3276
		return result;
3291 3277
	}
3292 3278

  
3279
	@Transactional(readOnly= false)
3293 3280
	@Override
3294 3281
	public DeleteResult deleteSynonym(UUID synonymUuid, UUID taxonUuid,
3295 3282
			SynonymDeletionConfigurator config) {
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest.java
396 396
     * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#generateTitleCache()}.
397 397
     */
398 398
    @Test
399
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class)
399 400
    public void testDeleteTaxonNameBaseAsStoredUnder() {
400 401
        final String[] tableNames = new String[]{"TaxonNameBase","SpecimenOrObservationBase"};
401 402

  
......
412 413
        if (result.isOk()){
413 414
    	   Assert.fail("This should throw an error because name is used for specimen#storedUnder.");
414 415
        }
415
         commitAndStartNewTransaction(tableNames);
416
        commitAndStartNewTransaction(tableNames);
416 417

  
417 418
        name1 = (NonViralName<?>)nameService.find(uuidName1);
418 419
        Assert.assertNotNull("Name should still be in database",name1);
......
422 423
        occurrenceService.saveOrUpdate(specimen);
423 424

  
424 425
        nameService.delete(name1); //should throw no exception
425

  
426
        commitAndStartNewTransaction(tableNames);
426 427

  
427 428
        name1 = (NonViralName<?>)nameService.find(uuidName1);
428 429
        Assert.assertNull("Name should not be in database anymore",name1);
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/SecurityTest.java
40 40
import org.unitils.spring.annotation.SpringBean;
41 41
import org.unitils.spring.annotation.SpringBeanByType;
42 42

  
43
import sun.security.provider.PolicyParser.ParsingException;
43 44
import eu.etaxonomy.cdm.database.PermissionDeniedException;
44 45
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
45 46
import eu.etaxonomy.cdm.model.common.User;
......
64 65
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator;
65 66
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation;
66 67
import eu.etaxonomy.cdm.persistence.query.MatchMode;
67
import sun.security.provider.PolicyParser.ParsingException;
68 68

  
69 69

  
70 70
@DataSet
......
825 825

  
826 826
        Taxon taxon = (Taxon)taxonService.load(UUID_LACTUCA);
827 827
        try{
828
        taxonService.deleteTaxon(taxon.getUuid(), null, null);
829
        Assert.fail();
828
        DeleteResult result = taxonService.deleteTaxon(taxon.getUuid(), null, null);
829
        if(result.isOk()){
830
            Assert.fail();
831
        }
830 832
        }catch(PermissionDeniedException e){
831 833

  
832 834
        }
......
1148 1150
        // test for success
1149 1151
        TaxonNode acherontia_node = taxonNodeService.load(ACHERONTIA_NODE_UUID);
1150 1152
        long numOfChildNodes = acherontia_node.getChildNodes().size();
1151
        acherontia_node.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.SPECIES()), null), null, null);
1153
        TaxonNode acherontia_child_node = acherontia_node.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.SPECIES()), null), null, null);
1152 1154

  
1153 1155
        try{
1154
            taxonNodeService.saveOrUpdate(acherontia_node);
1156
            taxonNodeService.saveOrUpdate(acherontia_child_node);
1155 1157
            commitAndStartNewTransaction(null);
1156 1158
        } catch (RuntimeException e){
1157 1159
            securityException = findSecurityRuntimeException(e);
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImplTest.java
170 170

  
171 171
		t4 = node4.getTaxon();
172 172
        UUID uuidT4 = t4.getUuid();
173
        t4 = (Taxon) taxonService.load(uuidT4);
174
        TaxonNameBase name4 = nameService.load(t4.getName().getUuid());
173
        t4 = (Taxon) taxonService.find(uuidT4);
174
        TaxonNameBase name4 = nameService.find(t4.getName().getUuid());
175 175
        result = taxonNodeService.makeTaxonNodeASynonymOfAnotherTaxonNode(node4, node2, synonymRelationshipType, reference, referenceDetail);
176 176
        if (result.isError() || result.isAbort()){
177 177
            Assert.fail();
......
198 198
		Set<CdmBase> updatedObjects = result.getUpdatedObjects();
199 199
		Iterator<CdmBase> it = updatedObjects.iterator();
200 200
		Taxon taxon;
201
		if (it.hasNext()) {
201
		while (it.hasNext()) {
202 202
			CdmBase updatedObject = it.next();
203 203
			if(updatedObject.isInstanceOf(Taxon.class)){
204 204
				taxon = HibernateProxyHelper.deproxy(updatedObject, Taxon.class);
205 205
				Set<Synonym> syns =  taxon.getSynonyms();
206 206
				assertNotNull(syns);
207
				assertEquals(4,syns.size());
207
				if (taxon.equals(t2)){
208
				    assertEquals(4,syns.size());
209
				    Set<TaxonNameBase> typifiedNames =taxon.getHomotypicGroup().getTypifiedNames();
210
	                assertEquals(typifiedNames.size(),4);
211
	                assertTrue(taxon.getHomotypicGroup().equals( nameT1.getHomotypicalGroup()));
208 212

  
209
				Set<TaxonNameBase> typifiedNames =taxon.getHomotypicGroup().getTypifiedNames();
210
				assertEquals(typifiedNames.size(),4);
211
				assertTrue(taxon.getHomotypicGroup().equals( nameT1.getHomotypicalGroup()));
213
	                assertEquals(taxon, t2);
214
				}
212 215

  
213
				assertEquals(taxon, t2);
214

  
215
			} else{
216
				Assert.fail();
217 216
			}
218 217

  
219 218

  
......
274 273
		if (!result.getUpdatedObjects().iterator().hasNext()){
275 274
			Assert.fail();
276 275
		}
277
		Taxon newAcceptedTaxon = (Taxon)result.getUpdatedObjects().iterator().next();
278
		assertNotNull(taxonService.find(t1Uuid));
279
		assertNull(taxonNodeService.find(node1Uuid));
276
		assertTrue(result.getUpdatedObjects().size() == 3);
277
		t1 = (Taxon) taxonService.find(t1Uuid);
278
		assertNotNull(t1);
279
		//taxonNodeService.getSession().flush();
280
		node1 = taxonNodeService.find(node1Uuid);
281
		assertNull(node1);
280 282

  
281 283

  
282 284
		synonym = (Synonym)taxonService.find(uuidSynonym);
......
284 286
		assertNotNull(synonym);
285 287
		keyNode.setTaxon(null);
286 288
		polKeyNodeService.saveOrUpdate(keyNode);
287
		HibernateProxyHelper.deproxy(t2);
289
		t2 =HibernateProxyHelper.deproxy(t2);
288 290
		HibernateProxyHelper.deproxy(t2.getHomotypicGroup());
289
		HibernateProxyHelper.deproxy(t2.getName());
291
		t2.setName(HibernateProxyHelper.deproxy(t2.getName()));
290 292
//		syn = taxonNodeService.makeTaxonNodeASynonymOfAnotherTaxonNode(node1, node2, synonymRelationshipType, reference, referenceDetail);
291 293
//		if (syn == null){
292 294
//			Assert.fail();
......
314 316
		Synonym syn =(Synonym) name1.getTaxonBases().iterator().next();
315 317

  
316 318
		assertEquals(syn.getName().getHomotypicalGroup(), synonym.getName().getHomotypicalGroup());
317
		assertFalse(newAcceptedTaxon.getHomotypicGroup().equals( syn.getName().getHomotypicalGroup()));
319
		assertFalse(t2.getHomotypicGroup().equals( syn.getName().getHomotypicalGroup()));
320

  
318 321

  
319
		assertEquals(newAcceptedTaxon, t2);
320 322
		TaxonNameBase name = syn.getName();
321 323
		assertEquals(name, nameT1);
322 324
	}
......
331 333
		String oldTreeIndex = node2.treeIndex();
332 334

  
333 335
		TaxonNode newNode = node2.addChildTaxon(taxon, null, null);
334
		taxonNodeService.saveOrUpdate(node2);
336
		taxonNodeService.saveOrUpdate(newNode);
335 337
		commitAndStartNewTransaction(new String[]{"TaxonNode"});
336 338
		newNode = taxonNodeService.load(newNode.getUuid());
337 339
		Assert.assertEquals("", oldTreeIndex + newNode.getId() + "#", newNode.treeIndex());
......
366 368
		//into new classification
367 369
		node2 = taxonNodeService.load(node2Uuid);
368 370
		TaxonNode node5 = taxonNodeService.load(node5Uuid);
369
		node5.addChildNode(node2, null, null);
370
		taxonNodeService.saveOrUpdate(node5);
371
		node2 =node5.addChildNode(node2, null, null);
372
		taxonNodeService.saveOrUpdate(node2);
371 373
		commitAndStartNewTransaction(new String[]{"TaxonNode"});
372 374
		node2 = taxonNodeService.load(node2Uuid);
373 375
		Assert.assertEquals("Node3 treeindex is not correct", "#t2#8#2#5#3#", node2.treeIndex());
......
471 473
        if (!result.isOk()){
472 474
            Assert.fail();
473 475
        }
474
        taxonService.getSession().flush();
476
        //taxonService.getSession().flush();
475 477
        newNode = taxonNodeService.load(uuidNewNode);
476 478
        node1 = taxonNodeService.load(node1Uuid);
477 479
        assertNull(newNode);
......
511 513
		node1 = taxonNodeService.load(node1Uuid);
512 514
		assertNull(newNode);
513 515
		assertNull(node1);
514
		taxonService.getSession().flush();
516
		//taxonService.getSession().flush();
515 517
		t1 = (Taxon) taxonService.load(t1Uuid);
516 518
		assertNull(t1);
517 519
		t2 = (Taxon) taxonService.load(t2Uuid);
......
563 565
        abiesBalsameaName.setSpecificEpithet("balsamea");
564 566
        Taxon abiesBalsamea = Taxon.NewInstance(abiesBalsameaName, null);
565 567

  
566

  
567
    	classification.addChildTaxon(abies, null, null);
568
        List<TaxonNode> nodes = new ArrayList<TaxonNode>();
569
    	nodes.add(classification.addChildTaxon(abies, null, null));
568 570
    	TaxonNode abiesAlbaNode = classification.addParentChild(abies, abiesAlba, null, null);
569 571
    	TaxonNode balsameaNode = classification.addParentChild(abies, abiesBalsamea, null, null);
570
    	classification.addChildTaxon(pinus, null, null);
571
    	classification.addParentChild(pinus, pinusPampa, null, null);
572
    	classificationService.save(classification);
573

  
572
    	nodes.add(balsameaNode);
573
    	nodes.add(abiesAlbaNode);
574
    	nodes.add(classification.addChildTaxon(pinus, null, null));
575
    	nodes.add(classification.addParentChild(pinus, pinusPampa, null, null));
576
    	classificationService.saveClassification(classification);
577
    	//this.taxonNodeService.save(nodes);
574 578
    	TaxonNaturalComparator comparator = new TaxonNaturalComparator();
575 579
    	List<TaxonNode> allNodes = new ArrayList<>(classification.getAllNodes());
576 580
    	Collections.sort(allNodes, comparator);
......
582 586
    	taxonNodeService.moveTaxonNode(balsameaNode, abiesAlbaNode,1);
583 587
    	classification = classificationService.load(classification.getUuid());
584 588

  
585
       allNodes = new ArrayList<>(classification.getAllNodes());
589
    	allNodes = new ArrayList<>(classification.getAllNodes());
586 590
        Collections.sort(allNodes, comparator);
587 591

  
588 592
        Assert.assertEquals(allNodes.get(0).getTaxon(), abies );
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.java
18 18
import java.util.ArrayList;
19 19
import java.util.Iterator;
20 20
import java.util.List;
21
import java.util.Random;
21 22
import java.util.Set;
22 23
import java.util.UUID;
23 24

  
......
34 35
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
35 36
import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
36 37
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
37
import eu.etaxonomy.cdm.datagenerator.TaxonGenerator;
38
import eu.etaxonomy.cdm.model.agent.Person;
38 39
import eu.etaxonomy.cdm.model.common.CdmBase;
39 40
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
41
import eu.etaxonomy.cdm.model.common.Language;
42
import eu.etaxonomy.cdm.model.common.LanguageString;
40 43
import eu.etaxonomy.cdm.model.common.Marker;
41 44
import eu.etaxonomy.cdm.model.common.MarkerType;
42 45
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
43 46
import eu.etaxonomy.cdm.model.common.RelationshipBase;
47
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
44 48
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
45 49
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
46 50
import eu.etaxonomy.cdm.model.description.TaxonDescription;
51
import eu.etaxonomy.cdm.model.description.TextData;
47 52
import eu.etaxonomy.cdm.model.name.BotanicalName;
48 53
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
49 54
import eu.etaxonomy.cdm.model.name.NameRelationship;
......
117 122
    private UUID uuidSyn2;
118 123
    private UUID uuidTaxWithSyn;
119 124

  
125
    private static String[] genera = {"Carex", "Abies", "Belladonna", "Dracula", "Maria", "Calendula", "Polygala", "Vincia"};
126
    private static String[] epitheta = {"vulgaris", "magdalena", "officinalis", "alba", "negra", "communa", "alpina", "rotundifolia", "greutheriana", "helventica", "allemania", "franca"};
127
    private static String[] ranks = {"subsp", "var", "f"};
128

  
129
    public static UUID GENUS_NAME_UUID = UUID.fromString("8d761fc4-b509-42f4-9568-244161934336");
130
    public static UUID GENUS_UUID = UUID.fromString("bf4298a8-1735-4353-a210-244442e1bd62");
131
    public static UUID BASIONYM_UUID = UUID.fromString("7911c51d-ccb7-4708-8992-639eae58a0e3");
132
    public static UUID SPECIES1_UUID = UUID.fromString("f0eb77d9-76e0-47f4-813f-9b5605b78685");
133
    public static UUID SPECIES1_NAME_UUID = UUID.fromString("efd78713-126f-42e1-9070-a1ff83f12abf");
134
    public static UUID SYNONYM_NAME_UUID = UUID.fromString("b9cbaa74-dbe0-4930-8050-b7754ce85dc0");
135
    public static UUID SPECIES2_NAME_UUID = UUID.fromString("0267ab67-483e-4da5-b654-11013b242c22");
136
    public static UUID SPECIES2_UUID = UUID.fromString("e20eb549-ced6-4e79-9d74-44f0792a4929");
137
    public static UUID SYNONYM2_NAME_UUID = UUID.fromString("7c17c811-4201-454b-8108-7be7c91c0938");
138
    public static UUID SPECIES5_NAME_UUID = UUID.fromString("0c6ecaac-804d-49e5-a33f-1b7ee77439e3");
139

  
120 140
/****************** TESTS *****************************/
121 141

  
122 142

  
......
1056 1076
        UUID uuidChild1=UUID.fromString("326167f9-0b97-4e7d-b1bf-4ca47b82e21e");
1057 1077
        UUID uuidSameAs=UUID.fromString("c2bb0f01-f2dd-43fb-ba12-2a85727ccb8d");
1058 1078
        commitAndStartNewTransaction(tableNames);
1059
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1060
        service.save(testTaxon);
1079
        Taxon testTaxon =getTestTaxon();
1080
       // service.save(testTaxon);
1061 1081
        commitAndStartNewTransaction(tableNames);
1062 1082
        int nTaxa = service.count(Taxon.class);
1063 1083

  
1064 1084
        Assert.assertEquals("There should be 4 taxa in the database", 4, nTaxa);
1065
        Taxon parent = (Taxon)service.find(TaxonGenerator.GENUS_UUID);
1085
        Taxon parent = (Taxon)service.find(GENUS_UUID);
1066 1086
        Assert.assertNotNull("Parent taxon should exist", parent);
1067
        Taxon child1 = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1087
        Taxon child1 = (Taxon)service.find(SPECIES1_UUID);
1068 1088
        Assert.assertNotNull("Child taxon should exist", child1);
1069 1089
        TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
1070 1090
        config.setDeleteTaxonNodes(false);
......
1079 1099

  
1080 1100
        nTaxa = service.count(Taxon.class);
1081 1101
        Assert.assertEquals("There should be 4 taxa in the database", 4, nTaxa);
1082
        child1 = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1102
        child1 = (Taxon)service.find(SPECIES1_UUID);
1083 1103
        Assert.assertNotNull("Child taxon should exist", child1);
1084 1104
        Assert.assertEquals("Child should belong to 1 node", 1, child1.getTaxonNodes().size());
1085 1105

  
......
1115 1135
        occurenceService.delete(identifiedUnit);
1116 1136

  
1117 1137
        commitAndStartNewTransaction(tableNames);
1118
        child1 = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1138
        child1 = (Taxon)service.find(SPECIES1_UUID);
1119 1139

  
1120 1140
        assertEquals(0, child1.getTaxonNodes().size());
1121 1141
       // try {
......
1130 1150
        Assert.assertEquals("There should be 3 taxa in the database", 3, nTaxa);
1131 1151

  
1132 1152
        config.setDeleteTaxonNodes(true);
1133
        Taxon child2 =(Taxon) service.find(TaxonGenerator.SPECIES2_UUID);
1153
        Taxon child2 =(Taxon) service.find(SPECIES2_UUID);
1134 1154

  
1135 1155
       // try {
1136 1156
        result = service.deleteTaxon(child2.getUuid(), config, child2.getTaxonNodes().iterator().next().getClassification().getUuid());
......
1155 1175
    public final void testDeleteTaxon(){
1156 1176

  
1157 1177
        //create a small classification
1158
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1178

  
1179
        Taxon testTaxon = getTestTaxon();
1159 1180

  
1160 1181
        service.save(testTaxon).getUuid();
1161 1182

  
1162
        Taxon speciesTaxon = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1183
        Taxon speciesTaxon = (Taxon)service.find(SPECIES1_UUID);
1163 1184
        Iterator<TaxonDescription> descriptionIterator = speciesTaxon.getDescriptions().iterator();
1164 1185
        UUID descrUUID = null;
1165 1186
        UUID descrElementUUID = null;
......
1168 1189
            descrUUID = descr.getUuid();
1169 1190
            descrElementUUID = descr.getElements().iterator().next().getUuid();
1170 1191
        }
1171
        BotanicalName taxonName = (BotanicalName) nameService.find(TaxonGenerator.SPECIES1_NAME_UUID);
1192
        BotanicalName taxonName = (BotanicalName) nameService.find(SPECIES1_NAME_UUID);
1172 1193
        assertNotNull(taxonName);
1173 1194

  
1174 1195
        TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
......
1184 1205
        }
1185 1206
        commitAndStartNewTransaction(null);
1186 1207

  
1187
        taxonName = (BotanicalName) nameService.find(TaxonGenerator.SPECIES1_NAME_UUID);
1188
        Taxon taxon = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1208
        taxonName = (BotanicalName) nameService.find(SPECIES1_NAME_UUID);
1209
        Taxon taxon = (Taxon)service.find(SPECIES1_UUID);
1189 1210

  
1190 1211
        //descriptionService.find(descrUUID);
1191 1212
        assertNull(descriptionService.find(descrUUID));
......
1210 1231
    public final void testDeleteTaxonUsedInTaxonRelation(){
1211 1232

  
1212 1233
        //create a small classification
1213
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1234
        Taxon testTaxon = getTestTaxon();
1214 1235

  
1215 1236
        service.save(testTaxon).getUuid();
1216 1237

  
1217
        Taxon speciesTaxon = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1218
        Taxon speciesTaxon2 = (Taxon)service.find(TaxonGenerator.SPECIES2_UUID);
1238
        Taxon speciesTaxon = (Taxon)service.find(SPECIES1_UUID);
1239
        Taxon speciesTaxon2 = (Taxon)service.find(SPECIES2_UUID);
1219 1240
        speciesTaxon.addTaxonRelation(speciesTaxon2, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), null, null);
1220 1241

  
1221
        BotanicalName taxonName = (BotanicalName) nameService.find(TaxonGenerator.SPECIES1_NAME_UUID);
1242
        BotanicalName taxonName = (BotanicalName) nameService.find(SPECIES1_NAME_UUID);
1222 1243
        assertNotNull(taxonName);
1223 1244

  
1224 1245
        TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
......
1234 1255
        }
1235 1256
        commitAndStartNewTransaction(null);
1236 1257

  
1237
        taxonName = (BotanicalName) nameService.find(TaxonGenerator.SPECIES1_NAME_UUID);
1238
        Taxon taxon = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1258
        taxonName = (BotanicalName) nameService.find(SPECIES1_NAME_UUID);
1259
        Taxon taxon = (Taxon)service.find(SPECIES1_UUID);
1239 1260

  
1240 1261

  
1241 1262
        assertNotNull(taxonName);
......
1278 1299
                 "TaxonNameBase","TaxonNameBase_AUD"};
1279 1300
    	 commitAndStartNewTransaction(tableNames);
1280 1301
        //create a small classification
1281
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1302
        Taxon testTaxon = getTestTaxon();
1282 1303

  
1283 1304
        service.save(testTaxon).getUuid();
1284 1305

  
1285
        Taxon speciesTaxon = (Taxon)service.find(TaxonGenerator.SPECIES2_UUID);
1306
        Taxon speciesTaxon = (Taxon)service.find(SPECIES2_UUID);
1286 1307

  
1287 1308
        SynonymRelationship synRel = speciesTaxon.getSynonymRelations().iterator().next();
1288 1309
        UUID synonymRelationUuid = synRel.getUuid();
......
1299 1320
        }
1300 1321
        commitAndStartNewTransaction(null);
1301 1322

  
1302
        Taxon taxon = (Taxon)service.find(TaxonGenerator.SPECIES2_UUID);
1323
        Taxon taxon = (Taxon)service.find(SPECIES2_UUID);
1303 1324
        assertNull("The deleted taxon should no longer exist", taxon);
1304 1325

  
1305 1326
        assertNotNull("The synonym should still exist since DeleteSynonymsIfPossible was false", service.find(synonymUuid));
......
1317 1338
    public final void testDeleteTaxonNameUsedInOtherContext(){
1318 1339

  
1319 1340
        //create a small classification
1320
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1341
        Taxon testTaxon = getTestTaxon();
1321 1342

  
1322 1343
        service.save(testTaxon).getUuid();
1323 1344

  
1324
        Taxon speciesTaxon = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1345
        Taxon speciesTaxon = (Taxon)service.find(SPECIES1_UUID);
1325 1346

  
1326
        BotanicalName taxonName = (BotanicalName) nameService.find(TaxonGenerator.SPECIES1_NAME_UUID);
1347
        BotanicalName taxonName = (BotanicalName) nameService.find(SPECIES1_NAME_UUID);
1327 1348
        assertNotNull(taxonName);
1328 1349
        BotanicalName fromName = BotanicalName.NewInstance(Rank.SPECIES());
1329 1350
        taxonName.addRelationshipFromName(fromName, NameRelationshipType.VALIDATED_BY_NAME(), null);
......
1336 1357
        }
1337 1358
        commitAndStartNewTransaction(null);
1338 1359

  
1339
        taxonName = (BotanicalName) nameService.find(TaxonGenerator.SPECIES1_NAME_UUID);
1340
        Taxon taxon = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);
1360
        taxonName = (BotanicalName) nameService.find(SPECIES1_NAME_UUID);
1361
        Taxon taxon = (Taxon)service.find(SPECIES1_UUID);
1341 1362
        //because of the namerelationship the name cannot be deleted
1342 1363
        assertNotNull(taxonName);
1343 1364
        assertNull(taxon);
......
1350 1371
        commitAndStartNewTransaction(null);
1351 1372
        TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
1352 1373
        //create a small classification
1353
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1374
        Taxon testTaxon = getTestTaxon();
1354 1375

  
1355 1376
        UUID uuid = service.save(testTaxon).getUuid();
1356 1377
        //BotanicalName name = nameService.find(uuid);
......
1359 1380
        List<TaxonNode> childNodes = node.getChildNodes();
1360 1381
        TaxonNode childNode = childNodes.iterator().next();
1361 1382
        UUID childUUID = childNode.getTaxon().getUuid();
1362
        Classification secondClassification = TaxonGenerator.getTestClassification("secondClassification");
1383
        Classification secondClassification = getTestClassification("secondClassification");
1363 1384

  
1364 1385
        secondClassification.addChildTaxon(testTaxon, null, null);
1365 1386
        //delete the taxon in all classifications
......
1385 1406
    @DataSet(value="BlankDataSet.xml")
1386 1407
    public final void testDeleteTaxonNameUsedInTwoClassificationsDoNotDeleteAllNodes(){
1387 1408
        // delete the taxon only in second classification, this should delete only the nodes, not the taxa
1388
        Taxon testTaxon = TaxonGenerator.getTestTaxon();
1409
        Taxon testTaxon = getTestTaxon();
1389 1410
        UUID uuid = service.save(testTaxon).getUuid();
1390
        Classification secondClassification = TaxonGenerator.getTestClassification("secondClassification");
1411
        Classification secondClassification = getTestClassification("secondClassification");
1391 1412
        Set<TaxonNode> nodes = testTaxon.getTaxonNodes();
1392 1413
        TaxonNode node = nodes.iterator().next();
1393 1414
        List<TaxonNode> childNodes = node.getChildNodes();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)