Project

General

Profile

Revision d914aab4

IDd914aab45e43cd7c0d24f3bf94f609edefd9cae9
Parent b4127a93
Child c790dee7

Added by Andreas Kohlbecker about 2 years ago

fix #7386 adding missing setBasionyms() method to taxonNameDTO

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/model/name/TaxonNameDTO.java
8 8
*/
9 9
package eu.etaxonomy.cdm.vaadin.model.name;
10 10

  
11
import java.util.HashMap;
12
import java.util.HashSet;
11 13
import java.util.List;
14
import java.util.Map;
12 15
import java.util.Set;
13 16

  
14 17
import org.joda.time.DateTime;
......
18 21
import eu.etaxonomy.cdm.model.common.Credit;
19 22
import eu.etaxonomy.cdm.model.common.Extension;
20 23
import eu.etaxonomy.cdm.model.common.Identifier;
24
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
21 25
import eu.etaxonomy.cdm.model.common.User;
22 26
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
27
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
23 28
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
24 29
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
25 30
import eu.etaxonomy.cdm.model.name.Rank;
......
67 72
        return name.getAuthorshipCache();
68 73
    }
69 74

  
70
    public TaxonName getBasionym() {
71
        return name.getBasionym();
72
    }
73

  
74 75
    public TeamOrPersonBase<?> getBasionymAuthorship() {
75 76
        return name.getBasionymAuthorship();
76 77
    }
77 78

  
78 79
    public Set<TaxonName> getBasionyms() {
79
        return name.getBasionyms();
80
        return name.getRelatedNames(Direction.relatedTo, NameRelationshipType.BASIONYM());
81
    }
82

  
83
    public void setBasionyms(Set<TaxonName> basionyms) {
84
        setRelatedTaxa(Direction.relatedTo, NameRelationshipType.BASIONYM(), basionyms);
85
    }
86

  
87
    /**
88
     * @param basionyms
89
     * @param relType
90
     * @param direction
91
     */
92
    protected void setRelatedTaxa(Direction direction, NameRelationshipType relType, Set<TaxonName> basionyms) {
93
        Map<Integer, TaxonName> currentBasionymUuids = new HashMap<>();
94
        Set<Integer> basionymsSeen = new HashSet<>();
95

  
96
        for(TaxonName tn : name.getRelatedNames(direction, relType)){
97
            currentBasionymUuids.put(tn.getId(), tn);
98
        }
99
        for(TaxonName tn : basionyms){
100
            if(!currentBasionymUuids.containsKey(tn.getId())){
101
                name.addBasionym(tn);
102
            } else {
103
                basionymsSeen.add(tn.getId());
104
            }
105
        }
106
        for(TaxonName tn : basionyms){
107
            if(!basionymsSeen.contains(tn.getId())){
108
                name.removeRelationWithTaxonName(tn, direction, relType);
109
            }
110
        }
80 111
    }
81 112

  
82 113
    public TeamOrPersonBase<?> getCombinationAuthorship() {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)