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 java
.util
.HashSet
;
16 import javax
.persistence
.Entity
;
17 import javax
.persistence
.FetchType
;
18 import javax
.persistence
.ManyToMany
;
19 import javax
.validation
.constraints
.NotNull
;
20 import javax
.xml
.bind
.annotation
.XmlAccessType
;
21 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
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
.envers
.Audited
;
32 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
35 * "A phylogenetic tree or evolutionary tree is a branching diagram or "tree" showing the
36 * inferred evolutionary relationships among various biological species or other entities
37 * based upon similarities and differences in their physical and/or genetic characteristics.
38 * The taxa joined together in the tree are implied to have descended from a common ancestor."
40 * <BR> In the CDM we currently store phylogenetic trees only as media. This may change in future.
45 @XmlAccessorType(XmlAccessType
.FIELD
)
46 @XmlType(name
= "PhylogeneticTree", propOrder
= {
49 @XmlRootElement(name
= "PhylogeneticTree")
51 //@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
52 //@Indexed(index = "eu.etaxonomy.cdm.model.media.Media")
54 public class PhylogeneticTree
extends Media
implements Cloneable
{
55 private static final long serialVersionUID
= -7020182117362324067L;
56 private static final Logger logger
= Logger
.getLogger(PhylogeneticTree
.class);
59 @XmlElementWrapper(name
= "UsedSequences")
60 @XmlElement(name
= "UsedSequence")
62 @XmlSchemaType(name
= "IDREF")
63 @ManyToMany(fetch
= FetchType
.LAZY
)
65 private Set
<Sequence
> usedSequences
= new HashSet
<Sequence
>();
67 //********************** Factory Method **********************************/
73 public static PhylogeneticTree
NewInstance(){
74 return new PhylogeneticTree();
78 //***************** Constructor ****************************/
80 private PhylogeneticTree(){
86 // ********************** GETTER / SETTER **************************/
88 public Set
<Sequence
> getUsedSequences() {
89 if(usedSequences
== null) {
90 this.usedSequences
= new HashSet
<Sequence
>();
95 public void addUsedSequences(Sequence usedSequence
) {
96 this.usedSequences
.add(usedSequence
);
99 public void removeUsedSequences(Sequence usedSequence
) {
100 this.usedSequences
.remove(usedSequence
);
104 //*********** CLONE **********************************/
107 * Clones <i>this</i> phylogenetic tree. This is a shortcut that enables to
108 * create a new instance that differs only slightly from <i>this</i> phylogenetic tree
109 * by modifying only some of the attributes.<BR>
110 * This method overrides the clone method from {@link Media Media}.
112 * @see eu.etaxonomy.cdm.model.media.Media#clone()
113 * @see java.lang.Object#clone()
117 public Object
clone(){
118 PhylogeneticTree result
;
120 result
= (PhylogeneticTree
) super.clone();
121 result
.usedSequences
= new HashSet
<Sequence
>();
122 for (Sequence seq
: this.usedSequences
){
123 result
.addUsedSequences((Sequence
)seq
.clone());
127 }catch (CloneNotSupportedException e
) {
128 logger
.warn("Object does not implement cloneable");