root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/molecular/DnaSample.java

Revision 10564, 3.9 kB (checked in by n.hoffmann, 19 months ago)

making constructor private again

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.molecular;
11
12
13import java.util.HashSet;
14import java.util.Set;
15
16import javax.persistence.Entity;
17import javax.persistence.FetchType;
18import javax.persistence.OneToMany;
19import javax.persistence.Transient;
20import javax.xml.bind.annotation.XmlAccessType;
21import javax.xml.bind.annotation.XmlAccessorType;
22import javax.xml.bind.annotation.XmlElement;
23import javax.xml.bind.annotation.XmlElementWrapper;
24import javax.xml.bind.annotation.XmlIDREF;
25import javax.xml.bind.annotation.XmlRootElement;
26import javax.xml.bind.annotation.XmlSchemaType;
27import javax.xml.bind.annotation.XmlType;
28
29import org.apache.log4j.Logger;
30import org.hibernate.envers.Audited;
31import org.hibernate.search.annotations.Indexed;
32
33import eu.etaxonomy.cdm.model.occurrence.Collection;
34import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
35import eu.etaxonomy.cdm.model.occurrence.Specimen;
36import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
37import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
38
39/**
40 * @author m.doering
41 * @version 1.0
42 * @created 08-Nov-2007 13:06:22
43 */
44@XmlAccessorType(XmlAccessType.FIELD)
45@XmlType(name = "DnaSample", propOrder = {
46    "sequences"
47})
48@XmlRootElement(name = "DnaSample")
49@Entity
50@Indexed(index = "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase")
51@Audited
52public class DnaSample extends Specimen implements Cloneable {
53        private static final long serialVersionUID = -2978411330023671805L;
54        private static final Logger logger = Logger.getLogger(DnaSample.class);
55       
56        /**
57         * Factory method
58         * @return
59         */
60        public static DnaSample NewInstance(){
61                return new DnaSample();
62        }
63
64       
65//      @XmlElement(name = "BankNumber")
66//      private String bankNumber;
67       
68        @XmlElementWrapper(name = "Sequences")
69        @XmlElement(name = "sequence")
70    @XmlIDREF
71    @XmlSchemaType(name = "IDREF")
72    @OneToMany(fetch = FetchType.LAZY)
73        private Set<Sequence> sequences = new HashSet<Sequence>();
74
75       
76       
77        /**
78         * Constructor
79         */
80        private DnaSample() {
81                super();
82                this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<Specimen>();
83        }
84       
85        public Set<Sequence> getSequences() {
86                return sequences;
87        }
88
89        // FIXME shouldn't this be the singular? i.e. addSequence( . . . )
90        public void addSequences(Sequence sequence) {
91                this.sequences.add(sequence);
92        }
93
94        // FIXME shouldn't this be the singular? i.e. removeSequence( . . . )
95        public void removeSequences(Sequence sequence) {
96                this.sequences.remove(sequence);
97        }
98
99        @Transient
100        public Collection getStoredAt(){
101                return this.getCollection();
102        }
103       
104        public void setStoredAt(Collection storedAt){
105                this.setCollection(storedAt);
106        }
107
108        @Transient
109        public Set<SpecimenOrObservationBase> getExtractedFrom(){
110                return getOriginals();
111        }
112
113        @Transient
114        public String getBankNumber(){
115                return this.getCatalogNumber();
116        }
117       
118        public void setBankNumber(String bankNumber){
119                this.setCatalogNumber(bankNumber);
120        }
121       
122
123//*********** CLONE **********************************/
124       
125        /**
126         * Clones <i>this</i> dna sample. This is a shortcut that enables to
127         * create a new instance that differs only slightly from <i>this</i> dna sample
128         * by modifying only some of the attributes.<BR>
129         * This method overrides the clone method from {@link Specimen Specimen}.
130         *
131         * @see Specimen#clone()
132         * @see DerivedUnitBase#clone()
133         * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
134         * @see java.lang.Object#clone()
135         */
136        @Override
137        public DnaSample clone(){
138                DnaSample result = (DnaSample)super.clone();
139                //sequenceSet
140                result.sequences = new HashSet<Sequence>();
141                for(Sequence sequence : this.sequences) {
142                        result.addSequences(sequence);
143                }
144                //no changes to: bankNumber
145                return result;
146        }
147}
Note: See TracBrowser for help on using the browser.