Revision 16833e53
Added by Katja Luther over 5 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonDistributionDTO.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.api.service.dto; |
10 | 10 |
|
11 | 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 | 12 |
import java.util.UUID; |
17 | 13 |
|
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 | 14 |
import eu.etaxonomy.cdm.model.name.Rank; |
23 | 15 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
24 | 16 |
|
... | ... | |
32 | 24 |
private static final long serialVersionUID = -6565463192135410612L; |
33 | 25 |
Taxon taxon; |
34 | 26 |
String nameCache; |
35 |
Rank rank; |
|
27 |
Integer rankOrderIndex; |
|
28 |
String rankLabel; |
|
36 | 29 |
TaxonDescriptionDTO descriptionsWrapper; |
37 |
Map<NamedArea,Set<DescriptionElementBase>> distributionMap = new HashMap(); |
|
30 |
// Map<NamedArea,Set<DescriptionElementBase>> distributionMap = new HashMap();
|
|
38 | 31 |
|
39 | 32 |
|
40 | 33 |
|
... | ... | |
44 | 37 |
if (nameCache == null){ |
45 | 38 |
nameCache = taxon.getTitleCache(); |
46 | 39 |
} |
40 |
this.rankOrderIndex = taxon.getName() != null ? taxon.getName().getRank().getOrderIndex(): null; |
|
41 |
this.rankLabel = taxon.getName() != null ? taxon.getName().getRank().getLabel(): null; |
|
47 | 42 |
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 |
} |
|
43 |
|
|
61 | 44 |
|
62 | 45 |
} |
63 | 46 |
|
... | ... | |
102 | 85 |
* @return the rankString |
103 | 86 |
*/ |
104 | 87 |
public String getRankString() { |
105 |
return rank.getLabel();
|
|
88 |
return rankLabel;
|
|
106 | 89 |
} |
107 | 90 |
|
108 | 91 |
/** |
109 | 92 |
* @return the rank |
110 | 93 |
*/ |
111 |
public Rank getRank() {
|
|
112 |
return rank; |
|
94 |
public Integer getRankOrderIndex() {
|
|
95 |
return rankOrderIndex;
|
|
113 | 96 |
} |
114 | 97 |
|
115 | 98 |
/** |
116 | 99 |
* @param rank the rank to set |
117 | 100 |
*/ |
118 | 101 |
public void setRank(Rank rank) { |
119 |
this.rank = rank; |
|
102 |
if (rank != null){ |
|
103 |
this.rankOrderIndex = rank.getOrderIndex(); |
|
104 |
this.rankLabel = rank.getLabel(); |
|
105 |
} |
|
120 | 106 |
} |
121 | 107 |
|
122 | 108 |
|
... | ... | |
134 | 120 |
this.descriptionsWrapper = descriptionsWrapper; |
135 | 121 |
} |
136 | 122 |
|
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 |
} |
|
123 |
// /**
|
|
124 |
// * @return the distributionMap
|
|
125 |
// */
|
|
126 |
// public Map<NamedArea, Set<DescriptionElementBase>> getDistributionMap() {
|
|
127 |
// return distributionMap;
|
|
128 |
// }
|
|
129 |
// |
|
130 |
// /**
|
|
131 |
// * @param distributionMap the distributionMap to set
|
|
132 |
// */
|
|
133 |
// public void setDistributionMap(Map<NamedArea, Set<DescriptionElementBase>> distributionMap) {
|
|
134 |
// this.distributionMap = distributionMap;
|
|
135 |
// }
|
|
150 | 136 |
|
151 | 137 |
} |
Also available in: Unified diff
ref #7854: adapt DTOs