230b26e0f034e94225e0454b22184c3c470f5a22
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
.*;
22 * Allows to hold one {@link Institution institution} to which a {@link Person person} is affiliated.
23 * It includes {@link common.TimePeriod time period} of membership and role of the person
24 * in this institution. In case one person belongs to several institutions
25 * the corresponding number of instances of InstitutionalMembership
30 * @created 08-Nov-2007 13:06:30
33 public class InstitutionalMembership
extends VersionableEntity
{
34 static Logger logger
= Logger
.getLogger(InstitutionalMembership
.class);
35 /*Time period a person belonged to the institution*/
36 private TimePeriod period
;
37 //Department of the institution this person was working in
38 private String department
;
39 //Role this person had in the institution
41 //current institute the person belongs to
42 private Institution institute
;
43 private Person person
;
47 * Class constructor using an {@link Institution institution}, a {@link Person person}, a {@link common.TimePeriod time period},
48 * a department name string and a role string.
50 * @param institute the institution in which the person is a member
51 * @param person the person who is a member of the institution
52 * @param period the time period during which the person belonged
54 * @param department the name string of the department (within the institution)
55 * this person is working in
56 * @param role the string which identifies the role played by the person
57 * in the institution (or in the department)
61 public InstitutionalMembership(Institution institute
, Person person
, TimePeriod period
, String department
,
65 this.department
= department
;
67 this.institute
= institute
;
72 * Returns the {@link Person person} involved in this institutional membership.
74 * @see Person#institutionalMemberships
75 * @see Person#addInstitutionalMembership(Institution, TimePeriod, String, String)
77 public Person
getPerson() {
81 * Assigns a new {@link Person person} (replacing the actual one) to this institutional membership.
82 * This method also updates both sets of institutions
83 * the two persons (the new one and the substituted one) belong to.
85 * @param newPerson the new person to be included in this institutional membership
87 * @see Person#removeInstitutionalMembership(InstitutionalMembership)
89 public void setPerson(Person newPerson
) {
90 // Hibernate bidirectional cascade hack:
91 // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
92 if(this.person
== newPerson
) return;
94 person
.institutionalMemberships
.remove(this);
96 if (newPerson
!= null) {
97 newPerson
.institutionalMemberships
.add(this);
99 this.person
= newPerson
;
104 * Returns the {@link Institution institution} corresponding to this institutional membership.
106 @Cascade({CascadeType
.SAVE_UPDATE
})
107 public Institution
getInstitute(){
108 return this.institute
;
111 * Assigns an new institution (replacing the actual one)
112 * to this institutional membership.
114 * @param newInstitute the new institution
115 * @see #getInstitute()
117 public void setInstitute(Institution newInstitute
){
118 this.institute
= newInstitute
;
122 * Returns the {@link common.TimePeriod time period} during which
123 * the {@link Person person} involved in this institutional membership belonged
124 * to the {@link Institution institution} also involved in it.
126 public TimePeriod
getPeriod(){
133 public void setPeriod(TimePeriod period
){
134 this.period
= period
;
138 * Returns the string representing the name of the department (within
139 * the {@link Institution institution} involved in this institutional membership) to which
140 * the {@link Person person} belongs.
142 public String
getDepartment(){
143 return this.department
;
147 * @see #getDepartment()
149 public void setDepartment(String department
){
150 this.department
= department
;
154 * Returns the string representing the role played by the {@link Person person} within
155 * the {@link Institution institution} (or within the department) involved
156 * in this institutional membership.
158 public String
getRole(){
165 public void setRole(String role
){