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
;
12 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
13 import eu
.etaxonomy
.cdm
.model
.common
.Keyword
;
14 import eu
.etaxonomy
.cdm
.strategy
.cache
.agent
.PersonDefaultCacheStrategy
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.hibernate
.annotations
.Cascade
;
18 import org
.hibernate
.annotations
.CascadeType
;
20 import javax
.persistence
.*;
21 import javax
.xml
.bind
.annotation
.XmlAccessType
;
22 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
23 import javax
.xml
.bind
.annotation
.XmlElement
;
24 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
25 import javax
.xml
.bind
.annotation
.XmlIDREF
;
26 import javax
.xml
.bind
.annotation
.XmlRootElement
;
27 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
28 import javax
.xml
.bind
.annotation
.XmlType
;
31 * This class represents human beings, living or dead.<BR>
32 * It includes name parts, {@link Contact contact} details, {@link InstitutionalMembership institutional membership},
33 * and other possible information such as life {@link TimePeriod time period},
34 * taxonomic and/or geographical {@link Keyword specialization}.
35 * For a short abbreviated name the inherited attribute {@link TeamOrPersonBase#getNomenclaturalTitle() nomenclaturalTitle}
37 * For other alternative (string-)names {@link eu.etaxonomy.cdm.model.common.OriginalSource OriginalSource} instances must be created
38 * and the inherited attribute {@link eu.etaxonomy.cdm.model.common.ReferencedEntityBase#getOriginalNameString() originalNameString} must be used.
40 * This class corresponds to: <ul>
41 * <li> Person according to the TDWG ontology
42 * <li> AgentName (partially) according to the TCS
43 * <li> Person (PersonName partially) according to the ABCD schema
48 * @created 08-Nov-2007 13:06:42
50 @XmlAccessorType(XmlAccessType
.FIELD
)
51 @XmlType(name
= "Person", propOrder
= {
57 "institutionalMemberships",
61 @XmlRootElement(name
= "Person")
63 public class Person
extends TeamOrPersonBase
{
64 static Logger logger
= Logger
.getLogger(Person
.class);
66 @XmlElement(name
= "Prefix")
67 private String prefix
;
69 @XmlElement(name
= "FirstName")
70 private String firstname
;
72 @XmlElement(name
= "LastName")
73 private String lastname
;
75 @XmlElement(name
= "Suffix")
76 private String suffix
;
78 @XmlElement(name
= "Lifespan")
79 //@XmlJavaTypeAdapter(IntervalAdapter.class)
80 private TimePeriod lifespan
;
82 @XmlElementWrapper(name
= "InstitutionalMemberships")
83 @XmlElement(name
= "InstitutionalMembership")
84 protected Set
<InstitutionalMembership
> institutionalMemberships
;
86 @XmlElement(name
= "Contact")
87 private Contact contact
;
89 @XmlElementWrapper(name
= "Keywords")
90 @XmlElement(name
= "Keyword")
92 @XmlSchemaType(name
="IDREF")
93 private Set
<Keyword
> keywords
= new HashSet
<Keyword
>();
96 * Creates a new empty instance for a person whose existence is all what is known.
97 * This can be a provisional solution until more information about <i>this</i> person
98 * can be gathered, for instance in case a member of a nomenclatural author team
99 * is not explicitly mentioned. It also includes the cache strategy defined in
100 * {@link eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy PersonDefaultCacheStrategy}.
102 public static Person
NewInstance(){
107 * Creates a new instance for a person for whom an "identification" string
108 * is all what is known. This string is generally a short or a complete name.
109 * As this string is kept in the {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache() titleCache}
110 * attribute and should not be overwritten by the {@link #generateTitle() generateTitle} method
111 * the {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#isProtectedTitleCache() protectedTitleCache} flag will be turned on.
113 public static Person
NewTitledInstance(String titleCache
){
114 Person result
= new Person();
115 result
.setTitleCache(titleCache
);
123 * @see #Person(String, String, String)
127 this.cacheStrategy
= PersonDefaultCacheStrategy
.NewInstance();
132 * Class constructor using a "forenames" string (including initials),
133 * a surname (family name) and an abbreviated name as used in nomenclature.
134 * For the abbreviated name the inherited attribute {@link TeamOrPersonBase#getNomenclaturalTitle() nomenclaturalTitle}
137 * @param firstname the given name
138 * @param lastname the hereditary name
139 * @param nomenclaturalTitel the abbreviated name
141 * @see #NewInstance()
143 public Person(String firstname
, String lastname
, String nomenclaturalTitel
) {
144 this.setFirstname(firstname
);
145 this.setLastname(lastname
);
146 this.setNomenclaturalTitle(nomenclaturalTitel
);
151 * Returns the set of {@link InstitutionalMembership institution memberships} corresponding to <i>this</i> person.
153 * @see InstitutionalMembership
155 @OneToMany(fetch
=FetchType
.LAZY
)
156 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE
})
157 public Set
<InstitutionalMembership
> getInstitutionalMemberships(){
158 return this.institutionalMemberships
;
161 * @see #getInstitutionalMemberships()
163 protected void setInstitutionalMemberships(Set
<InstitutionalMembership
> institutionalMemberships
){
164 this.institutionalMemberships
= institutionalMemberships
;
168 * Adds a new {@link InstitutionalMembership membership} of <i>this</i> person in an {@link Institution institution}
169 * to the set of his institution memberships.
170 * This method also creates a new institutional membership instance.
172 * @param institution the institution <i>this</i> person belongs to
173 * @param period the time period for which <i>this</i> person has been a member of the institution
174 * @param department the string label for the department <i>this</i> person belongs to,
175 * within the institution
176 * @param role the string label for the persons's role within the department or institution
177 * @see #getInstitutionalMemberships()
178 * @see InstitutionalMembership#InstitutionalMembership(Institution, Person, TimePeriod, String, String)
180 public void addInstitutionalMembership(Institution institution
, TimePeriod period
, String department
, String role
){
181 //TODO to be implemented?
182 logger
.warn("not yet fully implemented?");
183 InstitutionalMembership ims
= new InstitutionalMembership(institution
, this, period
, department
, role
);
184 institutionalMemberships
.add(ims
);
188 * Removes one element from the set of institutional memberships of <i>this</i> person.
189 * Institute and person attributes of the institutional membership object
192 * @param ims the institutional membership of <i>this</i> person which should be deleted
193 * @see #getInstitutionalMemberships()
195 public void removeInstitutionalMembership(InstitutionalMembership ims
){
196 //TODO to be implemented?
197 logger
.warn("not yet fully implemented?");
198 ims
.setInstitute(null);
200 this.institutionalMemberships
.remove(ims
);
205 * Returns the set of {@link eu.etaxonomy.cdm.model.common.Keyword keywords} mostly representing a taxonomic or
206 * a geographical specialization of <i>this</i> person.
207 * Keywords are items of a controlled {@link eu.etaxonomy.cdm.model.common.TermVocabulary vocabulary}.
211 @ManyToMany(fetch
=FetchType
.LAZY
,
212 targetEntity
=eu
.etaxonomy
.cdm
.model
.common
.Keyword
.class
215 name
="Person_Keyword",
216 joinColumns
=@JoinColumn(name
="person_fk"),
217 inverseJoinColumns
=@JoinColumn(name
="keyword_fk")
219 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE_ORPHAN
})
220 public Set
<Keyword
> getKeywords(){
221 return this.keywords
;
224 * @see #getKeywords()
226 public void setKeywords(Set
<Keyword
> keywords
){
227 this.keywords
= keywords
;
230 * Adds a new keyword from the keyword vocabulary to the set of keywords
231 * describing or circumscribing <i>this</i> person's activities.
233 * @param keyword any keyword
234 * @see #getKeywords()
235 * @see eu.etaxonomy.cdm.model.common.Keyword
237 public void addKeyword(Keyword keyword
){
238 this.keywords
.add(keyword
);
241 * Removes one element from the set of keywords for <i>this</i> person.
243 * @param keyword the keyword which should be deleted
244 * @see #getKeywords()
246 public void removeKeyword(Keyword keyword
){
247 this.keywords
.remove(keyword
);
253 * Returns the {@link Contact contact} of <i>this</i> person.
254 * The contact contains several ways to approach <i>this</i> person.
258 @ManyToOne(fetch
=FetchType
.LAZY
)
259 @Cascade({CascadeType
.SAVE_UPDATE
})
260 public Contact
getContact(){
266 public void setContact(Contact contact
){
267 this.contact
= contact
;
272 * Returns the string representing the prefix (for instance "Prof. Dr.<!-- -->")
273 * to <i>this</i> person's name.
275 public String
getPrefix(){
281 public void setPrefix(String prefix
){
282 this.prefix
= prefix
;
287 * Returns the string representing the given name or forename
288 * (for instance "John") of <i>this</i> person.
289 * This is the part of his name which is not shared with other
290 * family members. Actually it may be just initials (for instance "G. Jr."),
291 * all forenames in full or a combination of expanded names and initials.
293 public String
getFirstname(){
294 return this.firstname
;
297 * @see #getFirstname()
299 public void setFirstname(String firstname
){
300 this.firstname
= firstname
;
305 * Returns the string representing the hereditary name (surname or family name)
306 * (for instance "Smith") of <i>this</i> person.
307 * This is the part of his name which is common to (all) other
308 * members of his family, as distinct from the given name or forename.
310 public String
getLastname(){
311 return this.lastname
;
314 * @see #getLastname()
316 public void setLastname(String lastname
){
317 this.lastname
= lastname
;
322 * Returns the string representing the suffix (for instance "Junior")
323 * of <i>this</i> person's name.
325 public String
getSuffix(){
331 public void setSuffix(String suffix
){
332 this.suffix
= suffix
;
337 * Returns the {@link eu.etaxonomy.cdm.model.common.TimePeriod period of time}
338 * in which <i>this</i> person was alive (life span).
339 * The general form is birth date - death date
340 * (XXXX - YYYY; XXXX - or - YYYY as appropriate),
341 * but a simple flourished date (fl. XXXX) is also possible
342 * if that is all what is known.
344 * @see eu.etaxonomy.cdm.model.common.TimePeriod
346 public TimePeriod
getLifespan(){
347 return this.lifespan
;
350 * @see #getLifespan()
352 public void setLifespan(TimePeriod lifespan
){
353 this.lifespan
= lifespan
;
357 * Generates the "full" name string of <i>this</i> person according to the strategy
358 * defined in {@link eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy PersonDefaultCacheStrategy}.
359 * The used attributes are:
360 * {@link #getPrefix() prefix}, {@link #getFirstname() firstname}, {@link #getLastname() lastname} and {@link #getSuffix() suffix}.
361 * This method overrides {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle() generateTitle}.
362 * The result might be kept as {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#setTitleCache(String) titleCache} if the
363 * flag {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
365 * @return the string with the full name of <i>this</i> person
368 public String
generateTitle() {
370 if (cacheStrategy
!= null) {
371 title
= cacheStrategy
.getTitleCache(this);