references and microreferences for name relations
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / TaxonNameBase.java
index f325990e2859c45f7f74c3ffed4e39192a65847f..035707ebb385047d627a779e3e249ee86d02d486 100644 (file)
@@ -11,8 +11,10 @@ package eu.etaxonomy.cdm.model.name;
 
 import java.lang.reflect.Method;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
+import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
@@ -23,14 +25,12 @@ import javax.persistence.OneToMany;
 import javax.persistence.Transient;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAnyElement;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlIDREF;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 import org.apache.log4j.Logger;
@@ -38,7 +38,9 @@ import org.hibernate.annotations.Cascade;
 import org.hibernate.annotations.CascadeType;
 import org.hibernate.annotations.Index;
 import org.hibernate.annotations.Table;
-import org.hibernate.annotations.Target;
+import org.hibernate.envers.Audited;
+import org.hibernate.search.annotations.Field;
+import org.springframework.util.ReflectionUtils;
 
 import eu.etaxonomy.cdm.model.common.IParsable;
 import eu.etaxonomy.cdm.model.common.IReferencedEntity;
@@ -59,9 +61,9 @@ import eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy;
  * The upmost (abstract) class for scientific taxon names regardless of any
  * particular {@link NomenclaturalCode nomenclature code}. The scientific taxon name does not depend
  * on the use made of it in a publication or a treatment
- * ({@link taxon.TaxonBase taxon concept respectively potential taxon})
- * as an {@link taxon.Taxon "accepted" respectively "correct" (taxon) name}
- * or as a {@link taxon.Synonym synonym}.
+ * ({@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon concept respectively potential taxon})
+ * as an {@link eu.etaxonomy.cdm.model.taxon.Taxon "accepted" respectively "correct" (taxon) name}
+ * or as a {@link eu.etaxonomy.cdm.model.taxon.Synonym synonym}.
  * <P>
  * This class corresponds partially to: <ul>
  * <li> TaxonName according to the TDWG ontology
@@ -79,79 +81,114 @@ import eu.etaxonomy.cdm.strategy.cache.name.INameCacheStrategy;
     "nomenclaturalMicroReference",
     "nomenclaturalReference",
     "rank",
+    "fullTitleCache",
+    "protectedFullTitleCache",
     "homotypicalGroup",
-    "nameTypeDesignations",
-    "specimenTypeDesignations",
+    "typeDesignations",
     "relationsFromThisName",
     "relationsToThisName",
     "status",
-    "descriptions"
-//    "taxonBases"
+    "descriptions",
+    "taxonBases"
 })
 @XmlRootElement(name = "TaxonNameBase")
 @Entity
+@Audited
 @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
-@Table(appliesTo="TaxonNameBase", indexes = { @Index(name = "taxonNameBaseTitleCacheIndex", columnNames = { "persistentTitleCache" }) })
-public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCacheStrategy> extends IdentifiableEntity<TaxonNameBase> implements IReferencedEntity, IParsable, IRelated {
+@Table(appliesTo="TaxonNameBase", indexes = { @Index(name = "taxonNameBaseTitleCacheIndex", columnNames = { "titleCache" }) })
+public abstract class TaxonNameBase<T extends TaxonNameBase<?,?>, S extends INameCacheStrategy> extends IdentifiableEntity<S> implements IReferencedEntity, IParsable, IRelated {
 
-       static Logger logger = Logger.getLogger(TaxonNameBase.class);
-
-       private static Method methodDescriptionSetTaxonName;
+       private static final long serialVersionUID = -4530368639601532116L;
+       private static final Logger logger = Logger.getLogger(TaxonNameBase.class);
 
+       @XmlElement(name = "FullTitleCache")
+       @Column(length=330, name="fullTitleCache")
+       private String fullTitleCache;
+       
+       //if true titleCache will not be automatically generated/updated
+       @XmlElement(name = "ProtectedFullTitleCache")
+       private boolean protectedFullTitleCache;
+       
     @XmlElementWrapper(name = "Descriptions")
     @XmlElement(name = "Description")
+    @OneToMany(mappedBy="taxonName", fetch= FetchType.LAZY) 
+       @Cascade({CascadeType.SAVE_UPDATE})
        private Set<TaxonNameDescription> descriptions = new HashSet<TaxonNameDescription>();
        
     @XmlElement(name = "AppendedPhrase")
+    @Field(index= org.hibernate.search.annotations.Index.TOKENIZED)
        private String appendedPhrase;
        
     @XmlElement(name = "NomenclaturalMicroReference")
+    @Field(index= org.hibernate.search.annotations.Index.TOKENIZED)
        private String nomenclaturalMicroReference;
        
     @XmlAttribute
        private boolean hasProblem = false;
        
+    @XmlAttribute
+    private int problemStarts = -1;
+    
+    @XmlAttribute
+    private int problemEnds = -1;
+    
     @XmlElementWrapper(name = "TypeDesignations")
     @XmlElement(name = "TypeDesignation")
+    @XmlIDREF
+    @XmlSchemaType(name = "IDREF")
+    @ManyToMany(fetch = FetchType.LAZY)
+       //TODO @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN})
+       @Cascade(CascadeType.SAVE_UPDATE)
        private Set<TypeDesignationBase> typeDesignations = new HashSet<TypeDesignationBase>();
 
-    // List homotypical groups here in TaxonomicNames or separately?
-    // FIXME: Stack overflow if listed here.
     @XmlElement(name = "HomotypicalGroup")
     @XmlIDREF
     @XmlSchemaType(name = "IDREF")
-       private HomotypicalGroup homotypicalGroup = new HomotypicalGroup();
+    @ManyToOne(fetch = FetchType.LAZY)
+       @Cascade({CascadeType.SAVE_UPDATE})
+       private HomotypicalGroup homotypicalGroup;
 
     @XmlElementWrapper(name = "RelationsFromThisName")
     @XmlElement(name = "RelationFromThisName")
-    @XmlIDREF
+    @OneToMany(mappedBy="relatedFrom", fetch= FetchType.LAZY)
+       //TODO @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN}) => DELETE_ORPHAN does not work ( org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan": eu.etaxonomy.cdm.model.name.TaxonNameBase.relationsFromThisName)
+       @Cascade(CascadeType.SAVE_UPDATE)
        private Set<NameRelationship> relationsFromThisName = new HashSet<NameRelationship>();
 
     @XmlElementWrapper(name = "RelationsToThisName")
     @XmlElement(name = "RelationToThisName")
     @XmlIDREF
+    @XmlSchemaType(name = "IDREF")
+    @OneToMany(mappedBy="relatedTo", fetch= FetchType.LAZY)
+       //@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN})
+       @Cascade(CascadeType.SAVE_UPDATE)
        private Set<NameRelationship> relationsToThisName = new HashSet<NameRelationship>();
 
-    @XmlElementWrapper(name = "Statuses")
-    @XmlElement(name = "Status")
-    @XmlIDREF
+    @XmlElementWrapper(name = "NomenclaturalStatuses")
+    @XmlElement(name = "NomenclaturalStatus")
+    @OneToMany(fetch= FetchType.LAZY)
+       @Cascade({CascadeType.SAVE_UPDATE})
        private Set<NomenclaturalStatus> status = new HashSet<NomenclaturalStatus>();
 
-    @XmlTransient
-    //@XmlElementWrapper(name = "TaxonBases")
-    //@XmlElement(name = "TaxonBase")
+    @XmlElementWrapper(name = "TaxonBases")
+    @XmlElement(name = "TaxonBase")
+    @XmlIDREF
+    @XmlSchemaType(name = "IDREF")
+    @OneToMany(mappedBy="name", fetch= FetchType.LAZY)
        private Set<TaxonBase> taxonBases = new HashSet<TaxonBase>();
-
+    
     @XmlElement(name = "Rank")
        @XmlIDREF
        @XmlSchemaType(name = "IDREF")
+       @ManyToOne(fetch = FetchType.EAGER)
        private Rank rank;
 
-//  FIXME: This must be an IDREF to the corresponding nomenclatural reference.
-    @XmlAnyElement
-       private INomenclaturalReference nomenclaturalReference;
-
-       static Method methodTaxonBaseSetName;
+       @XmlElement(name = "NomenclaturalReference")
+    @XmlIDREF
+    @XmlSchemaType(name = "IDREF")
+    @ManyToOne(fetch = FetchType.LAZY)
+       @Cascade({CascadeType.SAVE_UPDATE})
+       private ReferenceBase nomenclaturalReference;
        
 // ************* CONSTRUCTORS *************/   
        /** 
@@ -162,16 +199,16 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see #TaxonNameBase(Rank, HomotypicalGroup)
         */
        public TaxonNameBase() {
-               this(null, null);
+               super();
        }
        /** 
         * Class constructor: creates a new taxon name
-        * only containing its {@link common.Rank rank}.
+        * only containing its {@link Rank rank}.
         * 
         * @param  rank  the rank to be assigned to <i>this</i> taxon name
-        * @see    #TaxonNameBase()
-        * @see    #TaxonNameBase(HomotypicalGroup)
-        * @see    #TaxonNameBase(Rank, HomotypicalGroup)
+        * @see                  #TaxonNameBase()
+        * @see                  #TaxonNameBase(HomotypicalGroup)
+        * @see                  #TaxonNameBase(Rank, HomotypicalGroup)
         */
        public TaxonNameBase(Rank rank) {
                this(rank, null);
@@ -183,25 +220,25 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * belonging to this homotypical group.
         * 
         * @param  homotypicalGroup  the homotypical group to which <i>this</i> taxon name belongs
-        * @see    #TaxonNameBase()
-        * @see    #TaxonNameBase(Rank)
-        * @see    #TaxonNameBase(Rank, HomotypicalGroup)
+        * @see                                          #TaxonNameBase()
+        * @see                                          #TaxonNameBase(Rank)
+        * @see                                          #TaxonNameBase(Rank, HomotypicalGroup)
         */
        public TaxonNameBase(HomotypicalGroup homotypicalGroup) {
                this(null, homotypicalGroup);
        }
        /** 
         * Class constructor: creates a new taxon name
-        * only containing its {@link common.Rank rank} and
+        * only containing its {@link Rank rank} and
         * its {@link HomotypicalGroup homotypical group}.
         * The new taxon name will be also added to the set of taxon names
         * belonging to this homotypical group.
         * 
-        * @param  rank  the rank to be assigned to <i>this</i> taxon name
+        * @param  rank                          the rank to be assigned to <i>this</i> taxon name
         * @param  homotypicalGroup  the homotypical group to which <i>this</i> taxon name belongs
-        * @see    #TaxonNameBase()
-        * @see    #TaxonNameBase(Rank)
-        * @see    #TaxonNameBase(HomotypicalGroup)
+        * @see                                          #TaxonNameBase()
+        * @see                                          #TaxonNameBase(Rank)
+        * @see                                          #TaxonNameBase(HomotypicalGroup)
         */
        public TaxonNameBase(Rank rank, HomotypicalGroup homotypicalGroup) {
                super();
@@ -213,11 +250,6 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        }
        
 //********* METHODS **************************************/
-
-       //@Index(name="TaxonNameBaseTitleCacheIndex")
-//     public String getTitleCache(){
-//             return super.getTitleCache();
-//     }
        
        /**
         * Returns the boolean value "false" since the components of <i>this</i> taxon name
@@ -233,7 +265,46 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        @Transient
        public abstract boolean isCodeCompliant();
        
+       public abstract String generateFullTitle();
+
+       @Transient
+       public String getFullTitleCache(){
+               if (protectedFullTitleCache){
+                       return this.fullTitleCache;                     
+               }
+               if (fullTitleCache == null){
+                       this.setFullTitleCache(generateFullTitle(), protectedFullTitleCache);
+               }
+               return fullTitleCache;
+       }
+       
+       @Transient
+       public List<Object> getTaggedName(){
+               return getCacheStrategy().getTaggedName(this);
+       }
+
+    public void setFullTitleCache(String fullTitleCache){
+               setFullTitleCache(fullTitleCache, PROTECTED);
+       }
+       
+       public void setFullTitleCache(String fullTitleCache, boolean protectCache){
+               //TODO truncation of full title cache
+               if (fullTitleCache != null && fullTitleCache.length() > 329){
+                       logger.warn("Truncation of full title cache: " + this.toString() + "/" + fullTitleCache);
+                       fullTitleCache = fullTitleCache.substring(0, 329) + "...";
+               }
+               this.fullTitleCache = fullTitleCache;
+               this.setProtectedFullTitleCache(protectCache);
+       }
+       
+       public boolean isProtectedFullTitleCache() {
+               return protectedFullTitleCache;
+       }
 
+       public void setProtectedFullTitleCache(boolean protectedFullTitleCache) {
+               this.protectedFullTitleCache = protectedFullTitleCache;
+       }
+       
        /** 
         * Returns the set of all {@link NameRelationship name relationships}
         * in which <i>this</i> taxon name is involved. A taxon name can be both source
@@ -252,6 +323,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
                rels.addAll(getRelationsToThisName());
                return rels;
        }
+       
        /**
         * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from <i>this</i> taxon name to another taxon name
         * and adds it both to the set of {@link #getRelationsFromThisName() relations from <i>this</i> taxon name} and
@@ -268,6 +340,11 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered){
                NameRelationship rel = new NameRelationship(toName, this, type, ruleConsidered);
        }
+       
+       public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, ReferenceBase citation, String microCitation, String ruleConsidered){
+               NameRelationship rel = new NameRelationship(toName, this, type, citation, microCitation, ruleConsidered);
+       }
+       
        /**
         * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from another taxon name to <i>this</i> taxon name
         * and adds it both to the set of {@link #getRelationsToThisName() relations to <i>this</i> taxon name} and
@@ -284,6 +361,10 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        public void addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered){
                NameRelationship rel = new NameRelationship(this, fromName, type, ruleConsidered);
        }
+       public void addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, ReferenceBase citation, String microCitation, String ruleConsidered){
+               NameRelationship rel = new NameRelationship(this, fromName, type, citation, microCitation, ruleConsidered);
+       }
+
        /**
         * Adds an existing {@link NameRelationship name relationship} either to the set of
         * {@link #getRelationsToThisName() relations to <i>this</i> taxon name} or to the set of
@@ -313,11 +394,51 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * attributes of the name relationship object will be nullified. 
         *
         * @param  nameRelation  the name relationship which should be deleted from one of both sets
-        * @see    #getNameRelations()
+        * @see                                  #getNameRelations()
         */
        public void removeNameRelationship(NameRelationship nameRelation) {
-               //TODO to be implemented?
-               logger.warn("not yet fully implemented?");
+               
+               TaxonNameBase fromName = nameRelation.getFromName();
+               TaxonNameBase toName = nameRelation.getToName();
+
+               if (nameRelation != null) {
+                       nameRelation.setToName(null);
+                       nameRelation.setFromName(null);
+               }
+               
+               if (fromName != null) {
+                       fromName.removeNameRelationship(nameRelation);
+               }
+               
+               if (toName != null) {
+                       toName.removeNameRelationship(nameRelation);
+               }
+               
+               this.relationsToThisName.remove(nameRelation);
+               this.relationsFromThisName.remove(nameRelation);
+       }
+               
+       public void removeTaxonName(TaxonNameBase taxonName) {
+               Set<NameRelationship> nameRelationships = new HashSet<NameRelationship>();
+//             nameRelationships.addAll(this.getNameRelations());
+               nameRelationships.addAll(this.getRelationsFromThisName());
+               nameRelationships.addAll(this.getRelationsToThisName());
+               for(NameRelationship nameRelationship : nameRelationships) {
+                       // remove name relationship from this side 
+                       if (nameRelationship.getFromName().equals(this) && nameRelationship.getToName().equals(taxonName)) {
+                               this.removeNameRelation(nameRelationship);
+                       }
+               }
+       }
+       
+       public void removeNameRelation(NameRelationship nameRelation) {
+               nameRelation.setToName(null);
+       
+               TaxonNameBase name = nameRelation.getFromName();
+               if (name != null){
+                       nameRelation.setFromName(null);
+                       name.removeNameRelation(nameRelation);
+               }
                this.relationsToThisName.remove(nameRelation);
                this.relationsFromThisName.remove(nameRelation);
        }
@@ -331,7 +452,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see                         #addNameRelationship(NameRelationship)
         * @see                         #getNameRelations()
         * @see                         NameRelationship
-        * @see                         common.RelationshipBase
+        * @see                         eu.etaxonomy.cdm.model.common.RelationshipBase
         */
        public void addRelationship(RelationshipBase relation) {
                if (relation instanceof NameRelationship){
@@ -359,15 +480,10 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see    #getRelationsToThisName()
         * @see    #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
         */
-       @OneToMany(mappedBy="relatedFrom", fetch= FetchType.LAZY)
-       @Cascade({CascadeType.SAVE_UPDATE})
        public Set<NameRelationship> getRelationsFromThisName() {
                return relationsFromThisName;
        }
-       private void setRelationsFromThisName(Set<NameRelationship> relationsFromThisName) {
-               this.relationsFromThisName = relationsFromThisName;
-       }
-       
+
        /** 
         * Returns the set of all {@link NameRelationship name relationships}
         * in which <i>this</i> taxon name is involved as a target.
@@ -376,15 +492,9 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see    #getRelationsFromThisName()
         * @see    #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
         */
-       @OneToMany(mappedBy="relatedTo", fetch= FetchType.LAZY)
-       @Cascade({CascadeType.SAVE_UPDATE})
        public Set<NameRelationship> getRelationsToThisName() {
                return relationsToThisName;
        }
-       private void setRelationsToThisName(Set<NameRelationship> relationsToThisName) {
-               this.relationsToThisName = relationsToThisName;
-       }
-
        
        /** 
         * Returns the set of {@link NomenclaturalStatus nomenclatural status} assigned
@@ -395,17 +505,10 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see     NomenclaturalStatus
         * @see     NomenclaturalStatusType
         */
-       @OneToMany(fetch= FetchType.LAZY)
-       @Cascade({CascadeType.SAVE_UPDATE})
        public Set<NomenclaturalStatus> getStatus() {
                return status;
        }
-       /** 
-        * @see     #getStatus()
-        */
-       protected void setStatus(Set<NomenclaturalStatus> nomStatus) {
-               this.status = nomStatus;
-       }
+
        /** 
         * Adds a new {@link NomenclaturalStatus nomenclatural status}
         * to <i>this</i> taxon name's set of nomenclatural status.
@@ -416,6 +519,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        public void addStatus(NomenclaturalStatus nomStatus) {
                this.status.add(nomStatus);
        }
+       
        /** 
         * Removes one element from the set of nomenclatural status of <i>this</i> taxon name.
         * Type and ruleConsidered attributes of the nomenclatural status object
@@ -432,10 +536,10 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
 
        
        /**
-        * Indicates whether <i>this</i> taxon name is a {@link NameRelationshipType.BASIONYM() basionym}
-        * or a {@link NameRelationshipType.REPLACED_SYNONYM() replaced synonym}
+        * Indicates whether <i>this</i> taxon name is a {@link NameRelationshipType#BASIONYM() basionym}
+        * or a {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonym}
         * of any other taxon name. Returns "true", if a basionym or a replaced 
-        * synonym relationship from <i>this</i> taxon name to another taxon name exists,
+        * synonym {@link NameRelationship relationship} from <i>this</i> taxon name to another taxon name exists,
         * false otherwise (also in case <i>this</i> taxon name is the only one in the
         * homotypical group).
         */
@@ -452,11 +556,11 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        }
        
        /**
-        * Returns the taxon name which is the {@link NameRelationshipType.BASIONYM() basionym} of <i>this</i> taxon name.
+        * Returns the taxon name which is the {@link NameRelationshipType#BASIONYM() basionym} of <i>this</i> taxon name.
         * The basionym of a taxon name is its epithet-bringing synonym.
-        * For instance Pinus abies L. was published by Linnaeus and the botanist
+        * For instance <i>Pinus abies</i> L. was published by Linnaeus and the botanist
         * Karsten transferred later <i>this</i> taxon to the genus Picea. Therefore,
-        * Pinus abies L. is the basionym of the new combination Picea abies (L.) H. Karst.
+        * <i>Pinus abies</i> L. is the basionym of the new combination <i>Picea abies</i> (L.) H. Karst.
         */
        @Transient
        public T getBasionym(){
@@ -465,52 +569,61 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
                return null;
        }
        /**
-        * Assigns another taxon name as {@link NameRelationshipType.BASIONYM() basionym} of <i>this</i> taxon name.
-        * The basionym relationship will be added to <i>this</i> taxon name
+        * Assigns a taxon name as {@link NameRelationshipType#BASIONYM() basionym} of <i>this</i> taxon name.
+        * The basionym {@link NameRelationship relationship} will be added to <i>this</i> taxon name
         * and to the basionym. The basionym cannot have itself a basionym.
-        * The homotypical group of <i>this</i> taxon name will be changed the basionyms homotypical group.
-        * @see  #getBasionym()
-        * @see  #addBasionym(TaxonNameBase, String)
+        * The {@link HomotypicalGroup homotypical groups} of <i>this</i> taxon name and of the basionym
+        * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}.
+        * 
+        * @param  basionym             the taxon name to be set as the basionym of <i>this</i> taxon name
+        * @see                                 #getBasionym()
+        * @see                                 #addBasionym(TaxonNameBase, String)
         */
        public void addBasionym(T basionym){
-               addBasionym(basionym, null);
+               addBasionym(basionym, null, null, null);
        }
        /**
-        * Assigns another taxon name as {@link NameRelationshipType.BASIONYM() basionym} of <i>this</i> taxon name
+        * Assigns a taxon name as {@link NameRelationshipType#BASIONYM() basionym} of <i>this</i> taxon name
         * and keeps the nomenclatural rule considered for it. The basionym
-        * relationship will be added to <i>this</i> taxon name and to the basionym.
-        * The basionym cannot have itself as a basionym.
-        * The homotypical group of <i>this</i> taxon name will be changed the basionyms homotypical group.
-        * @see  #getBasionym()
-        * @see  #setBasionym(TaxonNameBase)
+        * {@link NameRelationship relationship} will be added to <i>this</i> taxon name and to the basionym.
+        * The basionym cannot have itself a basionym.
+        * The {@link HomotypicalGroup homotypical groups} of <i>this</i> taxon name and of the basionym
+        * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}.
+        * 
+        * @param  basionym                     the taxon name to be set as the basionym of <i>this</i> taxon name
+        * @param  ruleConsidered       the string identifying the nomenclatural rule
+        * @see                                         #getBasionym()
+        * @see                                         #addBasionym(TaxonNameBase)
         */
-       public void addBasionym(T basionym, String ruleConsidered){
+       public void addBasionym(T basionym, ReferenceBase citation, String microcitation, String ruleConsidered){
                if (basionym != null){
-                       basionym.addRelationshipToName(this, NameRelationshipType.BASIONYM(), ruleConsidered);
+                       basionym.addRelationshipToName(this, NameRelationshipType.BASIONYM(), citation, microcitation, ruleConsidered);
                }
        }
        
+       /** 
+        * Removes the {@link NameRelationshipType#BASIONYM() basionym} {@link NameRelationship relationship} from the set of
+        * {@link #getRelationsToThisName() name relationships to} <i>this</i> taxon name. The same relationhip will be
+        * removed from the set of {@link #getRelationsFromThisName() name relationships from} the taxon name
+        * previously used as basionym.
+        *
+        * @see   #getBasionym()
+        * @see   #addBasionym(TaxonNameBase)
+        */
        public void removeBasionym(){
                //TODO implement
                logger.warn("not yet implemented");
        }
-
-
-
-       @Transient
-       public abstract S getCacheStrategy();
-       public abstract void setCacheStrategy(S cacheStrategy);
        
        /** 
         * Returns the taxonomic {@link Rank rank} of <i>this</i> taxon name.
         *
         * @see         Rank
         */
-       @ManyToOne
-       //@Cascade({CascadeType.SAVE_UPDATE})
        public Rank getRank(){
                return this.rank;
        }
+       
        /**
         * @see  #getRank()
         */
@@ -519,29 +632,34 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        }
 
        /** 
-        * Returns the {@link reference.INomenclaturalReference nomenclatural reference} of <i>this</i> taxon name.
+        * Returns the {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} of <i>this</i> taxon name.
         * The nomenclatural reference is here meant to be the one publication
         * <i>this</i> taxon name was originally published in while fulfilling the formal
         * requirements as specified by the corresponding {@link NomenclaturalCode nomenclatural code}.
         *
-        * @see         reference.INomenclaturalReference
-        * @see         reference.ReferenceBase
+        * @see         eu.etaxonomy.cdm.model.reference.INomenclaturalReference
+        * @see         eu.etaxonomy.cdm.model.reference.ReferenceBase
         */
-       @ManyToOne
-       @Cascade({CascadeType.SAVE_UPDATE})
-       @Target(ReferenceBase.class)
-       public INomenclaturalReference getNomenclaturalReference(){
+       public ReferenceBase getNomenclaturalReference(){
                return this.nomenclaturalReference;
        }
        /**
-        * Assigns a nomenclatural {@link reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name.
-        * The corresponding {@link reference.ReferenceBase.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
+        * Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to <i>this</i> taxon name.
+        * The corresponding {@link eu.etaxonomy.cdm.model.reference.ReferenceBase.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
         * as it is obviously used for nomenclatural purposes.
         *
+        * @throws IllegalArgumentException if parameter <code>nomenclaturalReference</code> is not assignable from {@link INomenclaturalReference}
         * @see  #getNomenclaturalReference()
         */
-       public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference){
-               this.nomenclaturalReference = nomenclaturalReference;
+       public void setNomenclaturalReference(ReferenceBase nomenclaturalReference){
+               if(nomenclaturalReference != null){
+                       if(!INomenclaturalReference.class.isAssignableFrom(nomenclaturalReference.getClass())){
+                               throw new IllegalArgumentException("Parameter nomenclaturalReference is not assignable from INomenclaturalReference");
+                       }
+                       this.nomenclaturalReference = (ReferenceBase)nomenclaturalReference;
+               } else {
+                       this.nomenclaturalReference = null;
+               }
        }
 
        /** 
@@ -552,6 +670,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        public String getAppendedPhrase(){
                return this.appendedPhrase;
        }
+       
        /**
         * @see  #getAppendedPhrase()
         */
@@ -560,7 +679,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        }
 
        /** 
-        * Returns the details string of the nomenclatural reference assigned
+        * Returns the details string of the {@link #getNomenclaturalReference() nomenclatural reference} assigned
         * to <i>this</i> taxon name. The details describe the exact localisation within
         * the publication used as nomenclature reference. These are mostly
         * (implicitly) pages but can also be figures or tables or any other
@@ -578,38 +697,56 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
                this.nomenclaturalMicroReference = nomenclaturalMicroReference;
        }
 
-       /**
-        * Returns the boolean value of the flag indicating whether the used {@link eu.etaxonomy.cdm.strategy.parser.INonViralNameParser parser} 
-        * method was able to parse the taxon name string successfully (false)
-        * or not (true). The parser itself may also depend on the {@link NomenclaturalCode nomenclatural code}
-        * governing the construction of <i>this</i> taxon name.
-        *  
-        * @return  the boolean value of the hasProblem flag
-        * @see     #getNameCache()
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#getHasProblem()
         */
        public boolean getHasProblem(){
                return this.hasProblem;
        }
-       /**
-        * @see  #getHasProblem()
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#setHasProblem(boolean)
         */
        public void setHasProblem(boolean hasProblem){
                this.hasProblem = hasProblem;
        }
-       /**
-        * Returns exactly the same boolean value as the {@link #getHasProblem() getHasProblem} method.  
-        *  
-        * @see  #getHasProblem()
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#hasProblem()
         */
        public boolean hasProblem(){
                return getHasProblem();
        }
-
        
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#problemStarts()
+        */
+       public int getProblemStarts(){
+               return this.problemStarts;
+       }
        
-//*********************** TYPE DESIGNATION *********************************************//     
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemStarts(int)
+        */
+       public void setProblemStarts(int start) {
+               this.problemStarts = start;
+       }
        
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#problemEnds()
+        */
+       public int getProblemEnds(){
+               return this.problemEnds;
+       }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.model.common.IParsable#setProblemEnds(int)
+        */
+       public void setProblemEnds(int end) {
+               this.problemEnds = end;
+       }
+
+//*********************** TYPE DESIGNATION *********************************************//     
        
        /** 
         * Returns the set of {@link TypeDesignationBase type designations} assigned
@@ -617,46 +754,33 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see     NameTypeDesignation
         * @see     SpecimenTypeDesignation
         */
-       @ManyToMany
-       //TODO @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN})
-       @Cascade(CascadeType.SAVE_UPDATE)
        public Set<TypeDesignationBase> getTypeDesignations() {
                return typeDesignations;
        }
        
        /** 
-        * @see     #getNameTypeDesignations()
-        */
-       private void setTypeDesignations(Set<TypeDesignationBase> typeDesignations) {
-               this.typeDesignations = typeDesignations;
-       }
-       
-       /** 
-        * Removes one element from the set of {@link TypeDesignationBase type designations} assigned to the
-        * {@link HomotypicalGroup homotypical group} to which <i>this</i> taxon name belongs.
-        * The type designation itself will be nullified.
+        * Removes one element from the set of {@link TypeDesignationBase type designations} assigned to
+        * <i>this</i> taxon name. The type designation itself will be nullified.
         *
         * @param  typeDesignation  the type designation which should be deleted
-        * @see     #removeSpecimenTypeDesignation(SpecimenTypeDesignation)
-        * @see     #removeNameTypeDesignation(NameTypeDesignation)
         */
        public void removeTypeDesignation(TypeDesignationBase typeDesignation) {
                logger.warn("not yet fully implemented: nullify the specimen type designation itself?");
                this.typeDesignations.remove(typeDesignation);
        }
        
-       
        /** 
         * Returns the set of {@link SpecimenTypeDesignation specimen type designations} assigned
-        * indirectly to <i>this</i> taxon name through its {@link HomotypicalGroup homotypical group}.
-        * The rank of <i>this</i> taxon name is generally "species" or below.
-        * The specimen type designations include all the specimens on which
-        * the typification of this name is based (and which are common to all
-        * taxon names belonging to the homotypical group) and eventually
-        * the status of these designations.
+        * to <i>this</i> taxon name. The {@link Rank rank} of <i>this</i> taxon name is generally
+        * "species" or below. The specimen type designations include all the
+        * specimens on which the typification of this name is based (which are
+        * exclusively used to typify taxon names belonging to the same
+        * {@link HomotypicalGroup homotypical group} to which <i>this</i> taxon name
+        * belongs) and eventually the status of these designations.
         *
         * @see     SpecimenTypeDesignation
         * @see     NameTypeDesignation
+        * @see     HomotypicalGroup
         */
        @Transient
        public Set<SpecimenTypeDesignation> getSpecimenTypeDesignationsOfHomotypicalGroup() {
@@ -669,7 +793,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * Returns the set of {@link NameTypeDesignation name type designations} assigned
         * to <i>this</i> taxon name the rank of which must be above "species".
         * The name type designations include all the taxon names used to typify
-        * this name and eventually the rejected or conserved status
+        * <i>this</i> taxon name and eventually the rejected or conserved status
         * of these designations.
         *
         * @see     NameTypeDesignation
@@ -688,21 +812,21 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        
        /** 
         * Creates and adds a new {@link NameTypeDesignation name type designation}
-        * to <i>this</i> taxon name's set of name type designations.
+        * to <i>this</i> taxon name's set of type designations.
         *
         * @param  typeSpecies                          the taxon name to be used as type of <i>this</i> taxon name
         * @param  citation                                     the reference for this new designation
         * @param  citationMicroReference       the string with the details (generally pages) within the reference
         * @param  originalNameString           the taxon name string used in the reference to assert this designation
-        * @param  isRejectedType                       the boolean status for rejected
-        * @param  isConservedType                      the boolean status for conserved
-        * @param  isLectoType                          the boolean status for isLectotype
-        * @param  lectoCitation                the reference for the lectotype
-        * @param  lectoMicroCitation   the String for the micro citation of a lectotype
-        * @param  addToAllHomotypicNames       boolean, if true the name type designation is added to all names of the homotypical
-        *                                                              group this taxon name belongs to
+        * @param  isRejectedType                       the boolean status for a rejected name type designation
+        * @param  isConservedType                      the boolean status for a conserved name type designation
+        * @param  isLectoType                          the boolean status for a lectotype name type designation
+        * @param  isNotDesignated                      the boolean status for a name type designation without name type
+        * @param  addToAllHomotypicNames       the boolean indicating whether the name type designation should be
+        *                                                                      added to all taxon names of the homotypical group this taxon name belongs to
         * @see                                                         #getNameTypeDesignations()
-        * @see                                                         #addTypeDesignation(Specimen, TypeDesignationStatus, ReferenceBase, String, String)
+        * @see                                                         NameTypeDesignation
+        * @see                                                         TypeDesignationBase#isNotDesignated()
         */
        public void addNameTypeDesignation(TaxonNameBase typeSpecies, 
                                ReferenceBase citation, 
@@ -713,7 +837,8 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
                                boolean isLectoType, 
                                boolean isNotDesignated, 
                                boolean addToAllHomotypicNames) {
-               NameTypeDesignation nameTypeDesignation = new NameTypeDesignation(typeSpecies, citation, citationMicroReference, originalNameString, isRejectedType, isConservedType, isNotDesignated);
+               NameTypeDesignation nameTypeDesignation = new NameTypeDesignation(typeSpecies, citation, citationMicroReference, originalNameString, isRejectedType, isConservedType, isLectoType, isNotDesignated);
+               nameTypeDesignation.setLectoType(isLectoType);
                addTypeDesignation(nameTypeDesignation, addToAllHomotypicNames);
        }
        
@@ -736,28 +861,31 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
 
        
        /** 
-        * Adds a new {@link SpecimenTypeDesignation specimen type designation}
-        * (using its attributes as parameters) to the set of specimen type designations assigned to the
-        * {@link HomotypicalGroup homotypical group} to which <i>this</i> taxon name belongs.
+        * Creates and adds a new {@link SpecimenTypeDesignation specimen type designation}
+        * to <i>this</i> taxon name's set of type designations.
         *
-        * @param  typeSpecimen                         the specimen to be used as a type for <i>this</i> taxon name's homotypical group
+        * @param  typeSpecimen                         the specimen to be used as a type for <i>this</i> taxon name
         * @param  status                                       the specimen type designation status
         * @param  citation                                     the reference for this new specimen type designation
         * @param  citationMicroReference       the string with the details (generally pages) within the reference
         * @param  originalNameString           the taxon name used in the reference to assert this designation
-        * @param  addToAllHomotypicNames       boolean, if true the name type designation is added to all names of the homotypical
-        *                                                              group this taxon name belongs to
-        * @see                                                         HomotypicalGroup#getSpecimenTypeDesignations()
-        * @see                                                         #addTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
-        * @see                                                         TypeDesignationStatus
+        * @param  isNotDesignated                      the boolean status for a specimen type designation without specimen type
+        * @param  addToAllHomotypicNames       the boolean indicating whether the specimen type designation should be
+        *                                                                      added to all taxon names of the homotypical group the typified
+        *                                                                      taxon name belongs to
+        * @see                                                         #getSpecimenTypeDesignations()
+        * @see                                                         SpecimenTypeDesignationStatus
+        * @see                                                         SpecimenTypeDesignation
+        * @see                                                         TypeDesignationBase#isNotDesignated()
         */
        public void addSpecimenTypeDesignation(Specimen typeSpecimen, 
-                               TypeDesignationStatus status, 
+                               SpecimenTypeDesignationStatus status, 
                                ReferenceBase citation, 
                                String citationMicroReference, 
                                String originalNameString, 
+                               boolean isNotDesignated, 
                                boolean addToAllHomotypicNames) {
-               SpecimenTypeDesignation specimenTypeDesignation = new SpecimenTypeDesignation(typeSpecimen, status, citation, citationMicroReference, originalNameString);
+               SpecimenTypeDesignation specimenTypeDesignation = new SpecimenTypeDesignation(typeSpecimen, status, citation, citationMicroReference, originalNameString, isNotDesignated);
                addTypeDesignation(specimenTypeDesignation, addToAllHomotypicNames);
        }
        
@@ -787,18 +915,20 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        /** 
         * Returns the {@link HomotypicalGroup homotypical group} to which
         * <i>this</i> taxon name belongs. A homotypical group represents all taxon names
-        * that share the same type specimens.
+        * that share the same types.
         *
         * @see         HomotypicalGroup
         */
-       @ManyToOne
-       @Cascade({CascadeType.SAVE_UPDATE})
+       
        public HomotypicalGroup getHomotypicalGroup() {
                return homotypicalGroup;
        }
-       @Deprecated //only for bidirectional and persistence use
-       protected void setHomotypicalGroup(HomotypicalGroup newHomotypicalGroup) {
-               this.homotypicalGroup = newHomotypicalGroup;            
+       
+       /* 
+        * @see #getHomotypicalGroup()
+        */
+       protected void setHomotypicalGroup(HomotypicalGroup homotypicalGroup) {
+               this.homotypicalGroup = homotypicalGroup;
        }
 
 // *************************************************************************//
@@ -815,21 +945,25 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
 
        /** 
         * Returns the complete string containing the
-        * {@link reference.INomenclaturalReference#getNomenclaturalCitation() nomenclatural reference citation}
-        * (including {@link #getNomenclaturalMicroReference() details}) assigned to <i>this</i> taxon name.
+        * {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getNomenclaturalCitation() nomenclatural reference citation}
+        * and the {@link #getNomenclaturalMicroReference() details} assigned to <i>this</i> taxon name.
         * 
         * @return  the string containing the nomenclatural reference of <i>this</i> taxon name
-        * @see         reference.INomenclaturalReference#getNomenclaturalCitation()
+        * @see         eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getNomenclaturalCitation()
         * @see         #getNomenclaturalReference()
         * @see         #getNomenclaturalMicroReference()
         */
        @Transient
+       @Deprecated
        public String getCitationString(){
                logger.warn("getCitationString not yet implemented");
                return null;
        }
 
-       @Transient
+       /** 
+        * Not yet implemented
+        */
+       @Deprecated
        public String[] getProblems(){
                logger.warn("getProblems not yet implemented");
                return null;
@@ -837,11 +971,11 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
 
        /**
         * Returns the string containing the publication date (generally only year)
-        * of the nomenclatural reference for <i>this</i> taxon name, null if there is
+        * of the {@link #getNomenclaturalReference() nomenclatural reference} for <i>this</i> taxon name, null if there is
         * no nomenclatural reference.
         * 
         * @return  the string containing the publication date of <i>this</i> taxon name
-        * @see         reference.INomenclaturalReference#getYear()
+        * @see         eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getYear()
         */
        @Transient
        public String getReferenceYear(){
@@ -853,32 +987,22 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        }
 
        /** 
-        * Returns the set of {@link taxon.TaxonBase taxon bases} that refer to <i>this</i> taxon name.
+        * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon bases} that refer to <i>this</i> taxon name.
         * In this context a taxon base means the use of a taxon name by a reference
-        * either as a taxon ("accepted/correct" name) or as a (junior) synonym.
-        * A taxon name can be used by several distinct references but only once
+        * either as a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon} ("accepted/correct" name) or
+        * as a (junior) {@link eu.etaxonomy.cdm.model.taxon.Synonym synonym}.
+        * A taxon name can be used by several distinct {@link eu.etaxonomy.cdm.model.reference.ReferenceBase references} but only once
         * within a taxonomic treatment (identified by one reference).
         *
-        * @see taxon.TaxonBase
         * @see #getTaxa()
         * @see #getSynonyms()
         */
-       @OneToMany(mappedBy="name", fetch= FetchType.LAZY)
        public Set<TaxonBase> getTaxonBases() {
                return this.taxonBases;
        }
+       
        /** 
-        * @see     #getTaxonBases()
-        */
-       protected void setTaxonBases(Set<TaxonBase> taxonBases) {
-               if (taxonBases == null){
-                       taxonBases = new HashSet<TaxonBase>();
-               }else{
-                       this.taxonBases = taxonBases;
-               }
-       }
-       /** 
-        * Adds a new {@link taxon.TaxonBase taxon base}
+        * Adds a new {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon base}
         * to the set of taxon bases using <i>this</i> taxon name.
         *
         * @param  taxonBase  the taxon base to be added
@@ -887,51 +1011,31 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         */
        //TODO protected
        public void addTaxonBase(TaxonBase taxonBase){
+               Method method = ReflectionUtils.findMethod(TaxonBase.class, "setName", new Class[] {TaxonNameBase.class});
+               ReflectionUtils.makeAccessible(method);
+               ReflectionUtils.invokeMethod(method, taxonBase, new Object[] {this});
                taxonBases.add(taxonBase);
-               initMethods();
-               invokeSetMethod(methodTaxonBaseSetName, taxonBase);
        }
        /** 
-        * Removes one element from the set of {@link taxon.TaxonBase taxon bases} that refer to <i>this</i> taxon name.
+        * Removes one element from the set of {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon bases} that refer to <i>this</i> taxon name.
         *
         * @param  taxonBase    the taxon base which should be removed from the corresponding set
+        * @see                                 #getTaxonBases()
         * @see                                 #addTaxonBase(TaxonBase)
         */
        public void removeTaxonBase(TaxonBase taxonBase){
+               Method method = ReflectionUtils.findMethod(TaxonBase.class, "setName", new Class[] {TaxonNameBase.class});
+               ReflectionUtils.makeAccessible(method);
+               ReflectionUtils.invokeMethod(method, taxonBase, new Object[] {null});
                taxonBases.remove(taxonBase);
-               initMethods();
-               invokeSetMethodWithNull(methodTaxonBaseSetName, taxonBase);
-       }
-
-       private void initMethods(){
-               if (methodTaxonBaseSetName == null){
-                       try {
-                               methodTaxonBaseSetName = TaxonBase.class.getDeclaredMethod("setName", TaxonNameBase.class);
-                               methodTaxonBaseSetName.setAccessible(true);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               //TODO handle exception
-                       }
-               }
-               if (methodDescriptionSetTaxonName == null){
-                       try {
-                               methodDescriptionSetTaxonName = TaxonNameDescription.class.getDeclaredMethod("setTaxonName", TaxonNameBase.class);
-                               methodDescriptionSetTaxonName.setAccessible(true);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               //TODO handle exception
-                       }
-               }
        }
        
-       
-       
        /**
-        * Returns the set of {@link taxon.Taxon taxa} ("accepted/correct" names according to any
+        * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.Taxon taxa} ("accepted/correct" names according to any
         * reference) that are based on <i>this</i> taxon name. This set is a subset of
         * the set returned by getTaxonBases(). 
         * 
-        * @see taxon.Taxon
+        * @see eu.etaxonomy.cdm.model.taxon.Taxon
         * @see #getTaxonBases()
         * @see #getSynonyms()
         */
@@ -947,11 +1051,11 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
        }
        
        /**
-        * Returns the set of {@link taxon.Synonym (junior) synonyms} (according to any
+        * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.Synonym (junior) synonyms} (according to any
         * reference) that are based on <i>this</i> taxon name. This set is a subset of
         * the set returned by getTaxonBases(). 
         * 
-        * @see taxon.Synonym
+        * @see eu.etaxonomy.cdm.model.taxon.Synonym
         * @see #getTaxonBases()
         * @see #getTaxa()
         */
@@ -970,30 +1074,23 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
 // *********** DESCRIPTIONS *************************************      
 
        /**
-        * Returns the set of {@link description.TaxonNameDescription taxon name descriptions} assigned
+        * Returns the set of {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name descriptions} assigned
         * to <i>this</i> taxon name. A taxon name description is a piece of information
         * concerning the taxon name like for instance the content of its first
         * publication (protolog) or a picture of this publication.
         * 
         * @see #addDescription(TaxonNameDescription)
         * @see #removeDescription(TaxonNameDescription)
-        * @see description.TaxonNameDescription
+        * @see eu.etaxonomy.cdm.model.description.TaxonNameDescription
         */
-       @OneToMany(mappedBy="taxonName", fetch= FetchType.LAZY) 
-       @Cascade({CascadeType.SAVE_UPDATE})
        public Set<TaxonNameDescription> getDescriptions() {
                return descriptions;
        }
-       /**
-        * @see #getDescriptions()
-        */
-       protected void setDescriptions(Set<TaxonNameDescription> descriptions) {
-               this.descriptions = descriptions;
-       }
+
        /** 
-        * Adds a new {@link description.TaxonNameDescription taxon name description}
+        * Adds a new {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name description}
         * to the set of taxon name descriptions assigned to <i>this</i> taxon name. The
-        * content of the {@link description.TaxonNameDescription#getTaxonName() taxonName attribute} of the
+        * content of the {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() taxonName attribute} of the
         * taxon name description itself will be replaced with <i>this</i> taxon name.
         *
         * @param  description  the taxon name description to be added
@@ -1001,31 +1098,28 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see                                 #removeDescription(TaxonNameDescription)
         */
        public void addDescription(TaxonNameDescription description) {
-               initMethods();
-               this.invokeSetMethod(methodDescriptionSetTaxonName, description);
+               java.lang.reflect.Field field = ReflectionUtils.findField(TaxonNameDescription.class, "taxonName", TaxonNameBase.class);
+               ReflectionUtils.makeAccessible(field);
+               ReflectionUtils.setField(field, description, this);
                descriptions.add(description);
        }
        /** 
-        * Removes one element from the set of {@link description.TaxonNameDescription taxon name descriptions} assigned
-        * to <i>this</i> taxon name. The content of the {@link description.TaxonNameDescription#getTaxonName() taxonName attribute}
+        * Removes one element from the set of {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name descriptions} assigned
+        * to <i>this</i> taxon name. The content of the {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() taxonName attribute}
         * of the description itself will be set to "null".
         *
         * @param  description  the taxon name description which should be removed
         * @see                         #getDescriptions()
         * @see                         #addDescription(TaxonNameDescription)
-        * @see                                 description.TaxonNameDescription#getTaxonName()
+        * @see                                 eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName()
         */
        public void removeDescription(TaxonNameDescription description) {
-               initMethods();
-               this.invokeSetMethod(methodDescriptionSetTaxonName, null);
+               java.lang.reflect.Field field = ReflectionUtils.findField(TaxonNameDescription.class, "taxonName", TaxonNameBase.class);
+               ReflectionUtils.makeAccessible(field);
+               ReflectionUtils.setField(field, description, null);
                descriptions.remove(description);
        }
        
-       
-       
-       
-       
-       
 // ***********
        /**
         * Returns the boolean value indicating whether a given taxon name belongs
@@ -1037,6 +1131,7 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @return                         the boolean value of the check
         * @see                            HomotypicalGroup
         */
+       @Transient
        public boolean isHomotypic(TaxonNameBase homoTypicName) {
                if (homoTypicName == null) {
                        return false;
@@ -1051,8 +1146,6 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
                return false;
        }
        
-       
-       
 //*********  Rank comparison shortcuts   ********************//
        /**
         * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of <i>this</i>
@@ -1158,7 +1251,6 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * @see         #isCodeCompliant()
         * @see         #getHasProblem()
         */
-       @Transient
        abstract public NomenclaturalCode getNomenclaturalCode();
        /* (non-Javadoc)
         * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
@@ -1167,19 +1259,15 @@ public abstract class TaxonNameBase<T extends TaxonNameBase, S extends INameCach
         * Generates and returns the string with the scientific name of <i>this</i>
         * taxon name (only non viral taxon names can be generated from their
         * components). This string may be stored in the inherited
-        * {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.
+        * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} attribute.
         * This method overrides the generic and inherited
-        * IdentifiableEntity#generateTitle() method.
+        * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() method} from
+        * {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity IdentifiableEntity}.
         *
         * @return  the string with the composed name of this non viral taxon name with authorship (and maybe year)
-        * @see         common.IdentifiableEntity#generateTitle()
-        * @see         common.IdentifiableEntity#getTitleCache()
+        * @see         eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
+        * @see         eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
         */
-       @Override
-       public String generateTitle() {
-               // TODO Auto-generated method stub
-               logger.warn("not yet implemented");
-               return null;
-       }
-       
-}
\ No newline at end of file
+//     @Override
+//     public abstract String generateTitle();
+}