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.
9 package eu
.etaxonomy
.cdm
.model
.molecular
;
11 import javax
.persistence
.Column
;
12 import javax
.persistence
.Entity
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.ManyToOne
;
15 import javax
.xml
.bind
.annotation
.XmlAccessType
;
16 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
17 import javax
.xml
.bind
.annotation
.XmlElement
;
18 import javax
.xml
.bind
.annotation
.XmlIDREF
;
19 import javax
.xml
.bind
.annotation
.XmlRootElement
;
20 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
21 import javax
.xml
.bind
.annotation
.XmlType
;
23 import org
.apache
.log4j
.Logger
;
24 import org
.hibernate
.annotations
.Cascade
;
25 import org
.hibernate
.annotations
.CascadeType
;
26 import org
.hibernate
.envers
.Audited
;
28 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
29 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
30 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
33 * A primer is a (short) DNA Sequence used for replication and extraction
34 * of DNA parts during e.g. {@link Amplification amplification} or
35 * {@link SingleRead sequence reading}.
41 @XmlAccessorType(XmlAccessType
.FIELD
)
42 @XmlType(name
= "Primer", propOrder
= {
48 @XmlRootElement(name
= "Primer")
51 //TODO which base class (..., identifiable, definedTerm, ...)
52 public class Primer
extends AnnotatableEntity
{
53 private static final long serialVersionUID
= 6179007910988646989L;
54 private static final Logger logger
= Logger
.getLogger(Primer
.class);
56 /** @see #getLabel() */
57 @XmlElement(name
= "Label")
61 /** @see #getSequence() */
63 @XmlElement(name
= "Sequence")
64 private SequenceString sequence
= SequenceString
.NewInstance();
67 /** @see #getDnaMarker()*/
68 @XmlElement(name
= "DnaMarker")
70 @XmlSchemaType(name
= "IDREF")
71 @ManyToOne(fetch
=FetchType
.LAZY
)
72 private DefinedTerm dnaMarker
;
74 /** @see #getPublishedIn() */
75 @XmlElement(name
= "PublishedIn")
77 @XmlSchemaType(name
= "IDREF")
78 @ManyToOne(fetch
=FetchType
.LAZY
)
79 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
80 private Reference
<?
> publishedIn
;
84 // ******************** FACTORY METHOD ******************/
86 public static Primer
NewInstance(String label
){
87 Primer result
= new Primer();
88 result
.setLabel(label
);
92 // ********************* CONSTRUCTOR ********************/
94 //made protected to fix a java.lang.InstantiationException which occurred while loading an Amplification
95 //and its primer. see https://stackoverflow.com/questions/7273125/hibernate-envers-and-javassist-enhancement-failed-exception
98 // ********************* GETTER / SETTER ********************/
102 * The name of this primer, usually given by the producers.
103 * @return the label of this primer.
105 public String
getLabel() {
112 public void setLabel(String label
) {
117 * The DNA {@link Sequence} of this primer. A primer is usually a
118 * small piece of DNA and therefore can be expressed as a sequence.
120 public SequenceString
getSequence() {
125 * @see Primer#getSequence()
127 public void setSequence(SequenceString sequence
) {
128 if (sequence
== null){
129 sequence
= SequenceString
.NewInstance();
131 this.sequence
= sequence
;
138 public DefinedTerm
getDnaMarker() {
142 public void setDnaMarker(DefinedTerm dnaMarker
) {
143 this.dnaMarker
= dnaMarker
;
147 * The reference in which this primer was published and described
148 * for the first time. It is not a reference or citation for the
149 * sequence of this primer.<BR>
150 * Links to this reference are stored with the reference itself.
151 * @return the describing publication of this primer
153 public Reference
getPublishedIn() {
158 * @see #getPublishedIn()
160 public void setPublishedIn(Reference publishedIn
) {
161 this.publishedIn
= publishedIn
;
164 // ********************* CLONE ********************/
166 * Clones <i>this</i> primer. This is a shortcut that enables to create
167 * a new instance that differs only slightly from <i>this</i> primer by
168 * modifying only some of the attributes.<BR><BR>
171 * @see eu.etaxonomy.cdm.model.media.IdentifiableEntity#clone()
172 * @see java.lang.Object#clone()
175 public Object
clone() {
177 Primer result
= (Primer
)super.clone();
179 // don't change label, sequence
180 result
.publishedIn
= this.publishedIn
;
183 }catch (CloneNotSupportedException e
) {
184 logger
.warn("Object does not implement cloneable");