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 java
.util
.List
;
15 import javax
.persistence
.Embedded
;
16 import javax
.persistence
.Entity
;
17 import javax
.persistence
.Transient
;
18 import javax
.validation
.constraints
.NotNull
;
19 import javax
.xml
.bind
.annotation
.XmlAccessType
;
20 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
21 import javax
.xml
.bind
.annotation
.XmlElement
;
22 import javax
.xml
.bind
.annotation
.XmlType
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.hibernate
.annotations
.Index
;
26 import org
.hibernate
.annotations
.Table
;
27 import org
.hibernate
.envers
.Audited
;
29 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
30 import eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
31 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
32 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
33 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchable
;
34 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
35 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
36 import eu
.etaxonomy
.cdm
.strategy
.merge
.IMergable
;
37 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
38 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
41 * The upmost (abstract) class for agents such as persons, teams or institutions.
42 * An agent is a conscious entity which can make decisions, act and create
43 * according to its own knowledge and goals and which may be approached.
44 * Agents can be authors for nomenclatural or bibliographical references as well
45 * as creators of pictures or field collectors or administrators of collections.
49 * @created 08-Nov-2007 13:06:57
51 @XmlAccessorType(XmlAccessType
.FIELD
)
52 @XmlType(name
= "AgentBase", propOrder
= {
57 @Table(appliesTo
="AgentBase", indexes
= { @Index(name
= "agentTitleCacheIndex", columnNames
= { "titleCache" }) })
58 public abstract class AgentBase
<S
extends IIdentifiableEntityCacheStrategy
> extends IdentifiableMediaEntity
<S
> implements IMergable
, IMatchable
, Cloneable
{
59 private static final long serialVersionUID
= 7732768617469448829L;
60 @SuppressWarnings("unused")
61 private static final Logger logger
= Logger
.getLogger(AgentBase
.class);
63 @XmlElement(name
= "Contact")
65 @Merge(MergeMode
.MERGE
)
66 @Match(MatchMode
.IGNORE
)
68 private Contact contact
;
71 * Returns the {@link Contact contact} of <i>this</i> person.
72 * The contact contains several ways to approach <i>this</i> person.
76 public Contact
getContact(){
78 this.contact
= new Contact();
85 public void setContact(Contact contact
){
86 this.contact
= contact
;
91 * Returns the existing contact, or if it does not exists a new contact.
92 * If <code>create</code> is true the new contact will be set as this agent's
98 private Contact
getNewOrExistingContact(boolean create
){
102 Contact newContact
= Contact
.NewInstance();
104 contact
= newContact
;
112 * Adds a new address to this agent
120 * @see eu.etaxonomy.cdm.model.agent.Contact#addAddress(java.lang.String, java.lang.String, java.lang.String, eu.etaxonomy.cdm.model.location.WaterbodyOrCountry, java.lang.String, java.lang.String, eu.etaxonomy.cdm.model.location.Point)
122 public void addAddress(String street
, String postcode
, String locality
,
123 WaterbodyOrCountry country
, String pobox
, String region
,
125 getNewOrExistingContact(true).addAddress(street
, postcode
, locality
, country
, pobox
, region
,
130 * @see eu.etaxonomy.cdm.model.agent.Contact#addAddress(eu.etaxonomy.cdm.model.agent.Address)
132 public void addAddress(Address address
) {
133 getNewOrExistingContact(true).addAddress(address
);
136 * @param emailAddress
137 * @see eu.etaxonomy.cdm.model.agent.Contact#addEmailAddress(java.lang.String)
139 public void addEmailAddress(String emailAddress
) {
140 getNewOrExistingContact(true).addEmailAddress(emailAddress
);
144 * @see eu.etaxonomy.cdm.model.agent.Contact#addFaxNumber(java.lang.String)
146 public void addFaxNumber(String faxNumber
) {
147 getNewOrExistingContact(true).addFaxNumber(faxNumber
);
151 * @see eu.etaxonomy.cdm.model.agent.Contact#addPhoneNumber(java.lang.String)
153 public void addPhoneNumber(String phoneNumber
) {
154 getNewOrExistingContact(true).addPhoneNumber(phoneNumber
);
158 * @see eu.etaxonomy.cdm.model.agent.Contact#addUrl(java.lang.String)
160 public void addUrl(String url
) {
161 getNewOrExistingContact(true).addUrl(url
);
165 * @see eu.etaxonomy.cdm.model.agent.Contact#getAddresses()
168 public Set
<Address
> getAddresses() {
169 return getNewOrExistingContact(false).getAddresses();
173 * @see eu.etaxonomy.cdm.model.agent.Contact#getEmailAddresses()
176 public List
<String
> getEmailAddresses() {
177 return getNewOrExistingContact(false).getEmailAddresses();
181 * @see eu.etaxonomy.cdm.model.agent.Contact#getFaxNumbers()
184 public List
<String
> getFaxNumbers() {
185 return getNewOrExistingContact(false).getFaxNumbers();
189 * @see eu.etaxonomy.cdm.model.agent.Contact#getPhoneNumbers()
192 public List
<String
> getPhoneNumbers() {
193 return getNewOrExistingContact(false).getPhoneNumbers();
197 * @see eu.etaxonomy.cdm.model.agent.Contact#getUrls()
200 public List
<String
> getUrls() {
201 return getNewOrExistingContact(false).getUrls();
205 * @see eu.etaxonomy.cdm.model.agent.Contact#removeAddress(eu.etaxonomy.cdm.model.agent.Address)
207 public void removeAddress(Address address
) {
208 getNewOrExistingContact(false).removeAddress(address
);
211 * @param emailAddress
212 * @see eu.etaxonomy.cdm.model.agent.Contact#removeEmailAddress(java.lang.String)
214 public void removeEmailAddress(String emailAddress
) {
215 getNewOrExistingContact(false).removeEmailAddress(emailAddress
);
219 * @see eu.etaxonomy.cdm.model.agent.Contact#removeFaxNumber(java.lang.String)
221 public void removeFaxNumber(String faxNumber
) {
222 getNewOrExistingContact(false).removeFaxNumber(faxNumber
);
226 * @see eu.etaxonomy.cdm.model.agent.Contact#removePhoneNumber(java.lang.String)
228 public void removePhoneNumber(String phoneNumber
) {
229 getNewOrExistingContact(false).removePhoneNumber(phoneNumber
);
233 * @see eu.etaxonomy.cdm.model.agent.Contact#removeUrl(java.lang.String)
235 public void removeUrl(String url
) {
236 getNewOrExistingContact(false).removeUrl(url
);