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 javax
.persistence
.Entity
;
14 import javax
.persistence
.FetchType
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.xml
.bind
.annotation
.XmlAccessType
;
17 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
18 import javax
.xml
.bind
.annotation
.XmlElement
;
19 import javax
.xml
.bind
.annotation
.XmlIDREF
;
20 import javax
.xml
.bind
.annotation
.XmlRootElement
;
21 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
22 import javax
.xml
.bind
.annotation
.XmlType
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.hibernate
.annotations
.Cascade
;
26 import org
.hibernate
.annotations
.CascadeType
;
27 import org
.hibernate
.envers
.Audited
;
29 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
30 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
33 * This class allows to hold one {@link Institution institution} to which a {@link Person person}
34 * is affiliated. It includes {@link eu.etaxonomy.cdm.model.common.TimePeriod time period} of membership and role of
35 * the person in this institution. In case one person belongs to several
36 * institutions a corresponding number of instances of InstitutionalMembership
41 * @created 08-Nov-2007 13:06:30
43 @XmlAccessorType(XmlAccessType
.FIELD
)
44 @XmlType(name
= "InstitutionalMembership", propOrder
= {
51 @XmlRootElement(name
= "InstitutionalMembership")
54 public class InstitutionalMembership
extends VersionableEntity
{
55 private static final long serialVersionUID
= -800814712134999042L;
56 public static final Logger logger
= Logger
.getLogger(InstitutionalMembership
.class);
58 /*Time period a person belonged to the institution*/
59 @XmlElement(name
= "Period")
60 private TimePeriod period
= TimePeriod
.NewInstance();
62 //Department of the institution this person was working in
63 @XmlElement(name
= "Department")
64 private String department
;
66 //Role this person had in the institution
67 @XmlElement(name
= "Role")
70 //current institute the person belongs to
71 @XmlElement(name
= "Institution", required
= true)
73 @XmlSchemaType(name
= "IDREF")
74 @ManyToOne(fetch
= FetchType
.LAZY
)
75 @Cascade(CascadeType
.SAVE_UPDATE
)
76 private Institution institute
;
78 @XmlElement(name
= "Person", required
= true)
80 @XmlSchemaType(name
= "IDREF")
81 @ManyToOne(fetch
= FetchType
.LAZY
)
82 @Cascade(CascadeType
.SAVE_UPDATE
)
83 private Person person
;
85 public static InstitutionalMembership
NewInstance() {
86 InstitutionalMembership mship
= new InstitutionalMembership();
90 protected InstitutionalMembership() {
95 * Class constructor using an {@link Institution institution}, a {@link Person person}, a {@link common.TimePeriod time period},
96 * a department name string and a role string.
97 * Adds this membership to the persons memberships.
99 * @param institute the institution in which the person is a member
100 * @param person the person who is a member of the institution
101 * @param period the time period during which the person belonged
103 * @param department the name string of the department (within the institution)
104 * this person is working in
105 * @param role the string which identifies the role played by the person
106 * in the institution (or in the department)
110 public InstitutionalMembership(Institution institute
, Person person
, TimePeriod period
, String department
,
113 this.period
= period
;
114 this.department
= department
;
116 this.institute
= institute
;
117 this.person
= person
;
118 person
.addInstitutionalMembership(this);
122 * Returns the {@link Person person} involved in <i>this</i> institutional membership.
124 * @see Person#institutionalMemberships
125 * @see Person#addInstitutionalMembership(Institution, TimePeriod, String, String)
127 public Person
getPerson() {
132 * Assigns a new {@link Person person} (replacing the actual one) to <i>this</i> institutional membership.
133 * This method also updates both sets of institutions
134 * the two persons (the new one and the substituted one) belong to.
136 * @param newPerson the new person to be included in <i>this</i> institutional membership
138 * @see Person#removeInstitutionalMembership(InstitutionalMembership)
140 protected void setPerson(Person person
) {
141 this.person
= person
;
145 * Returns the {@link Institution institution} corresponding to <i>this</i> institutional membership.
147 public Institution
getInstitute(){
148 return this.institute
;
151 * Assigns an new institution (replacing the actual one)
152 * to <i>this</i> institutional membership.
154 * @param newInstitute the new institution
155 * @see #getInstitute()
157 public void setInstitute(Institution newInstitute
){
158 this.institute
= newInstitute
;
162 * Returns the {@link TimePeriod time period} during which
163 * the {@link Person person} involved in <i>this</i> institutional membership belonged
164 * to the {@link Institution institution} also involved in it.
166 public TimePeriod
getPeriod(){
173 public void setPeriod(TimePeriod period
){
174 this.period
= period
;
178 * Returns the string representing the name of the department (within
179 * the {@link Institution institution} involved in <i>this</i> institutional membership) to which
180 * the {@link Person person} belongs.
182 public String
getDepartment(){
183 return this.department
;
187 * @see #getDepartment()
189 public void setDepartment(String department
){
190 this.department
= department
;
194 * Returns the string representing the role played by the {@link Person person} within
195 * the {@link Institution institution} (or within the department) involved
196 * in <i>this</i> institutional membership.
198 public String
getRole(){
205 public void setRole(String role
){