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 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 have to be created.
29 * @created 08-Nov-2007 13:06:30
32 public class InstitutionalMembership
extends VersionableEntity
{
33 static Logger logger
= Logger
.getLogger(InstitutionalMembership
.class);
34 /*Time period a person belonged to the institution*/
35 private TimePeriod period
;
36 //Department of the institution this person was working in
37 private String department
;
38 //Role this person had in the institution
40 //current institute the person belongs to
41 private Institution institute
;
42 private Person person
;
46 * Class constructor using an institution, a person, a time period,
47 * a department name string and a role string.
49 * @param institute the institution in which the person is a member
50 * @param person the person who is a member of the institution
51 * @param period the time period during which the person belonged
53 * @param department the name string of the department (within the institution)
54 * this person was working in
55 * @param role the string which identifies the role played by the person
56 * in the institution (or in the department)
60 public InstitutionalMembership(Institution institute
, Person person
, TimePeriod period
, String department
,
64 this.department
= department
;
66 this.institute
= institute
;
70 public Person
getPerson() {
74 * Assigns a new person to this institutional membership.
75 * This method also updates the set of institutions
76 * the two persons (the new one and the substituted one) belong to.
78 * @param newPerson the new person involved in this institutional membership
79 * @see Person#institutionalMemberships
80 * @see Person#removeInstitutionalMembership(InstitutionalMembership)
82 public void setPerson(Person newPerson
) {
83 // Hibernate bidirectional cascade hack:
84 // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
85 if(this.person
== newPerson
) return;
87 person
.institutionalMemberships
.remove(this);
89 if (newPerson
!= null) {
90 newPerson
.institutionalMemberships
.add(this);
92 this.person
= newPerson
;
96 @Cascade({CascadeType
.SAVE_UPDATE
})
97 public Institution
getInstitute(){
98 return this.institute
;
101 * Assigns an institution to this institutional membership.
103 * @param newInstitute the institution involved in this institutional membership
105 public void setInstitute(Institution newInstitute
){
106 this.institute
= newInstitute
;
109 public TimePeriod
getPeriod(){
114 * Assigns a time period applying for this institutional membership.
116 * @param period the time period during which the person belonged
119 public void setPeriod(TimePeriod period
){
120 this.period
= period
;
123 public String
getDepartment(){
124 return this.department
;
128 * Assigns a department within the institution involved
129 * in this institutional membership.
131 * @param department the string for the department name within the institution
133 public void setDepartment(String department
){
134 this.department
= department
;
137 public String
getRole(){
142 * Assigns a role to the person within the institution (or department).
144 * @param role the string which identifies the role played by the person
145 * within the institution (or within the department)
147 public void setRole(String role
){