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
.hibernate
.search
.annotations
.Field
;
28 import org
.hibernate
.search
.annotations
.Indexed
;
29 import org
.springframework
.beans
.factory
.annotation
.Configurable
;
33 import javax
.persistence
.*;
34 import javax
.xml
.bind
.annotation
.XmlAccessType
;
35 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
36 import javax
.xml
.bind
.annotation
.XmlAttribute
;
37 import javax
.xml
.bind
.annotation
.XmlElement
;
38 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
39 import javax
.xml
.bind
.annotation
.XmlIDREF
;
40 import javax
.xml
.bind
.annotation
.XmlRootElement
;
41 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
42 import javax
.xml
.bind
.annotation
.XmlType
;
47 * @created 08-Nov-2007 13:06:51
49 @XmlAccessorType(XmlAccessType
.FIELD
)
50 @XmlType(name
= "Sequence", propOrder
= {
55 "citationMicroReference",
62 @XmlRootElement(name
= "Sequence")
66 @Table(appliesTo
="Sequence", indexes
= { @Index(name
= "sequenceTitleCacheIndex", columnNames
= { "titleCache" }) })
67 public class Sequence
extends IdentifiableEntity
<IIdentifiableEntityCacheStrategy
<Sequence
>> implements IReferencedEntity
, IMediaDocumented
{
68 private static final long serialVersionUID
= 8298983152731241775L;
69 private static final Logger logger
= Logger
.getLogger(Sequence
.class);
71 //the sequence as a string of base pairs. 5'->3'
72 @XmlElement(name
= "Sequence")
73 private String sequence
;
75 //should be calculated in case sequence is set
76 @XmlElement(name
= "Length")
77 private Integer length
;
79 //should be calculated in case sequence is set
80 // FIXME Should be a DateTime
81 @XmlElement(name
= "DateSequenced")
82 @Temporal(TemporalType
.DATE
)
83 private Calendar dateSequenced
;
85 //should be calculated in case sequence is set
86 @XmlAttribute(name
= "isBarcode")
87 private boolean barcode
;
89 //the sequence as a string of base pairs. 5'->3'
90 @XmlElement(name
= "CitationMicroReference")
91 private String citationMicroReference
;
93 @XmlElement(name
= "PublishedIn")
95 @XmlSchemaType(name
= "IDREF")
96 @ManyToOne(fetch
= FetchType
.LAZY
)
97 @Cascade(CascadeType
.SAVE_UPDATE
)
98 private ReferenceBase publishedIn
;
100 @XmlElementWrapper(name
= "Citations")
101 @XmlElement(name
= "Citation")
103 @XmlSchemaType(name
= "IDREF")
104 @OneToMany(fetch
= FetchType
.LAZY
)
105 private Set
<ReferenceBase
> citations
= new HashSet
<ReferenceBase
>();
107 @XmlElementWrapper(name
= "GenBankAccessions")
108 @XmlElement(name
= "GenBankAccession")
109 @OneToMany(fetch
= FetchType
.LAZY
)
110 private Set
<GenBankAccession
> genBankAccession
= new HashSet
<GenBankAccession
>();
112 @XmlElement(name
= "Locus")
114 @XmlSchemaType(name
= "IDREF")
115 @ManyToOne(fetch
= FetchType
.LAZY
)
116 @Cascade(CascadeType
.SAVE_UPDATE
)
119 @XmlElementWrapper(name
= "Chromatograms")
120 @XmlElement(name
= "Chromatogram")
122 @XmlSchemaType(name
= "IDREF")
123 @OneToMany(fetch
= FetchType
.LAZY
)
124 private Set
<Media
> chromatograms
= new HashSet
<Media
>();
126 protected Sequence() {
127 super(); // FIXME I think this is explicit - do we really need to call this?
128 this.cacheStrategy
= new IdentifiableEntityDefaultCacheStrategy
<Sequence
>();
131 public Locus
getLocus(){
132 logger
.debug("getLocus");
136 public void setLocus(Locus locus
){
140 public ReferenceBase
getPublishedIn(){
141 return this.publishedIn
;
144 public void setPublishedIn(ReferenceBase publishedIn
){
145 this.publishedIn
= publishedIn
;
148 public Set
<ReferenceBase
> getCitations() {
151 protected void setCitations(Set
<ReferenceBase
> citations
) {
152 this.citations
= citations
;
154 public void addCitation(ReferenceBase citation
) {
155 this.citations
.add(citation
);
157 public void removeCitation(ReferenceBase citation
) {
158 this.citations
.remove(citation
);
161 public Set
<GenBankAccession
> getGenBankAccession() {
162 return genBankAccession
;
165 public void addGenBankAccession(GenBankAccession genBankAccession
) {
166 this.genBankAccession
.add(genBankAccession
);
169 public void removeGenBankAccession(GenBankAccession genBankAccession
) {
170 this.genBankAccession
.remove(genBankAccession
);
173 public Set
<Media
> getChromatograms() {
174 return chromatograms
;
177 public void addChromatogram(Media chromatogram
) {
178 this.chromatograms
.add(chromatogram
);
181 public void removeChromatogram(Media chromatogram
) {
182 this.chromatograms
.remove(chromatogram
);
186 public Set
<Media
> getMedia() {
187 return getChromatograms();
190 public String
getSequence(){
191 return this.sequence
;
196 * @param sequence sequence
198 public void setSequence(String sequence
){
199 this.sequence
= sequence
;
202 public Integer
getLength(){
208 * @param length length
210 public void setLength(Integer length
){
211 this.length
= length
;
214 public Calendar
getDateSequenced(){
215 return this.dateSequenced
;
220 * @param dateSequenced dateSequenced
222 public void setDateSequenced(Calendar dateSequenced
){
223 this.dateSequenced
= dateSequenced
;
226 public boolean isBarcode(){
232 * @param isBarcode isBarcode
234 public void setBarcode(boolean barcode
){
235 this.barcode
= barcode
;
238 public String
getCitationMicroReference(){
239 return this.citationMicroReference
;
244 * @param citationMicroReference citationMicroReference
246 public void setCitationMicroReference(String citationMicroReference
){
247 this.citationMicroReference
= citationMicroReference
;
250 public ReferenceBase
getCitation(){