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
|
|
13
|
import eu.etaxonomy.cdm.model.location.WaterbodyOrCountry;
|
14
|
import eu.etaxonomy.cdm.model.location.Point;
|
15
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
16
|
import org.apache.log4j.Logger;
|
17
|
import java.util.*;
|
18
|
import javax.persistence.*;
|
19
|
|
20
|
/**
|
21
|
* Representation of an atomized postal address.
|
22
|
* <p>
|
23
|
* See also the <a href="http://rs.tdwg.org/ontology/voc/ContactDetails#Address">TDWG Ontology</a>
|
24
|
*
|
25
|
* @author m.doering
|
26
|
* @version 1.0
|
27
|
* @created 08-Nov-2007 13:06:09
|
28
|
*/
|
29
|
@Entity
|
30
|
public class Address extends VersionableEntity {
|
31
|
static Logger logger = Logger.getLogger(Address.class);
|
32
|
private String pobox;
|
33
|
private String street;
|
34
|
private String postcode;
|
35
|
private String locality;
|
36
|
private String region;
|
37
|
private WaterbodyOrCountry country;
|
38
|
private Point location;
|
39
|
//Bidirectional only private
|
40
|
private Contact contact;
|
41
|
|
42
|
|
43
|
@ManyToOne
|
44
|
public Contact getContact() {
|
45
|
return contact;
|
46
|
}
|
47
|
/**
|
48
|
* Assigns this postal address to a new contact.
|
49
|
* This method also updates the sets of postal addresses
|
50
|
* which belong to the two contacts (the new one and the substituted one).
|
51
|
*
|
52
|
* @param newContact the new contact to which this postal address should belong
|
53
|
* @see Contact#addAddress(Address)
|
54
|
* @see Contact#removeAddress(Address)
|
55
|
*/
|
56
|
protected void setContact(Contact newContact) {
|
57
|
// Hibernate bidirectional cascade hack:
|
58
|
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
|
59
|
if(this.contact == newContact) return;
|
60
|
if (contact != null) {
|
61
|
contact.addresses.remove(this);
|
62
|
}
|
63
|
if (newContact!= null) {
|
64
|
newContact.addresses.add(this);
|
65
|
}
|
66
|
this.contact = newContact;
|
67
|
}
|
68
|
|
69
|
|
70
|
@ManyToOne
|
71
|
public WaterbodyOrCountry getCountry(){
|
72
|
return this.country;
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* Assigns a country to this postal address.
|
77
|
*
|
78
|
* @param country the (waterbody or) country
|
79
|
*/
|
80
|
public void setCountry(WaterbodyOrCountry country){
|
81
|
this.country = country;
|
82
|
}
|
83
|
|
84
|
public Point getLocation(){
|
85
|
return this.location;
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* Assigns a geophysical location to this postal address.
|
90
|
*
|
91
|
* @param location the point corresponding to this address
|
92
|
* @see location.Point
|
93
|
*/
|
94
|
public void setLocation(Point location){
|
95
|
this.location = location;
|
96
|
}
|
97
|
|
98
|
public String getPobox(){
|
99
|
return this.pobox;
|
100
|
}
|
101
|
|
102
|
/**
|
103
|
* Assigns a post office box to this postal address.
|
104
|
*
|
105
|
* @param pobox string describing a post office box
|
106
|
*/
|
107
|
public void setPobox(String pobox){
|
108
|
this.pobox = pobox;
|
109
|
}
|
110
|
|
111
|
public String getStreet(){
|
112
|
return this.street;
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* Assigns a street name and number to this postal address.
|
117
|
*
|
118
|
* @param street string containing a street name and a street number
|
119
|
*/
|
120
|
public void setStreet(String street){
|
121
|
this.street = street;
|
122
|
}
|
123
|
|
124
|
public String getPostcode(){
|
125
|
return this.postcode;
|
126
|
}
|
127
|
|
128
|
/**
|
129
|
* Assigns a post code number to this postal address.
|
130
|
*
|
131
|
* @param postcode string representing a post code
|
132
|
*/
|
133
|
public void setPostcode(String postcode){
|
134
|
this.postcode = postcode;
|
135
|
}
|
136
|
|
137
|
public String getLocality(){
|
138
|
return this.locality;
|
139
|
}
|
140
|
|
141
|
/**
|
142
|
* Assigns a town (possibly with locality or suburb) to this postal address.
|
143
|
*
|
144
|
* @param locality string representing a town (may include locality or suburb)
|
145
|
*/
|
146
|
public void setLocality(String locality){
|
147
|
this.locality = locality;
|
148
|
}
|
149
|
|
150
|
public String getRegion(){
|
151
|
return this.region;
|
152
|
}
|
153
|
|
154
|
/**
|
155
|
* Assigns a region or state to this postal address.
|
156
|
*
|
157
|
* @param region string representing a region or a state
|
158
|
*/
|
159
|
public void setRegion(String region){
|
160
|
this.region = region;
|
161
|
}
|
162
|
|
163
|
}
|