Project

General

Profile

Download (3.83 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.dto;
10

    
11
import java.io.Serializable;
12
import java.util.HashMap;
13
import java.util.HashSet;
14
import java.util.Map;
15
import java.util.Set;
16
import java.util.UUID;
17

    
18
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
19
import eu.etaxonomy.cdm.model.description.Distribution;
20
import eu.etaxonomy.cdm.model.description.TaxonDescription;
21
import eu.etaxonomy.cdm.model.location.NamedArea;
22
import eu.etaxonomy.cdm.model.name.Rank;
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24

    
25
/**
26
 * @author k.luther
27
 * @since 27.11.2018
28
 *
29
 */
30
public class TaxonDistributionDTO implements Serializable{
31

    
32
    private static final long serialVersionUID = -6565463192135410612L;
33
    Taxon taxon;
34
    String nameCache;
35
    Rank rank;
36
    TaxonDescriptionDTO descriptionsWrapper;
37
    Map<NamedArea,Set<DescriptionElementBase>> distributionMap = new HashMap();
38

    
39

    
40

    
41
    public TaxonDistributionDTO(Taxon taxon){
42
        this.taxon = taxon;
43
        this.nameCache = taxon.getName().getNameCache() != null ? taxon.getName().getNameCache(): taxon.getName().getTitleCache();
44
        if (nameCache == null){
45
            nameCache = taxon.getTitleCache();
46
        }
47
        this.descriptionsWrapper = new TaxonDescriptionDTO(taxon);
48
        for (TaxonDescription desc: descriptionsWrapper.descriptions){
49
            for (DescriptionElementBase descElement: desc.getElements()){
50
                if (descElement instanceof Distribution){
51
                    Set<DescriptionElementBase> distributions = distributionMap.get(((Distribution)descElement).getArea());
52
                    if (distributions == null){
53
                        distributions = new HashSet();
54
                        distributionMap.put(((Distribution)descElement).getArea(), distributions);
55
                    }
56
                    distributions.add(descElement);
57

    
58
                }
59
            }
60
        }
61

    
62
    }
63

    
64
   /* ------ Getter / Setter -----------*/
65

    
66
    /**
67
     * @return the taxonUuid
68
     */
69
    public UUID getTaxonUuid() {
70
        return taxon.getUuid();
71
    }
72
    /**
73
     * @return the taxon
74
     */
75
    public Taxon getTaxon() {
76
        return taxon;
77
    }
78

    
79

    
80
    /**
81
     * @param taxon the taxon to set
82
     */
83
    public void setTaxon(Taxon taxon) {
84
        this.taxon = taxon;
85
    }
86

    
87
    /**
88
     * @return the nameCache
89
     */
90
    public String getNameCache() {
91
        return nameCache;
92
    }
93

    
94
    /**
95
     * @param nameCache the nameCache to set
96
     */
97
    public void setNameCache(String nameCache) {
98
        this.nameCache = nameCache;
99
    }
100

    
101
    /**
102
     * @return the rankString
103
     */
104
    public String getRankString() {
105
        return rank.getLabel();
106
    }
107

    
108
    /**
109
     * @return the rank
110
     */
111
    public Rank getRank() {
112
        return rank;
113
    }
114

    
115
    /**
116
     * @param rank the rank to set
117
     */
118
    public void setRank(Rank rank) {
119
        this.rank = rank;
120
    }
121

    
122

    
123
    /**
124
     * @return the descriptionsWrapper
125
     */
126
    public TaxonDescriptionDTO getDescriptionsWrapper() {
127
        return descriptionsWrapper;
128
    }
129

    
130
    /**
131
     * @param descriptionsWrapper the descriptionsWrapper to set
132
     */
133
    public void setDescriptionsWrapper(TaxonDescriptionDTO descriptionsWrapper) {
134
        this.descriptionsWrapper = descriptionsWrapper;
135
    }
136

    
137
    /**
138
     * @return the distributionMap
139
     */
140
    public Map<NamedArea, Set<DescriptionElementBase>> getDistributionMap() {
141
        return distributionMap;
142
    }
143

    
144
    /**
145
     * @param distributionMap the distributionMap to set
146
     */
147
    public void setDistributionMap(Map<NamedArea, Set<DescriptionElementBase>> distributionMap) {
148
        this.distributionMap = distributionMap;
149
    }
150

    
151
}
(27-27/30)