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 java
.util
.HashSet
;
14 import javax
.persistence
.Entity
;
15 import javax
.persistence
.FetchType
;
16 import javax
.persistence
.ManyToOne
;
17 import javax
.persistence
.OneToMany
;
18 import javax
.validation
.constraints
.Size
;
19 import javax
.xml
.bind
.annotation
.XmlAccessType
;
20 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
21 import javax
.xml
.bind
.annotation
.XmlAttribute
;
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
.annotations
.Cascade
;
31 import org
.hibernate
.annotations
.CascadeType
;
32 import org
.hibernate
.envers
.Audited
;
33 import org
.hibernate
.search
.annotations
.Analyze
;
34 import org
.hibernate
.search
.annotations
.Field
;
35 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
36 import org
.hibernate
.search
.annotations
.NumericField
;
38 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
39 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
40 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
41 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
42 import eu
.etaxonomy
.cdm
.model
.occurrence
.MaterialOrMethodEvent
;
49 @XmlAccessorType(XmlAccessType
.FIELD
)
50 @XmlType(name
= "Amplification", propOrder
= {
60 "electrophoresisVoltage",
66 @XmlRootElement(name
= "Amplification")
69 public class Amplification
extends EventBase
implements Cloneable
{
70 private static final long serialVersionUID
= -8614860617229484621L;
71 private static final Logger logger
= Logger
.getLogger(Amplification
.class);
74 /** @see #getDnaSample() */
75 @XmlElement( name
= "DnaSample")
77 @XmlSchemaType(name
= "IDREF")
78 @ManyToOne(fetch
= FetchType
.LAZY
)
80 private DnaSample dnaSample
;
82 @XmlElementWrapper(name
= "SingleReads")
83 @XmlElement(name
= "SingleRead")
85 @XmlSchemaType(name
= "IDREF")
86 @OneToMany(fetch
= FetchType
.LAZY
)
87 @Cascade({CascadeType
.SAVE_UPDATE
})
88 private Set
<SingleRead
> singleReads
= new HashSet
<SingleRead
>();
90 /** @see #getMarker()*/
91 @XmlElement(name
= "DnaMarker")
93 @XmlSchemaType(name
= "IDREF")
94 @ManyToOne(fetch
=FetchType
.EAGER
)
95 private DefinedTerm dnaMarker
;
97 /** @see #getForwardPrimer() */
98 @XmlElement(name
= "ForwardPrimer")
100 @XmlSchemaType(name
= "IDREF")
101 @ManyToOne(fetch
=FetchType
.LAZY
)
102 @Cascade({CascadeType
.SAVE_UPDATE
})
103 private Primer forwardPrimer
;
105 /** @see #getReversePrimer()*/
106 @XmlElement(name
= "ReversePrimer")
108 @XmlSchemaType(name
= "IDREF")
109 @ManyToOne(fetch
=FetchType
.LAZY
)
110 @Cascade({CascadeType
.SAVE_UPDATE
})
111 private Primer reversePrimer
;
114 @XmlElement(name
= "Purification")
116 @XmlSchemaType(name
= "IDREF")
117 @ManyToOne(fetch
=FetchType
.LAZY
)
118 @Cascade({CascadeType
.SAVE_UPDATE
})
119 private MaterialOrMethodEvent purification
;
121 @XmlElement(name
= "Cloning")
123 @XmlSchemaType(name
= "IDREF")
124 @ManyToOne(fetch
=FetchType
.LAZY
)
125 @Cascade({CascadeType
.SAVE_UPDATE
})
126 private Cloning cloning
;
129 /** @see #getSuccessful() */
130 @XmlAttribute(name
= "successful")
131 private Boolean successful
;
133 /** @see #getSuccessText() */
134 @XmlElement(name
= "successText")
137 private String successText
;
139 /** @see #getLadderUsed() */
140 @XmlElement(name
= "ladderUsed")
143 private String ladderUsed
;
145 /** @see #getElectrophoresisVoltage()*/
146 @XmlElement(name
= "electrophoresisVoltage")
147 @Field(analyze
= Analyze
.NO
)
149 private Double electrophoresisVoltage
;
151 /** @see #getGelRunningTime() */
152 @XmlElement(name
= "gelRunningTime")
153 @Field(analyze
= Analyze
.NO
)
155 private Double gelRunningTime
;
157 /** @see #getGelConcentration() */
158 @XmlElement(name
= "gelConcentration")
159 @Field(analyze
= Analyze
.NO
)
161 private Double gelConcentration
;
163 @XmlElement(name
= "GelPhoto")
165 @XmlSchemaType(name
= "IDREF")
166 @ManyToOne(fetch
=FetchType
.LAZY
)
167 @Cascade({CascadeType
.SAVE_UPDATE
})
168 private Media gelPhoto
;
171 // ********************* FACTORY METHODS ************************/
173 public static Amplification
NewInstance(DnaSample dnaSample
){
174 Amplification result
= new Amplification();
175 dnaSample
.addAmplification(result
);
180 // ******************* CONSTRUCTOR *******************************/
182 private Amplification(){}
185 //********************* GETTER / SETTER ************/
189 * The {@link DnaSample dna sample} which is the input for this {@link Amplification amplification}.
191 public DnaSample
getDnaSample() {
196 * For use by DnaSample.addAmplification(ampl.) only. For now.
197 * @see #getDnaSample()
199 protected void setDnaSample(DnaSample dnaSample
) {
200 this.dnaSample
= dnaSample
;
204 * The {@link SingleRead single sequences} created by using this amplification's result.
206 public Set
<SingleRead
> getSingleReads() {
210 public void addSingleRead(SingleRead singleRead
){
211 if (singleRead
.getAmplification() != null){
212 singleRead
.getAmplification().singleReads
.remove(singleRead
);
214 this.singleReads
.add(singleRead
);
215 singleRead
.setAmplification(this);
219 * @see #getSingleReads()
221 //TODO private until it is clear how bidirectionality is handled
222 private void setSingleReads(Set
<SingleRead
> singleReads
) {
223 this.singleReads
= singleReads
;
228 * The {@link TermType#DnaMarker marker} examined by this amplification.
230 public DefinedTerm
getMarker() {
237 public void setMarker(DefinedTerm marker
) {
238 this.dnaMarker
= marker
;
242 * The primer used for forward amplification.
243 * @see #getReversePrimer()
245 public Primer
getForwardPrimer() {
246 return forwardPrimer
;
250 * @see #getForwardPrimer()
251 * @see #getReversePrimer()
253 public void setForwardPrimer(Primer forwardPrimer
) {
254 this.forwardPrimer
= forwardPrimer
;
258 * The primer used for reverse amplification.
259 * @see #getForwardPrimer()
261 public Primer
getReversePrimer() {
262 return reversePrimer
;
266 * @see #getReversePrimer()
267 * @see #getForwardPrimer()
269 public void setReversePrimer(Primer reversePrimer
) {
270 this.reversePrimer
= reversePrimer
;
274 * Information if this amplification was successful or not. Success may be defined
275 * by the results of the electrophoresis.
277 * @see #getSuccessText()
279 public Boolean
getSuccessful() {
284 * @see #getSuccessful()
285 * @see #getSuccessText()
287 public void setSuccessful(Boolean successful
) {
288 this.successful
= successful
;
292 * Freetext about the success of this amplification explaining
293 * in detail why it is concidered to be successful/unsucessful
295 * @see #getSuccessful()
297 public String
getSuccessText() {
302 * @see #getSuccessText()
303 * @see #getSuccessful()
305 public void setSuccessText(String successText
) {
306 this.successText
= successText
;
311 * The material and/or method used for purification.
313 public MaterialOrMethodEvent
getPurification() {
318 * @see #getPurification()
320 public void setPurification(MaterialOrMethodEvent purification
) {
321 this.purification
= purification
;
326 * The cloning process (including materials and methods) involved in this amplification.
328 public Cloning
getCloning() {
335 public void setCloning(Cloning cloning
) {
336 this.cloning
= cloning
;
340 * The voltage used for running the electrophoresis quality check.
342 * @see #getGelRunningTime()
343 * @see #getGelPhoto()
344 * @see #getLadderUsed()
345 * @see #getGelConcentration()
348 public Double
getElectrophoresisVoltage() {
349 return electrophoresisVoltage
;
353 * @see #getElectrophoresisVoltage()
355 public void setElectrophoresisVoltage(Double electrophoresisVoltage
) {
356 this.electrophoresisVoltage
= electrophoresisVoltage
;
360 * The time for running the electrophoresis quality check.
362 public Double
getGelRunningTime() {
363 return gelRunningTime
;
367 * @see #getGelRunningTime()
369 public void setGelRunningTime(Double gelRunningTime
) {
370 this.gelRunningTime
= gelRunningTime
;
375 * The gel concentration used for the electrophoresis.
376 * @see #getElectrophoresisVoltage()
377 * @see #getGelRunningTime()
378 * @see #getGelPhoto()
379 * @see #getLadderUsed()
381 public Double
getGelConcentration() {
382 return gelConcentration
;
386 * @see #getGelConcentration()
388 public void setGelConcentration(Double gelConcentration
) {
389 this.gelConcentration
= gelConcentration
;
393 * Material and method used for testing quality of this amplification.
394 * @see #getElectrophoresisVoltage()
395 * @see #getGelPhoto()
396 * @see #getGelConcentration()
397 * @see #getGelRunningTime()
399 public String
getLadderUsed() {
404 * @see #getLadderUsed()
406 public void setLadderUsed(String ladderUsed
) {
407 this.ladderUsed
= ladderUsed
;
411 * The photo taken from the electrophoresis result showing the quality of the amplification.
412 * Gelphotos often do show multiple electrophoresis results. One may either cut or mark
413 * the part of the photo that displays <code>this</code> amplification.
414 * @see #getElectrophoresisVoltage()
415 * @see #getLadderUsed()
416 * @see #getGelConcentration()
417 * @see #getGelRunningTime()
419 public Media
getGelPhoto() {
425 * @param gelPhoto the gelPhoto to set
427 public void setGelPhoto(Media gelPhoto
) {
428 this.gelPhoto
= gelPhoto
;
432 // ********************** CLONE ***********************************/
434 * Clones <i>this</i> amplification. This is a shortcut that enables to create
435 * a new instance that differs only slightly from <i>this</i> amplification by
436 * modifying only some of the attributes.<BR><BR>
439 * @see EventBase#clone()
440 * @see java.lang.Object#clone()
443 public Object
clone() {
445 Amplification result
= (Amplification
)super.clone();
447 result
.singleReads
= new HashSet
<SingleRead
>();
448 for (SingleRead seq
: this.singleReads
){
449 result
.singleReads
.add((SingleRead
) seq
);
453 //don't change dnaSample, marker, successful, successText, forwardPrimer,
454 //reversePrimer, purifiaction, cloning, ladderUsed, electrophoresisVoltage,
455 //gelRunningTime, gelPhoto, gelConcentration
457 }catch (CloneNotSupportedException e
) {
458 logger
.warn("Object does not implement cloneable");