(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / agent / Team.java
index a3fc4ab43f884cfe53abc13c2965c5cc12434e03..b561989c0bf2d7d44a12f748d633e888360c0283 100644 (file)
 package eu.etaxonomy.cdm.model.agent;
 
 import org.apache.log4j.Logger;
-import eu.etaxonomy.cdm.strategy.cache.TeamDefaultCacheStrategy;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
+
+import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;
 
 import java.util.*;
 
@@ -20,16 +23,24 @@ import javax.xml.bind.annotation.XmlAccessorType;
 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.XmlType;
 
 /**
- * A team exists for itself or is built with the list of (distinct) persons
- * who belong to it.
- * In the first case the inherited attribute {@link common.IdentifiableEntity#getTitleCache() titleCache} is to be used.
+ * This class represents teams of {@link Person persons}. A team exists either for itself
+ * or is built with the list of (distinct) persons who belong to it.
+ * In the first case the inherited attribute {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache} is to be used.
  * In the second case at least all abbreviated names
  * (the inherited attributes {@link TeamOrPersonBase#getNomenclaturalTitle() nomenclaturalTitle})
  * or all full names (the strings returned by Person.generateTitle)
  * of the persons must exist. A team is a {@link java.util.List list} of persons.
+ * <P>
+ * This class corresponds to: <ul>
+ * <li> Team according to the TDWG ontology
+ * <li> AgentNames (partially) according to the TCS
+ * <li> MicroAgent (partially) according to the ABCD schema
+ * </ul>
  * 
  * @author m.doering
  * @version 1.0
@@ -40,6 +51,7 @@ import javax.xml.bind.annotation.XmlType;
        "protectedNomenclaturalTitleCache",
     "teamMembers"
 })
+@XmlRootElement
 @Entity
 public class Team extends TeamOrPersonBase {
        
@@ -51,14 +63,14 @@ public class Team extends TeamOrPersonBase {
        //An abreviated name for the team (e. g. in case of nomenclatural authorteams). A non abreviated name for the team (e. g.
        //in case of some bibliographical references)
     @XmlElementWrapper(name = "TeamMembers")
-    @XmlElement(name = "Member")
-    //@XmlIDREF
+    @XmlElement(name = "TeamMember")
+    @XmlIDREF
+    @XmlSchemaType(name = "IDREF")
        private List<Person> teamMembers = new ArrayList<Person>();
        
        
        /** 
-        * Creates a new team without any concrete {@link Person members}.
-        * This method calls the {@link #Team()constructor}.
+        * Creates a new team instance without any concrete {@link Person members}.
         */
        static public Team NewInstance(){
                return new Team();
@@ -66,7 +78,7 @@ public class Team extends TeamOrPersonBase {
        
        /** 
         * Class constructor (including the cache strategy defined in
-        * {@link eu.etaxonomy.cdm.strategy.cache.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}).
+        * {@link eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}).
         */
        public Team() {
                super();
@@ -74,10 +86,11 @@ public class Team extends TeamOrPersonBase {
        }
 
        /** 
-        * Returns the list of {@link Person members} belonging to this team. 
+        * Returns the list of {@link Person members} belonging to <i>this</i> team. 
         * A person may be a member of several distinct teams. 
         */
        @ManyToMany
+       @Cascade({CascadeType.SAVE_UPDATE})
        public List<Person> getTeamMembers(){
                return this.teamMembers;
        }
@@ -89,7 +102,7 @@ public class Team extends TeamOrPersonBase {
        }
        
        /** 
-        * Adds a new {@link Person person} to this team at the end of the members' list. 
+        * Adds a new {@link Person person} to <i>this</i> team at the end of the members' list. 
         *
         * @param  person  the person who should be added to the other team members
         * @see            #getTeamMembers()
@@ -100,7 +113,7 @@ public class Team extends TeamOrPersonBase {
        }
        
        /** 
-        * Adds a new {@link Person person} to this team
+        * Adds a new {@link Person person} to <i>this</i> team
         * at the given index place of the members' list. If the person is already
         * a member of the list he will be moved to the given index place. 
         * The index must be a positive integer. If the index is bigger than
@@ -122,9 +135,9 @@ public class Team extends TeamOrPersonBase {
        }
        
        /** 
-        * Removes one person from the list of members of this team.
+        * Removes one person from the list of members of <i>this</i> team.
         *
-        * @param  person  the person who should be deleted from this team
+        * @param  person  the person who should be deleted from <i>this</i> team
         * @see            #getTeamMembers()
         */
        public void removeTeamMember(Person person){
@@ -132,14 +145,14 @@ public class Team extends TeamOrPersonBase {
        }
 
        /**
-        * Generates an identification string for this team according to the strategy
-        * defined in {@link eu.etaxonomy.cdm.strategy.cache.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}. This string is built
+        * Generates an identification string for <i>this</i> team according to the strategy
+        * defined in {@link eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}. This string is built
         * with the full names of all persons belonging to its (ordered) members' list.
-        * This method overrides {@link common.IdentifiableEntity#generateTitle() generateTitle}.
-        * The result might be kept as {@link common.IdentifiableEntity#setTitleCache(String) titleCache} if the
-        * flag {@link common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
+        * This method overrides {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() generateTitle}.
+        * The result might be kept as {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#setTitleCache(String) titleCache} if the
+        * flag {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
         * 
-        * @return  a string which identifies this team
+        * @return  a string which identifies <i>this</i> team
         */
        @Override
        public String generateTitle() {
@@ -148,18 +161,18 @@ public class Team extends TeamOrPersonBase {
        
        
        /**
-        * Generates or returns the {@link TeamOrPersonBase#getnomenclaturalTitle() nomenclatural identification} string for this team.
+        * Generates or returns the {@link TeamOrPersonBase#getnomenclaturalTitle() nomenclatural identification} string for <i>this</i> team.
         * This method overrides {@link TeamOrPersonBase#getNomenclaturalTitle() getNomenclaturalTitle}.
         * This string is built with the {@link TeamOrPersonBase#getNomenclaturalTitle() abbreviated names}
         * of all persons belonging to its (ordered) members' list if the flag
         * {@link #protectedNomenclaturalTitleCache protectedNomenclaturalTitleCache} is not set.
         * Otherwise this method returns the present nomenclatural abbreviation.
         * In case the string is generated the cache strategy used is defined in
-        * {@link eu.etaxonomy.cdm.strategy.cache.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}.
+        * {@link eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}.
         * The result might be kept as nomenclatural abbreviation
         * by using the {@link #setNomenclaturalTitle(String) setNomenclaturalTitle} method.
         * 
-        * @return  a string which identifies this team for nomenclature
+        * @return  a string which identifies <i>this</i> team for nomenclature
         */
        @Override
        @Transient
@@ -174,7 +187,7 @@ public class Team extends TeamOrPersonBase {
        }
        
        /**
-        * Assigns a {@link TeamOrPersonBase#nomenclaturalTitle nomenclatural identification} string to this team
+        * Assigns a {@link TeamOrPersonBase#nomenclaturalTitle nomenclatural identification} string to <i>this</i> team
         * and protects it from overwriting.
         * This method overrides {@link TeamOrPersonBase#setNomenclaturalTitle(String) setNomenclaturalTitle}.
         * 
@@ -188,7 +201,7 @@ public class Team extends TeamOrPersonBase {
        }
 
        /**
-        * Assigns a {@link TeamOrPersonBase#nomenclaturalTitle nomenclatural identification} string to this team
+        * Assigns a {@link TeamOrPersonBase#nomenclaturalTitle nomenclatural identification} string to <i>this</i> team
         * and a protection flag status to this string.
         * 
         * @see  #getNomenclaturalTitle()