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
|
|
13
|
import javax.persistence.Entity;
|
14
|
import javax.persistence.FetchType;
|
15
|
import javax.persistence.ManyToOne;
|
16
|
import javax.xml.bind.annotation.XmlAccessType;
|
17
|
import javax.xml.bind.annotation.XmlAccessorType;
|
18
|
import javax.xml.bind.annotation.XmlElement;
|
19
|
import javax.xml.bind.annotation.XmlIDREF;
|
20
|
import javax.xml.bind.annotation.XmlRootElement;
|
21
|
import javax.xml.bind.annotation.XmlSchemaType;
|
22
|
import javax.xml.bind.annotation.XmlType;
|
23
|
|
24
|
import org.apache.log4j.Logger;
|
25
|
import org.hibernate.annotations.Cascade;
|
26
|
import org.hibernate.annotations.CascadeType;
|
27
|
import org.hibernate.envers.Audited;
|
28
|
import org.hibernate.search.annotations.Indexed;
|
29
|
|
30
|
import eu.etaxonomy.cdm.model.media.Media;
|
31
|
import eu.etaxonomy.cdm.strategy.cache.occurrence.MediaSpecimenDefaultCacheStrategy;
|
32
|
|
33
|
/**
|
34
|
* Instances of MediaSpecimen represent a specimen which IS a media (photo, drawing, ...).
|
35
|
* Therefore it usually the media is part of a collection and has it's own catalog/collection
|
36
|
* number. The individuum shown by the media may or may not be a collection specimen on it's own.
|
37
|
* Often it is not, which may be the reason why a picture (or other media) is taken instead.
|
38
|
* This is often the case for older (type) specimen which have only be drawn or painted.
|
39
|
* Also it may be the cases for small biota which can not be individualized
|
40
|
* or preserved accordingly and may therefore be photographed instead.
|
41
|
*
|
42
|
* @author a.mueller
|
43
|
* @since 14-Jul-2013 13:06:22
|
44
|
*/
|
45
|
@XmlAccessorType(XmlAccessType.FIELD)
|
46
|
@XmlType(name = "MediaSpecimen", propOrder = {
|
47
|
"mediaSpecimen"
|
48
|
})
|
49
|
@XmlRootElement(name = "MediaSpecimen")
|
50
|
@Entity
|
51
|
@Indexed(index = "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase")
|
52
|
@Audited
|
53
|
public class MediaSpecimen extends DerivedUnit {
|
54
|
|
55
|
private static final long serialVersionUID = -5717424451590705378L;
|
56
|
@SuppressWarnings("unused")
|
57
|
private static final Logger logger = Logger.getLogger(MediaSpecimen.class);
|
58
|
|
59
|
// ****************** FACTORY METHOD *****************/
|
60
|
|
61
|
/**
|
62
|
* Factory method.
|
63
|
* @param type must be {@link SpecimenOrObservationType#Media} or a subtype of it.
|
64
|
* @return
|
65
|
*/
|
66
|
public static MediaSpecimen NewInstance(SpecimenOrObservationType type){
|
67
|
return new MediaSpecimen(type);
|
68
|
}
|
69
|
|
70
|
// ************** ATTRIBUTES ****************************/
|
71
|
|
72
|
@XmlElement(name = "sequence")
|
73
|
@XmlIDREF
|
74
|
@XmlSchemaType(name = "IDREF")
|
75
|
@ManyToOne(fetch = FetchType.LAZY)
|
76
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
77
|
private Media mediaSpecimen;
|
78
|
|
79
|
// ******************* CONSTRUCTOR *************************/
|
80
|
|
81
|
private MediaSpecimen() {
|
82
|
this(SpecimenOrObservationType.Media);
|
83
|
}
|
84
|
|
85
|
private MediaSpecimen(SpecimenOrObservationType type) {
|
86
|
super(type);
|
87
|
}
|
88
|
|
89
|
@Override
|
90
|
protected void initDefaultCacheStrategy() {
|
91
|
this.cacheStrategy = new MediaSpecimenDefaultCacheStrategy();
|
92
|
}
|
93
|
|
94
|
//************ GETTER / SETTER **********************************/
|
95
|
|
96
|
/**
|
97
|
* The media which represents this specimen. It is important to realize
|
98
|
* that a media specimen is not a media which only shows the specimen
|
99
|
* but it is the specimen itself. Therefore this method should only be used
|
100
|
* for specimen which ARE media.<BR>
|
101
|
* This is often the case for older (type) specimen which have only be drawn or painted.
|
102
|
* Also it may be the cases for small biota which can not be individualized
|
103
|
* or preserved accordingly and may therefore be photographed instead.
|
104
|
*/
|
105
|
public Media getMediaSpecimen() {
|
106
|
return mediaSpecimen;
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* @see #getMediaSpecimen()
|
111
|
*/
|
112
|
public void setMediaSpecimen(Media mediaSpecimen) {
|
113
|
this.mediaSpecimen = mediaSpecimen;
|
114
|
resetTitleCache();
|
115
|
}
|
116
|
|
117
|
// ************* Convenience Getter / Setter ************/
|
118
|
|
119
|
|
120
|
|
121
|
//*********** CLONE **********************************/
|
122
|
|
123
|
|
124
|
/**
|
125
|
* Clones <i>this</i> dna sample. This is a shortcut that enables to
|
126
|
* create a new instance that differs only slightly from <i>this</i> dna sample
|
127
|
* by modifying only some of the attributes.<BR>
|
128
|
* This method overrides the clone method from {@link Specimen Specimen}.
|
129
|
* @throws CloneNotSupportedException
|
130
|
*
|
131
|
* @see Specimen#clone()
|
132
|
* @see DerivedUnit#clone()
|
133
|
* @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
|
134
|
* @see java.lang.Object#clone()
|
135
|
*/
|
136
|
@Override
|
137
|
public MediaSpecimen clone() {
|
138
|
MediaSpecimen result = (MediaSpecimen)super.clone();
|
139
|
|
140
|
//no changes to: mediaSpecimen
|
141
|
return result;
|
142
|
}
|
143
|
}
|