warning clean cdmlib-model agent and jaxb
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / agent / Address.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.cdm.model.agent;
11
12 import javax.persistence.Entity;
13 import javax.persistence.ManyToOne;
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlIDREF;
18 import javax.xml.bind.annotation.XmlRootElement;
19 import javax.xml.bind.annotation.XmlSchemaType;
20 import javax.xml.bind.annotation.XmlTransient;
21 import javax.xml.bind.annotation.XmlType;
22
23 import org.apache.log4j.Logger;
24
25 import eu.etaxonomy.cdm.model.common.VersionableEntity;
26 import eu.etaxonomy.cdm.model.location.Point;
27 import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;
28
29 /**
30 * This class represents atomized postal addresses.
31 * <P>
32 * This class corresponds to: <ul>
33 * <li> Address according to the TDWG ontology
34 * <li> Address according to the TCS
35 * <li> Address according to the ABCD schema
36 * </ul>
37 *
38 * @author m.doering
39 * @version 1.0
40 * @created 08-Nov-2007 13:06:09
41 */
42 @XmlAccessorType(XmlAccessType.FIELD)
43 @XmlType(name = "", propOrder = {
44 "pobox",
45 "street",
46 "postcode",
47 "locality",
48 "region",
49 "country",
50 "location",
51 "contact"
52 })
53 @XmlRootElement(name = "Address")
54 @Entity
55 public class Address extends VersionableEntity<Address> {
56
57 /**
58 *
59 */
60 private static final long serialVersionUID = 682106303069088972L;
61
62 static Logger logger = Logger.getLogger(Address.class);
63
64 @XmlElement(name = "POBox")
65 private String pobox;
66
67 @XmlElement(name = "Street")
68 private String street;
69
70 @XmlElement(name = "Postcode")
71 private String postcode;
72
73 @XmlElement(name = "Locality", required = true)
74 private String locality;
75
76 @XmlElement(name = "Region")
77 private String region;
78
79 @XmlElement(name = "Country")
80 @XmlIDREF
81 @XmlSchemaType(name = "IDREF")
82 private WaterbodyOrCountry country;
83
84 @XmlElement(name = "Location")
85 private Point location;
86
87 //Bidirectional only private
88 @XmlElement(name = "Contact")
89 private Contact contact;
90
91
92 /**
93 * Returns the {@link Contact contact} (of a {@link Person person} or of an {@link Institution institution})
94 * to which <i>this</i> address belongs.
95 * Both kinds of agents cannot have more than one contact, but a contact may include
96 * several postal addresses.
97 *
98 * @return the contact <i>this</i> postal address belongs to
99 * @see Contact
100 */
101 @ManyToOne
102 public Contact getContact() {
103 return contact;
104 }
105
106
107 /**
108 * Adds <i>this</i> postal address to the set of addresses of a {@link Contact contact}.
109 * The same address instance cannot be assigned to different persons
110 * or institutions (if they do have the same postal address several
111 * address instances must be created). If <i>this</i> address already belongs to a
112 * contact this method shifts it from this contact to a new one.
113 * Therefore <i>this</i> address will be removed from the set of addresses of the old
114 * contact and added to the set of the new one.
115 *
116 * @param newContact the new contact to which <i>this</i> postal address should belong
117 * @see Contact#addAddress(Address)
118 * @see Contact#removeAddress(Address)
119 */
120 protected void setContact(Contact newContact) {
121 this.contact = newContact;
122 }
123
124
125 /**
126 * Returns the {@link WaterbodyOrCountry country} involved in <i>this</i> postal address.
127 *
128 * @return the country
129 */
130 @ManyToOne
131 public WaterbodyOrCountry getCountry(){
132 return this.country;
133 }
134
135 /**
136 * @see #getCountry()
137 */
138 public void setCountry(WaterbodyOrCountry country){
139 this.country = country;
140 }
141
142 /**
143 * Returns the geophysical {@link Point location} (coordinates) of <i>this</i> postal address.
144 * The location can be useful for instance to visualize the address on a map.
145 *
146 * @return the point corresponding to <i>this</i> address
147 * @see eu.etaxonomy.cdm.model.location.Point
148 */
149 @XmlTransient
150 public Point getLocation(){
151 return this.location;
152 }
153
154 /**
155 * @see #getLocation()
156 */
157 public void setLocation(Point location){
158 this.location = location;
159 }
160
161 /**
162 * Returns a string corresponding to the post office box
163 * involved in <i>this</i> postal address.
164 *
165 * @return the post office box string
166 */
167 public String getPobox(){
168 return this.pobox;
169 }
170
171 /**
172 * @see #getPobox()
173 */
174 public void setPobox(String pobox){
175 this.pobox = pobox;
176 }
177
178 /**
179 * Returns the street name and number involved in <i>this</i> postal address.
180 * Street numbers are part of the street string.
181 *
182 * @return the string composed of street name and number
183 */
184 public String getStreet(){
185 return this.street;
186 }
187
188 /**
189 * @see #getStreet()
190 */
191 public void setStreet(String street){
192 this.street = street;
193 }
194
195 /**
196 * Returns the post code number involved in <i>this</i> postal address.
197 *
198 * @return the post code number string
199 */
200 public String getPostcode(){
201 return this.postcode;
202 }
203
204 /**
205 * @see #getPostcode()
206 */
207 public void setPostcode(String postcode){
208 this.postcode = postcode;
209 }
210
211 /**
212 * Returns the town (possibly with locality or suburb) involved in <i>this</i> postal address.
213 *
214 * @return the string representing a town
215 */
216 public String getLocality(){
217 return this.locality;
218 }
219
220 /**
221 * @see #getLocality()
222 */
223 public void setLocality(String locality){
224 this.locality = locality;
225 }
226
227 /**
228 * Returns the region or state involved in <i>this</i> postal address.
229 *
230 * @return the string representing a region or a state
231 */
232 public String getRegion(){
233 return this.region;
234 }
235
236 /**
237 * @see #getRegion()
238 */
239 public void setRegion(String region){
240 this.region = region;
241 }
242
243 }