(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / agent / Team.java
index 4d0838e85dcfcb0e4311ae1a5347c99f0f98c0ae..b561989c0bf2d7d44a12f748d633e888360c0283 100644 (file)
@@ -10,6 +10,8 @@
 package eu.etaxonomy.cdm.model.agent;
 
 import org.apache.log4j.Logger;
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
 
 import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;
 
@@ -20,12 +22,15 @@ import javax.xml.bind.annotation.XmlAccessType;
 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;
 
 /**
  * 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 common.IdentifiableEntity#getTitleCache() titleCache} is to be used.
+ * 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)
@@ -46,6 +51,7 @@ import javax.xml.bind.annotation.XmlType;
        "protectedNomenclaturalTitleCache",
     "teamMembers"
 })
+@XmlRootElement
 @Entity
 public class Team extends TeamOrPersonBase {
        
@@ -57,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();
@@ -84,6 +90,7 @@ public class Team extends TeamOrPersonBase {
         * A person may be a member of several distinct teams. 
         */
        @ManyToMany
+       @Cascade({CascadeType.SAVE_UPDATE})
        public List<Person> getTeamMembers(){
                return this.teamMembers;
        }
@@ -141,9 +148,9 @@ public class Team extends TeamOrPersonBase {
         * 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 <i>this</i> team
         */