merging branches/cdmlib/2.2 [7345:7377] to trunk
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameTypeDesignation.java
index c66bb042e04459e5ba401643799afde4c2a671c7..df57551d996c0a4951f127c4c7d52aa46e3be6e0 100644 (file)
@@ -26,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;
 
 /**
@@ -79,6 +78,11 @@ implements ITypeDesignation {
        @ManyToOne(fetch = FetchType.LAZY)
        @Cascade(CascadeType.SAVE_UPDATE)
        private TaxonNameBase typeName;
+
+       
+       public static NameTypeDesignation NewInstance() {
+               return new NameTypeDesignation();
+       }
        
        
        // ************* CONSTRUCTORS *************/    
@@ -90,6 +94,7 @@ implements ITypeDesignation {
        protected NameTypeDesignation() {
        }
 
+
        /**
         * Class constructor: creates a new name type designation instance
         * (including its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and eventually
@@ -137,13 +142,19 @@ implements ITypeDesignation {
         * @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 lectoType,*/ boolean isNotDesignated) {
-               super(citation, citationMicroReference, originalNameString, isNotDesignated);
-               this.setTypeName(typeName);
+       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;
-//             this.lectoType = lectoType;
        }
                
        //********* METHODS **************************************/
@@ -160,7 +171,7 @@ implements ITypeDesignation {
        /**
         * @see  #getTypeName()
         */
-       private void setTypeName(TaxonNameBase typeName){
+       public void setTypeName(TaxonNameBase typeName){
                this.typeName = typeName;
        }
 
@@ -200,6 +211,9 @@ implements ITypeDesignation {
 
        @Transient
        public boolean isLectoType() {
+               if (getTypeStatus() == null) {
+                       return false;
+               }
                return getTypeStatus().isLectotype();
        }