2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.molecular
;
13 import java
.util
.HashSet
;
16 import javax
.persistence
.Entity
;
17 import javax
.persistence
.FetchType
;
18 import javax
.persistence
.OneToMany
;
19 import javax
.persistence
.Transient
;
20 import javax
.validation
.constraints
.NotNull
;
21 import javax
.xml
.bind
.annotation
.XmlAccessType
;
22 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
23 import javax
.xml
.bind
.annotation
.XmlElement
;
24 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
25 import javax
.xml
.bind
.annotation
.XmlIDREF
;
26 import javax
.xml
.bind
.annotation
.XmlRootElement
;
27 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
28 import javax
.xml
.bind
.annotation
.XmlType
;
30 import org
.apache
.log4j
.Logger
;
31 import org
.hibernate
.annotations
.Cascade
;
32 import org
.hibernate
.annotations
.CascadeType
;
33 import org
.hibernate
.envers
.Audited
;
34 import org
.hibernate
.search
.annotations
.ContainedIn
;
35 import org
.hibernate
.search
.annotations
.Indexed
;
37 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
38 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
39 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
40 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
41 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IdentifiableEntityDefaultCacheStrategy
;
44 * A DNA Sample is the extracted DNA of a given tissue sample. It may be stored in
45 * a DNA Bank and should then be handled as a collection unit.
46 * DNA Sample are used to determine their {@link Sequence DNA sequences}
47 * starting with a process called {@link Amplification amplification}.
50 * @created 08-Nov-2007
52 @XmlAccessorType(XmlAccessType
.FIELD
)
53 @XmlType(name
= "DnaSample", propOrder
= {
57 @XmlRootElement(name
= "DnaSample")
59 @Indexed(index
= "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase")
61 public class DnaSample
extends DerivedUnit
implements Cloneable
{
62 private static final long serialVersionUID
= -2978411330023671805L;
63 @SuppressWarnings("unused")
64 private static final Logger logger
= Logger
.getLogger(DnaSample
.class);
66 // ****************** FACTORY METHOD *****************/
72 public static DnaSample
NewInstance(){
73 return new DnaSample();
76 // ************** ATTRIBUTES ****************************/
78 // @XmlElement(name = "BankNumber")
79 // private String bankNumber;
81 @XmlElementWrapper(name
= "Sequences")
82 @XmlElement(name
= "sequence")
84 @XmlSchemaType(name
= "IDREF")
85 @OneToMany(fetch
= FetchType
.LAZY
)
86 @Cascade(CascadeType
.SAVE_UPDATE
)
87 private Set
<Sequence
> sequences
= new HashSet
<Sequence
>();
90 @XmlElementWrapper(name
= "Amplifications")
91 @XmlElement(name
= "Amplification")
92 @OneToMany(mappedBy
="dnaSample", fetch
= FetchType
.LAZY
)
93 @Cascade( { CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE
})
96 private Set
<Amplification
> amplifications
= new HashSet
<Amplification
>();
99 // ******************* CONSTRUCTOR *************************/
104 private DnaSample() {
105 super(SpecimenOrObservationType
.DnaSample
);
106 this.cacheStrategy
= new IdentifiableEntityDefaultCacheStrategy
<DerivedUnit
>();
109 //************ GETTER / SETTER **********************************/
112 public Set
<Sequence
> getSequences() {
116 public void addSequence(Sequence sequence
) {
117 this.sequences
.add(sequence
);
120 public void removeSequence(Sequence sequence
) {
121 this.sequences
.remove(sequence
);
125 public Set
<Amplification
> getAmplifications() {
126 return amplifications
;
129 public void addAmplification(Amplification amplification
) {
130 this.amplifications
.add(amplification
);
131 amplification
.setDnaSample(this);
134 public void removeAmplification(Amplification amplification
) {
135 this.amplifications
.remove(amplification
);
138 // ************* Convenience Getter / Setter ************/
141 public Collection
getStoredAt(){
142 return this.getCollection();
145 public void setStoredAt(Collection storedAt
){
146 this.setCollection(storedAt
);
150 public Set
<SpecimenOrObservationBase
> getExtractedFrom(){
151 return getOriginals();
155 public String
getBankNumber(){
156 return this.getCatalogNumber();
159 public void setBankNumber(String bankNumber
){
160 this.setCatalogNumber(bankNumber
);
164 //*********** CLONE **********************************/
167 * Clones <i>this</i> dna sample. This is a shortcut that enables to
168 * create a new instance that differs only slightly from <i>this</i> dna sample
169 * by modifying only some of the attributes.<BR>
170 * This method overrides the clone method from {@link Specimen Specimen}.
171 * @throws CloneNotSupportedException
173 * @see Specimen#clone()
174 * @see DerivedUnit#clone()
175 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
176 * @see java.lang.Object#clone()
179 public DnaSample
clone() {
180 DnaSample result
= (DnaSample
)super.clone();
182 result
.sequences
= new HashSet
<Sequence
>();
183 for(Sequence sequence
: this.sequences
) {
184 result
.addSequence(sequence
);
186 //no changes to: bankNumber