1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.model.occurrence;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.Collection;
|
15
|
import java.util.HashMap;
|
16
|
import java.util.HashSet;
|
17
|
import java.util.Map;
|
18
|
import java.util.Set;
|
19
|
|
20
|
import javax.persistence.Column;
|
21
|
import javax.persistence.Entity;
|
22
|
import javax.persistence.FetchType;
|
23
|
import javax.persistence.Inheritance;
|
24
|
import javax.persistence.InheritanceType;
|
25
|
import javax.persistence.ManyToMany;
|
26
|
import javax.persistence.ManyToOne;
|
27
|
import javax.persistence.MapKeyJoinColumn;
|
28
|
import javax.persistence.OneToMany;
|
29
|
import javax.persistence.Transient;
|
30
|
import javax.validation.constraints.Min;
|
31
|
import javax.validation.constraints.NotNull;
|
32
|
import javax.xml.bind.annotation.XmlAccessType;
|
33
|
import javax.xml.bind.annotation.XmlAccessorType;
|
34
|
import javax.xml.bind.annotation.XmlAttribute;
|
35
|
import javax.xml.bind.annotation.XmlElement;
|
36
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
37
|
import javax.xml.bind.annotation.XmlIDREF;
|
38
|
import javax.xml.bind.annotation.XmlRootElement;
|
39
|
import javax.xml.bind.annotation.XmlSchemaType;
|
40
|
import javax.xml.bind.annotation.XmlType;
|
41
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
42
|
|
43
|
import org.apache.log4j.Logger;
|
44
|
import org.hibernate.annotations.Cascade;
|
45
|
import org.hibernate.annotations.CascadeType;
|
46
|
import org.hibernate.annotations.Index;
|
47
|
import org.hibernate.annotations.Table;
|
48
|
import org.hibernate.annotations.Type;
|
49
|
import org.hibernate.envers.Audited;
|
50
|
import org.hibernate.search.annotations.Analyze;
|
51
|
import org.hibernate.search.annotations.Field;
|
52
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
53
|
import org.hibernate.search.annotations.NumericField;
|
54
|
|
55
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
56
|
import eu.etaxonomy.cdm.jaxb.MultilanguageTextAdapter;
|
57
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
58
|
import eu.etaxonomy.cdm.model.common.IMultiLanguageTextHolder;
|
59
|
import eu.etaxonomy.cdm.model.common.IPublishable;
|
60
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
61
|
import eu.etaxonomy.cdm.model.common.Language;
|
62
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
63
|
import eu.etaxonomy.cdm.model.common.MultilanguageText;
|
64
|
import eu.etaxonomy.cdm.model.common.TermType;
|
65
|
import eu.etaxonomy.cdm.model.description.DescriptionBase;
|
66
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
67
|
import eu.etaxonomy.cdm.model.description.IDescribable;
|
68
|
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
|
69
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
70
|
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
|
71
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
72
|
|
73
|
/**
|
74
|
* type figures are observations with at least a figure object in media
|
75
|
* @author m.doering
|
76
|
* @created 08-Nov-2007 13:06:41
|
77
|
*/
|
78
|
@XmlAccessorType(XmlAccessType.FIELD)
|
79
|
@XmlType(name = "SpecimenOrObservationBase", propOrder = {
|
80
|
"recordBasis",
|
81
|
"publish",
|
82
|
"preferredStableUri",
|
83
|
"sex",
|
84
|
"lifeStage",
|
85
|
"kindOfUnit",
|
86
|
"individualCount",
|
87
|
"definition",
|
88
|
"descriptions",
|
89
|
"determinations",
|
90
|
"derivationEvents"
|
91
|
})
|
92
|
@XmlRootElement(name = "SpecimenOrObservationBase")
|
93
|
@Entity
|
94
|
@Audited
|
95
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
96
|
@Table(appliesTo="SpecimenOrObservationBase", indexes = { @Index(name = "specimenOrObservationBaseTitleCacheIndex", columnNames = { "titleCache" }) })
|
97
|
public abstract class SpecimenOrObservationBase<S extends IIdentifiableEntityCacheStrategy> extends IdentifiableEntity<S>
|
98
|
implements IMultiLanguageTextHolder, IDescribable<DescriptionBase>, IPublishable {
|
99
|
private static final long serialVersionUID = 6932680139334408031L;
|
100
|
private static final Logger logger = Logger.getLogger(SpecimenOrObservationBase.class);
|
101
|
|
102
|
/**
|
103
|
* An indication of what the unit record describes.
|
104
|
*
|
105
|
* NOTE: The name of the attribute was chosen against the common naming conventions of the CDM
|
106
|
* as it is well known in common standards like ABCD and DarwinCore. According to CDM naming
|
107
|
* conventions it would be specimenOrObservationType.
|
108
|
*
|
109
|
* @see ABCD: DataSets/DataSet/Units/Unit/RecordBasis
|
110
|
* @see Darwin Core: http://wiki.tdwg.org/twiki/bin/view/DarwinCore/BasisOfRecord
|
111
|
*/
|
112
|
@XmlAttribute(name ="RecordBasis")
|
113
|
@Column(name="recordBasis")
|
114
|
@NotNull
|
115
|
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumUserType",
|
116
|
parameters = {@org.hibernate.annotations.Parameter(name = "enumClass", value = "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType")}
|
117
|
)
|
118
|
@Audited
|
119
|
private SpecimenOrObservationType recordBasis;
|
120
|
|
121
|
|
122
|
@XmlElementWrapper(name = "Descriptions")
|
123
|
@XmlElement(name = "Description")
|
124
|
@OneToMany(mappedBy="describedSpecimenOrObservation", fetch = FetchType.LAZY)
|
125
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
126
|
@NotNull
|
127
|
private Set<DescriptionBase> descriptions = new HashSet<DescriptionBase>();
|
128
|
|
129
|
|
130
|
@XmlElementWrapper(name = "Determinations")
|
131
|
@XmlElement(name = "Determination")
|
132
|
@OneToMany(mappedBy="identifiedUnit", orphanRemoval=true)
|
133
|
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE})
|
134
|
@IndexedEmbedded(depth = 2)
|
135
|
@NotNull
|
136
|
private Set<DeterminationEvent> determinations = new HashSet<DeterminationEvent>();
|
137
|
|
138
|
@XmlElement(name = "Sex")
|
139
|
@XmlIDREF
|
140
|
@XmlSchemaType(name = "IDREF")
|
141
|
@ManyToOne(fetch = FetchType.LAZY)
|
142
|
private DefinedTerm sex;
|
143
|
|
144
|
@XmlElement(name = "LifeStage")
|
145
|
@XmlIDREF
|
146
|
@XmlSchemaType(name = "IDREF")
|
147
|
@ManyToOne(fetch = FetchType.LAZY)
|
148
|
private DefinedTerm lifeStage;
|
149
|
|
150
|
/**
|
151
|
* Part(s) of organism or class of materials represented by this unit.
|
152
|
* Example: fruits, seeds, tissue, gDNA, leaves
|
153
|
*
|
154
|
* @see ABCD: DataSets/DataSet/Units/Unit/KindOfUnit
|
155
|
* @see TermType#KindOfUnit
|
156
|
*/
|
157
|
@XmlElement(name = "KindOfUnit")
|
158
|
@XmlIDREF
|
159
|
@XmlSchemaType(name = "IDREF")
|
160
|
@ManyToOne(fetch = FetchType.LAZY)
|
161
|
// @IndexedEmbedded(depth=1)
|
162
|
private DefinedTerm kindOfUnit;
|
163
|
|
164
|
@XmlElement(name = "IndividualCount")
|
165
|
@Field(analyze = Analyze.NO)
|
166
|
@NumericField
|
167
|
@Min(0)
|
168
|
private Integer individualCount;
|
169
|
|
170
|
/**
|
171
|
* The preferred stable identifer (URI) as discussed in
|
172
|
* {@link http://dev.e-taxonomy.eu/trac/ticket/5606}
|
173
|
*/
|
174
|
@XmlElement(name = "PreferredStableUri")
|
175
|
@Field(analyze = Analyze.NO)
|
176
|
@Type(type="uriUserType")
|
177
|
private URI preferredStableUri;
|
178
|
|
179
|
// the verbatim description of this occurrence. Free text usable when no atomised data is available.
|
180
|
// in conjunction with titleCache which serves as the "citation" string for this object
|
181
|
@XmlElement(name = "Description")
|
182
|
@XmlJavaTypeAdapter(MultilanguageTextAdapter.class)
|
183
|
@OneToMany(fetch = FetchType.LAZY, orphanRemoval=true)
|
184
|
@MapKeyJoinColumn(name="definition_mapkey_id")
|
185
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE, CascadeType.DELETE})
|
186
|
@IndexedEmbedded
|
187
|
@NotNull
|
188
|
protected Map<Language,LanguageString> definition = new HashMap<Language,LanguageString>();
|
189
|
|
190
|
// events that created derivedUnits from this unit
|
191
|
@XmlElementWrapper(name = "DerivationEvents")
|
192
|
@XmlElement(name = "DerivationEvent")
|
193
|
@XmlIDREF
|
194
|
@XmlSchemaType(name = "IDREF")
|
195
|
@ManyToMany(fetch=FetchType.LAZY)
|
196
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE, CascadeType.DELETE})
|
197
|
@NotNull
|
198
|
protected Set<DerivationEvent> derivationEvents = new HashSet<DerivationEvent>();
|
199
|
|
200
|
@XmlAttribute(name = "publish")
|
201
|
private boolean publish = true;
|
202
|
|
203
|
|
204
|
//********************************** CONSTRUCTOR *********************************/
|
205
|
|
206
|
//for hibernate use only
|
207
|
@Deprecated
|
208
|
protected SpecimenOrObservationBase(){
|
209
|
super();
|
210
|
}
|
211
|
|
212
|
protected SpecimenOrObservationBase(SpecimenOrObservationType recordBasis) {
|
213
|
super();
|
214
|
if (recordBasis == null){ throw new IllegalArgumentException("RecordBasis must not be null");}
|
215
|
this.recordBasis = recordBasis;
|
216
|
}
|
217
|
|
218
|
|
219
|
/**
|
220
|
* Subclasses should implement setting the default cache strate
|
221
|
*/
|
222
|
protected abstract void initDefaultCacheStrategy();
|
223
|
|
224
|
|
225
|
//************************* GETTER / SETTER ***********************/
|
226
|
|
227
|
|
228
|
/**@see #recordBasis */
|
229
|
public SpecimenOrObservationType getRecordBasis() {
|
230
|
return recordBasis;
|
231
|
}
|
232
|
/**@see #recordBasis */
|
233
|
public void setRecordBasis(SpecimenOrObservationType recordBasis) {
|
234
|
this.recordBasis = recordBasis;
|
235
|
}
|
236
|
|
237
|
|
238
|
/**@see #preferredStableUri */
|
239
|
public URI getPreferredStableUri() {
|
240
|
return preferredStableUri;
|
241
|
}
|
242
|
/**@see #preferredStableUri */
|
243
|
public void setPreferredStableUri(URI preferredStableUri) {
|
244
|
this.preferredStableUri = preferredStableUri;
|
245
|
}
|
246
|
|
247
|
|
248
|
/**
|
249
|
* Returns the boolean value indicating if this specimen or observation should be withheld
|
250
|
* (<code>publish=false</code>) or not (<code>publish=true</code>) during any publication
|
251
|
* process to the general public.
|
252
|
* This publish flag implementation is preliminary and may be replaced by a more general
|
253
|
* implementation of READ rights in future.<BR>
|
254
|
* The default value is <code>true</code>.
|
255
|
*/
|
256
|
@Override
|
257
|
public boolean isPublish() {
|
258
|
return publish;
|
259
|
}
|
260
|
|
261
|
/**
|
262
|
* @see #isPublish()
|
263
|
* @param publish
|
264
|
*/
|
265
|
@Override
|
266
|
public void setPublish(boolean publish) {
|
267
|
this.publish = publish;
|
268
|
}
|
269
|
|
270
|
/**
|
271
|
* The descriptions this specimen or observation is part of.<BR>
|
272
|
* A specimen can not only have it's own {@link SpecimenDescription specimen description }
|
273
|
* but can also be part of a {@link TaxonDescription taxon description} or a
|
274
|
* {@link TaxonNameDescription taxon name description}.<BR>
|
275
|
* @see #getSpecimenDescriptions()
|
276
|
* @return
|
277
|
*/
|
278
|
@Override
|
279
|
public Set<DescriptionBase> getDescriptions() {
|
280
|
if(descriptions == null) {
|
281
|
this.descriptions = new HashSet<DescriptionBase>();
|
282
|
}
|
283
|
return this.descriptions;
|
284
|
}
|
285
|
|
286
|
/**
|
287
|
* Returns the {@link SpecimenDescription specimen descriptions} this specimen is part of.
|
288
|
* @see #getDescriptions()
|
289
|
* @return
|
290
|
*/
|
291
|
@Transient
|
292
|
public Set<SpecimenDescription> getSpecimenDescriptions() {
|
293
|
return getSpecimenDescriptions(true);
|
294
|
}
|
295
|
|
296
|
/**
|
297
|
* Returns the {@link SpecimenDescription specimen descriptions} this specimen is part of.
|
298
|
* @see #getDescriptions()
|
299
|
* @return
|
300
|
*/
|
301
|
@Transient
|
302
|
public Set<SpecimenDescription> getSpecimenDescriptions(boolean includeImageGallery) {
|
303
|
Set<SpecimenDescription> specimenDescriptions = new HashSet<SpecimenDescription>();
|
304
|
for (DescriptionBase descriptionBase : getDescriptions()){
|
305
|
if (descriptionBase.isInstanceOf(SpecimenDescription.class)){
|
306
|
if (includeImageGallery || descriptionBase.isImageGallery() == false){
|
307
|
specimenDescriptions.add(descriptionBase.deproxy(descriptionBase, SpecimenDescription.class));
|
308
|
}
|
309
|
|
310
|
}
|
311
|
}
|
312
|
return specimenDescriptions;
|
313
|
}
|
314
|
/**
|
315
|
* Returns the {@link SpecimenDescription specimen descriptions} which act as an image gallery
|
316
|
* and which this specimen is part of.
|
317
|
* @see #getDescriptions()
|
318
|
* @return
|
319
|
*/
|
320
|
@Transient
|
321
|
public Set<SpecimenDescription> getSpecimenDescriptionImageGallery() {
|
322
|
Set<SpecimenDescription> specimenDescriptions = new HashSet<SpecimenDescription>();
|
323
|
for (DescriptionBase descriptionBase : getDescriptions()){
|
324
|
if (descriptionBase.isInstanceOf(SpecimenDescription.class)){
|
325
|
if (descriptionBase.isImageGallery() == true){
|
326
|
specimenDescriptions.add(descriptionBase.deproxy(descriptionBase, SpecimenDescription.class));
|
327
|
}
|
328
|
}
|
329
|
}
|
330
|
return specimenDescriptions;
|
331
|
}
|
332
|
|
333
|
/**
|
334
|
* Adds a new description to this specimen or observation
|
335
|
* @param description
|
336
|
*/
|
337
|
@Override
|
338
|
public void addDescription(DescriptionBase description) {
|
339
|
if (description.getDescribedSpecimenOrObservation() != null){
|
340
|
description.getDescribedSpecimenOrObservation().removeDescription(description);
|
341
|
}
|
342
|
descriptions.add(description);
|
343
|
description.setDescribedSpecimenOrObservation(this);
|
344
|
}
|
345
|
|
346
|
/**
|
347
|
* Removes a specimen from a description (removes a description from this specimen)
|
348
|
* @param description
|
349
|
*/
|
350
|
@Override
|
351
|
public void removeDescription(DescriptionBase description) {
|
352
|
boolean existed = descriptions.remove(description);
|
353
|
if (existed){
|
354
|
description.setDescribedSpecimenOrObservation(null);
|
355
|
}
|
356
|
}
|
357
|
|
358
|
|
359
|
public Set<DerivationEvent> getDerivationEvents() {
|
360
|
if(derivationEvents == null) {
|
361
|
this.derivationEvents = new HashSet<DerivationEvent>();
|
362
|
}
|
363
|
return this.derivationEvents;
|
364
|
}
|
365
|
|
366
|
public void addDerivationEvent(DerivationEvent derivationEvent) {
|
367
|
if (! this.derivationEvents.contains(derivationEvent)){
|
368
|
this.derivationEvents.add(derivationEvent);
|
369
|
derivationEvent.addOriginal(this);
|
370
|
}
|
371
|
}
|
372
|
|
373
|
public void removeDerivationEvent(DerivationEvent derivationEvent) {
|
374
|
if (this.derivationEvents.contains(derivationEvent)){
|
375
|
this.derivationEvents.remove(derivationEvent);
|
376
|
derivationEvent.removeOriginal(this);
|
377
|
}
|
378
|
}
|
379
|
|
380
|
public Set<DeterminationEvent> getDeterminations() {
|
381
|
if(determinations == null) {
|
382
|
this.determinations = new HashSet<DeterminationEvent>();
|
383
|
}
|
384
|
return this.determinations;
|
385
|
}
|
386
|
|
387
|
public void addDetermination(DeterminationEvent determination) {
|
388
|
// FIXME bidirectional integrity. Use protected Determination setter
|
389
|
this.determinations.add(determination);
|
390
|
}
|
391
|
|
392
|
public void removeDetermination(DeterminationEvent determination) {
|
393
|
// FIXME bidirectional integrity. Use protected Determination setter
|
394
|
this.determinations.remove(determination);
|
395
|
}
|
396
|
|
397
|
public DefinedTerm getSex() {
|
398
|
return sex;
|
399
|
}
|
400
|
|
401
|
public void setSex(DefinedTerm sex) {
|
402
|
this.sex = sex;
|
403
|
}
|
404
|
|
405
|
public DefinedTerm getLifeStage() {
|
406
|
return lifeStage;
|
407
|
}
|
408
|
|
409
|
public void setLifeStage(DefinedTerm lifeStage) {
|
410
|
this.lifeStage = lifeStage;
|
411
|
}
|
412
|
|
413
|
|
414
|
/**
|
415
|
* @see #kindOfUnit
|
416
|
* @return
|
417
|
*/
|
418
|
public DefinedTerm getKindOfUnit() {
|
419
|
return kindOfUnit;
|
420
|
}
|
421
|
|
422
|
/**
|
423
|
* @see #kindOfUnit
|
424
|
* @param kindOfUnit
|
425
|
*/
|
426
|
public void setKindOfUnit(DefinedTerm kindOfUnit) {
|
427
|
this.kindOfUnit = kindOfUnit;
|
428
|
}
|
429
|
|
430
|
public Integer getIndividualCount() {
|
431
|
return individualCount;
|
432
|
}
|
433
|
|
434
|
public void setIndividualCount(Integer individualCount) {
|
435
|
this.individualCount = individualCount;
|
436
|
}
|
437
|
|
438
|
public Map<Language,LanguageString> getDefinition(){
|
439
|
return this.definition;
|
440
|
}
|
441
|
|
442
|
/**
|
443
|
* adds the {@link LanguageString description} to the {@link MultilanguageText multilanguage text}
|
444
|
* used to define <i>this</i> specimen or observation.
|
445
|
*
|
446
|
* @param description the languageString in with the title string and the given language
|
447
|
*
|
448
|
* @see #getDefinition()
|
449
|
* @see #putDefinition(Language, String)
|
450
|
*/
|
451
|
public void putDefinition(LanguageString description){
|
452
|
this.definition.put(description.getLanguage(),description);
|
453
|
}
|
454
|
|
455
|
/**
|
456
|
* Creates a {@link LanguageString language string} based on the given text string
|
457
|
* and the given {@link Language language} and adds it to the {@link MultilanguageText multilanguage text}
|
458
|
* used to define <i>this</i> specimen or observation.
|
459
|
*
|
460
|
* @param language the language in which the title string is formulated
|
461
|
* @param text the definition in a particular language
|
462
|
*
|
463
|
* @see #getDefinition()
|
464
|
* @see #putDefinition(LanguageString)
|
465
|
*/
|
466
|
public void putDefinition(Language language, String text){
|
467
|
this.definition.put(language, LanguageString.NewInstance(text, language));
|
468
|
}
|
469
|
|
470
|
|
471
|
public void removeDefinition(Language lang){
|
472
|
this.definition.remove(lang);
|
473
|
}
|
474
|
|
475
|
/**
|
476
|
* for derived units get the single next higher parental/original unit.
|
477
|
* If multiple original units exist throw error
|
478
|
* @return
|
479
|
*/
|
480
|
@Transient
|
481
|
public SpecimenOrObservationBase getOriginalUnit(){
|
482
|
logger.warn("GetOriginalUnit not yet implemented");
|
483
|
return null;
|
484
|
}
|
485
|
|
486
|
|
487
|
public boolean hasCharacterData() {
|
488
|
Set<DescriptionBase> descriptions = this.getDescriptions();
|
489
|
for (DescriptionBase<?> descriptionBase : descriptions) {
|
490
|
if (descriptionBase.isInstanceOf(SpecimenDescription.class)) {
|
491
|
SpecimenDescription specimenDescription = HibernateProxyHelper.deproxy(descriptionBase, SpecimenDescription.class);
|
492
|
Set<DescriptionElementBase> elements = specimenDescription.getElements();
|
493
|
for (DescriptionElementBase descriptionElementBase : elements) {
|
494
|
if (descriptionElementBase.isCharacterData()){
|
495
|
return true;
|
496
|
}
|
497
|
}
|
498
|
}
|
499
|
}
|
500
|
return false;
|
501
|
}
|
502
|
|
503
|
/**
|
504
|
* Returns a list of all description items which
|
505
|
* @return
|
506
|
*/
|
507
|
@Transient
|
508
|
public Collection<DescriptionElementBase> characterData() {
|
509
|
Collection<DescriptionElementBase> states = new ArrayList<DescriptionElementBase>();
|
510
|
Set<DescriptionBase> descriptions = this.getDescriptions();
|
511
|
for (DescriptionBase<?> descriptionBase : descriptions) {
|
512
|
if (descriptionBase.isInstanceOf(SpecimenDescription.class)) {
|
513
|
SpecimenDescription specimenDescription = HibernateProxyHelper.deproxy(descriptionBase, SpecimenDescription.class);
|
514
|
Set<DescriptionElementBase> elements = specimenDescription.getElements();
|
515
|
for (DescriptionElementBase descriptionElementBase : elements) {
|
516
|
if(descriptionElementBase.isCharacterData()){
|
517
|
states.add(descriptionElementBase);
|
518
|
}
|
519
|
}
|
520
|
}
|
521
|
}
|
522
|
return states;
|
523
|
}
|
524
|
|
525
|
|
526
|
|
527
|
//******************** CLONE **********************************************/
|
528
|
|
529
|
/* (non-Javadoc)
|
530
|
* @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
|
531
|
* @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#clone()
|
532
|
* @see java.lang.Object#clone()
|
533
|
*/
|
534
|
@Override
|
535
|
public Object clone() throws CloneNotSupportedException {
|
536
|
SpecimenOrObservationBase result = null;
|
537
|
result = (SpecimenOrObservationBase)super.clone();
|
538
|
|
539
|
//defininion (description, languageString)
|
540
|
result.definition = new HashMap<Language,LanguageString>();
|
541
|
for(LanguageString languageString : this.definition.values()) {
|
542
|
LanguageString newLanguageString = (LanguageString)languageString.clone();
|
543
|
result.putDefinition(newLanguageString);
|
544
|
}
|
545
|
|
546
|
//sex
|
547
|
result.setSex(this.sex);
|
548
|
//life stage
|
549
|
result.setLifeStage(this.lifeStage);
|
550
|
|
551
|
//Descriptions
|
552
|
for(DescriptionBase description : this.descriptions) {
|
553
|
result.addDescription(description);
|
554
|
}
|
555
|
|
556
|
//DeterminationEvent FIXME should clone() the determination
|
557
|
// as the relationship is OneToMany
|
558
|
for(DeterminationEvent determination : this.determinations) {
|
559
|
result.addDetermination(determination);
|
560
|
}
|
561
|
|
562
|
//DerivationEvent
|
563
|
for(DerivationEvent derivationEvent : this.derivationEvents) {
|
564
|
result.addDerivationEvent(derivationEvent);
|
565
|
}
|
566
|
|
567
|
//no changes to: individualCount
|
568
|
return result;
|
569
|
}
|
570
|
|
571
|
|
572
|
}
|