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 eu
.etaxonomy
.cdm
.model
.media
.IMediaDocumented
;
14 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
16 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
17 import eu
.etaxonomy
.cdm
.model
.common
.IReferencedEntity
;
18 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
19 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IdentifiableEntityDefaultCacheStrategy
;
21 import org
.apache
.log4j
.Logger
;
22 import org
.hibernate
.annotations
.Cascade
;
23 import org
.hibernate
.annotations
.CascadeType
;
24 import org
.hibernate
.annotations
.Index
;
25 import org
.hibernate
.annotations
.Table
;
26 import org
.hibernate
.envers
.Audited
;
27 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
31 import javax
.persistence
.*;
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
;
45 * @created 08-Nov-2007 13:06:51
47 @XmlAccessorType(XmlAccessType
.FIELD
)
48 @XmlType(name
= "Sequence", propOrder
= {
53 "citationMicroReference",
60 @XmlRootElement(name
= "Sequence")
64 @Table(appliesTo
="Sequence", indexes
= { @Index(name
= "sequenceTitleCacheIndex", columnNames
= { "titleCache" }) })
65 public class Sequence
extends IdentifiableEntity
<IIdentifiableEntityCacheStrategy
<Sequence
>> implements IReferencedEntity
, IMediaDocumented
{
66 private static final long serialVersionUID
= 8298983152731241775L;
67 private static final Logger logger
= Logger
.getLogger(Sequence
.class);
69 //the sequence as a string of base pairs. 5'->3'
70 @XmlElement(name
= "Sequence")
71 private String sequence
;
73 //should be calculated in case sequence is set
74 @XmlElement(name
= "Length")
75 private Integer length
;
77 //should be calculated in case sequence is set
78 @XmlElement(name
= "DateSequenced")
79 @Temporal(TemporalType
.DATE
)
80 private Calendar dateSequenced
;
82 //should be calculated in case sequence is set
83 @XmlAttribute(name
= "isBarcode")
84 private boolean barcode
;
86 //the sequence as a string of base pairs. 5'->3'
87 @XmlElement(name
= "CitationMicroReference")
88 private String citationMicroReference
;
90 @XmlElement(name
= "PublishedIn")
92 @XmlSchemaType(name
= "IDREF")
93 @ManyToOne(fetch
= FetchType
.LAZY
)
94 @Cascade(CascadeType
.SAVE_UPDATE
)
95 private ReferenceBase publishedIn
;
97 @XmlElementWrapper(name
= "Citations")
98 @XmlElement(name
= "Citation")
100 @XmlSchemaType(name
= "IDREF")
101 @OneToMany(fetch
= FetchType
.LAZY
)
102 private Set
<ReferenceBase
> citations
= new HashSet
<ReferenceBase
>();
104 @XmlElementWrapper(name
= "GenBankAccessions")
105 @XmlElement(name
= "GenBankAccession")
106 @OneToMany(fetch
= FetchType
.LAZY
)
107 private Set
<GenBankAccession
> genBankAccession
= new HashSet
<GenBankAccession
>();
109 @XmlElement(name
= "Locus")
111 @XmlSchemaType(name
= "IDREF")
112 @ManyToOne(fetch
= FetchType
.LAZY
)
113 @Cascade(CascadeType
.SAVE_UPDATE
)
116 @XmlElementWrapper(name
= "Chromatograms")
117 @XmlElement(name
= "Chromatogram")
119 @XmlSchemaType(name
= "IDREF")
120 @OneToMany(fetch
= FetchType
.LAZY
)
121 private Set
<Media
> chromatograms
= new HashSet
<Media
>();
123 protected Sequence() {
124 super(); // FIXME I think this is explicit - do we really need to call this?
125 this.cacheStrategy
= new IdentifiableEntityDefaultCacheStrategy
<Sequence
>();
128 public Locus
getLocus(){
129 logger
.debug("getLocus");
133 public void setLocus(Locus locus
){
137 public ReferenceBase
getPublishedIn(){
138 return this.publishedIn
;
141 public void setPublishedIn(ReferenceBase publishedIn
){
142 this.publishedIn
= publishedIn
;
145 public Set
<ReferenceBase
> getCitations() {
148 protected void setCitations(Set
<ReferenceBase
> citations
) {
149 this.citations
= citations
;
151 public void addCitation(ReferenceBase citation
) {
152 this.citations
.add(citation
);
154 public void removeCitation(ReferenceBase citation
) {
155 this.citations
.remove(citation
);
158 public Set
<GenBankAccession
> getGenBankAccession() {
159 return genBankAccession
;
162 public void addGenBankAccession(GenBankAccession genBankAccession
) {
163 this.genBankAccession
.add(genBankAccession
);
166 public void removeGenBankAccession(GenBankAccession genBankAccession
) {
167 this.genBankAccession
.remove(genBankAccession
);
170 public Set
<Media
> getChromatograms() {
171 return chromatograms
;
174 public void addChromatogram(Media chromatogram
) {
175 this.chromatograms
.add(chromatogram
);
178 public void removeChromatogram(Media chromatogram
) {
179 this.chromatograms
.remove(chromatogram
);
183 public Set
<Media
> getMedia() {
184 return getChromatograms();
187 public String
getSequence(){
188 return this.sequence
;
193 * @param sequence sequence
195 public void setSequence(String sequence
){
196 this.sequence
= sequence
;
199 public Integer
getLength(){
205 * @param length length
207 public void setLength(Integer length
){
208 this.length
= length
;
211 public Calendar
getDateSequenced(){
212 return this.dateSequenced
;
217 * @param dateSequenced dateSequenced
219 public void setDateSequenced(Calendar dateSequenced
){
220 this.dateSequenced
= dateSequenced
;
223 public boolean isBarcode(){
229 * @param isBarcode isBarcode
231 public void setBarcode(boolean barcode
){
232 this.barcode
= barcode
;
235 public String
getCitationMicroReference(){
236 return this.citationMicroReference
;
241 * @param citationMicroReference citationMicroReference
243 public void setCitationMicroReference(String citationMicroReference
){
244 this.citationMicroReference
= citationMicroReference
;
247 public ReferenceBase
getCitation(){