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
.Keyword
;
15 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.hibernate
.annotations
.Cascade
;
18 import org
.hibernate
.annotations
.CascadeType
;
22 import javax
.persistence
.*;
25 * A representation of a human being, living or dead.
26 * It includes name parts, contact details, institutional membership,
27 * and other possible information such as life period,
28 * taxonomic and/or geographical specialization. For a short name
29 * the inherited attribute {@link common.IdentifiableEntity#setTitleCache(String) titleCache} is to be used.
30 * For other alternative (string-)names {@link common.OriginalSource OriginalSource} instances must be created.
31 * and the inherited attribute {@link common.ReferencedEntityBase#setOriginalNameString(String) originalNameString} must be used.
33 * See also the <a href="http://rs.tdwg.org/ontology/voc/Person.rdf">TDWG Ontology</a>
37 * @created 08-Nov-2007 13:06:42
40 public class Person
extends Agent
{
41 static Logger logger
= Logger
.getLogger(Person
.class);
43 private String prefix
;
44 private String firstname
;
45 private String lastname
;
46 private String suffix
;
47 private TimePeriod lifespan
;
48 protected Set
<InstitutionalMembership
> institutionalMemberships
;
49 private Contact contact
;
50 private Set
<Keyword
> keywords
= new HashSet();
55 * @see #Person(String, String, String)
60 * Class constructor using a "forenames" string (including initials),
61 * a surname (family name) and an abbreviated name.
63 * @param firstname the given name of this person
64 * @param lastname the hereditary name of this person
65 * @param abbreviation a standardised or abbreviated name of this person
68 public Person(String firstname
, String lastname
, String abbreviation
) {
69 this.setFirstname(firstname
);
70 this.setLastname(lastname
);
71 this.setTitleCache(abbreviation
);
76 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE
})
77 public Set
<InstitutionalMembership
> getInstitutionalMemberships(){
78 return this.institutionalMemberships
;
80 protected void setInstitutionalMemberships(Set
<InstitutionalMembership
> institutionalMemberships
){
81 this.institutionalMemberships
= institutionalMemberships
;
84 * Adds a new membership of this person in an institution.
86 * @param institution the institution this person belongs to
87 * @param period the time period for which this person has been a member of the institution
88 * @param department the string label for the department this person belongs to,
89 * within the institution
90 * @param role the string label for the persons's role within the department or institution
91 * @see InstitutionalMembership#InstitutionalMembership(Institution, Person, TimePeriod, String, String)
93 public void addInstitutionalMembership(Institution institution
, TimePeriod period
, String department
, String role
){
94 InstitutionalMembership ims
= new InstitutionalMembership(institution
, this, period
, department
, role
);
97 * Removes one element of the set of institutional memberships of this person.
99 * @param ims the institutional membership of this person which should be deleted
100 * @see #addInstitutionalMembership(Institution, TimePeriod, String, String)
102 public void removeInstitutionalMembership(InstitutionalMembership ims
){
103 ims
.setInstitute(null);
105 //this.institutionalMemberships.remove(ims);
110 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE_ORPHAN
})
111 public Set
<Keyword
> getKeywords(){
112 return this.keywords
;
114 public void setKeywords(Set
<Keyword
> keywords
){
115 this.keywords
= keywords
;
118 * Adds a new keyword to describe better this person or circumscribe his activities.
120 * @param keyword any relevant keyword for this person or for his activities
121 * @see common.Keyword
123 public void addKeyword(Keyword keyword
){
124 this.keywords
.add(keyword
);
127 * Removes one element of the set of keywords for this person.
129 * @param keyword the keyword describing this person or his activities which should be deleted
130 * @see #addKeyword(Keyword)
132 public void removeKeyword(Keyword keyword
){
133 this.keywords
.remove(keyword
);
139 @Cascade({CascadeType
.SAVE_UPDATE
})
140 public Contact
getContact(){
144 * Assigns a {@link Contact contact} to this person.
146 * @param contact the contact which should be assigned to this person
148 public void setContact(Contact contact
){
149 this.contact
= contact
;
153 public String
getPrefix(){
157 * Assigns a prefix (for instance "Prof. Dr.<!-- -->") to this person's name.
159 * @param prefix the string which should be assigned as a prefix to this person's name
161 public void setPrefix(String prefix
){
162 this.prefix
= prefix
;
166 public String
getFirstname(){
167 return this.firstname
;
170 * Assigns a given name or forename (for instance "John") to this person.
171 * This is the part of his name which is not shared with other
172 * family members. Actually it may be just initials (for instance "G. Jr."),
173 * all forenames in full or a combination of expanded names and initials.
175 * @param firstname the string which should be assigned as a given name to this person
177 public void setFirstname(String firstname
){
178 this.firstname
= firstname
;
182 public String
getLastname(){
183 return this.lastname
;
186 * Assigns a hereditary name (surname or family name)
187 * to this person (for instance "Smith").
188 * This is the part of his name which is common to (all) other
189 * members of his family, as distinct from the given name or forename.
191 * @param lastname the string which should be assigned as a hereditary name to this person
193 public void setLastname(String lastname
){
194 this.lastname
= lastname
;
198 public String
getSuffix(){
202 * Assigns a suffix (for instance "Junior") to this person's name.
204 * @param suffix the string which should be assigned as a suffix to this person's name
206 public void setSuffix(String suffix
){
207 this.suffix
= suffix
;
211 public TimePeriod
getLifespan(){
212 return this.lifespan
;
215 * Assigns to this person a period of time in which he was alive.
216 * The form birthdate - deathdate (XXXX - YYYY; XXXX - or - YYYY as appropriate) is
217 * preferred, but a simple flourished date (fl. XXXX) may be given
218 * if that is all what is known.
220 * @param lifespan the time period to be assigned as life time to this person
221 * @see common.TimePeriod
223 public void setLifespan(TimePeriod lifespan
){
224 this.lifespan
= lifespan
;
229 * Generates the "full" name string of this person on the basis of the attributes:
230 * {@link #prefix prefix}, {@link #firstname firstname}, {@link #lastname lastname} and {@link #suffix suffix}.
231 * This method overrides {@link common.IdentifiableEntity#generateTitle() generateTitle}
232 * The result might be kept as {@link common.IdentifiableEntity#setTitleCache(String) titleCache} if the
233 * flag {@link common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
235 * @return the full name string of this person
237 public String
generateTitle(){