1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.model.molecular;
|
10
|
|
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;
|
22
|
|
23
|
import org.apache.logging.log4j.LogManager;
|
24
|
import org.apache.logging.log4j.Logger;
|
25
|
import org.hibernate.annotations.Cascade;
|
26
|
import org.hibernate.annotations.CascadeType;
|
27
|
import org.hibernate.envers.Audited;
|
28
|
|
29
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
30
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
31
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
32
|
|
33
|
/**
|
34
|
* A primer is a (short) DNA Sequence used for replication and extraction
|
35
|
* of DNA parts during e.g. {@link Amplification amplification} or
|
36
|
* {@link SingleRead sequence reading}.
|
37
|
*
|
38
|
* @author a.mueller
|
39
|
* @since 2013-07-08
|
40
|
*/
|
41
|
@XmlAccessorType(XmlAccessType.FIELD)
|
42
|
@XmlType(name = "Primer", propOrder = {
|
43
|
"label",
|
44
|
"sequence",
|
45
|
"dnaMarker",
|
46
|
"publishedIn"
|
47
|
})
|
48
|
@XmlRootElement(name = "Primer")
|
49
|
@Entity
|
50
|
@Audited
|
51
|
//TODO which base class (..., identifiable, definedTerm, ...)
|
52
|
public class Primer extends AnnotatableEntity {
|
53
|
|
54
|
private static final long serialVersionUID = 6179007910988646989L;
|
55
|
private static final Logger logger = LogManager.getLogger();
|
56
|
|
57
|
/** @see #getLabel() */
|
58
|
@XmlElement(name = "Label")
|
59
|
@Column(length=255)
|
60
|
private String label;
|
61
|
|
62
|
/** @see #getSequence() */
|
63
|
//(see #4139)
|
64
|
@XmlElement(name = "Sequence")
|
65
|
private SequenceString sequence = SequenceString.NewInstance();
|
66
|
|
67
|
|
68
|
/** @see #getDnaMarker()*/
|
69
|
@XmlElement(name = "DnaMarker")
|
70
|
@XmlIDREF
|
71
|
@XmlSchemaType(name = "IDREF")
|
72
|
@ManyToOne(fetch=FetchType.LAZY)
|
73
|
private DefinedTerm dnaMarker;
|
74
|
|
75
|
/** @see #getPublishedIn() */
|
76
|
@XmlElement(name = "PublishedIn")
|
77
|
@XmlIDREF
|
78
|
@XmlSchemaType(name = "IDREF")
|
79
|
@ManyToOne(fetch=FetchType.LAZY)
|
80
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
81
|
private Reference publishedIn;
|
82
|
|
83
|
// ******************** FACTORY METHOD ******************/
|
84
|
|
85
|
public static Primer NewInstance(String label){
|
86
|
Primer result = new Primer();
|
87
|
result.setLabel(label);
|
88
|
return result;
|
89
|
}
|
90
|
|
91
|
// ********************* CONSTRUCTOR ********************/
|
92
|
|
93
|
//for hibernate use only, *packet* private required by bytebuddy
|
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
|
96
|
Primer(){}
|
97
|
|
98
|
// ********************* GETTER / SETTER ********************/
|
99
|
|
100
|
/**
|
101
|
* The name of this primer, usually given by the producers.
|
102
|
* @return the label of this primer.
|
103
|
*/
|
104
|
public String getLabel() {
|
105
|
return label;
|
106
|
}
|
107
|
/**
|
108
|
* @see #getLabel()
|
109
|
*/
|
110
|
public void setLabel(String label) {
|
111
|
this.label = label;
|
112
|
}
|
113
|
|
114
|
/**
|
115
|
* The DNA {@link Sequence} of this primer. A primer is usually a
|
116
|
* small piece of DNA and therefore can be expressed as a sequence.
|
117
|
*/
|
118
|
public SequenceString getSequence() {
|
119
|
return sequence;
|
120
|
}
|
121
|
/**
|
122
|
* @see Primer#getSequence()
|
123
|
*/
|
124
|
public void setSequence(SequenceString sequence) {
|
125
|
if (sequence == null){
|
126
|
sequence = SequenceString.NewInstance();
|
127
|
}
|
128
|
this.sequence = sequence;
|
129
|
}
|
130
|
|
131
|
/**
|
132
|
* #4470
|
133
|
*/
|
134
|
public DefinedTerm getDnaMarker() {
|
135
|
return dnaMarker;
|
136
|
}
|
137
|
public void setDnaMarker(DefinedTerm dnaMarker) {
|
138
|
this.dnaMarker = dnaMarker;
|
139
|
}
|
140
|
|
141
|
/**
|
142
|
* The reference in which this primer was published and described
|
143
|
* for the first time. It is not a reference or citation for the
|
144
|
* sequence of this primer.<BR>
|
145
|
* Links to this reference are stored with the reference itself.
|
146
|
* @return the describing publication of this primer
|
147
|
*/
|
148
|
public Reference getPublishedIn() {
|
149
|
return publishedIn;
|
150
|
}
|
151
|
/**
|
152
|
* @see #getPublishedIn()
|
153
|
*/
|
154
|
public void setPublishedIn(Reference publishedIn) {
|
155
|
this.publishedIn = publishedIn;
|
156
|
}
|
157
|
|
158
|
// ********************* CLONE ********************/
|
159
|
|
160
|
/**
|
161
|
* Clones <i>this</i> primer. This is a shortcut that enables to create
|
162
|
* a new instance that differs only slightly from <i>this</i> primer by
|
163
|
* modifying only some of the attributes.<BR><BR>
|
164
|
*
|
165
|
* @see java.lang.Object#clone()
|
166
|
*/
|
167
|
@Override
|
168
|
public Primer clone() {
|
169
|
try{
|
170
|
Primer result = (Primer)super.clone();
|
171
|
|
172
|
// don't change label, sequence
|
173
|
result.publishedIn = this.publishedIn;
|
174
|
|
175
|
return result;
|
176
|
}catch (CloneNotSupportedException e) {
|
177
|
logger.warn("Object does not implement cloneable");
|
178
|
e.printStackTrace();
|
179
|
return null;
|
180
|
}
|
181
|
}
|
182
|
}
|