1 |
9479da48
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
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.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.cdm.model.agent;
|
11 |
|
|
|
12 |
|
|
|
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;
|
18 |
|
|
|
19 |
|
|
import javax.persistence.*;
|
20 |
|
|
|
21 |
|
|
/**
|
22 |
a28eb18d
|
m.geoffroy
|
* Allows to hold one {@link Institution institution} to which a {@link Person person} is affiliated.
|
23 |
975192f9
|
m.geoffroy
|
* 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.
|
26 |
|
|
*
|
27 |
9479da48
|
Andreas Müller
|
* @author m.doering
|
28 |
|
|
* @version 1.0
|
29 |
|
|
* @created 08-Nov-2007 13:06:30
|
30 |
|
|
*/
|
31 |
|
|
@Entity
|
32 |
|
|
public class InstitutionalMembership extends VersionableEntity {
|
33 |
|
|
static Logger logger = Logger.getLogger(InstitutionalMembership.class);
|
34 |
814a8233
|
Andreas Müller
|
/*Time period a person belonged to the institution*/
|
35 |
9479da48
|
Andreas Müller
|
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
|
39 |
|
|
private String role;
|
40 |
|
|
//current institute the person belongs to
|
41 |
|
|
private Institution institute;
|
42 |
|
|
private Person person;
|
43 |
|
|
|
44 |
|
|
|
45 |
a28eb18d
|
m.geoffroy
|
/**
|
46 |
|
|
* Class constructor using an institution, a person, a time period,
|
47 |
|
|
* a department name string and a role string.
|
48 |
|
|
*
|
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
|
52 |
|
|
* to the institution
|
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)
|
57 |
|
|
* @see Person
|
58 |
|
|
* @see Institution
|
59 |
|
|
*/
|
60 |
9479da48
|
Andreas Müller
|
public InstitutionalMembership(Institution institute, Person person, TimePeriod period, String department,
|
61 |
|
|
String role) {
|
62 |
|
|
super();
|
63 |
|
|
this.period = period;
|
64 |
|
|
this.department = department;
|
65 |
|
|
this.role = role;
|
66 |
|
|
this.institute = institute;
|
67 |
|
|
this.person = person;
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
public Person getPerson() {
|
71 |
|
|
return person;
|
72 |
|
|
}
|
73 |
a28eb18d
|
m.geoffroy
|
/**
|
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.
|
77 |
|
|
*
|
78 |
|
|
* @param newPerson the new person involved in this institutional membership
|
79 |
|
|
* @see Person#institutionalMemberships
|
80 |
|
|
* @see Person#removeInstitutionalMembership(InstitutionalMembership)
|
81 |
|
|
*/
|
82 |
9479da48
|
Andreas Müller
|
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;
|
86 |
|
|
if (person != null) {
|
87 |
|
|
person.institutionalMemberships.remove(this);
|
88 |
|
|
}
|
89 |
|
|
if (newPerson!= null) {
|
90 |
|
|
newPerson.institutionalMemberships.add(this);
|
91 |
|
|
}
|
92 |
|
|
this.person = newPerson;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
@Cascade({CascadeType.SAVE_UPDATE})
|
97 |
|
|
public Institution getInstitute(){
|
98 |
|
|
return this.institute;
|
99 |
|
|
}
|
100 |
a28eb18d
|
m.geoffroy
|
/**
|
101 |
|
|
* Assigns an institution to this institutional membership.
|
102 |
|
|
*
|
103 |
|
|
* @param newInstitute the institution involved in this institutional membership
|
104 |
|
|
*/
|
105 |
9479da48
|
Andreas Müller
|
public void setInstitute(Institution newInstitute){
|
106 |
|
|
this.institute = newInstitute;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
public TimePeriod getPeriod(){
|
110 |
|
|
return this.period;
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
/**
|
114 |
a28eb18d
|
m.geoffroy
|
* Assigns a time period applying for this institutional membership.
|
115 |
9479da48
|
Andreas Müller
|
*
|
116 |
a28eb18d
|
m.geoffroy
|
* @param period the time period during which the person belonged
|
117 |
|
|
* to the institution
|
118 |
9479da48
|
Andreas Müller
|
*/
|
119 |
|
|
public void setPeriod(TimePeriod period){
|
120 |
|
|
this.period = period;
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
public String getDepartment(){
|
124 |
|
|
return this.department;
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
/**
|
128 |
a28eb18d
|
m.geoffroy
|
* Assigns a department within the institution involved
|
129 |
|
|
* in this institutional membership.
|
130 |
9479da48
|
Andreas Müller
|
*
|
131 |
a28eb18d
|
m.geoffroy
|
* @param department the string for the department name within the institution
|
132 |
9479da48
|
Andreas Müller
|
*/
|
133 |
|
|
public void setDepartment(String department){
|
134 |
|
|
this.department = department;
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
public String getRole(){
|
138 |
|
|
return this.role;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
/**
|
142 |
a28eb18d
|
m.geoffroy
|
* Assigns a role to the person within the institution (or department).
|
143 |
9479da48
|
Andreas Müller
|
*
|
144 |
a28eb18d
|
m.geoffroy
|
* @param role the string which identifies the role played by the person
|
145 |
|
|
* within the institution (or within the department)
|
146 |
9479da48
|
Andreas Müller
|
*/
|
147 |
|
|
public void setRole(String role){
|
148 |
|
|
this.role = role;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
}
|