root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/SpecimenTypeDesignation.java

Revision 13176, 7.9 kB (checked in by a.mueller, 8 months ago)

Implement correct mapping between TaxonNameBase? and TypeDesignationBase? and add delete method for type designations to NameService? (#2396, #2647)

  • 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.name;
11
12
13import javax.persistence.Entity;
14import javax.persistence.FetchType;
15import javax.persistence.JoinColumn;
16import javax.persistence.ManyToOne;
17import javax.persistence.Transient;
18import javax.xml.bind.annotation.XmlAccessType;
19import javax.xml.bind.annotation.XmlAccessorType;
20import javax.xml.bind.annotation.XmlElement;
21import javax.xml.bind.annotation.XmlIDREF;
22import javax.xml.bind.annotation.XmlRootElement;
23import javax.xml.bind.annotation.XmlSchemaType;
24import javax.xml.bind.annotation.XmlType;
25
26import org.apache.log4j.Logger;
27import org.hibernate.annotations.Cascade;
28import org.hibernate.annotations.CascadeType;
29import org.hibernate.envers.Audited;
30
31import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
32import eu.etaxonomy.cdm.model.occurrence.Specimen;
33import eu.etaxonomy.cdm.model.reference.Reference;
34
35/**
36 * The class representing a typification of one or several {@link TaxonNameBase taxon names} by a
37 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or a figure}. All {@link TaxonNameBase taxon names}
38 * which have a {@link Rank rank} "species aggregate" or lower can only be typified
39 * by specimens. Moreover each typification by a specimen (or by a figure) has a
40 * {@link SpecimenTypeDesignationStatus status} like "holotype" or "isotype".
41 * <P>
42 * This class corresponds to: <ul>
43 * <li> NomenclaturalType according to the TDWG ontology
44 * <li> Typification (partially) according to the TCS
45 * <li> NomenclaturalTypeDesignation according to the ABCD schema
46 * </ul>
47 *
48 * @see         TypeDesignationBase
49 * @see         NameTypeDesignation
50 * @author      m.doering
51 * @version 1.0
52 * @created 08-Nov-2007 13:06:38
53 */
54@XmlRootElement(name = "SpecimenTypeDesignation")
55@XmlAccessorType(XmlAccessType.FIELD)
56@XmlType(name = "SpecimenTypeDesignation", propOrder = {
57    "typeSpecimen"
58})
59@Entity
60@Audited
61public class SpecimenTypeDesignation extends TypeDesignationBase<SpecimenTypeDesignationStatus> implements ITypeDesignation, Cloneable {
62        private static final long serialVersionUID = 6481627446997275007L;
63        private static final Logger logger = Logger.getLogger(SpecimenTypeDesignation.class);
64       
65        @XmlElement(name = "TypeSpecimen")
66        @XmlIDREF
67        @XmlSchemaType(name = "IDREF")
68        @ManyToOne(fetch = FetchType.LAZY)
69        @JoinColumn(name="typeSpecimen_id")
70        @Cascade(CascadeType.SAVE_UPDATE)
71        private DerivedUnitBase typeSpecimen;
72       
73//      /**
74//       * Creates a new specimen type designation instance
75//       * (including its {@link reference.Reference reference source} and eventually
76//       * the taxon name string originally used by this reference when establishing
77//       * the former designation) and adds it to the corresponding
78//       * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type designation set} of the
79//       * {@link HomotypicalGroup homotypical group}.
80//       *
81//       * @param specimen                              the derived unit (specimen or figure) used as type
82//       * @param status                                the type designation status
83//       * @param citation                              the reference source for the new designation
84//       * @param citationMicroReference        the string with the details describing the exact localisation within the reference
85//       * @param originalNameString    the taxon name string used originally in the reference source for the new designation
86//       * @see                                                 #SpecimenTypeDesignation(DerivedUnitBase, TypeDesignationStatus, Reference, String, String)
87//       * @see                                                 HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
88//       * @see                                                 occurrence.DerivedUnitBase
89//       */
90//      protected static SpecimenTypeDesignation NewInstance2(DerivedUnitBase specimen, TypeDesignationStatus status,
91//                      Reference citation, String citationMicroReference, String originalNameString){
92//              SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
93//              return specTypeDesig;
94//      }
95       
96       
97        // ************* CONSTRUCTORS *************/   
98        /**
99         * Class constructor: creates a new empty specimen type designation.
100         *
101         * @see #SpecimenTypeDesignation(DerivedUnitBase, SpecimenTypeDesignationStatus,
102         * Reference, String, String, boolean)
103         */
104        protected SpecimenTypeDesignation(){
105        }
106       
107        public static SpecimenTypeDesignation NewInstance() {
108                return new SpecimenTypeDesignation();
109        }
110       
111        /**
112         * Class constructor: creates a new specimen type designation instance
113         * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and
114         * eventually the taxon name string originally used by this reference when
115         * establishing the former designation).
116         *
117         * @param specimen                              the derived unit (specimen or figure) used
118         *                                                              as type
119         * @param status                                the type designation status
120         * @param citation                              the reference source for the new designation
121         * @param citationMicroReference        the string with the details describing
122         *                                                              the exact localisation within the reference
123         * @param originalNameString    the taxon name string used originally in the
124         *                                                              reference source for the new designation
125         * @param isNotDesignated               the boolean flag indicating whether there is no specimen type at all for
126         *                                                              <i>this</i> specimen type designation
127         * @see                                                 #SpecimenTypeDesignation()
128         * @see                                                 TaxonNameBase#addSpecimenTypeDesignation(Specimen, SpecimenTypeDesignationStatus, Reference, String, String, boolean, boolean)
129         * @see                                                 TypeDesignationBase#isNotDesignated()
130         * @see                                                 eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase
131         */
132        protected SpecimenTypeDesignation(DerivedUnitBase specimen, SpecimenTypeDesignationStatus status, Reference citation, String citationMicroReference, 
133                        String originalNameString, boolean isNotDesignated) {
134                super(citation, citationMicroReference, originalNameString, isNotDesignated);
135                this.setTypeSpecimen(specimen);
136               
137                this.setTypeStatus(status);
138        }
139       
140        //********* METHODS **************************************/
141       
142       
143        /* (non-Javadoc)
144         * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#removeType()
145         */
146        @Override
147        public void removeType() {
148                this.setTypeSpecimen(null);
149        }
150       
151        /**
152         * Returns the {@link occurrence.DerivedUnitBase derived unit} (specimen or figure) that is used
153         * in <i>this</i> specimen type designation to typify the {@link TaxonNameBase taxon name}.
154         * 
155         * @see   #getHomotypicalGroup()
156         */
157        public DerivedUnitBase getTypeSpecimen(){
158                return this.typeSpecimen;
159        }
160       
161        /**
162         * @see  #getTypeSpecimen()
163         */
164        public void setTypeSpecimen(DerivedUnitBase typeSpecimen){
165                if (this.typeSpecimen == typeSpecimen){
166                        return;
167                }
168                if (this.typeSpecimen != null){
169                        this.typeSpecimen.removeSpecimenTypeDesignation(this);
170                }
171                if (typeSpecimen != null && ! typeSpecimen.getSpecimenTypeDesignations().contains(this)){
172                        typeSpecimen.addSpecimenTypeDesignation(this);
173                }
174                this.typeSpecimen = typeSpecimen;
175        }
176
177        /* (non-Javadoc)
178         * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
179         */
180        @Transient
181        public boolean isLectoType() {
182                if(getTypeStatus() == null){
183                        return false;
184                }
185                return getTypeStatus().isLectotype();
186        }
187       
188//*********************** CLONE ********************************************************/
189       
190        /**
191         * Clones <i>this</i> type specimen. This is a shortcut that enables to create
192         * a new instance that differs only slightly from <i>this</i> type specimen by
193         * modifying only some of the attributes.
194         *
195         * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
196         * @see java.lang.Object#clone()
197         */
198        @Override
199        public Object clone() {
200                SpecimenTypeDesignation result;
201                try {
202                        result = (SpecimenTypeDesignation)super.clone();
203                        //no changes to: typeSpecimen
204                        return result;
205                } catch (CloneNotSupportedException e) {
206                        logger.warn("Object does not implement cloneable");
207                        e.printStackTrace();
208                        return null;
209                }
210        }
211
212       
213}
Note: See TracBrowser for help on using the browser.