1 |
b40e0f56
|
Patric Plitzner
|
/**
|
2 |
|
|
* Copyright (C) 2015 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 |
d88833a9
|
Patrick Plitzner
|
import java.io.Serializable;
|
12 |
|
|
import java.util.AbstractMap;
|
13 |
77993547
|
Katja Luther
|
import java.util.ArrayList;
|
14 |
a9527b12
|
Andreas Kohlbecker
|
import java.util.Collection;
|
15 |
255327ca
|
Patric Plitzner
|
import java.util.Comparator;
|
16 |
1d8a4f7e
|
Andreas Kohlbecker
|
import java.util.EnumSet;
|
17 |
6b53ead8
|
Katja Luther
|
import java.util.HashSet;
|
18 |
77993547
|
Katja Luther
|
import java.util.List;
|
19 |
1d8a4f7e
|
Andreas Kohlbecker
|
import java.util.Map;
|
20 |
6b53ead8
|
Katja Luther
|
import java.util.Set;
|
21 |
255327ca
|
Patric Plitzner
|
import java.util.TreeSet;
|
22 |
b40e0f56
|
Patric Plitzner
|
|
23 |
7e0e6396
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
24 |
6b53ead8
|
Katja Luther
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
25 |
c233acf5
|
Katja Luther
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
26 |
|
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
27 |
|
|
import eu.etaxonomy.cdm.model.description.Feature;
|
28 |
|
|
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
|
29 |
|
|
import eu.etaxonomy.cdm.model.description.TextData;
|
30 |
77993547
|
Katja Luther
|
import eu.etaxonomy.cdm.model.media.Media;
|
31 |
c233acf5
|
Katja Luther
|
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
|
32 |
|
|
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
|
33 |
6b53ead8
|
Katja Luther
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
34 |
c31ff29d
|
Katja Luther
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
35 |
d70a126f
|
Katja Luther
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
36 |
25dfcf2f
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
37 |
7e0e6396
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
38 |
|
|
import eu.etaxonomy.cdm.model.term.TermBase;
|
39 |
970272ed
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.ref.TypedEntityReference;
|
40 |
d70a126f
|
Katja Luther
|
|
41 |
6b53ead8
|
Katja Luther
|
|
42 |
970272ed
|
Andreas Kohlbecker
|
public abstract class SpecimenOrObservationBaseDTO extends TypedEntityReference<SpecimenOrObservationBase<?>>{
|
43 |
b40e0f56
|
Patric Plitzner
|
|
44 |
a731ca32
|
Patrick Plitzner
|
private static final long serialVersionUID = -7597690654462090732L;
|
45 |
|
|
|
46 |
e1779d28
|
Andreas Kohlbecker
|
private int id;
|
47 |
d88833a9
|
Patrick Plitzner
|
private TreeSet<AbstractMap.SimpleEntry<String, String>> characterData;
|
48 |
d7a609e3
|
Andreas Kohlbecker
|
private DerivationTreeSummaryDTO derivationTreeSummary;
|
49 |
abfe22d1
|
Katja Luther
|
protected String taxonName;
|
50 |
545f8115
|
Katja Luther
|
|
51 |
1d8a4f7e
|
Andreas Kohlbecker
|
protected String summaryLabel;
|
52 |
60d168b0
|
Patric Plitzner
|
protected boolean hasDetailImage;
|
53 |
|
|
private boolean hasCharacterData;
|
54 |
|
|
private boolean hasDna;
|
55 |
b40e0f56
|
Patric Plitzner
|
private boolean hasSpecimenScan;
|
56 |
77993547
|
Katja Luther
|
|
57 |
25dfcf2f
|
Andreas Kohlbecker
|
private SpecimenOrObservationType recordBase;
|
58 |
7e0e6396
|
Andreas Kohlbecker
|
private TermBase kindOfUnit;
|
59 |
6b53ead8
|
Katja Luther
|
private CollectionDTO collection;
|
60 |
|
|
private String catalogNumber;
|
61 |
|
|
private String collectorsNumber;
|
62 |
|
|
private String barcode;
|
63 |
|
|
private String preservationMethod;
|
64 |
dc174713
|
Andreas Kohlbecker
|
private String individualCount;
|
65 |
002cdd32
|
Andreas Kohlbecker
|
private Set<DerivedUnitDTO> derivatives;
|
66 |
6b53ead8
|
Katja Luther
|
|
67 |
e2334714
|
Andreas Kohlbecker
|
private Set<SpecimenTypeDesignationDTO> specimenTypeDesignations;
|
68 |
6b53ead8
|
Katja Luther
|
|
69 |
|
|
private DerivationEventDTO derivationEvent;
|
70 |
|
|
|
71 |
54b7f04e
|
Andreas Kohlbecker
|
// TODO use DTO !!!
|
72 |
6b53ead8
|
Katja Luther
|
private Set<IdentifiableSource> sources;
|
73 |
c233acf5
|
Katja Luther
|
private List<MediaDTO> listOfMedia = new ArrayList<>();
|
74 |
6b53ead8
|
Katja Luther
|
|
75 |
7e0e6396
|
Andreas Kohlbecker
|
private DefinedTerm sex;
|
76 |
|
|
|
77 |
|
|
private DefinedTerm lifeStage;
|
78 |
|
|
|
79 |
970272ed
|
Andreas Kohlbecker
|
protected SpecimenOrObservationBaseDTO(SpecimenOrObservationBase<?> specimenOrObservation) {
|
80 |
9ad46d6b
|
Andreas Kohlbecker
|
super(HibernateProxyHelper.getClassWithoutInitializingProxy(specimenOrObservation), specimenOrObservation.getUuid(), specimenOrObservation.getTitleCache());
|
81 |
e1779d28
|
Andreas Kohlbecker
|
this.id = specimenOrObservation.getId();
|
82 |
9c9b6874
|
Andreas Kohlbecker
|
Set<Media> collectedMedia = collectMedia(specimenOrObservation);
|
83 |
|
|
addMediaAsDTO(collectedMedia);
|
84 |
7e0e6396
|
Andreas Kohlbecker
|
setKindOfUnit(specimenOrObservation.getKindOfUnit());
|
85 |
|
|
setSex(specimenOrObservation.getSex());
|
86 |
dc174713
|
Andreas Kohlbecker
|
setIndividualCount(specimenOrObservation.getIndividualCount());
|
87 |
7e0e6396
|
Andreas Kohlbecker
|
lifeStage = specimenOrObservation.getLifeStage();
|
88 |
c31ff29d
|
Katja Luther
|
if (specimenOrObservation instanceof DerivedUnit){
|
89 |
|
|
DerivedUnit derivedUnit = (DerivedUnit)specimenOrObservation;
|
90 |
|
|
if (derivedUnit.getSpecimenTypeDesignations() != null){
|
91 |
|
|
setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations());
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
d70a126f
|
Katja Luther
|
}
|
95 |
6b53ead8
|
Katja Luther
|
|
96 |
|
|
public void setCollection(CollectionDTO collection) {
|
97 |
|
|
this.collection = collection;
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
public String getCatalogNumber() {
|
101 |
|
|
return catalogNumber;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
public void setCatalogNumber(String catalogNumber) {
|
105 |
|
|
this.catalogNumber = catalogNumber;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
public String getCollectorsNumber() {
|
109 |
|
|
return collectorsNumber;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
public void setCollectorsNumber(String collectorsNumber) {
|
113 |
|
|
this.collectorsNumber = collectorsNumber;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
public String getBarcode() {
|
117 |
|
|
return barcode;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
public void setBarcode(String barcode) {
|
121 |
|
|
this.barcode = barcode;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
public String getPreservationMethod() {
|
125 |
|
|
return preservationMethod;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
public void setPreservationMethod(String preservationMethod) {
|
129 |
|
|
this.preservationMethod = preservationMethod;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
e2334714
|
Andreas Kohlbecker
|
public Set<SpecimenTypeDesignationDTO> getSpecimenTypeDesignations() {
|
133 |
6b53ead8
|
Katja Luther
|
return specimenTypeDesignations;
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
public void setSpecimenTypeDesignations(Set<SpecimenTypeDesignation> specimenTypeDesignations) {
|
137 |
d88833a9
|
Patrick Plitzner
|
this.specimenTypeDesignations = new HashSet<>();
|
138 |
cb9801c1
|
Katja Luther
|
for (SpecimenTypeDesignation typeDes: specimenTypeDesignations){
|
139 |
442916a4
|
Katja Luther
|
if (typeDes != null){
|
140 |
1d9ed98e
|
Andreas Kohlbecker
|
this.specimenTypeDesignations.add(new SpecimenTypeDesignationDTO(typeDes));
|
141 |
442916a4
|
Katja Luther
|
}
|
142 |
cb9801c1
|
Katja Luther
|
}
|
143 |
|
|
|
144 |
6b53ead8
|
Katja Luther
|
}
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
public Set<IdentifiableSource> getSources() {
|
148 |
|
|
return sources;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
public void setSources(Set<IdentifiableSource> sources) {
|
152 |
|
|
this.sources = sources;
|
153 |
|
|
}
|
154 |
b40e0f56
|
Patric Plitzner
|
|
155 |
77993547
|
Katja Luther
|
|
156 |
b40e0f56
|
Patric Plitzner
|
/**
|
157 |
|
|
* @return the derivateDataDTO
|
158 |
|
|
*/
|
159 |
d7a609e3
|
Andreas Kohlbecker
|
public DerivationTreeSummaryDTO getDerivationTreeSummary() {
|
160 |
|
|
return derivationTreeSummary;
|
161 |
b40e0f56
|
Patric Plitzner
|
}
|
162 |
|
|
|
163 |
|
|
/**
|
164 |
d7a609e3
|
Andreas Kohlbecker
|
* @param derivationTreeSummary the derivateDataDTO to set
|
165 |
b40e0f56
|
Patric Plitzner
|
*/
|
166 |
d7a609e3
|
Andreas Kohlbecker
|
public void setDerivationTreeSummary(DerivationTreeSummaryDTO derivationTreeSummary) {
|
167 |
|
|
this.derivationTreeSummary = derivationTreeSummary;
|
168 |
|
|
if(derivationTreeSummary != null) {
|
169 |
|
|
setHasSpecimenScan(isHasSpecimenScan() || !derivationTreeSummary.getSpecimenScans().isEmpty());
|
170 |
|
|
setHasDetailImage(isHasDetailImage() || !derivationTreeSummary.getDetailImages().isEmpty());
|
171 |
|
|
setHasDna(isHasDna() || !derivationTreeSummary.getMolecularDataList().isEmpty());
|
172 |
8dcc00a3
|
Andreas Kohlbecker
|
}
|
173 |
b40e0f56
|
Patric Plitzner
|
}
|
174 |
|
|
|
175 |
|
|
/**
|
176 |
|
|
* @return the characterData
|
177 |
|
|
*/
|
178 |
d88833a9
|
Patrick Plitzner
|
public TreeSet<AbstractMap.SimpleEntry<String, String>> getCharacterData() {
|
179 |
b40e0f56
|
Patric Plitzner
|
return characterData;
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
public void addCharacterData(String character, String state){
|
183 |
|
|
if(characterData==null){
|
184 |
d88833a9
|
Patrick Plitzner
|
characterData = new TreeSet<AbstractMap.SimpleEntry<String,String>>(new PairComparator());
|
185 |
b40e0f56
|
Patric Plitzner
|
}
|
186 |
d88833a9
|
Patrick Plitzner
|
characterData.add(new AbstractMap.SimpleEntry<>(character, state));
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
private class PairComparator implements Comparator<AbstractMap.SimpleEntry<String,String>>, Serializable {
|
190 |
|
|
|
191 |
|
|
private static final long serialVersionUID = -8589392050761963540L;
|
192 |
|
|
|
193 |
|
|
@Override
|
194 |
|
|
public int compare(AbstractMap.SimpleEntry<String, String> o1, AbstractMap.SimpleEntry<String, String> o2) {
|
195 |
|
|
if(o1==null && o2!=null){
|
196 |
|
|
return -1;
|
197 |
|
|
}
|
198 |
|
|
if(o1!=null && o2==null){
|
199 |
|
|
return 1;
|
200 |
|
|
}
|
201 |
|
|
if(o1!=null && o2!=null){
|
202 |
|
|
return o1.getKey().compareTo(o2.getKey());
|
203 |
|
|
}
|
204 |
|
|
return 0;
|
205 |
|
|
}
|
206 |
b40e0f56
|
Patric Plitzner
|
}
|
207 |
|
|
|
208 |
60d168b0
|
Patric Plitzner
|
/**
|
209 |
|
|
* @return the hasCharacterData
|
210 |
|
|
*/
|
211 |
|
|
public boolean isHasCharacterData() {
|
212 |
|
|
return hasCharacterData;
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
/**
|
216 |
|
|
* @param hasCharacterData the hasCharacterData to set
|
217 |
|
|
*/
|
218 |
|
|
public void setHasCharacterData(boolean hasCharacterData) {
|
219 |
|
|
this.hasCharacterData = hasCharacterData;
|
220 |
|
|
}
|
221 |
|
|
|
222 |
b40e0f56
|
Patric Plitzner
|
/**
|
223 |
|
|
* @return the hasDna
|
224 |
|
|
*/
|
225 |
|
|
public boolean isHasDna() {
|
226 |
|
|
return hasDna;
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
/**
|
230 |
|
|
* @param hasDna the hasDna to set
|
231 |
|
|
*/
|
232 |
|
|
public void setHasDna(boolean hasDna) {
|
233 |
|
|
this.hasDna = hasDna;
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
/**
|
237 |
|
|
* @return the hasDetailImage
|
238 |
|
|
*/
|
239 |
|
|
public boolean isHasDetailImage() {
|
240 |
|
|
return hasDetailImage;
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
/**
|
244 |
|
|
* @param hasDetailImage the hasDetailImage to set
|
245 |
|
|
*/
|
246 |
|
|
public void setHasDetailImage(boolean hasDetailImage) {
|
247 |
|
|
this.hasDetailImage = hasDetailImage;
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
/**
|
251 |
|
|
* @return the hasSpecimenScan
|
252 |
|
|
*/
|
253 |
|
|
public boolean isHasSpecimenScan() {
|
254 |
|
|
return hasSpecimenScan;
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
/**
|
258 |
|
|
* @param hasSpecimenScan the hasSpecimenScan to set
|
259 |
|
|
*/
|
260 |
|
|
public void setHasSpecimenScan(boolean hasSpecimenScan) {
|
261 |
|
|
this.hasSpecimenScan = hasSpecimenScan;
|
262 |
|
|
}
|
263 |
60d168b0
|
Patric Plitzner
|
/**
|
264 |
1d8a4f7e
|
Andreas Kohlbecker
|
* @return The summary of all DerivedUnit identifiers with the label of
|
265 |
|
|
* this SpecimenOrObservationBase.
|
266 |
|
|
* This label is usually being user for citing the unit in publications.
|
267 |
60d168b0
|
Patric Plitzner
|
*/
|
268 |
1d8a4f7e
|
Andreas Kohlbecker
|
public String getSummaryLabel() {
|
269 |
|
|
return summaryLabel;
|
270 |
60d168b0
|
Patric Plitzner
|
}
|
271 |
1d8a4f7e
|
Andreas Kohlbecker
|
|
272 |
60d168b0
|
Patric Plitzner
|
/**
|
273 |
1d8a4f7e
|
Andreas Kohlbecker
|
* Summary of all DerivedUnit identifiers with the label of this SpecimenOrObservationBase.
|
274 |
|
|
* This label is usually being user for citing the unit in publications.
|
275 |
60d168b0
|
Patric Plitzner
|
*/
|
276 |
1d8a4f7e
|
Andreas Kohlbecker
|
public void setSummaryLabel(String summaryLabel) {
|
277 |
|
|
this.summaryLabel = summaryLabel;
|
278 |
60d168b0
|
Patric Plitzner
|
}
|
279 |
b40e0f56
|
Patric Plitzner
|
|
280 |
77993547
|
Katja Luther
|
|
281 |
25dfcf2f
|
Andreas Kohlbecker
|
public SpecimenOrObservationType getRecordBase() {
|
282 |
6b53ead8
|
Katja Luther
|
return recordBase;
|
283 |
|
|
}
|
284 |
25dfcf2f
|
Andreas Kohlbecker
|
public void setRecordBase(SpecimenOrObservationType specimenOrObservationType) {
|
285 |
|
|
this.recordBase = specimenOrObservationType;
|
286 |
6b53ead8
|
Katja Luther
|
}
|
287 |
|
|
|
288 |
|
|
/**
|
289 |
|
|
* @return the collection
|
290 |
8cbcd5c2
|
Andreas Kohlbecker
|
*
|
291 |
|
|
* @deprecated TODO remove as it only duplicates the information contained in the collectionDTO
|
292 |
6b53ead8
|
Katja Luther
|
*/
|
293 |
8cbcd5c2
|
Andreas Kohlbecker
|
@Deprecated
|
294 |
|
|
public String getCollectionCode() {
|
295 |
6b53ead8
|
Katja Luther
|
if (collection != null){
|
296 |
|
|
return collection.getCode();
|
297 |
|
|
} else {
|
298 |
|
|
return null;
|
299 |
|
|
}
|
300 |
|
|
}
|
301 |
8cbcd5c2
|
Andreas Kohlbecker
|
|
302 |
6b53ead8
|
Katja Luther
|
/**
|
303 |
|
|
* @return the collection
|
304 |
|
|
*/
|
305 |
8cbcd5c2
|
Andreas Kohlbecker
|
public CollectionDTO getCollection() {
|
306 |
6b53ead8
|
Katja Luther
|
return collection;
|
307 |
|
|
}
|
308 |
|
|
/**
|
309 |
|
|
* @param collection the collection to set
|
310 |
|
|
*/
|
311 |
1d8a4f7e
|
Andreas Kohlbecker
|
public void setCollectioDTO(CollectionDTO collection) {
|
312 |
6b53ead8
|
Katja Luther
|
this.collection = collection;
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
002cdd32
|
Andreas Kohlbecker
|
public Set<DerivedUnitDTO> getDerivatives() {
|
318 |
|
|
if (this.derivatives == null){
|
319 |
|
|
this.derivatives = new HashSet<>();
|
320 |
a9527b12
|
Andreas Kohlbecker
|
}
|
321 |
002cdd32
|
Andreas Kohlbecker
|
return derivatives;
|
322 |
6b53ead8
|
Katja Luther
|
}
|
323 |
|
|
|
324 |
002cdd32
|
Andreas Kohlbecker
|
public void setDerivatives(Set<DerivedUnitDTO> derivatives) {
|
325 |
|
|
this.derivatives = derivatives;
|
326 |
6b53ead8
|
Katja Luther
|
}
|
327 |
|
|
|
328 |
021cc0fe
|
Andreas Kohlbecker
|
public void addDerivative(DerivedUnitDTO derivate){
|
329 |
002cdd32
|
Andreas Kohlbecker
|
if (this.derivatives == null){
|
330 |
|
|
this.derivatives = new HashSet<>();
|
331 |
6b53ead8
|
Katja Luther
|
}
|
332 |
002cdd32
|
Andreas Kohlbecker
|
this.derivatives.add(derivate);
|
333 |
6b53ead8
|
Katja Luther
|
}
|
334 |
002cdd32
|
Andreas Kohlbecker
|
public void addAllDerivatives(Set<DerivedUnitDTO> derivatives){
|
335 |
|
|
if (this.derivatives == null){
|
336 |
|
|
this.derivatives = new HashSet<>();
|
337 |
6b53ead8
|
Katja Luther
|
}
|
338 |
002cdd32
|
Andreas Kohlbecker
|
this.derivatives.addAll(derivatives);
|
339 |
6b53ead8
|
Katja Luther
|
}
|
340 |
a9527b12
|
Andreas Kohlbecker
|
|
341 |
|
|
/**
|
342 |
6b891987
|
Andreas Kohlbecker
|
* Recursively collects all derivatives from this.
|
343 |
a9527b12
|
Andreas Kohlbecker
|
*/
|
344 |
|
|
public Collection<DerivedUnitDTO> collectDerivatives() {
|
345 |
|
|
return collectDerivatives(new HashSet<>());
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
/**
|
349 |
|
|
* private partner method to {@link #collectDerivatives()} for recursive calls.
|
350 |
|
|
*
|
351 |
|
|
* @param dtos
|
352 |
|
|
*/
|
353 |
|
|
private Collection<DerivedUnitDTO> collectDerivatives(Set<DerivedUnitDTO> dtos) {
|
354 |
002cdd32
|
Andreas Kohlbecker
|
dtos.addAll(getDerivatives());
|
355 |
|
|
if(derivatives != null) {
|
356 |
|
|
for(SpecimenOrObservationBaseDTO subDto : derivatives) {
|
357 |
a9527b12
|
Andreas Kohlbecker
|
dtos.addAll(subDto.collectDerivatives(dtos));
|
358 |
|
|
}
|
359 |
|
|
}
|
360 |
|
|
return dtos;
|
361 |
|
|
}
|
362 |
6b53ead8
|
Katja Luther
|
|
363 |
1d8a4f7e
|
Andreas Kohlbecker
|
|
364 |
|
|
|
365 |
6b53ead8
|
Katja Luther
|
public DerivationEventDTO getDerivationEvent() {
|
366 |
|
|
return derivationEvent;
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
public void setDerivationEvent(DerivationEventDTO derivationEvent) {
|
370 |
|
|
this.derivationEvent = derivationEvent;
|
371 |
|
|
}
|
372 |
|
|
|
373 |
77993547
|
Katja Luther
|
|
374 |
|
|
/**
|
375 |
|
|
* @return the listOfMedia
|
376 |
|
|
*/
|
377 |
c233acf5
|
Katja Luther
|
public List<MediaDTO> getListOfMedia() {
|
378 |
77993547
|
Katja Luther
|
return listOfMedia;
|
379 |
6b53ead8
|
Katja Luther
|
}
|
380 |
|
|
|
381 |
77993547
|
Katja Luther
|
/**
|
382 |
|
|
* @param listOfMedia the listOfMedia to set
|
383 |
|
|
*/
|
384 |
c233acf5
|
Katja Luther
|
public void setListOfMedia(List<MediaDTO> listOfMedia) {
|
385 |
77993547
|
Katja Luther
|
this.listOfMedia = listOfMedia;
|
386 |
6b53ead8
|
Katja Luther
|
}
|
387 |
|
|
|
388 |
9c9b6874
|
Andreas Kohlbecker
|
|
389 |
|
|
protected Set<Media> collectMedia(SpecimenOrObservationBase<?> specimenOrObservation){
|
390 |
|
|
Set<Media> collectedMedia = new HashSet<>();
|
391 |
|
|
Set<SpecimenDescription> descriptions = specimenOrObservation.getSpecimenDescriptionImageGallery();
|
392 |
|
|
for (DescriptionBase<?> desc : descriptions){
|
393 |
c233acf5
|
Katja Luther
|
if (desc instanceof SpecimenDescription){
|
394 |
|
|
SpecimenDescription specimenDesc = (SpecimenDescription)desc;
|
395 |
c31ff29d
|
Katja Luther
|
for (DescriptionElementBase element : specimenDesc.getElements()){
|
396 |
|
|
if (element.isInstanceOf(TextData.class)&& element.getFeature().equals(Feature.IMAGE())) {
|
397 |
|
|
for (Media media :element.getMedia()){
|
398 |
9c9b6874
|
Andreas Kohlbecker
|
collectedMedia.add(media);
|
399 |
c233acf5
|
Katja Luther
|
}
|
400 |
|
|
}
|
401 |
|
|
}
|
402 |
|
|
}
|
403 |
|
|
}
|
404 |
9c9b6874
|
Andreas Kohlbecker
|
return collectedMedia;
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
private void addMediaAsDTO(Set<Media> media) {
|
408 |
|
|
for(Media m : media) {
|
409 |
|
|
m.getAllTitles(); // initialize all titles!!!
|
410 |
|
|
for (MediaRepresentation rep :m.getRepresentations()){
|
411 |
|
|
for(MediaRepresentationPart p : rep.getParts()){
|
412 |
|
|
if(p.getUri() != null){
|
413 |
|
|
MediaDTO dto = new MediaDTO(m.getUuid());
|
414 |
|
|
dto.setUri(p.getUri().toString());
|
415 |
|
|
getListOfMedia().add(dto);
|
416 |
|
|
}
|
417 |
|
|
}
|
418 |
|
|
}
|
419 |
|
|
}
|
420 |
c233acf5
|
Katja Luther
|
}
|
421 |
9c9b6874
|
Andreas Kohlbecker
|
|
422 |
1d8a4f7e
|
Andreas Kohlbecker
|
/**
|
423 |
|
|
* @param sob
|
424 |
|
|
* The Unit to assemble the derivatives information for
|
425 |
2edb5aa1
|
Andreas Kohlbecker
|
* @param maxDepth
|
426 |
|
|
* The maximum number of derivation events levels up to which derivatives are to be assembled.
|
427 |
|
|
* <code>NULL</code> means infinitely.
|
428 |
|
|
* @param includeTypes
|
429 |
1d8a4f7e
|
Andreas Kohlbecker
|
* Allows for positive filtering by {@link SpecimenOrObservationType}.
|
430 |
|
|
* Filter is disabled when <code>NULL</code>. This only affects the derivatives assembled in the
|
431 |
2edb5aa1
|
Andreas Kohlbecker
|
* {@link #derivatives} list. The <code>unitLabelsByCollection</code> are always collected for the
|
432 |
1d8a4f7e
|
Andreas Kohlbecker
|
* whole bouquet of derivatives.
|
433 |
2edb5aa1
|
Andreas Kohlbecker
|
* @param unitLabelsByCollection
|
434 |
1d8a4f7e
|
Andreas Kohlbecker
|
* A map to record the unit labels (most significant identifier + collection code) per collection.
|
435 |
|
|
* Optional parameter, may be <code>NULL</code>.
|
436 |
|
|
*/
|
437 |
|
|
protected void assembleDerivatives(SpecimenOrObservationBase<?> sob,
|
438 |
2edb5aa1
|
Andreas Kohlbecker
|
Integer maxDepth, EnumSet<SpecimenOrObservationType> includeTypes,
|
439 |
1d8a4f7e
|
Andreas Kohlbecker
|
Map<eu.etaxonomy.cdm.model.occurrence.Collection, List<String>> unitLabelsByCollection) {
|
440 |
|
|
|
441 |
2edb5aa1
|
Andreas Kohlbecker
|
boolean doDescend = maxDepth == null || maxDepth > 0;
|
442 |
|
|
Integer nextLevelMaxDepth = maxDepth != null ? maxDepth - 1 : null;
|
443 |
1d8a4f7e
|
Andreas Kohlbecker
|
for (DerivedUnit derivedUnit : sob.collectDerivedUnits()) {
|
444 |
|
|
if(!derivedUnit.isPublish()){
|
445 |
|
|
continue;
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
if(unitLabelsByCollection != null) {
|
449 |
|
|
// collect accession numbers for citation
|
450 |
|
|
// collect collections for herbaria column
|
451 |
|
|
eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
|
452 |
|
|
if (collection != null) {
|
453 |
|
|
//combine collection with identifier
|
454 |
|
|
String identifier = derivedUnit.getMostSignificantIdentifier();
|
455 |
|
|
if (identifier != null && collection.getCode()!=null) {
|
456 |
|
|
identifier = (collection.getCode()!=null?collection.getCode():"[no collection]")+" "+identifier;
|
457 |
|
|
}
|
458 |
|
|
if(!unitLabelsByCollection.containsKey(collection)) {
|
459 |
|
|
unitLabelsByCollection.put(collection, new ArrayList<>());
|
460 |
|
|
}
|
461 |
|
|
unitLabelsByCollection.get(collection).add(identifier);
|
462 |
|
|
}
|
463 |
|
|
}
|
464 |
|
|
|
465 |
2edb5aa1
|
Andreas Kohlbecker
|
if (doDescend && (includeTypes == null || includeTypes.contains(derivedUnit.getRecordBasis()))) {
|
466 |
|
|
DerivedUnitDTO derivedUnitDTO = DerivedUnitDTO.fromEntity(derivedUnit, nextLevelMaxDepth, includeTypes, null);
|
467 |
021cc0fe
|
Andreas Kohlbecker
|
addDerivative(derivedUnitDTO);
|
468 |
1d8a4f7e
|
Andreas Kohlbecker
|
setHasCharacterData(isHasCharacterData() || derivedUnitDTO.isHasCharacterData());
|
469 |
|
|
// NOTE! the flags setHasDetailImage, setHasDna, setHasSpecimenScan are also set in
|
470 |
|
|
// setDerivateDataDTO(), see below
|
471 |
|
|
setHasDetailImage(isHasDetailImage() || derivedUnitDTO.isHasDetailImage());
|
472 |
|
|
setHasDna(isHasDna() || derivedUnitDTO.isHasDna());
|
473 |
|
|
setHasSpecimenScan(isHasSpecimenScan() || derivedUnitDTO.isHasSpecimenScan());
|
474 |
|
|
}
|
475 |
|
|
}
|
476 |
|
|
}
|
477 |
|
|
|
478 |
7e0e6396
|
Andreas Kohlbecker
|
public TermBase getKindOfUnit() {
|
479 |
|
|
return kindOfUnit;
|
480 |
|
|
}
|
481 |
|
|
public void setKindOfUnit(TermBase kindOfUnit) {
|
482 |
|
|
this.kindOfUnit = HibernateProxyHelper.deproxy(kindOfUnit);
|
483 |
|
|
}
|
484 |
|
|
public DefinedTerm getSex() {
|
485 |
|
|
return sex;
|
486 |
|
|
}
|
487 |
|
|
public void setSex(DefinedTerm sex) {
|
488 |
|
|
this.sex = sex;
|
489 |
|
|
}
|
490 |
|
|
public DefinedTerm getLifeStage() {
|
491 |
|
|
return lifeStage;
|
492 |
c31ff29d
|
Katja Luther
|
}
|
493 |
7e0e6396
|
Andreas Kohlbecker
|
public void setLifeStage(DefinedTerm lifeStage) {
|
494 |
|
|
this.lifeStage = lifeStage;
|
495 |
c31ff29d
|
Katja Luther
|
}
|
496 |
c233acf5
|
Katja Luther
|
|
497 |
b40e0f56
|
Patric Plitzner
|
|
498 |
e1779d28
|
Andreas Kohlbecker
|
public int getId() {
|
499 |
|
|
return id;
|
500 |
|
|
}
|
501 |
|
|
|
502 |
dc174713
|
Andreas Kohlbecker
|
public String getIndividualCount() {
|
503 |
|
|
return individualCount;
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
public void setIndividualCount(String individualCount) {
|
507 |
|
|
this.individualCount = individualCount;
|
508 |
|
|
}
|
509 |
|
|
|
510 |
e1779d28
|
Andreas Kohlbecker
|
|
511 |
b40e0f56
|
Patric Plitzner
|
}
|