001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.kuali.kfs.vnd.businessobject;
018
019 import java.util.LinkedHashMap;
020 import java.util.List;
021
022 import org.apache.commons.lang.builder.EqualsBuilder;
023 import org.apache.log4j.Logger;
024 import org.kuali.rice.kns.bo.Country;
025 import org.kuali.rice.kns.bo.State;
026 import org.kuali.kfs.sys.context.SpringContext;
027 import org.kuali.rice.kns.service.CountryService;
028 import org.kuali.rice.kns.service.StateService;
029 import org.kuali.kfs.vnd.document.service.VendorService;
030 import org.kuali.rice.kns.bo.Inactivateable;
031 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
032 import org.kuali.rice.kns.util.ObjectUtils;
033 import org.kuali.rice.kns.util.TypedArrayList;
034
035 /**
036 * Address to be associated with a particular Vendor.
037 */
038 public class VendorAddress extends PersistableBusinessObjectBase implements VendorRoutingComparable, Inactivateable {
039 private static Logger LOG = Logger.getLogger(VendorAddress.class);
040
041 private Integer vendorAddressGeneratedIdentifier;
042 private Integer vendorHeaderGeneratedIdentifier;
043 private Integer vendorDetailAssignedIdentifier;
044 private String vendorAddressTypeCode;
045 private String vendorLine1Address;
046 private String vendorLine2Address;
047 private String vendorCityName;
048 private String vendorStateCode;
049 private String vendorZipCode;
050 private String vendorCountryCode;
051 private String vendorAttentionName;
052 private String vendorAddressInternationalProvinceName;
053 private String vendorAddressEmailAddress;
054 private String vendorBusinessToBusinessUrlAddress;
055 private String vendorFaxNumber;
056 private boolean vendorDefaultAddressIndicator;
057 private boolean active;
058
059 private List<VendorDefaultAddress> vendorDefaultAddresses;
060
061 private VendorDetail vendorDetail;
062 private AddressType vendorAddressType;
063 private State vendorState;
064 private Country vendorCountry;
065
066 /**
067 * Default constructor.
068 */
069 public VendorAddress() {
070 vendorDefaultAddresses = new TypedArrayList(VendorDefaultAddress.class);
071 }
072
073 public Integer getVendorAddressGeneratedIdentifier() {
074 return vendorAddressGeneratedIdentifier;
075 }
076
077 public void setVendorAddressGeneratedIdentifier(Integer vendorAddressGeneratedIdentifier) {
078 this.vendorAddressGeneratedIdentifier = vendorAddressGeneratedIdentifier;
079 }
080
081 public Integer getVendorHeaderGeneratedIdentifier() {
082 return vendorHeaderGeneratedIdentifier;
083 }
084
085 public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
086 this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
087 }
088
089 public Integer getVendorDetailAssignedIdentifier() {
090 return vendorDetailAssignedIdentifier;
091 }
092
093 public void setVendorDetailAssignedIdentifier(Integer vendorDetailAssignedIdentifier) {
094 this.vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier;
095 }
096
097 public String getVendorAddressInternationalProvinceName() {
098 return vendorAddressInternationalProvinceName;
099 }
100
101 public void setVendorAddressInternationalProvinceName(String vendorAddressInternationalProvinceName) {
102 this.vendorAddressInternationalProvinceName = vendorAddressInternationalProvinceName;
103 }
104
105 public String getVendorAddressEmailAddress() {
106 return vendorAddressEmailAddress;
107 }
108
109 public void setVendorAddressEmailAddress(String vendorAddressEmailAddress) {
110 this.vendorAddressEmailAddress = vendorAddressEmailAddress;
111 }
112
113 public String getVendorAddressTypeCode() {
114 return vendorAddressTypeCode;
115 }
116
117 public void setVendorAddressTypeCode(String vendorAddressTypeCode) {
118 this.vendorAddressTypeCode = vendorAddressTypeCode;
119 }
120
121 public String getVendorLine1Address() {
122 return vendorLine1Address;
123 }
124
125 public void setVendorLine1Address(String vendorLine1Address) {
126 this.vendorLine1Address = vendorLine1Address;
127 }
128
129 public String getVendorLine2Address() {
130 return vendorLine2Address;
131 }
132
133 public void setVendorLine2Address(String vendorLine2Address) {
134 this.vendorLine2Address = vendorLine2Address;
135 }
136
137 public String getVendorCityName() {
138 return vendorCityName;
139 }
140
141 public void setVendorCityName(String vendorCityName) {
142 this.vendorCityName = vendorCityName;
143 }
144
145 public String getVendorStateCode() {
146 return vendorStateCode;
147 }
148
149 public void setVendorStateCode(String vendorStateCode) {
150 this.vendorStateCode = vendorStateCode;
151 }
152
153 public String getVendorZipCode() {
154 return vendorZipCode;
155 }
156
157 public void setVendorZipCode(String vendorZipCode) {
158 this.vendorZipCode = vendorZipCode;
159 }
160
161 public String getVendorCountryCode() {
162 return vendorCountryCode;
163 }
164
165 public void setVendorCountryCode(String vendorCountryCode) {
166 this.vendorCountryCode = vendorCountryCode;
167 }
168
169 public String getVendorAttentionName() {
170 return vendorAttentionName;
171 }
172
173 public void setVendorAttentionName(String vendorAttentionName) {
174 this.vendorAttentionName = vendorAttentionName;
175 }
176
177 public String getVendorBusinessToBusinessUrlAddress() {
178 return vendorBusinessToBusinessUrlAddress;
179 }
180
181 public void setVendorBusinessToBusinessUrlAddress(String vendorBusinessToBusinessUrlAddress) {
182 this.vendorBusinessToBusinessUrlAddress = vendorBusinessToBusinessUrlAddress;
183 }
184
185 public VendorDetail getVendorDetail() {
186 return vendorDetail;
187 }
188
189 /**
190 * Sets the vendorDetail attribute.
191 *
192 * @param vendorDetail The vendorDetail to set.
193 * @deprecated
194 */
195 public void setVendorDetail(VendorDetail vendorDetail) {
196 this.vendorDetail = vendorDetail;
197 }
198
199 public AddressType getVendorAddressType() {
200 return vendorAddressType;
201 }
202
203 /**
204 * Sets the vendorAddressType attribute.
205 *
206 * @param vendorAddressType The vendorAddressType to set.
207 * @deprecated
208 */
209 public void setVendorAddressType(AddressType vendorAddressType) {
210 this.vendorAddressType = vendorAddressType;
211 }
212
213 public State getVendorState() {
214 vendorState = SpringContext.getBean(StateService.class).getByPrimaryIdIfNecessary(vendorCountryCode, vendorStateCode, vendorState);
215 return vendorState;
216 }
217
218 /**
219 * Sets the vendorState attribute.
220 *
221 * @param vendorState The vendorState to set.
222 * @deprecated
223 */
224 public void setVendorState(State vendorState) {
225 this.vendorState = vendorState;
226 }
227
228 public Country getVendorCountry() {
229 vendorCountry = SpringContext.getBean(CountryService.class).getByPrimaryIdIfNecessary(vendorCountryCode, vendorCountry);
230 return vendorCountry;
231 }
232
233 /**
234 * Sets the vendorCountry attribute.
235 *
236 * @param vendorCountry The vendorCountry to set.
237 * @deprecated
238 */
239 public void setVendorCountry(Country vendorCountry) {
240 this.vendorCountry = vendorCountry;
241 }
242
243 /**
244 * Gets the vendorFaxNumber attribute.
245 *
246 * @return Returns the vendorFaxNumber.
247 */
248 public String getVendorFaxNumber() {
249 return vendorFaxNumber;
250 }
251
252 /**
253 * Sets the vendorFaxNumber attribute value.
254 *
255 * @param vendorFaxNumber The vendorFaxNumber to set.
256 */
257 public void setVendorFaxNumber(String vendorFaxNumber) {
258 this.vendorFaxNumber = vendorFaxNumber;
259 }
260
261 /**
262 * Gets the vendorDefaultAddressIndicator attribute.
263 *
264 * @return Returns the vendorDefaultAddressIndicator.
265 */
266 public boolean isVendorDefaultAddressIndicator() {
267 return vendorDefaultAddressIndicator;
268 }
269
270 /**
271 * Sets the vendorDefaultAddressIndicator attribute value.
272 *
273 * @param vendorDefaultAddressIndicator The vendorDefaultAddressIndicator to set.
274 */
275 public void setVendorDefaultAddressIndicator(boolean vendorDefaultAddressIndicator) {
276 this.vendorDefaultAddressIndicator = vendorDefaultAddressIndicator;
277 }
278
279 public boolean isActive() {
280 return active;
281 }
282
283 public void setActive(boolean active) {
284 this.active = active;
285 }
286
287 public List<VendorDefaultAddress> getVendorDefaultAddresses() {
288 return vendorDefaultAddresses;
289 }
290
291 public void setVendorDefaultAddresses(List<VendorDefaultAddress> vendorDefaultAddresses) {
292 this.vendorDefaultAddresses = vendorDefaultAddresses;
293 }
294
295 /**
296 * @see org.kuali.kfs.vnd.document.routing.VendorRoutingComparable#isEqualForRouting(java.lang.Object)
297 */
298 public boolean isEqualForRouting(Object toCompare) {
299 LOG.debug("Entering isEqualForRouting.");
300 if ((ObjectUtils.isNull(toCompare)) || !(toCompare instanceof VendorAddress)) {
301 LOG.debug("Exiting isEqualForRouting");
302 return false;
303 }
304 else {
305 VendorAddress va = (VendorAddress) toCompare;
306 boolean eq = new EqualsBuilder().append(this.getVendorAddressGeneratedIdentifier(), va.getVendorAddressGeneratedIdentifier()).append(this.getVendorHeaderGeneratedIdentifier(), va.getVendorHeaderGeneratedIdentifier()).append(this.getVendorDetailAssignedIdentifier(), va.getVendorDetailAssignedIdentifier()).append(this.getVendorAddressTypeCode(), va.getVendorAddressTypeCode()).append(this.getVendorLine1Address(), va.getVendorLine1Address()).append(this.getVendorLine2Address(), va.getVendorLine2Address()).append(this.getVendorCityName(), va.getVendorCityName()).append(this.getVendorStateCode(), va.getVendorStateCode()).append(this.getVendorZipCode(), va.getVendorZipCode()).append(this.getVendorCountryCode(), va.getVendorCountryCode()).append(this.getVendorAttentionName(), va.getVendorAttentionName()).append(this.getVendorAddressInternationalProvinceName(), va.getVendorAddressInternationalProvinceName()).append(this.getVendorAddressEmailAddress(),
307 va.getVendorAddressEmailAddress()).append(this.getVendorBusinessToBusinessUrlAddress(), va.getVendorBusinessToBusinessUrlAddress()).append(this.getVendorFaxNumber(), va.getVendorFaxNumber()).append(this.isVendorDefaultAddressIndicator(), va.isVendorDefaultAddressIndicator()).isEquals();
308 eq &= SpringContext.getBean(VendorService.class).equalMemberLists(this.getVendorDefaultAddresses(), va.getVendorDefaultAddresses());
309 LOG.debug("Exiting isEqualForRouting.");
310 return eq;
311 }
312 }
313
314 /**
315 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
316 */
317 protected LinkedHashMap toStringMapper() {
318 LinkedHashMap m = new LinkedHashMap();
319 if (this.vendorAddressGeneratedIdentifier != null) {
320 m.put("vendorAddressGeneratedIdentifier", this.vendorAddressGeneratedIdentifier.toString());
321 }
322 return m;
323 }
324
325 }