Project

General

Profile

Download (3.61 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
    UUID taxonUuid;
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.taxonUuid = taxon.getUuid();
43
        this.nameCache = taxon.getName().getNameCache();
44
        this.descriptionsWrapper = new TaxonDescriptionDTO(taxon);
45
        for (TaxonDescription desc: descriptionsWrapper.descriptions){
46
            for (DescriptionElementBase descElement: desc.getElements()){
47
                if (descElement instanceof Distribution){
48
                    Set<DescriptionElementBase> distributions = distributionMap.get(((Distribution)descElement).getArea());
49
                    if (distributions == null){
50
                        distributions = new HashSet();
51
                        distributionMap.put(((Distribution)descElement).getArea(), distributions);
52
                    }
53
                    distributions.add(descElement);
54

    
55
                }
56
            }
57
        }
58

    
59
    }
60

    
61
   /* ------ Getter / Setter -----------*/
62

    
63
    /**
64
     * @return the taxonUuid
65
     */
66
    public UUID getTaxonUuid() {
67
        return taxonUuid;
68
    }
69

    
70
    /**
71
     * @param taxonUuid the taxonUuid to set
72
     */
73
    public void setTaxonUuid(UUID taxonUuid) {
74
        this.taxonUuid = taxonUuid;
75
    }
76

    
77
    /**
78
     * @return the nameCache
79
     */
80
    public String getNameCache() {
81
        return nameCache;
82
    }
83

    
84
    /**
85
     * @param nameCache the nameCache to set
86
     */
87
    public void setNameCache(String nameCache) {
88
        this.nameCache = nameCache;
89
    }
90

    
91
    /**
92
     * @return the rankString
93
     */
94
    public String getRankString() {
95
        return rank.getLabel();
96
    }
97

    
98
    /**
99
     * @return the rank
100
     */
101
    public Rank getRank() {
102
        return rank;
103
    }
104

    
105
    /**
106
     * @param rank the rank to set
107
     */
108
    public void setRank(Rank rank) {
109
        this.rank = rank;
110
    }
111

    
112

    
113
    /**
114
     * @return the descriptionsWrapper
115
     */
116
    public TaxonDescriptionDTO getDescriptionsWrapper() {
117
        return descriptionsWrapper;
118
    }
119

    
120
    /**
121
     * @param descriptionsWrapper the descriptionsWrapper to set
122
     */
123
    public void setDescriptionsWrapper(TaxonDescriptionDTO descriptionsWrapper) {
124
        this.descriptionsWrapper = descriptionsWrapper;
125
    }
126

    
127
    /**
128
     * @return the distributionMap
129
     */
130
    public Map<NamedArea, Set<DescriptionElementBase>> getDistributionMap() {
131
        return distributionMap;
132
    }
133

    
134
    /**
135
     * @param distributionMap the distributionMap to set
136
     */
137
    public void setDistributionMap(Map<NamedArea, Set<DescriptionElementBase>> distributionMap) {
138
        this.distributionMap = distributionMap;
139
    }
140

    
141
}
(27-27/30)