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
;
20 import javax
.persistence
.*;
23 * Allows to keep one {@link Institution institution} to which a {@link Person person} is affiliated.
24 * It includes time period of membership and role of the person
25 * in this institution. In case one person belongs to several institutions
26 * the corresponding number of instances have to be created.
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
;
46 public InstitutionalMembership(Institution institute
, Person person
, TimePeriod period
, String department
,
50 this.department
= department
;
52 this.institute
= institute
;
56 public Person
getPerson() {
59 public void setPerson(Person newPerson
) {
60 // Hibernate bidirectional cascade hack:
61 // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
62 if(this.person
== newPerson
) return;
64 person
.institutionalMemberships
.remove(this);
66 if (newPerson
!= null) {
67 newPerson
.institutionalMemberships
.add(this);
69 this.person
= newPerson
;
73 @Cascade({CascadeType
.SAVE_UPDATE
})
74 public Institution
getInstitute(){
75 return this.institute
;
77 public void setInstitute(Institution newInstitute
){
78 this.institute
= newInstitute
;
81 public TimePeriod
getPeriod(){
87 * @param period period
89 public void setPeriod(TimePeriod period
){
93 public String
getDepartment(){
94 return this.department
;
99 * @param department department
101 public void setDepartment(String department
){
102 this.department
= department
;
105 public String
getRole(){
113 public void setRole(String role
){