Project

General

Profile

Download (4.57 KB) Statistics
| Branch: | Tag: | Revision:
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.common.IdentifiableEntityDefaultCacheStrategy;
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
 * @created 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 implements Cloneable {
54
	private static final long serialVersionUID = -5717424451590705378L;
55
	@SuppressWarnings("unused")
56
	private static final Logger logger = Logger.getLogger(MediaSpecimen.class);
57
	
58
// ****************** FACTORY METHOD *****************/
59
	
60
	/**
61
	 * Factory method.
62
	 * @param type must be {@link SpecimenOrObservationType#Media} or a subtype of it.
63
	 * @return
64
	 */
65
	public static MediaSpecimen NewInstance(SpecimenOrObservationType type){
66
		return new MediaSpecimen(type);
67
	}
68

    
69
// ************** ATTRIBUTES ****************************/	
70
		
71
	@XmlElement(name = "sequence")
72
    @XmlIDREF
73
    @XmlSchemaType(name = "IDREF")
74
	@ManyToOne(fetch = FetchType.LAZY)
75
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
76
	private Media mediaSpecimen;
77

    
78
// ******************* CONSTRUCTOR *************************/
79
	
80
	/**
81
	 * Constructor
82
	 */
83
	private MediaSpecimen() {
84
		this(SpecimenOrObservationType.Media);
85
	}
86
	
87
	private MediaSpecimen(SpecimenOrObservationType type) {
88
		super(type);
89
		this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<DerivedUnit>();
90
	}
91

    
92
	
93
//************ GETTER / SETTER  **********************************/	
94

    
95
	/**
96
	 * The media which represents this specimen. It is important to realize
97
	 * that a media specimen is not a media which only shows the specimen
98
	 * but it is the specimen itself. Therefore this method should only be used
99
	 * for specimen which ARE media.<BR>
100
	 * This is often the case for older (type) specimen which have only be drawn or painted.
101
	 * Also it may be the cases for small biota which can not be individualized 
102
	 * or preserved accordingly and may therefore be photographed instead.
103
	 */
104
	public Media getMediaSpecimen() {
105
		return mediaSpecimen;
106
	}
107

    
108
	/**
109
	 * @see #getMediaSpecimen()
110
	 */
111
	public void setMediaSpecimen(Media mediaSpecimen) {
112
		this.mediaSpecimen = mediaSpecimen;
113
	}
114
	
115
// ************* Convenience Getter / Setter ************/
116
	
117
	
118

    
119
//*********** CLONE **********************************/	
120

    
121

    
122
	/** 
123
	 * Clones <i>this</i> dna sample. This is a shortcut that enables to
124
	 * create a new instance that differs only slightly from <i>this</i> dna sample
125
	 * by modifying only some of the attributes.<BR>
126
	 * This method overrides the clone method from {@link Specimen Specimen}.
127
	 * @throws CloneNotSupportedException 
128
	 * 
129
	 * @see Specimen#clone()
130
	 * @see DerivedUnit#clone()
131
	 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
132
	 * @see java.lang.Object#clone()
133
	 */
134
	@Override
135
	public MediaSpecimen clone() {
136
		MediaSpecimen result = (MediaSpecimen)super.clone();
137

    
138
		//no changes to: mediaSpecimen
139
		return result;
140
	}
141
}
(9-9/14)