BrightSide Workbench Full Report + Source Code
Address.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.contacts;
19 
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.Id;
24 import javax.persistence.JoinColumn;
25 import javax.persistence.ManyToOne;
26 import org.turro.jpa.entity.IDaoEntity;
27 import org.turro.util.PhraseBuilder;
28 import org.zkoss.lang.Strings;
29 
30 @Entity
31 @org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid", strategy = "uuid")
32 public class Address implements java.io.Serializable, IDaoEntity {
33 
34  @Id
35  @GeneratedValue(generator = "hibernate-uuid")
36  @Column(name="IDENTIFIER")
37  private String id;
38 
39  private String owner;
40 
41  private boolean onlyOwner;
42 
43  private String street;
44 
45  private String zipCode;
46 
47  private String city;
48 
49  private String province;
50 
51  @Column(name="ADDRESS_STATE")
52  private String state;
53 
54  private String description;
55 
56  private double latitude, longitude;
57 
58  @ManyToOne
59  @JoinColumn(name="CONTACT_FK")
60  private org.turro.contacts.Contact contact;
61 
62  public String getFullAddress() {
63  String result = "";
64  if(getDescription() != null) result = getDescription() + ":";
65  return result + getAddressString();
66  }
67 
68  public String getAddressString() {
69  PhraseBuilder pb = new PhraseBuilder();
70  pb.addWord(street);
71  pb.addWord(zipCode);
72  pb.addWord(city);
73  pb.addWord(province);
74  pb.addWord(state);
75  return pb.toString();
76  }
77 
78  public String getId() {
79  return id;
80  }
81 
82  protected void setId(String id) {
83  this.id = id;
84  }
85 
86  public String getOwner() {
87  return owner;
88  }
89 
90  public void setOwner(String owner) {
91  this.owner = owner;
92  }
93 
94  public boolean isOnlyOwner() {
95  return onlyOwner;
96  }
97 
98  public void setOnlyOwner(boolean onlyOwner) {
99  this.onlyOwner = onlyOwner;
100  }
101 
102  public String getStreet() {
103  return street;
104  }
105 
106  public void setStreet(String street) {
107  this.street = street;
108  }
109 
110  public String getZipCode() {
111  return zipCode;
112  }
113 
114  public void setZipCode(String zipCode) {
115  this.zipCode = zipCode;
116  }
117 
118  public String getCity() {
119  return city;
120  }
121 
122  public void setCity(String city) {
123  this.city = city;
124  }
125 
126  public String getProvince() {
127  return province;
128  }
129 
130  public void setProvince(String province) {
131  this.province = province;
132  }
133 
134  public String getState() {
135  return state;
136  }
137 
138  public void setState(String state) {
139  this.state = state;
140  }
141 
142  public String getDescription() {
143  return description;
144  }
145 
146  public void setDescription(String description) {
147  this.description = description;
148  }
149 
150  public double getLatitude() {
151  return latitude;
152  }
153 
154  public void setLatitude(double latitude) {
155  this.latitude = latitude;
156  }
157 
158  public double getLongitude() {
159  return longitude;
160  }
161 
162  public void setLongitude(double longitude) {
163  this.longitude = longitude;
164  }
165 
166  public org.turro.contacts.Contact getContact() {
167  return contact;
168  }
169 
170  public void setContact(org.turro.contacts.Contact contact) {
171  this.contact = contact;
172  }
173 
174  public boolean getCanShow(String userId) {
175  return true;
176  }
177 
178  /* IDaoEntity */
179 
180  @Override
181  public Object entityId() {
182  return id;
183  }
184 
185  @Override
186  public boolean isEmpty() {
187  return Strings.isEmpty(description) || Strings.isEmpty(street);
188  }
189 
190 }
void setProvince(String province)
Definition: Address.java:130
void setState(String state)
Definition: Address.java:138
boolean getCanShow(String userId)
Definition: Address.java:174
org.turro.contacts.Contact getContact()
Definition: Address.java:166
void setLatitude(double latitude)
Definition: Address.java:154
void setOwner(String owner)
Definition: Address.java:90
void setZipCode(String zipCode)
Definition: Address.java:114
void setOnlyOwner(boolean onlyOwner)
Definition: Address.java:98
void setCity(String city)
Definition: Address.java:122
void setStreet(String street)
Definition: Address.java:106
void setId(String id)
Definition: Address.java:82
void setDescription(String description)
Definition: Address.java:146
void setContact(org.turro.contacts.Contact contact)
Definition: Address.java:170
void setLongitude(double longitude)
Definition: Address.java:162