merging branches/cdmlib/2.2 [7345:7377] to trunk
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameTypeDesignation.java
index 4129a246bfee64637dc278d411e6694e3742c734..df57551d996c0a4951f127c4c7d52aa46e3be6e0 100644 (file)
@@ -12,6 +12,7 @@ package eu.etaxonomy.cdm.model.name;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.ManyToOne;
+import javax.persistence.Transient;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -25,7 +26,6 @@ import org.hibernate.annotations.Cascade;
 import org.hibernate.annotations.CascadeType;
 import org.hibernate.envers.Audited;
 
-import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
 
 /**
@@ -53,14 +53,15 @@ import eu.etaxonomy.cdm.model.reference.ReferenceBase;
 @XmlType(name = "NameTypeDesignation", propOrder = {
     "rejectedType",
     "conservedType",
-    "lectoType",
+    /*"lectoType",*/
     "typeName"
 })
 @Entity
 @Audited
-public class NameTypeDesignation extends TypeDesignationBase implements ITypeDesignation {
+public class NameTypeDesignation extends TypeDesignationBase<NameTypeDesignationStatus> 
+implements ITypeDesignation {
        
-       static Logger logger = Logger.getLogger(NameTypeDesignation.class);
+       final static Logger logger = Logger.getLogger(NameTypeDesignation.class);
        
        @XmlElement(name = "IsRejectedType")
        private boolean rejectedType;
@@ -68,8 +69,8 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
        @XmlElement(name = "IsConservedType")
        private boolean conservedType;
        
-       @XmlElement(name = "IsLectoType")
-       private boolean lectoType;
+//     @XmlElement(name = "IsLectoType")
+//     private boolean lectoType;
        
        @XmlElement(name = "TypeName")
        @XmlIDREF
@@ -77,12 +78,11 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
        @ManyToOne(fetch = FetchType.LAZY)
        @Cascade(CascadeType.SAVE_UPDATE)
        private TaxonNameBase typeName;
+
        
-//     @XmlElement(name = "HomotypicalGroup")
-//     @XmlIDREF
-//     @XmlSchemaType(name = "IDREF")
-//     private HomotypicalGroup homotypicalGroup;
-       
+       public static NameTypeDesignation NewInstance() {
+               return new NameTypeDesignation();
+       }
        
        
        // ************* CONSTRUCTORS *************/    
@@ -92,9 +92,9 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
         * @see #NameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean, boolean)
         */
        protected NameTypeDesignation() {
-               super();
        }
 
+
        /**
         * Class constructor: creates a new name type designation instance
         * (including its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and eventually
@@ -115,10 +115,44 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
         * @see                                                 TypeDesignationBase#isNotDesignated()
         * @see                                                 TaxonNameBase#addNameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean, boolean, boolean, boolean)
         */
-       protected NameTypeDesignation(TaxonNameBase typeName, ReferenceBase citation, String citationMicroReference,
-                       String originalNameString, boolean rejectedType, boolean conservedType, boolean isNotDesignated) {
-               super(citation, citationMicroReference, originalNameString, isNotDesignated);
+       protected NameTypeDesignation(TaxonNameBase typeName, NameTypeDesignationStatus status,
+                       ReferenceBase citation, String citationMicroReference, String originalNameString) {
+               super(citation, citationMicroReference, originalNameString);
                this.setTypeName(typeName);
+               this.setTypeStatus(status);
+       }
+
+       /**
+        * Class constructor: creates a new name type designation instance
+        * (including its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and eventually
+        * the taxon name string originally used by this reference when establishing
+        * the former designation).
+        * 
+        * @param typeName                              the taxon name used as a type 
+        * @param citation                              the reference source for the new designation
+        * @param citationMicroReference        the string with the details describing the exact localisation within the reference
+        * @param originalNameString    the taxon name string used originally in the reference source for the new designation
+        * @param isRejectedType                the boolean flag indicating whether the competent authorities rejected
+        *                                                              <i>this</i> name type designation
+        * @param isConservedType               the boolean flag indicating whether the competent authorities conserved
+        *                                                              <i>this</i> name type designation
+        * @param isNotDesignated               the boolean flag indicating whether there is no name type at all for 
+        *                                                              <i>this</i> name type designation
+        * @see                                                 #NameTypeDesignation()
+        * @see                                                 TypeDesignationBase#isNotDesignated()
+        * @see                                                 TaxonNameBase#addNameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean, boolean, boolean, boolean)
+        */
+       protected NameTypeDesignation(  TaxonNameBase typeName, 
+                                                                       ReferenceBase citation, 
+                                                                       String citationMicroReference,
+                                                                       String originalNameString, 
+                                                                       NameTypeDesignationStatus status, 
+                                                                       boolean rejectedType, 
+                                                                       boolean conservedType, 
+                                                                       boolean isNotDesignated
+                                                               ) {
+               this(typeName, status, citation, citationMicroReference, originalNameString);
+               this.setNotDesignated(isNotDesignated);
                this.rejectedType = rejectedType;
                this.conservedType = conservedType;
        }
@@ -137,7 +171,7 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
        /**
         * @see  #getTypeName()
         */
-       private void setTypeName(TaxonNameBase typeName){
+       public void setTypeName(TaxonNameBase typeName){
                this.typeName = typeName;
        }
 
@@ -175,6 +209,14 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
                this.conservedType = conservedType;
        }
 
+       @Transient
+       public boolean isLectoType() {
+               if (getTypeStatus() == null) {
+                       return false;
+               }
+               return getTypeStatus().isLectotype();
+       }
+       
        /** 
         * Returns the boolean value "true" if the use of the species {@link TaxonNameBase taxon name}
         * as the type for <i>this</i> taxon name type designation was posterior to the
@@ -184,17 +226,17 @@ public class NameTypeDesignation extends TypeDesignationBase implements ITypeDes
         *  
         * @see   ReferencedEntityBase#getCitation()
         */
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
-        */
-       public boolean isLectoType() {
-               return lectoType;
-       }
-
-       /**
-        * @see   #isLectoType()
-        */
-       public void setLectoType(boolean lectoType) {
-               this.lectoType = lectoType;
-       }
+//     /* (non-Javadoc)
+//      * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
+//      */
+//     public boolean isLectoType() {
+//             return lectoType;
+//     }
+//
+//     /**
+//      * @see   #isLectoType()
+//      */
+//     public void setLectoType(boolean lectoType) {
+//             this.lectoType = lectoType;
+//     }
 }
\ No newline at end of file