Project

General

Profile

Revision d97ab2bf

IDd97ab2bfb82c496c37bbb0d7f9b45aae078288be
Parent 82bf3f79
Child 721d9357

Added by Andreas Müller over 3 years ago

fix #3465 implement setSecundumForSubtree

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
31 31

  
32 32
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
33 33
import eu.etaxonomy.cdm.model.common.TreeIndex;
34
import eu.etaxonomy.cdm.model.reference.Reference;
34 35
import eu.etaxonomy.cdm.model.taxon.Classification;
36
import eu.etaxonomy.cdm.model.taxon.Synonym;
35 37
import eu.etaxonomy.cdm.model.taxon.Taxon;
36 38
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
37 39
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
......
435 437
    }
436 438

  
437 439

  
440
    @Override
441
    public void setSecundumForSubtreeAcceptedTaxa(TreeIndex subTreeIndex, Reference newSec, boolean overwriteExisting, boolean includeSharedTaxa, boolean emptyDetail) {
442
        //for some reason this does not work, maybe because the listeners are not activated,
443
        //but also the first taxon for some reason does not get updated in terms of secundum, but only by the udpate listener
444
//        String where = "SELECT t.id FROM TaxonNode tn JOIN tn.taxon t " +
445
//                " WHERE tn.treeIndex like '%s%%' ORDER BY t.id";
446
//        where = String.format(where, subTreeIndex.toString());
447
//        Query query1 = getSession().createQuery(where);
448
//        List l = query1.list();
449
//
450
//        String hql = "UPDATE Taxon SET sec = :newSec, publish=false WHERE id IN (" + where + ")";
451
//        Query query = getSession().createQuery(hql);
452
//        query.setParameter("newSec", newSec);
453
//        int n = query.executeUpdate();
454

  
455
        String where = "SELECT t FROM TaxonNode tn JOIN tn.taxon t " +
456
                " WHERE tn.treeIndex like '%s%%' ";
457
        if (!overwriteExisting){
458
            where += " AND t.sec IS NULL ";
459
        }
460
        if (!includeSharedTaxa){
461
            where += " AND t.taxonNodes.size <= 1  ";
462
        }
463

  
464
        where = String.format(where, subTreeIndex.toString());
465
        Query query1 = getSession().createQuery(where);
466
        @SuppressWarnings("unchecked")
467
        List<Taxon> taxonList = query1.list();
468
        for (Taxon taxon : taxonList){
469
            taxon.setSec(newSec);
470
            if (emptyDetail){
471
                taxon.setSecMicroReference(null);
472
            }
473
        }
474

  
475
    }
476

  
477
    @Override
478
    public void setSecundumForSubtreeSynonyms(TreeIndex subTreeIndex, Reference newSec, boolean overwriteExisting, boolean includeSharedTaxa, boolean emptyDetail) {
479
        String where = "SELECT syn FROM TaxonNode tn JOIN tn.taxon t JOIN t.synonyms syn" +
480
                " WHERE tn.treeIndex like '%s%%' ";
481
        if (!overwriteExisting){
482
            where += " AND syn.sec IS NULL ";
483
        }
484
        if (!includeSharedTaxa){
485
            where += " AND t.taxonNodes.size <= 1  ";
486
        }
487
        where = String.format(where, subTreeIndex.toString());
488
        Query query1 = getSession().createQuery(where);
489
        @SuppressWarnings("unchecked")
490
        List<Synonym> synonymList = query1.list();
491
        for (Synonym taxon : synonymList){
492
            taxon.setSec(newSec);
493
            if (emptyDetail){
494
                taxon.setSecMicroReference(null);
495
            }
496
        }
497
    }
498

  
499

  
438 500

  
439 501
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonNodeDao.java
15 15
import java.util.UUID;
16 16

  
17 17
import eu.etaxonomy.cdm.model.common.TreeIndex;
18
import eu.etaxonomy.cdm.model.reference.Reference;
18 19
import eu.etaxonomy.cdm.model.taxon.Classification;
19 20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 21
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
......
121 122
     */
122 123
    Map<TreeIndex, UuidAndTitleCache<?>> taxonUuidsForTreeIndexes(Collection<TreeIndex> treeIndexSet);
123 124

  
125
    /**
126
     * @param ref
127
     */
128
    public void setSecundumForSubtreeAcceptedTaxa(TreeIndex subTreeIndex, Reference newSec, boolean overwriteExisting, boolean includeSharedTaxa, boolean emptyDetail);
129

  
130
    /**
131
     * @param ref
132
     */
133
    public void setSecundumForSubtreeSynonyms(TreeIndex subTreeIndex, Reference newSec, boolean overwriteExisting, boolean includeSharedTaxa, boolean emptyDetail);
134

  
124 135
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonNodeService.java
14 14
import java.util.Set;
15 15
import java.util.UUID;
16 16

  
17
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
17 18
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
18 19
import eu.etaxonomy.cdm.api.service.pager.Pager;
19 20
import eu.etaxonomy.cdm.model.common.DefinedTerm;
......
31 32
/**
32 33
 * @author n.hoffmann
33 34
 * @created Apr 9, 2010
34
 * @version 1.0
35 35
 */
36 36
public interface ITaxonNodeService extends IAnnotatableService<TaxonNode>{
37 37

  
......
241 241
     */
242 242
    UpdateResult createNewTaxonNode(UUID parentNodeUuid, UUID taxonUuid, Reference ref, String microref);
243 243

  
244
    /**
245
     * Sets the secundum reference for all taxa of the given subtree.
246
     * Depending on the configuration, also synonym secundum will be set.
247
     * See {@link SetSecundumForSubtreeConfigurator} for further configuration
248
     * options.
249
     * @param configurator
250
     * @return UpdateResult
251
     */
252
    UpdateResult setSecundumForSubtree(SetSecundumForSubtreeConfigurator configurator);
244 253

  
245 254
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
25 25

  
26 26
import eu.etaxonomy.cdm.api.service.UpdateResult.Status;
27 27
import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
28
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
28 29
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
29 30
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
30 31
import eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier;
......
36 37
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
37 38
import eu.etaxonomy.cdm.model.common.CdmBase;
38 39
import eu.etaxonomy.cdm.model.common.DefinedTerm;
40
import eu.etaxonomy.cdm.model.common.TreeIndex;
39 41
import eu.etaxonomy.cdm.model.description.TaxonDescription;
40 42
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
41 43
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
......
748 750
        return result;
749 751
    }
750 752

  
753
    @Override
754
    public UpdateResult setSecundumForSubtree(SetSecundumForSubtreeConfigurator config) {
755
        UpdateResult result = new UpdateResult();
756
        UUID subtreeUuid = config.getSubtreeUuid();
757
        if (subtreeUuid == null){
758
            result.setError();
759
            result.addException(new NullPointerException("No subtree given"));
760
            return result;
761
        }
762
        TaxonNode subTree = find(subtreeUuid);
763
        if (subTree == null){
764
            result.setError();
765
            result.addException(new NullPointerException("Subtree does not exist"));
766
            return result;
767
        }
768
        TreeIndex subTreeIndex = TreeIndex.NewInstance(subTree.treeIndex());
769

  
770
        Reference ref = config.getNewSecundum();
771
        if (config.isIncludeAcceptedTaxa()){
772
            dao.setSecundumForSubtreeAcceptedTaxa(subTreeIndex, ref, config.isOverwriteExistingAccepted(), config.isIncludeSharedTaxa() ,config.isEmptySecundumDetail());
773
        }
774
        if (config.isIncludeSynonyms()){
775
            dao.setSecundumForSubtreeSynonyms(subTreeIndex, ref, config.isOverwriteExistingSynonyms(), config.isIncludeSharedTaxa() , config.isEmptySecundumDetail());
776
        }
777

  
778
        return result;
779
    }
780

  
751 781

  
752 782
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/config/SetSecundumForSubtreeConfigurator.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service.config;
10

  
11
import java.util.UUID;
12

  
13
import eu.etaxonomy.cdm.model.reference.Reference;
14

  
15
/**
16
 * Configurator for the setSecundumForSubtree operation.
17
 * @author a.mueller
18
 * @date 06.01.2017
19
 *
20
 */
21
public class SetSecundumForSubtreeConfigurator {
22
    private UUID subtreeUuid;
23
    private Reference newSecundum;
24
    private boolean includeAcceptedTaxa = true;
25
    private boolean includeSynonyms = true;
26
    private boolean overwriteExistingAccepted = true;
27
    private boolean overwriteExistingSynonyms = true;
28
    private boolean emptySecundumDetail = true;
29
    private boolean includeSharedTaxa = true;
30

  
31
    /**
32
     * @return the subtreeUuid
33
     */
34
    public UUID getSubtreeUuid() {
35
        return subtreeUuid;
36
    }
37
    /**
38
     * @param subtreeUuid the subtreeUuid to set
39
     */
40
    public void setSubtreeUuid(UUID subtreeUuid) {
41
        this.subtreeUuid = subtreeUuid;
42
    }
43
    /**
44
     * @return the newSecundum
45
     */
46
    public Reference getNewSecundum() {
47
        return newSecundum;
48
    }
49
    /**
50
     * @param newSecundum the newSecundum to set
51
     */
52
    public void setNewSecundum(Reference newSecundum) {
53
        this.newSecundum = newSecundum;
54
    }
55
    /**
56
     * @return the overrideExisting
57
     */
58
    public boolean isOverwriteExistingAccepted() {
59
        return overwriteExistingAccepted;
60
    }
61
    /**
62
     * @param overrideExisting the overrideExisting to set
63
     */
64
    public void setOverwriteExistingAccepted(boolean overwriteExistingAccepted) {
65
        this.overwriteExistingAccepted = overwriteExistingAccepted;
66
    }
67
    /**
68
     * @return the overrideExisting
69
     */
70
    public boolean isOverwriteExistingSynonyms() {
71
        return overwriteExistingSynonyms;
72
    }
73
    /**
74
     * @param overrideExisting the overrideExisting to set
75
     */
76
    public void setOverwriteExistingSynonyms(boolean overwriteExistingSynonyms) {
77
        this.overwriteExistingSynonyms = overwriteExistingSynonyms;
78
    }
79
    /**
80
     * @return the emptySecundumDetail
81
     */
82
    public boolean isEmptySecundumDetail() {
83
        return emptySecundumDetail;
84
    }
85
    /**
86
     * @param emptySecundumDetail the emptySecundumDetail to set
87
     */
88
    public void setEmptySecundumDetail(boolean emptySecundumDetail) {
89
        this.emptySecundumDetail = emptySecundumDetail;
90
    }
91
    /**
92
     * @return the includeSynonyms
93
     */
94
    public boolean isIncludeSynonyms() {
95
        return includeSynonyms;
96
    }
97
    /**
98
     * @param includeSynonyms the includeSynonyms to set
99
     */
100
    public void setIncludeSynonyms(boolean includeSynonyms) {
101
        this.includeSynonyms = includeSynonyms;
102
    }
103
    /**
104
     * @return the includeAcceptedTaxa
105
     */
106
    public boolean isIncludeAcceptedTaxa() {
107
        return includeAcceptedTaxa;
108
    }
109
    /**
110
     * @param includeAcceptedTaxa the includeAcceptedTaxa to set
111
     */
112
    public void setIncludeAcceptedTaxa(boolean includeAcceptedTaxa) {
113
        this.includeAcceptedTaxa = includeAcceptedTaxa;
114
    }
115
    /**
116
     * @return the includeSharedTaxa
117
     */
118
    public boolean isIncludeSharedTaxa() {
119
        return includeSharedTaxa;
120
    }
121
    /**
122
     * @param includeSharedTaxa the includeSharedTaxa to set
123
     */
124
    public void setIncludeSharedTaxa(boolean includeSharedTaxa) {
125
        this.includeSharedTaxa = includeSharedTaxa;
126
    }
127

  
128
}
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImplTest.java
29 29
import org.unitils.dbunit.annotation.DataSet;
30 30
import org.unitils.spring.annotation.SpringBeanByType;
31 31

  
32
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
32 33
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
33 34
import eu.etaxonomy.cdm.model.common.CdmBase;
34 35
import eu.etaxonomy.cdm.model.description.PolytomousKey;
......
42 43
import eu.etaxonomy.cdm.model.taxon.Synonym;
43 44
import eu.etaxonomy.cdm.model.taxon.SynonymType;
44 45
import eu.etaxonomy.cdm.model.taxon.Taxon;
46
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
45 47
import eu.etaxonomy.cdm.model.taxon.TaxonNaturalComparator;
46 48
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
47 49
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
......
701 703
        return foundMatch;
702 704
    }
703 705

  
706
    @Test
707
    @DataSet("TaxonNodeServiceImplTest.testSetSecundumForSubtree.xml")
708
    public void testSetSecundumForSubtree(){
709
        UUID subTreeUuid = UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
710
//        UUID taxon1uuid = UUID.fromString("55c3e41a-c629-40e6-aa6a-ff274ac6ddb1");
711
//        UUID taxon5uuid = UUID.fromString("d0b99fee-a783-4dda-b8a2-8960703cfcc2");
712
        Reference newSec = referenceService.find(UUID.fromString("1d3fb074-d7ba-47e4-be94-b4cb1a99afa7"));
713

  
714
        //assert current state
715
        Assert.assertNotNull(newSec);
716
        Assert.assertNull(taxonService.find(1).getSec());
717
        Assert.assertNull(taxonService.find(2).getSec());
718
        Assert.assertNull(taxonService.find(3).getSec());
719
        Assert.assertNull(taxonService.find(4).getSec());
720
        TaxonBase<?> taxon5 = taxonService.find(5);
721
        Assert.assertNotNull(taxon5.getSec());
722
        Assert.assertNotEquals(newSec, taxon5.getSec());
723
        Assert.assertNotNull(taxon5.getSecMicroReference());
724

  
725
        //set secundum
726
        SetSecundumForSubtreeConfigurator config = new SetSecundumForSubtreeConfigurator();
727
        config.setSubtreeUuid(subTreeUuid);
728
        config.setNewSecundum(newSec);
729
        taxonNodeService.setSecundumForSubtree(config);
730

  
731
        commitAndStartNewTransaction(new String[]{"TaxonBase","TaxonBase_AUD"});
732
        Assert.assertEquals(newSec, taxonService.find(1).getSec());
733
        Assert.assertNull(taxonService.find(2).getSec());
734
        Assert.assertEquals(newSec, taxonService.find(3).getSec());
735
        Assert.assertNull(taxonService.find(4).getSec());
736
        taxon5 = taxonService.find(5);
737
        Assert.assertEquals(newSec, taxon5.getSec());
738
        Assert.assertNull(taxon5.getSecMicroReference());
739
    }
740

  
741
    @Test
742
    @DataSet("TaxonNodeServiceImplTest.testSetSecundumForSubtree.xml")
743
    public void testSetSecundumForSubtreeNoOverwrite(){
744
        UUID subTreeUuid = UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
745
//        UUID taxon1uuid = UUID.fromString("55c3e41a-c629-40e6-aa6a-ff274ac6ddb1");
746
//        UUID taxon5uuid = UUID.fromString("d0b99fee-a783-4dda-b8a2-8960703cfcc2");
747
        Reference newSec = referenceService.find(UUID.fromString("1d3fb074-d7ba-47e4-be94-b4cb1a99afa7"));
748

  
749
        //assert current state
750
        Assert.assertNotNull(newSec);
751
        Assert.assertNull(taxonService.find(1).getSec());
752
        Assert.assertNull(taxonService.find(2).getSec());
753
        Assert.assertNull(taxonService.find(3).getSec());
754
        Assert.assertNull(taxonService.find(4).getSec());
755
        TaxonBase<?> taxon5 = taxonService.find(5);
756
        Assert.assertNotNull(taxon5.getSec());
757
        Assert.assertNotEquals(newSec, taxon5.getSec());
758
        Assert.assertNotNull(taxon5.getSecMicroReference());
759

  
760
        //set secundum
761
        SetSecundumForSubtreeConfigurator config = new SetSecundumForSubtreeConfigurator();
762
        config.setSubtreeUuid(subTreeUuid);
763
        config.setNewSecundum(newSec);
764
        config.setOverwriteExistingAccepted(false);
765
        config.setOverwriteExistingSynonyms(false);
766
        taxonNodeService.setSecundumForSubtree(config);
767

  
768
        commitAndStartNewTransaction(new String[]{"TaxonBase","TaxonBase_AUD"});
769
        Assert.assertEquals(newSec, taxonService.find(1).getSec());
770
        Assert.assertNull(taxonService.find(2).getSec());
771
        Assert.assertEquals(newSec, taxonService.find(3).getSec());
772
        Assert.assertNull(taxonService.find(4).getSec());
773
        Reference oldTaxon5Sec = taxon5.getSec();
774
        taxon5 = taxonService.find(5);
775
        Assert.assertEquals(oldTaxon5Sec, taxon5.getSec());
776
        Assert.assertNotEquals(newSec, taxon5.getSec());
777
        Assert.assertNotNull(taxon5.getSecMicroReference());
778
    }
779

  
780
    @Test
781
    @DataSet("TaxonNodeServiceImplTest.testSetSecundumForSubtree.xml")
782
    public void testSetSecundumForSubtreeOnlyAccepted(){
783
        UUID subTreeUuid = UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
784
        Reference newSec = referenceService.find(UUID.fromString("1d3fb074-d7ba-47e4-be94-b4cb1a99afa7"));
785

  
786
        //assert current state
787
        Assert.assertNotNull(newSec);
788
        Assert.assertNull(taxonService.find(1).getSec());
789
        Assert.assertNull(taxonService.find(2).getSec());
790
        Assert.assertNull(taxonService.find(3).getSec());
791
        Assert.assertNull(taxonService.find(4).getSec());
792
        TaxonBase<?> taxon5 = taxonService.find(5);
793
        Assert.assertNotNull(taxon5.getSec());
794
        Assert.assertNotEquals(newSec, taxon5.getSec());
795
        Assert.assertNotNull(taxon5.getSecMicroReference());
796

  
797
        //set secundum
798
        SetSecundumForSubtreeConfigurator config = new SetSecundumForSubtreeConfigurator();
799
        config.setSubtreeUuid(subTreeUuid);
800
        config.setNewSecundum(newSec);
801
        config.setIncludeSynonyms(false);
802
        taxonNodeService.setSecundumForSubtree(config);
803

  
804
        commitAndStartNewTransaction(new String[]{"TaxonBase","TaxonBase_AUD"});
805
        Assert.assertEquals(newSec, taxonService.find(1).getSec());
806
        Assert.assertNull(taxonService.find(2).getSec());
807
        Assert.assertNull(taxonService.find(3).getSec());
808
        Assert.assertNull(taxonService.find(4).getSec());
809
        taxon5 = taxonService.find(5);
810
        Assert.assertEquals(newSec, taxon5.getSec());
811
        Assert.assertNull(taxon5.getSecMicroReference());
812
    }
813

  
814
    @Test
815
    @DataSet("TaxonNodeServiceImplTest.testSetSecundumForSubtree.xml")
816
    public void testSetSecundumForSubtreeOnlySynonyms(){
817
        UUID subTreeUuid = UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
818
        Reference newSec = referenceService.find(UUID.fromString("1d3fb074-d7ba-47e4-be94-b4cb1a99afa7"));
819

  
820
        //assert current state
821
        Assert.assertNotNull(newSec);
822
        Assert.assertNull(taxonService.find(1).getSec());
823
        Assert.assertNull(taxonService.find(2).getSec());
824
        Assert.assertNull(taxonService.find(3).getSec());
825
        Assert.assertNull(taxonService.find(4).getSec());
826
        TaxonBase<?> taxon5 = taxonService.find(5);
827
        Assert.assertNotNull(taxon5.getSec());
828
        Assert.assertNotEquals(newSec, taxon5.getSec());
829
        Assert.assertNotNull(taxon5.getSecMicroReference());
830

  
831
        //set secundum
832
        SetSecundumForSubtreeConfigurator config = new SetSecundumForSubtreeConfigurator();
833
        config.setSubtreeUuid(subTreeUuid);
834
        config.setNewSecundum(newSec);
835
        config.setIncludeAcceptedTaxa(false);
836
        taxonNodeService.setSecundumForSubtree(config);
837

  
838
        commitAndStartNewTransaction(new String[]{"TaxonBase","TaxonBase_AUD"});
839
        Assert.assertNull(taxonService.find(1).getSec());
840
        Assert.assertNull(taxonService.find(2).getSec());
841
        Assert.assertEquals("Synonym should be updated", newSec, taxonService.find(3).getSec());
842
        Assert.assertNull(taxonService.find(4).getSec());
843
        Reference oldTaxon5Sec = taxon5.getSec();
844
        taxon5 = taxonService.find(5);
845
        Assert.assertEquals(oldTaxon5Sec, taxon5.getSec());
846
        Assert.assertNotEquals(newSec, taxon5.getSec());
847
        Assert.assertNotNull(taxon5.getSecMicroReference());
848
    }
849

  
850
    @Test
851
    @DataSet("TaxonNodeServiceImplTest.testSetSecundumForSubtree.xml")
852
    public void testSetSecundumForSubtreeNoShared(){
853
        UUID subTreeUuid = UUID.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
854
        Reference newSec = referenceService.find(UUID.fromString("1d3fb074-d7ba-47e4-be94-b4cb1a99afa7"));
855

  
856
        //assert current state
857
        Assert.assertNotNull(newSec);
858
        Assert.assertNull(taxonService.find(1).getSec());
859
        Assert.assertNull(taxonService.find(2).getSec());
860
        Assert.assertNull(taxonService.find(3).getSec());
861
        Assert.assertNull(taxonService.find(4).getSec());
862
        TaxonBase<?> taxon5 = taxonService.find(5);
863
        Assert.assertNotNull(taxon5.getSec());
864
        Assert.assertNotEquals(newSec, taxon5.getSec());
865
        Assert.assertNotNull(taxon5.getSecMicroReference());
866

  
867
        //set secundum
868
        SetSecundumForSubtreeConfigurator config = new SetSecundumForSubtreeConfigurator();
869
        config.setSubtreeUuid(subTreeUuid);
870
        config.setNewSecundum(newSec);
871
        config.setIncludeSharedTaxa(false);
872
        taxonNodeService.setSecundumForSubtree(config);
873

  
874
        commitAndStartNewTransaction(new String[]{"TaxonBase","TaxonBase_AUD"});
875
        Assert.assertNull("Shared taxon must not be set", taxonService.find(1).getSec());
876
        Assert.assertNull(taxonService.find(2).getSec());
877
        Assert.assertNull("Synonym of shared taxon must not be set", taxonService.find(3).getSec());
878
        Assert.assertNull(taxonService.find(4).getSec());
879
        taxon5 = taxonService.find(5);
880
        Assert.assertEquals(newSec, taxon5.getSec());
881
        Assert.assertNull(taxon5.getSecMicroReference());
882
    }
883

  
704 884

  
705 885
    @Override
706 886
//    @Test
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImplTest.testSetSecundumForSubtree.xml
1
<?xml version='1.0' encoding='UTF-8'?>
2
<dataset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../database/schema/dataset.xsd">
3
    <REFERENCE ID="1" UUID="de7d1205-291f-45d9-9059-ca83fc7ade14" PROTECTEDTITLECACHE="false" REFTYPE="GEN" PROTECTEDABBREVTITLECACHE="false" TITLECACHE="Sp. Pl." TITLE="Sp. Pl." NOMENCLATURALLYRELEVANT="false" PARSINGPROBLEM="0" PROBLEMENDS="-1" PROBLEMSTARTS="-1" />
4
    <REFERENCE ID="2" UUID="1d3fb074-d7ba-47e4-be94-b4cb1a99afa7" PROTECTEDTITLECACHE="false" REFTYPE="GEN" PROTECTEDABBREVTITLECACHE="false" TITLECACHE="New Secundum" TITLE="New Secundum" NOMENCLATURALLYRELEVANT="false" PARSINGPROBLEM="0" PROBLEMENDS="-1" PROBLEMSTARTS="-1" />
5
    <CLASSIFICATION ID="1" UUID="6c2bc8d9-ee62-4222-be89-4a8e31770878"  PROTECTEDTITLECACHE="true" ROOTNODE_ID = "1"/>
6
    <CLASSIFICATION ID="2" UUID="6aa9819a-9bd5-4b54-9149-ed0a832305da"  PROTECTEDTITLECACHE="true" ROOTNODE_ID = "10"/>
7
   <!-- <CLASSIFICATION_TAXONNODE CLASSIFICATION_ID="1" ROOTNODES_ID="1" SORTINDEX="0"/> --> 
8

  
9
    <TAXONNODE ID="1" TAXON_ID="[null]" PARENT_ID="[null]" SORTINDEX="[null]" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="1" UUID="324a1a77-689c-44be-8e65-347d835f4111" COUNTCHILDREN="2" TREEINDEX="#t1#1#"/>
10
    <TAXONNODE ID="2" TAXON_ID="1" PARENT_ID="1" SORTINDEX="0" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="1" UUID="484a1a77-689c-44be-8e65-347d835f47e8"  COUNTCHILDREN="0" TREEINDEX="#t1#1#2#"/>
11
    <TAXONNODE ID="3" TAXON_ID="2" PARENT_ID="1" SORTINDEX="1" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="1" UUID="2d41f0c2-b785-4f73-a436-cc2d5e93cc5b"  COUNTCHILDREN="0" TREEINDEX="#t1#1#3#"/>
12
 	<TAXONNODE ID="4" TAXON_ID="5" PARENT_ID="2" SORTINDEX="0" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="1" UUID="2fbf7bf5-22dd-4c1a-84e4-c8c93d1f0342"  COUNTCHILDREN="0" TREEINDEX="#t1#1#2#4#"/>
13
<!--     <TAXONNODE ID="5" TAXON_ID="1" PARENT_ID="2" SORTINDEX="1" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="1" UUID="cb209758-38d9-440e-9c54-a28dbd8039ea"  COUNTCHILDREN="0" TREEINDEX="#t1#1#2#5#"/> -->
14
    <TAXONNODE ID="10" TAXON_ID="[null]" PARENT_ID="[null]" SORTINDEX="[null]" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="2" UUID="93bd0c60-dd41-4cbc-9228-7e01a7de0526" COUNTCHILDREN="1" TREEINDEX="#t2#10#"/>
15
    <TAXONNODE ID="11" TAXON_ID="1" PARENT_ID="10" SORTINDEX="0" EXCLUDED="FALSE" UNPLACED="FALSE" CLASSIFICATION_ID="2" UUID="9af57eda-9f38-47a2-a8e0-b5c8fd363dde"  COUNTCHILDREN="0" TREEINDEX="#t2#10#11#"/>
16
 
17
    <TAXONBASE DTYPE="Taxon" ID="1" UUID="55c3e41a-c629-40e6-aa6a-ff274ac6ddb1" 	PROTECTEDTITLECACHE="false" DOUBTFUL="false" PUBLISH="true" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"/>
18
    <TAXONBASE DTYPE="Taxon" ID="2" UUID="2659a7e0-ff35-4ee4-8493-b453756ab955" 	PROTECTEDTITLECACHE="false" DOUBTFUL="false" PUBLISH="true" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"/>
19
    <TAXONBASE DTYPE="Synonym" ID="3" UUID="3034249e-9491-4439-bcb6-9c7d68e29bce" 	PROTECTEDTITLECACHE="false" DOUBTFUL="false" PUBLISH="true" USENAMECACHE="false" TAXONSTATUSUNKNOWN="[null]" ACCEPTEDTAXON_ID="1" PARTIAL="false" PROPARTE="false"/>
20
    <TAXONBASE DTYPE="Synonym" ID="4" UUID="ac6c5bb1-d36d-4068-af7c-4f0bb009880d" 	PROTECTEDTITLECACHE="false" DOUBTFUL="false" PUBLISH="true" USENAMECACHE="false" TAXONSTATUSUNKNOWN="[null]" ACCEPTEDTAXON_ID="2" PARTIAL="false" PROPARTE="false"/>
21
	<TAXONBASE DTYPE="Taxon" ID="5" UUID="d0b99fee-a783-4dda-b8a2-8960703cfcc2"	    PROTECTEDTITLECACHE="false" DOUBTFUL="false" PUBLISH="true" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false" SEC_ID="1" SECMICROREFERENCE="page 5"/>
22

  
23
</dataset>

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)