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
.xml
.bind
.annotation
.XmlAccessType
;
19 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
20 import javax
.xml
.bind
.annotation
.XmlElement
;
21 import javax
.xml
.bind
.annotation
.XmlType
;
23 import org
.apache
.log4j
.Logger
;
24 import org
.hibernate
.annotations
.Index
;
25 import org
.hibernate
.annotations
.Table
;
26 import org
.hibernate
.envers
.Audited
;
28 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
29 import eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
30 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
31 import eu
.etaxonomy
.cdm
.strategy
.cache
.common
.IIdentifiableEntityCacheStrategy
;
32 import eu
.etaxonomy
.cdm
.strategy
.match
.IMatchable
;
33 import eu
.etaxonomy
.cdm
.strategy
.match
.Match
;
34 import eu
.etaxonomy
.cdm
.strategy
.match
.MatchMode
;
35 import eu
.etaxonomy
.cdm
.strategy
.merge
.IMergable
;
36 import eu
.etaxonomy
.cdm
.strategy
.merge
.Merge
;
37 import eu
.etaxonomy
.cdm
.strategy
.merge
.MergeMode
;
40 * The upmost (abstract) class for agents such as persons, teams or institutions.
41 * An agent is a conscious entity which can take decisions, act and create
42 * according to its own knowledge and goals and which may be approached.
43 * Agents can be authors for nomenclatural or bibliographical references as well
44 * as creators of pictures or field collectors or administrators of collections.
48 * @created 08-Nov-2007 13:06:57
50 @XmlAccessorType(XmlAccessType
.FIELD
)
51 @XmlType(name
= "Agent", propOrder
= {
56 @Table(appliesTo
="AgentBase", indexes
= { @Index(name
= "agentTitleCacheIndex", columnNames
= { "titleCache" }) })
57 public abstract class AgentBase
<S
extends IIdentifiableEntityCacheStrategy
> extends IdentifiableMediaEntity
<S
> implements IMergable
, IMatchable
{
58 private static final long serialVersionUID
= 7732768617469448829L;
59 @SuppressWarnings("unused")
60 private static final Logger logger
= Logger
.getLogger(AgentBase
.class);
62 @XmlElement(name
= "Contact")
64 @Merge(MergeMode
.MERGE
)
65 @Match(MatchMode
.IGNORE
)
66 private Contact contact
;
69 * Returns the {@link Contact contact} of <i>this</i> person.
70 * The contact contains several ways to approach <i>this</i> person.
74 public Contact
getContact(){
80 public void setContact(Contact contact
){
81 this.contact
= contact
;
86 * Returns the existing contact, or if it does not exists a new contact.
87 * If <code>create</code> is true the new contact will be set as this agent's
93 private Contact
getNewOrExistingContact(boolean create
){
97 Contact newContact
= Contact
.NewInstance();
107 * Adds a new address to this agent
115 * @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)
117 public void addAddress(String street
, String postcode
, String locality
,
118 WaterbodyOrCountry country
, String pobox
, String region
,
120 getNewOrExistingContact(true).addAddress(street
, postcode
, locality
, country
, pobox
, region
,
125 * @see eu.etaxonomy.cdm.model.agent.Contact#addAddress(eu.etaxonomy.cdm.model.agent.Address)
127 public void addAddress(Address address
) {
128 getNewOrExistingContact(true).addAddress(address
);
131 * @param emailAddress
132 * @see eu.etaxonomy.cdm.model.agent.Contact#addEmailAddress(java.lang.String)
134 public void addEmailAddress(String emailAddress
) {
135 getNewOrExistingContact(true).addEmailAddress(emailAddress
);
139 * @see eu.etaxonomy.cdm.model.agent.Contact#addFaxNumber(java.lang.String)
141 public void addFaxNumber(String faxNumber
) {
142 getNewOrExistingContact(true).addFaxNumber(faxNumber
);
146 * @see eu.etaxonomy.cdm.model.agent.Contact#addPhoneNumber(java.lang.String)
148 public void addPhoneNumber(String phoneNumber
) {
149 getNewOrExistingContact(true).addPhoneNumber(phoneNumber
);
153 * @see eu.etaxonomy.cdm.model.agent.Contact#addUrl(java.lang.String)
155 public void addUrl(String url
) {
156 getNewOrExistingContact(true).addUrl(url
);
160 * @see eu.etaxonomy.cdm.model.agent.Contact#getAddresses()
163 public Set
<Address
> getAddresses() {
164 return getNewOrExistingContact(false).getAddresses();
168 * @see eu.etaxonomy.cdm.model.agent.Contact#getEmailAddresses()
171 public List
<String
> getEmailAddresses() {
172 return getNewOrExistingContact(false).getEmailAddresses();
176 * @see eu.etaxonomy.cdm.model.agent.Contact#getFaxNumbers()
179 public List
<String
> getFaxNumbers() {
180 return getNewOrExistingContact(false).getFaxNumbers();
184 * @see eu.etaxonomy.cdm.model.agent.Contact#getPhoneNumbers()
187 public List
<String
> getPhoneNumbers() {
188 return getNewOrExistingContact(false).getPhoneNumbers();
192 * @see eu.etaxonomy.cdm.model.agent.Contact#getUrls()
195 public List
<String
> getUrls() {
196 return getNewOrExistingContact(false).getUrls();
200 * @see eu.etaxonomy.cdm.model.agent.Contact#removeAddress(eu.etaxonomy.cdm.model.agent.Address)
202 public void removeAddress(Address address
) {
203 getNewOrExistingContact(false).removeAddress(address
);
206 * @param emailAddress
207 * @see eu.etaxonomy.cdm.model.agent.Contact#removeEmailAddress(java.lang.String)
209 public void removeEmailAddress(String emailAddress
) {
210 getNewOrExistingContact(false).removeEmailAddress(emailAddress
);
214 * @see eu.etaxonomy.cdm.model.agent.Contact#removeFaxNumber(java.lang.String)
216 public void removeFaxNumber(String faxNumber
) {
217 getNewOrExistingContact(false).removeFaxNumber(faxNumber
);
221 * @see eu.etaxonomy.cdm.model.agent.Contact#removePhoneNumber(java.lang.String)
223 public void removePhoneNumber(String phoneNumber
) {
224 getNewOrExistingContact(false).removePhoneNumber(phoneNumber
);
228 * @see eu.etaxonomy.cdm.model.agent.Contact#removeUrl(java.lang.String)
230 public void removeUrl(String url
) {
231 getNewOrExistingContact(false).removeUrl(url
);