2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.model
.agent
;
13 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
14 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.hibernate
.annotations
.Cascade
;
17 import org
.hibernate
.annotations
.CascadeType
;
19 import javax
.persistence
.*;
20 import javax
.xml
.bind
.annotation
.XmlAccessType
;
21 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
22 import javax
.xml
.bind
.annotation
.XmlElement
;
23 import javax
.xml
.bind
.annotation
.XmlIDREF
;
24 import javax
.xml
.bind
.annotation
.XmlRootElement
;
25 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
26 import javax
.xml
.bind
.annotation
.XmlType
;
27 import javax
.xml
.bind
.annotation
.adapters
.XmlJavaTypeAdapter
;
30 * Allows to hold one {@link Institution institution} to which a {@link Person person} is affiliated.
31 * It includes {@link common.TimePeriod time period} of membership and role of the person
32 * in this institution. In case one person belongs to several institutions
33 * the corresponding number of instances of InstitutionalMembership
38 * @created 08-Nov-2007 13:06:30
40 @XmlAccessorType(XmlAccessType
.FIELD
)
41 @XmlType(name
= "", propOrder
= {
48 @XmlRootElement(name
= "InstitutionalMembership")
50 public class InstitutionalMembership
extends VersionableEntity
{
52 static Logger logger
= Logger
.getLogger(InstitutionalMembership
.class);
54 /*Time period a person belonged to the institution*/
55 @XmlElement(name
= "Period")
56 //@XmlJavaTypeAdapter(IntervalAdapter.class)
57 private TimePeriod period
;
59 //Department of the institution this person was working in
60 @XmlElement(name
= "Department")
61 private String department
;
63 //Role this person had in the institution
64 @XmlElement(name
= "Role")
67 //current institute the person belongs to
68 @XmlElement(name
= "Institution", required
= true)
70 @XmlSchemaType(name
= "IDREF")
71 private Institution institute
;
73 @XmlElement(name
= "Person", required
= true)
75 @XmlSchemaType(name
= "IDREF")
76 private Person person
;
78 public static InstitutionalMembership
NewInstance() {
79 InstitutionalMembership mship
= new InstitutionalMembership();
83 public InstitutionalMembership() {
88 * Class constructor using an {@link Institution institution}, a {@link Person person}, a {@link common.TimePeriod time period},
89 * a department name string and a role string.
91 * @param institute the institution in which the person is a member
92 * @param person the person who is a member of the institution
93 * @param period the time period during which the person belonged
95 * @param department the name string of the department (within the institution)
96 * this person is working in
97 * @param role the string which identifies the role played by the person
98 * in the institution (or in the department)
102 public InstitutionalMembership(Institution institute
, Person person
, TimePeriod period
, String department
,
105 this.period
= period
;
106 this.department
= department
;
108 this.institute
= institute
;
109 this.person
= person
;
113 * Returns the {@link Person person} involved in this institutional membership.
115 * @see Person#institutionalMemberships
116 * @see Person#addInstitutionalMembership(Institution, TimePeriod, String, String)
118 public Person
getPerson() {
122 * Assigns a new {@link Person person} (replacing the actual one) to this institutional membership.
123 * This method also updates both sets of institutions
124 * the two persons (the new one and the substituted one) belong to.
126 * @param newPerson the new person to be included in this institutional membership
128 * @see Person#removeInstitutionalMembership(InstitutionalMembership)
130 protected void setPerson(Person newPerson
) {
131 this.person
= newPerson
;
136 * Returns the {@link Institution institution} corresponding to this institutional membership.
138 @Cascade({CascadeType
.SAVE_UPDATE
})
139 public Institution
getInstitute(){
140 return this.institute
;
143 * Assigns an new institution (replacing the actual one)
144 * to this institutional membership.
146 * @param newInstitute the new institution
147 * @see #getInstitute()
149 public void setInstitute(Institution newInstitute
){
150 this.institute
= newInstitute
;
154 * Returns the {@link common.TimePeriod time period} during which
155 * the {@link Person person} involved in this institutional membership belonged
156 * to the {@link Institution institution} also involved in it.
158 public TimePeriod
getPeriod(){
165 public void setPeriod(TimePeriod period
){
166 this.period
= period
;
170 * Returns the string representing the name of the department (within
171 * the {@link Institution institution} involved in this institutional membership) to which
172 * the {@link Person person} belongs.
174 public String
getDepartment(){
175 return this.department
;
179 * @see #getDepartment()
181 public void setDepartment(String department
){
182 this.department
= department
;
186 * Returns the string representing the role played by the {@link Person person} within
187 * the {@link Institution institution} (or within the department) involved
188 * in this institutional membership.
190 public String
getRole(){
197 public void setRole(String role
){