| 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 | |
|---|
| 10 | package eu.etaxonomy.cdm.model.name; |
|---|
| 11 | |
|---|
| 12 | import javax.persistence.Entity; |
|---|
| 13 | import javax.persistence.FetchType; |
|---|
| 14 | import javax.persistence.ManyToOne; |
|---|
| 15 | import javax.persistence.Transient; |
|---|
| 16 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 17 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 18 | import javax.xml.bind.annotation.XmlElement; |
|---|
| 19 | import javax.xml.bind.annotation.XmlIDREF; |
|---|
| 20 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 21 | import javax.xml.bind.annotation.XmlSchemaType; |
|---|
| 22 | import javax.xml.bind.annotation.XmlType; |
|---|
| 23 | |
|---|
| 24 | import org.apache.log4j.Logger; |
|---|
| 25 | import org.hibernate.annotations.Cascade; |
|---|
| 26 | import org.hibernate.annotations.CascadeType; |
|---|
| 27 | import org.hibernate.envers.Audited; |
|---|
| 28 | |
|---|
| 29 | import eu.etaxonomy.cdm.model.reference.Reference; |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * The class representing a typification of a {@link TaxonNameBase taxon name} with a {@link Rank rank} |
|---|
| 33 | * above "species aggregate" by another taxon name.<BR> |
|---|
| 34 | * According to nomenclature a type of a genus name or of any subdivision of a |
|---|
| 35 | * genus can only be a species name. A type of a family name or of any |
|---|
| 36 | * subdivision of a family is a genus name.<BR> |
|---|
| 37 | * Moreover the designation of a particular taxon name as a type might be |
|---|
| 38 | * nomenclaturally rejected or conserved. Depending on the date of publication, |
|---|
| 39 | * the same typification could be rejected according to one reference and later |
|---|
| 40 | * be conserved according to another reference, but a name type designation |
|---|
| 41 | * cannot be simultaneously rejected and conserved.<BR> |
|---|
| 42 | * Name type designations are treated as {@link TypeDesignationBase type designations} |
|---|
| 43 | * and not as {@link NameRelationship name relationships}. |
|---|
| 44 | * |
|---|
| 45 | * @see TypeDesignationBase |
|---|
| 46 | * @see SpecimenTypeDesignation |
|---|
| 47 | * @author m.doering |
|---|
| 48 | * @version 1.0 |
|---|
| 49 | * @created 08-Nov-2007 13:06:38 |
|---|
| 50 | */ |
|---|
| 51 | @XmlRootElement(name = "NameTypeDesignation") |
|---|
| 52 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 53 | @XmlType(name = "NameTypeDesignation", propOrder = { |
|---|
| 54 | "rejectedType", |
|---|
| 55 | "conservedType", |
|---|
| 56 | "typeName" |
|---|
| 57 | }) |
|---|
| 58 | @Entity |
|---|
| 59 | @Audited |
|---|
| 60 | public class NameTypeDesignation extends TypeDesignationBase<NameTypeDesignationStatus> implements ITypeDesignation, Cloneable { |
|---|
| 61 | private static final long serialVersionUID = 8478663508862210879L; |
|---|
| 62 | final static Logger logger = Logger.getLogger(NameTypeDesignation.class); |
|---|
| 63 | |
|---|
| 64 | @XmlElement(name = "IsRejectedType") |
|---|
| 65 | private boolean rejectedType; |
|---|
| 66 | |
|---|
| 67 | @XmlElement(name = "IsConservedType") |
|---|
| 68 | private boolean conservedType; |
|---|
| 69 | |
|---|
| 70 | @XmlElement(name = "TypeName") |
|---|
| 71 | @XmlIDREF |
|---|
| 72 | @XmlSchemaType(name = "IDREF") |
|---|
| 73 | @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 74 | @Cascade(CascadeType.SAVE_UPDATE) |
|---|
| 75 | private TaxonNameBase typeName; |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | public static NameTypeDesignation NewInstance() { |
|---|
| 79 | return new NameTypeDesignation(); |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | // ************* CONSTRUCTORS *************/ |
|---|
| 84 | /** |
|---|
| 85 | * Class constructor: creates a new empty name type designation. |
|---|
| 86 | * |
|---|
| 87 | * @see #NameTypeDesignation(TaxonNameBase, Reference, String, String, boolean, boolean, boolean) |
|---|
| 88 | */ |
|---|
| 89 | protected NameTypeDesignation() { |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | /** |
|---|
| 94 | * Class constructor: creates a new name type designation instance |
|---|
| 95 | * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and eventually |
|---|
| 96 | * the taxon name string originally used by this reference when establishing |
|---|
| 97 | * the former designation). |
|---|
| 98 | * |
|---|
| 99 | * @param typeName the taxon name used as a type |
|---|
| 100 | * @param citation the reference source for the new designation |
|---|
| 101 | * @param citationMicroReference the string with the details describing the exact localisation within the reference |
|---|
| 102 | * @param originalNameString the taxon name string used originally in the reference source for the new designation |
|---|
| 103 | * @param isRejectedType the boolean flag indicating whether the competent authorities rejected |
|---|
| 104 | * <i>this</i> name type designation |
|---|
| 105 | * @param isConservedType the boolean flag indicating whether the competent authorities conserved |
|---|
| 106 | * <i>this</i> name type designation |
|---|
| 107 | * @param isNotDesignated the boolean flag indicating whether there is no name type at all for |
|---|
| 108 | * <i>this</i> name type designation |
|---|
| 109 | * @see #NameTypeDesignation() |
|---|
| 110 | * @see TypeDesignationBase#isNotDesignated() |
|---|
| 111 | * @see TaxonNameBase#addNameTypeDesignation(TaxonNameBase, Reference, String, String, boolean, boolean, boolean, boolean, boolean) |
|---|
| 112 | */ |
|---|
| 113 | protected NameTypeDesignation(TaxonNameBase typeName, NameTypeDesignationStatus status, |
|---|
| 114 | Reference citation, String citationMicroReference, String originalNameString) { |
|---|
| 115 | super(citation, citationMicroReference, originalNameString); |
|---|
| 116 | this.setTypeName(typeName); |
|---|
| 117 | this.setTypeStatus(status); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | /** |
|---|
| 121 | * Class constructor: creates a new name type designation instance |
|---|
| 122 | * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and eventually |
|---|
| 123 | * the taxon name string originally used by this reference when establishing |
|---|
| 124 | * the former designation). |
|---|
| 125 | * |
|---|
| 126 | * @param typeName the taxon name used as a type |
|---|
| 127 | * @param citation the reference source for the new designation |
|---|
| 128 | * @param citationMicroReference the string with the details describing the exact localisation within the reference |
|---|
| 129 | * @param originalNameString the taxon name string used originally in the reference source for the new designation |
|---|
| 130 | * @param isRejectedType the boolean flag indicating whether the competent authorities rejected |
|---|
| 131 | * <i>this</i> name type designation |
|---|
| 132 | * @param isConservedType the boolean flag indicating whether the competent authorities conserved |
|---|
| 133 | * <i>this</i> name type designation |
|---|
| 134 | * @param isNotDesignated the boolean flag indicating whether there is no name type at all for |
|---|
| 135 | * <i>this</i> name type designation |
|---|
| 136 | * @see #NameTypeDesignation() |
|---|
| 137 | * @see TypeDesignationBase#isNotDesignated() |
|---|
| 138 | * @see TaxonNameBase#addNameTypeDesignation(TaxonNameBase, Reference, String, String, boolean, boolean, boolean, boolean, boolean) |
|---|
| 139 | */ |
|---|
| 140 | protected NameTypeDesignation( TaxonNameBase typeName, |
|---|
| 141 | Reference citation, |
|---|
| 142 | String citationMicroReference, |
|---|
| 143 | String originalNameString, |
|---|
| 144 | NameTypeDesignationStatus status, |
|---|
| 145 | boolean rejectedType, |
|---|
| 146 | boolean conservedType, |
|---|
| 147 | boolean isNotDesignated |
|---|
| 148 | ) { |
|---|
| 149 | this(typeName, status, citation, citationMicroReference, originalNameString); |
|---|
| 150 | this.setNotDesignated(isNotDesignated); |
|---|
| 151 | this.rejectedType = rejectedType; |
|---|
| 152 | this.conservedType = conservedType; |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | //********* METHODS **************************************/ |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | /* (non-Javadoc) |
|---|
| 159 | * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#removeType() |
|---|
| 160 | */ |
|---|
| 161 | @Override |
|---|
| 162 | public void removeType() { |
|---|
| 163 | this.typeName = null; |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | /** |
|---|
| 167 | * Returns the {@link TaxonNameBase taxon name} that plays the role of the |
|---|
| 168 | * taxon name type in <i>this</i> taxon name type designation. The {@link Rank rank} |
|---|
| 169 | * of the taxon name type must be "species". |
|---|
| 170 | */ |
|---|
| 171 | public TaxonNameBase getTypeName(){ |
|---|
| 172 | return this.typeName; |
|---|
| 173 | } |
|---|
| 174 | /** |
|---|
| 175 | * @see #getTypeName() |
|---|
| 176 | */ |
|---|
| 177 | public void setTypeName(TaxonNameBase typeName){ |
|---|
| 178 | this.typeName = typeName; |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | /** |
|---|
| 182 | * Returns the boolean value "true" if the competent authorities decided to |
|---|
| 183 | * reject the use of the species taxon name as the type for <i>this</i> taxon |
|---|
| 184 | * name type designation. |
|---|
| 185 | * |
|---|
| 186 | * @see #isConservedType() |
|---|
| 187 | */ |
|---|
| 188 | public boolean isRejectedType(){ |
|---|
| 189 | return this.rejectedType; |
|---|
| 190 | } |
|---|
| 191 | /** |
|---|
| 192 | * @see #isRejectedType() |
|---|
| 193 | */ |
|---|
| 194 | public void setRejectedType(boolean rejectedType){ |
|---|
| 195 | this.rejectedType = rejectedType; |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | /** |
|---|
| 199 | * Returns the boolean value "true" if the competent authorities decided to |
|---|
| 200 | * conserve the use of the species taxon name as the type for <i>this</i> taxon |
|---|
| 201 | * name type designation. |
|---|
| 202 | * |
|---|
| 203 | * @see #isRejectedType() |
|---|
| 204 | */ |
|---|
| 205 | public boolean isConservedType(){ |
|---|
| 206 | return this.conservedType; |
|---|
| 207 | } |
|---|
| 208 | /** |
|---|
| 209 | * @see #isConservedType() |
|---|
| 210 | */ |
|---|
| 211 | public void setConservedType(boolean conservedType){ |
|---|
| 212 | this.conservedType = conservedType; |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | @Transient |
|---|
| 216 | public boolean isLectoType() { |
|---|
| 217 | if (getTypeStatus() == null) { |
|---|
| 218 | return false; |
|---|
| 219 | } |
|---|
| 220 | return getTypeStatus().isLectotype(); |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | /** |
|---|
| 224 | * Returns the boolean value "true" if the use of the species {@link TaxonNameBase taxon name} |
|---|
| 225 | * as the type for <i>this</i> taxon name type designation was posterior to the |
|---|
| 226 | * publication of the typified taxon name. In this case the taxon name type |
|---|
| 227 | * designation should have a {@link eu.etaxonomy.cdm.model.reference.Reference reference} that is different to the |
|---|
| 228 | * {@link TaxonNameBase#getNomenclaturalReference() nomenclatural reference} of the typified taxon name. |
|---|
| 229 | * |
|---|
| 230 | * @see ReferencedEntityBase#getCitation() |
|---|
| 231 | */ |
|---|
| 232 | // /* (non-Javadoc) |
|---|
| 233 | // * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType() |
|---|
| 234 | // */ |
|---|
| 235 | // public boolean isLectoType() { |
|---|
| 236 | // return lectoType; |
|---|
| 237 | // } |
|---|
| 238 | // |
|---|
| 239 | // /** |
|---|
| 240 | // * @see #isLectoType() |
|---|
| 241 | // */ |
|---|
| 242 | // public void setLectoType(boolean lectoType) { |
|---|
| 243 | // this.lectoType = lectoType; |
|---|
| 244 | // } |
|---|
| 245 | |
|---|
| 246 | //*********************** CLONE ********************************************************/ |
|---|
| 247 | |
|---|
| 248 | /** |
|---|
| 249 | * Clones <i>this</i> name type. This is a shortcut that enables to create |
|---|
| 250 | * a new instance that differs only slightly from <i>this</i> name type by |
|---|
| 251 | * modifying only some of the attributes. |
|---|
| 252 | * |
|---|
| 253 | * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone() |
|---|
| 254 | * @see java.lang.Object#clone() |
|---|
| 255 | */ |
|---|
| 256 | @Override |
|---|
| 257 | public Object clone() { |
|---|
| 258 | NameTypeDesignation result; |
|---|
| 259 | try { |
|---|
| 260 | result = (NameTypeDesignation)super.clone(); |
|---|
| 261 | //no changes to: rejectedType, conservedType, typeName |
|---|
| 262 | return result; |
|---|
| 263 | } catch (CloneNotSupportedException e) { |
|---|
| 264 | logger.warn("Object does not implement cloneable"); |
|---|
| 265 | e.printStackTrace(); |
|---|
| 266 | return null; |
|---|
| 267 | } |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | } |
|---|