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
.xml
.bind
.annotation
.XmlAccessType
;
21 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
22 import javax
.xml
.bind
.annotation
.XmlElement
;
23 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
24 import javax
.xml
.bind
.annotation
.XmlIDREF
;
25 import javax
.xml
.bind
.annotation
.XmlRootElement
;
26 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
27 import javax
.xml
.bind
.annotation
.XmlType
;
29 import org
.apache
.log4j
.Logger
;
30 import org
.hibernate
.envers
.Audited
;
31 import org
.hibernate
.search
.annotations
.Indexed
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
34 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
35 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
36 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
37 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IdentifiableEntityDefaultCacheStrategy
;
42 * @created 08-Nov-2007 13:06:22
44 @XmlAccessorType(XmlAccessType
.FIELD
)
45 @XmlType(name
= "DnaSample", propOrder
= {
48 @XmlRootElement(name
= "DnaSample")
50 @Indexed(index
= "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase")
52 public class DnaSample
extends Specimen
implements Cloneable
{
53 private static final long serialVersionUID
= -2978411330023671805L;
54 private static final Logger logger
= Logger
.getLogger(DnaSample
.class);
60 public static DnaSample
NewInstance(){
61 return new DnaSample();
65 // @XmlElement(name = "BankNumber")
66 // private String bankNumber;
68 @XmlElementWrapper(name
= "Sequences")
69 @XmlElement(name
= "sequence")
71 @XmlSchemaType(name
= "IDREF")
72 @OneToMany(fetch
= FetchType
.LAZY
)
73 private Set
<Sequence
> sequences
= new HashSet
<Sequence
>();
82 this.cacheStrategy
= new IdentifiableEntityDefaultCacheStrategy
<Specimen
>();
85 public Set
<Sequence
> getSequences() {
89 // FIXME shouldn't this be the singular? i.e. addSequence( . . . )
90 public void addSequences(Sequence sequence
) {
91 this.sequences
.add(sequence
);
94 // FIXME shouldn't this be the singular? i.e. removeSequence( . . . )
95 public void removeSequences(Sequence sequence
) {
96 this.sequences
.remove(sequence
);
100 public Collection
getStoredAt(){
101 return this.getCollection();
104 public void setStoredAt(Collection storedAt
){
105 this.setCollection(storedAt
);
109 public Set
<SpecimenOrObservationBase
> getExtractedFrom(){
110 return getOriginals();
114 public String
getBankNumber(){
115 return this.getCatalogNumber();
118 public void setBankNumber(String bankNumber
){
119 this.setCatalogNumber(bankNumber
);
123 //*********** CLONE **********************************/
126 * Clones <i>this</i> dna sample. This is a shortcut that enables to
127 * create a new instance that differs only slightly from <i>this</i> dna sample
128 * by modifying only some of the attributes.<BR>
129 * This method overrides the clone method from {@link Specimen Specimen}.
131 * @see Specimen#clone()
132 * @see DerivedUnitBase#clone()
133 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
134 * @see java.lang.Object#clone()
137 public DnaSample
clone(){
138 DnaSample result
= (DnaSample
)super.clone();
140 result
.sequences
= new HashSet
<Sequence
>();
141 for(Sequence sequence
: this.sequences
) {
142 result
.addSequences(sequence
);
144 //no changes to: bankNumber