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 * A representation of a human being, living or dead.
32 * It includes name parts, {@link Contact contact} details, {@link InstitutionalMembership institutional membership},
33 * and other possible information such as life {@link common.TimePeriod time period},
34 * taxonomic and/or geographical {@link common.Keyword specialization}.
35 * For a short abbreviated name the inherited attribute {@link TeamOrPersonBase#getNomenclaturalTitle() nomenclaturalTitle}
37 * For other alternative (string-)names {@link common.OriginalSource OriginalSource} instances must be created
38 * and the inherited attribute {@link common.ReferencedEntityBase#getOriginalNameString() originalNameString} must be used.
40 * See also the <a href="http://rs.tdwg.org/ontology/voc/Person.rdf">TDWG Ontology</a>
44 * @created 08-Nov-2007 13:06:42
46 @XmlAccessorType(XmlAccessType
.FIELD
)
47 @XmlType(name
= "Person", propOrder
= {
53 "institutionalMemberships",
57 @XmlRootElement(name
= "Person")
59 public class Person
extends TeamOrPersonBase
{
60 static Logger logger
= Logger
.getLogger(Person
.class);
62 @XmlElement(name
= "Prefix")
63 private String prefix
;
65 @XmlElement(name
= "FirstName")
66 private String firstname
;
68 @XmlElement(name
= "LastName")
69 private String lastname
;
71 @XmlElement(name
= "Suffix")
72 private String suffix
;
74 @XmlElement(name
= "Lifespan")
75 //@XmlJavaTypeAdapter(IntervalAdapter.class)
76 private TimePeriod lifespan
;
78 @XmlElementWrapper(name
= "InstitutionalMemberships")
79 @XmlElement(name
= "InstitutionalMembership")
80 protected Set
<InstitutionalMembership
> institutionalMemberships
;
82 @XmlElement(name
= "Contact")
83 private Contact contact
;
85 @XmlElementWrapper(name
= "Keywords")
86 @XmlElement(name
= "Keyword")
88 @XmlSchemaType(name
="IDREF")
89 private Set
<Keyword
> keywords
= new HashSet
<Keyword
>();
92 * Creates a new empty instance for a person whose existence is all what is known.
93 * This can be a provisional solution until more information about <i>this</i> person
94 * can be gathered, for instance in case a member of a nomenclatural author team
95 * is not explicitly mentioned. It also includes the cache strategy defined in
96 * {@link eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy PersonDefaultCacheStrategy}.
98 public static Person
NewInstance(){
103 * Creates a new instance for a person for whom an "identification" string
104 * is all what is known. This string is generally a short or a complete name.
105 * As this string is kept in the {@link common.IdentifiableEntity#getTitleCache() titleCache}
106 * attribute and should not be overwritten by the {@link #generateTitle() generateTitle} method
107 * the {@link common.IdentifiableEntity#isProtectedTitleCache() protectedTitleCache} flag will be turned on.
109 public static Person
NewTitledInstance(String titleCache
){
110 Person result
= new Person();
111 result
.setTitleCache(titleCache
);
119 * @see #Person(String, String, String)
123 this.cacheStrategy
= PersonDefaultCacheStrategy
.NewInstance();
128 * Class constructor using a "forenames" string (including initials),
129 * a surname (family name) and an abbreviated name as used in nomenclature.
130 * For the abbreviated name the inherited attribute {@link TeamOrPersonBase#getNomenclaturalTitle() nomenclaturalTitle}
133 * @param firstname the given name
134 * @param lastname the hereditary name
135 * @param nomenclaturalTitel the abbreviated name
137 * @see #NewInstance()
139 public Person(String firstname
, String lastname
, String nomenclaturalTitel
) {
140 this.setFirstname(firstname
);
141 this.setLastname(lastname
);
142 this.setNomenclaturalTitle(nomenclaturalTitel
);
147 * Returns the set of {@link InstitutionalMembership institution memberships} corresponding to <i>this</i> person.
149 * @see InstitutionalMembership
151 @OneToMany(fetch
=FetchType
.LAZY
)
152 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE
})
153 public Set
<InstitutionalMembership
> getInstitutionalMemberships(){
154 return this.institutionalMemberships
;
157 * @see #getInstitutionalMemberships()
159 protected void setInstitutionalMemberships(Set
<InstitutionalMembership
> institutionalMemberships
){
160 this.institutionalMemberships
= institutionalMemberships
;
164 * Adds a new {@link InstitutionalMembership membership} of <i>this</i> person in an {@link Institution institution}
165 * to the set of his institution memberships.
166 * This method also creates a new institutional membership instance.
168 * @param institution the institution <i>this</i> person belongs to
169 * @param period the time period for which <i>this</i> person has been a member of the institution
170 * @param department the string label for the department <i>this</i> person belongs to,
171 * within the institution
172 * @param role the string label for the persons's role within the department or institution
173 * @see #getInstitutionalMemberships()
174 * @see InstitutionalMembership#InstitutionalMembership(Institution, Person, TimePeriod, String, String)
176 public void addInstitutionalMembership(Institution institution
, TimePeriod period
, String department
, String role
){
177 //TODO to be implemented?
178 logger
.warn("not yet fully implemented?");
179 InstitutionalMembership ims
= new InstitutionalMembership(institution
, this, period
, department
, role
);
180 institutionalMemberships
.add(ims
);
184 * Removes one element from the set of institutional memberships of <i>this</i> person.
185 * Institute and person attributes of the institutional membership object
188 * @param ims the institutional membership of <i>this</i> person which should be deleted
189 * @see #getInstitutionalMemberships()
191 public void removeInstitutionalMembership(InstitutionalMembership ims
){
192 //TODO to be implemented?
193 logger
.warn("not yet fully implemented?");
194 ims
.setInstitute(null);
196 this.institutionalMemberships
.remove(ims
);
201 * Returns the set of {@link common.Keyword keywords} mostly representing a taxonomic or
202 * a geographical specialization of <i>this</i> person.
203 * Keywords are items of a controlled {@link common.TermVocabulary vocabulary}.
205 * @see common.Keyword
207 @ManyToMany(fetch
=FetchType
.LAZY
,
208 targetEntity
=eu
.etaxonomy
.cdm
.model
.common
.Keyword
.class
211 name
="Person_Keyword",
212 joinColumns
=@JoinColumn(name
="person_fk"),
213 inverseJoinColumns
=@JoinColumn(name
="keyword_fk")
215 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE_ORPHAN
})
216 public Set
<Keyword
> getKeywords(){
217 return this.keywords
;
220 * @see #getKeywords()
222 public void setKeywords(Set
<Keyword
> keywords
){
223 this.keywords
= keywords
;
226 * Adds a new keyword from the keyword vocabulary to the set of keywords
227 * describing or circumscribing <i>this</i> person's activities.
229 * @param keyword any keyword
230 * @see #getKeywords()
231 * @see common.Keyword
233 public void addKeyword(Keyword keyword
){
234 this.keywords
.add(keyword
);
237 * Removes one element from the set of keywords for <i>this</i> person.
239 * @param keyword the keyword which should be deleted
240 * @see #getKeywords()
242 public void removeKeyword(Keyword keyword
){
243 this.keywords
.remove(keyword
);
249 * Returns the {@link Contact contact} of <i>this</i> person.
250 * The contact contains several ways to approach <i>this</i> person.
254 @ManyToOne(fetch
=FetchType
.LAZY
)
255 @Cascade({CascadeType
.SAVE_UPDATE
})
256 public Contact
getContact(){
262 public void setContact(Contact contact
){
263 this.contact
= contact
;
268 * Returns the string representing the prefix (for instance "Prof. Dr.<!-- -->")
269 * to <i>this</i> person's name.
271 public String
getPrefix(){
277 public void setPrefix(String prefix
){
278 this.prefix
= prefix
;
283 * Returns the string representing the given name or forename
284 * (for instance "John") of <i>this</i> person.
285 * This is the part of his name which is not shared with other
286 * family members. Actually it may be just initials (for instance "G. Jr."),
287 * all forenames in full or a combination of expanded names and initials.
289 public String
getFirstname(){
290 return this.firstname
;
293 * @see #getFirstname()
295 public void setFirstname(String firstname
){
296 this.firstname
= firstname
;
301 * Returns the string representing the hereditary name (surname or family name)
302 * (for instance "Smith") of <i>this</i> person.
303 * This is the part of his name which is common to (all) other
304 * members of his family, as distinct from the given name or forename.
306 public String
getLastname(){
307 return this.lastname
;
310 * @see #getLastname()
312 public void setLastname(String lastname
){
313 this.lastname
= lastname
;
318 * Returns the string representing the suffix (for instance "Junior")
319 * of <i>this</i> person's name.
321 public String
getSuffix(){
327 public void setSuffix(String suffix
){
328 this.suffix
= suffix
;
333 * Returns the {@link common.TimePeriod period of time}
334 * in which <i>this</i> person was alive (life span).
335 * The general form is birth date - death date
336 * (XXXX - YYYY; XXXX - or - YYYY as appropriate),
337 * but a simple flourished date (fl. XXXX) is also possible
338 * if that is all what is known.
340 * @see common.TimePeriod
342 public TimePeriod
getLifespan(){
343 return this.lifespan
;
346 * @see #getLifespan()
348 public void setLifespan(TimePeriod lifespan
){
349 this.lifespan
= lifespan
;
353 * Generates the "full" name string of <i>this</i> person according to the strategy
354 * defined in {@link eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy PersonDefaultCacheStrategy}.
355 * The used attributes are:
356 * {@link #prefix prefix}, {@link #firstname firstname}, {@link #lastname lastname} and {@link #suffix suffix}.
357 * This method overrides {@link common.IdentifiableEntity#generateTitle() generateTitle}.
358 * The result might be kept as {@link common.IdentifiableEntity#setTitleCache(String) titleCache} if the
359 * flag {@link common.IdentifiableEntity#protectedTitleCache protectedTitleCache} is not set.
361 * @return the string with the full name of <i>this</i> person
364 public String
generateTitle() {
366 if (cacheStrategy
!= null) {
367 title
= cacheStrategy
.getTitleCache(this);