(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameTypeDesignation.java
index 32f2504f90f1d8a5979a773899cb9dfb0363a156..043aa4070fef6fef8d48fe726e9febc3b49bcb0c 100644 (file)
@@ -16,17 +16,28 @@ import eu.etaxonomy.cdm.model.reference.ReferenceBase;
 import org.apache.log4j.Logger;
 import org.hibernate.annotations.Cascade;
 import org.hibernate.annotations.CascadeType;
-
-import java.util.*;
 import javax.persistence.*;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
 
 /**
- * {only for typified names which have a rank above "species", in this case the
- * type has to be a "species" name}
+ * 
+ * Only taxon names which have a rank above "species aggregate" are typified by other
+ * taxon names of lower rank. A type of a name of a genus or of any
+ * subdivision of a genus can only be the name of a species. A type of a name
+ * of a family or of any subdivision of a family is the name of a genus
+ * (or resolving it: a name of a species typifying this genus).
+ * Moreover the mentioned taxon name type may be rejected or conserved.
+ * Depending on the date of publication, the same designation could have the
+ * rejected status according to one reference and later have the conserved
+ * status according to another reference.
+ * 
  * @author m.doering
  * @version 1.0
  * @created 08-Nov-2007 13:06:38
  */
+@XmlType(name="NameTypeDesignation")
 @Entity
 public class NameTypeDesignation extends ReferencedEntityBase {
        static Logger logger = Logger.getLogger(NameTypeDesignation.class);
@@ -34,25 +45,35 @@ public class NameTypeDesignation extends ReferencedEntityBase {
        private boolean isConservedType;
        private TaxonNameBase typeSpecies;
        private TaxonNameBase typifiedName;
+       
+       /**
+        * Default Constructor
+        */
+       private NameTypeDesignation() {
+               super();
+       }
 
-       public NameTypeDesignation(TaxonNameBase typifiedName, TaxonNameBase typeSpecies, ReferenceBase citation, String citationMicroReference,
+       protected NameTypeDesignation(TaxonNameBase typifiedName, TaxonNameBase typeSpecies, ReferenceBase citation, String citationMicroReference,
                        String originalNameString, boolean isRejectedType, boolean isConservedType) {
                super(citation, citationMicroReference, originalNameString);
                this.setTypeSpecies(typeSpecies);
                this.setTypifiedName(typifiedName);
+               // the typified name has to be part of the same homotypical group as the type species
+               typifiedName.setHomotypicalGroup(typeSpecies.getHomotypicalGroup());
                this.isRejectedType = isRejectedType;
                this.isConservedType = isConservedType;
        }
-       
-       
+               
        @Cascade({CascadeType.SAVE_UPDATE})
        public TaxonNameBase getTypifiedName() {
                return typifiedName;
        }
        private void setTypifiedName(TaxonNameBase typifiedName) {
                this.typifiedName = typifiedName;
-               typifiedName.nameTypeDesignations.add(this);
+               if (typifiedName != null){
+                       typifiedName.getNameTypeDesignations().add(this);
                }
+       }
 
 
        @ManyToOne