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
.name
;
12 import java
.util
.HashSet
;
15 import javax
.persistence
.Entity
;
16 import javax
.persistence
.Inheritance
;
17 import javax
.persistence
.InheritanceType
;
18 import javax
.persistence
.FetchType
;
19 import javax
.persistence
.ManyToMany
;
20 import javax
.persistence
.ManyToOne
;
21 import javax
.persistence
.OneToMany
;
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
.XmlTransient
;
28 import javax
.xml
.bind
.annotation
.XmlType
;
30 import org
.apache
.log4j
.Logger
;
31 import org
.hibernate
.annotations
.Cascade
;
32 import org
.hibernate
.annotations
.CascadeType
;
34 import eu
.etaxonomy
.cdm
.model
.common
.ReferencedEntityBase
;
35 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
38 * The (abstract) class representing a typification of one or several {@link TaxonNameBase taxon names}.<BR>
39 * All taxon names which have a {@link Rank rank} "species aggregate" or lower
40 * can only be typified by specimens (a {@link SpecimenTypeDesignation specimen type designation}), but taxon
41 * names with a higher rank might be typified by an other taxon name with
42 * rank "species" or "genus" (a {@link NameTypeDesignation name type designation}).
45 * @see NameTypeDesignation
46 * @see SpecimenTypeDesignation
51 @XmlRootElement(name
= "TypeDesignationBase")
52 @XmlType(name
= "TypeDesignationBase", propOrder
= {
59 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
60 public abstract class TypeDesignationBase
extends ReferencedEntityBase
implements ITypeDesignation
{
61 private static final Logger logger
= Logger
.getLogger(TypeDesignationBase
.class);
64 @XmlElement(name
= "IsNotDesignated")
65 private boolean isNotDesignated
;
67 @XmlElementWrapper(name
= "TypifiedNames")
68 @XmlElement(name
= "TypifiedName")
70 @XmlSchemaType(name
= "IDREF")
71 // Need these references (bidirectional) to fill table TypeDesignationBase_TaxonNameBase
72 private Set
<TaxonNameBase
> typifiedNames
= new HashSet
<TaxonNameBase
>();
74 @XmlElement(name
= "HomotypicalGroup")
76 @XmlSchemaType(name
= "IDREF")
77 private HomotypicalGroup homotypicalGroup
;
79 // **************** CONSTRUCTOR *************************************/
82 * Class constructor: creates a new empty type designation.
84 * @see #TypeDesignationBase(ReferenceBase, String, String, Boolean)
86 protected TypeDesignationBase(){
91 * Class constructor: creates a new type designation
92 * (including its {@link ReferenceBase reference source} and eventually
93 * the taxon name string originally used by this reference when establishing
94 * the former designation).
96 * @param citation the reference source for the new designation
97 * @param citationMicroReference the string with the details describing the exact localisation within the reference
98 * @param originalNameString the taxon name string used originally in the reference source for the new designation
99 * @param isNotDesignated the boolean flag indicating whether there is no type at all for
100 * <i>this</i> type designation
101 * @see #TypeDesignationBase()
102 * @see #isNotDesignated()
103 * @see TaxonNameBase#getTypeDesignations()
105 protected TypeDesignationBase(ReferenceBase citation
, String citationMicroReference
, String originalNameString
, boolean isNotDesignated
){
106 super(citation
, citationMicroReference
, originalNameString
);
107 this.isNotDesignated
= isNotDesignated
;
111 // **************** METHODS *************************************/
115 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#getHomotypicalGroup()
118 * Returns the {@link HomotypicalGroup homotypical group} to which all (in <i>this</i>
119 * type designation) typified {@link TaxonNameBase taxon names} belong.
121 * @see #getTypifiedNames()
123 @ManyToOne(fetch
= FetchType
.LAZY
)
124 @Cascade({CascadeType
.SAVE_UPDATE
})
125 public HomotypicalGroup
getHomotypicalGroup() {
126 return homotypicalGroup
;
129 @Deprecated //for hibernate use only
130 private void setHomotypicalGroup(HomotypicalGroup homotypicalGroup
) {
131 this.homotypicalGroup
= homotypicalGroup
;
135 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#getTypifiedNames()
138 * Returns the set of {@link TaxonNameBase taxon names} typified in <i>this</i>
139 * type designation. This is a subset of the taxon names belonging to the
140 * corresponding {@link #getHomotypicalGroup() homotypical group}.
142 @ManyToMany(fetch
= FetchType
.LAZY
)
143 @Cascade({CascadeType
.SAVE_UPDATE
})
144 public Set
<TaxonNameBase
> getTypifiedNames() {
145 return typifiedNames
;
149 * Returns the boolean value "true" if it is known that a type does not
150 * exist and therefore the {@link TaxonNameBase taxon name} to which <i>this</i>
151 * type designation is assigned must still be typified. Two
152 * cases must be differentiated: <BR><ul>
153 * <li> a) it is unknown whether a type exists and
154 * <li> b) it is known that no type exists
156 * If a) is true there should be no TypeDesignation instance at all
157 * assigned to the "typified" taxon name.<BR>
158 * If b) is true there should be a TypeDesignation instance with the
159 * flag isNotDesignated set. The typeName attribute, in case of a
160 * {@link NameTypeDesignation name type designation}, or the typeSpecimen attribute,
161 * in case of a {@link SpecimenTypeDesignation specimen type designation}, should then be "null".
163 public boolean isNotDesignated() {
164 return isNotDesignated
;
168 * @see #isNotDesignated()
170 public void setNotDesignated(boolean isNotDesignated
) {
171 this.isNotDesignated
= isNotDesignated
;
175 @Deprecated //for hibernate use only
176 private void setTypifiedNames(Set
<TaxonNameBase
> typifiedNames
) {
177 this.typifiedNames
= typifiedNames
;
180 @Deprecated //for bidirectional use only
181 protected void addTypifiedName(TaxonNameBase taxonName
){
182 this.typifiedNames
.add(taxonName
);