001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.vendor.bo;
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.core.bo.Inactivateable;
025: import org.kuali.core.bo.PersistableBusinessObjectBase;
026: import org.kuali.core.util.ObjectUtils;
027: import org.kuali.core.util.TypedArrayList;
028: import org.kuali.kfs.bo.Country;
029: import org.kuali.kfs.bo.State;
030: import org.kuali.kfs.context.SpringContext;
031: import org.kuali.module.vendor.service.VendorService;
032: import org.kuali.module.vendor.util.VendorRoutingComparable;
033:
034: /**
035: * Address to be associated with a particular Vendor.
036: */
037: public class VendorAddress extends PersistableBusinessObjectBase
038: 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(
071: VendorDefaultAddress.class);
072: }
073:
074: public Integer getVendorAddressGeneratedIdentifier() {
075: return vendorAddressGeneratedIdentifier;
076: }
077:
078: public void setVendorAddressGeneratedIdentifier(
079: Integer vendorAddressGeneratedIdentifier) {
080: this .vendorAddressGeneratedIdentifier = vendorAddressGeneratedIdentifier;
081: }
082:
083: public Integer getVendorHeaderGeneratedIdentifier() {
084: return vendorHeaderGeneratedIdentifier;
085: }
086:
087: public void setVendorHeaderGeneratedIdentifier(
088: Integer vendorHeaderGeneratedIdentifier) {
089: this .vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
090: }
091:
092: public Integer getVendorDetailAssignedIdentifier() {
093: return vendorDetailAssignedIdentifier;
094: }
095:
096: public void setVendorDetailAssignedIdentifier(
097: Integer vendorDetailAssignedIdentifier) {
098: this .vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier;
099: }
100:
101: public String getVendorAddressInternationalProvinceName() {
102: return vendorAddressInternationalProvinceName;
103: }
104:
105: public void setVendorAddressInternationalProvinceName(
106: String vendorAddressInternationalProvinceName) {
107: this .vendorAddressInternationalProvinceName = vendorAddressInternationalProvinceName;
108: }
109:
110: public String getVendorAddressEmailAddress() {
111: return vendorAddressEmailAddress;
112: }
113:
114: public void setVendorAddressEmailAddress(
115: String vendorAddressEmailAddress) {
116: this .vendorAddressEmailAddress = vendorAddressEmailAddress;
117: }
118:
119: public String getVendorAddressTypeCode() {
120: return vendorAddressTypeCode;
121: }
122:
123: public void setVendorAddressTypeCode(String vendorAddressTypeCode) {
124: this .vendorAddressTypeCode = vendorAddressTypeCode;
125: }
126:
127: public String getVendorLine1Address() {
128: return vendorLine1Address;
129: }
130:
131: public void setVendorLine1Address(String vendorLine1Address) {
132: this .vendorLine1Address = vendorLine1Address;
133: }
134:
135: public String getVendorLine2Address() {
136: return vendorLine2Address;
137: }
138:
139: public void setVendorLine2Address(String vendorLine2Address) {
140: this .vendorLine2Address = vendorLine2Address;
141: }
142:
143: public String getVendorCityName() {
144: return vendorCityName;
145: }
146:
147: public void setVendorCityName(String vendorCityName) {
148: this .vendorCityName = vendorCityName;
149: }
150:
151: public String getVendorStateCode() {
152: return vendorStateCode;
153: }
154:
155: public void setVendorStateCode(String vendorStateCode) {
156: this .vendorStateCode = vendorStateCode;
157: }
158:
159: public String getVendorZipCode() {
160: return vendorZipCode;
161: }
162:
163: public void setVendorZipCode(String vendorZipCode) {
164: this .vendorZipCode = vendorZipCode;
165: }
166:
167: public String getVendorCountryCode() {
168: return vendorCountryCode;
169: }
170:
171: public void setVendorCountryCode(String vendorCountryCode) {
172: this .vendorCountryCode = vendorCountryCode;
173: }
174:
175: public String getVendorAttentionName() {
176: return vendorAttentionName;
177: }
178:
179: public void setVendorAttentionName(String vendorAttentionName) {
180: this .vendorAttentionName = vendorAttentionName;
181: }
182:
183: public String getVendorBusinessToBusinessUrlAddress() {
184: return vendorBusinessToBusinessUrlAddress;
185: }
186:
187: public void setVendorBusinessToBusinessUrlAddress(
188: String vendorBusinessToBusinessUrlAddress) {
189: this .vendorBusinessToBusinessUrlAddress = vendorBusinessToBusinessUrlAddress;
190: }
191:
192: public VendorDetail getVendorDetail() {
193: return vendorDetail;
194: }
195:
196: /**
197: * Sets the vendorDetail attribute.
198: *
199: * @param vendorDetail The vendorDetail to set.
200: * @deprecated
201: */
202: public void setVendorDetail(VendorDetail vendorDetail) {
203: this .vendorDetail = vendorDetail;
204: }
205:
206: public AddressType getVendorAddressType() {
207: return vendorAddressType;
208: }
209:
210: /**
211: * Sets the vendorAddressType attribute.
212: *
213: * @param vendorAddressType The vendorAddressType to set.
214: * @deprecated
215: */
216: public void setVendorAddressType(AddressType vendorAddressType) {
217: this .vendorAddressType = vendorAddressType;
218: }
219:
220: public State getVendorState() {
221: return vendorState;
222: }
223:
224: /**
225: * Sets the vendorState attribute.
226: *
227: * @param vendorState The vendorState to set.
228: * @deprecated
229: */
230: public void setVendorState(State vendorState) {
231: this .vendorState = vendorState;
232: }
233:
234: public Country getVendorCountry() {
235: return vendorCountry;
236: }
237:
238: /**
239: * Sets the vendorCountry attribute.
240: *
241: * @param vendorCountry The vendorCountry to set.
242: * @deprecated
243: */
244: public void setVendorCountry(Country vendorCountry) {
245: this .vendorCountry = vendorCountry;
246: }
247:
248: /**
249: * Gets the vendorFaxNumber attribute.
250: *
251: * @return Returns the vendorFaxNumber.
252: */
253: public String getVendorFaxNumber() {
254: return vendorFaxNumber;
255: }
256:
257: /**
258: * Sets the vendorFaxNumber attribute value.
259: *
260: * @param vendorFaxNumber The vendorFaxNumber to set.
261: */
262: public void setVendorFaxNumber(String vendorFaxNumber) {
263: this .vendorFaxNumber = vendorFaxNumber;
264: }
265:
266: /**
267: * Gets the vendorDefaultAddressIndicator attribute.
268: *
269: * @return Returns the vendorDefaultAddressIndicator.
270: */
271: public boolean isVendorDefaultAddressIndicator() {
272: return vendorDefaultAddressIndicator;
273: }
274:
275: /**
276: * Sets the vendorDefaultAddressIndicator attribute value.
277: *
278: * @param vendorDefaultAddressIndicator The vendorDefaultAddressIndicator to set.
279: */
280: public void setVendorDefaultAddressIndicator(
281: boolean vendorDefaultAddressIndicator) {
282: this .vendorDefaultAddressIndicator = vendorDefaultAddressIndicator;
283: }
284:
285: public boolean isActive() {
286: return active;
287: }
288:
289: public void setActive(boolean active) {
290: this .active = active;
291: }
292:
293: public List<VendorDefaultAddress> getVendorDefaultAddresses() {
294: return vendorDefaultAddresses;
295: }
296:
297: public void setVendorDefaultAddresses(
298: List<VendorDefaultAddress> vendorDefaultAddresses) {
299: this .vendorDefaultAddresses = vendorDefaultAddresses;
300: }
301:
302: /**
303: * @see org.kuali.module.vendor.util.VendorRoutingComparable#isEqualForRouting(java.lang.Object)
304: */
305: public boolean isEqualForRouting(Object toCompare) {
306: LOG.debug("Entering isEqualForRouting.");
307: if ((ObjectUtils.isNull(toCompare))
308: || !(toCompare instanceof VendorAddress)) {
309: LOG.debug("Exiting isEqualForRouting");
310: return false;
311: } else {
312: VendorAddress va = (VendorAddress) toCompare;
313: boolean eq = new EqualsBuilder()
314: .append(this .getVendorAddressGeneratedIdentifier(),
315: va.getVendorAddressGeneratedIdentifier())
316: .append(this .getVendorHeaderGeneratedIdentifier(),
317: va.getVendorHeaderGeneratedIdentifier())
318: .append(this .getVendorDetailAssignedIdentifier(),
319: va.getVendorDetailAssignedIdentifier())
320: .append(this .getVendorAddressTypeCode(),
321: va.getVendorAddressTypeCode())
322: .append(this .getVendorLine1Address(),
323: va.getVendorLine1Address())
324: .append(this .getVendorLine2Address(),
325: va.getVendorLine2Address())
326: .append(this .getVendorCityName(),
327: va.getVendorCityName())
328: .append(this .getVendorStateCode(),
329: va.getVendorStateCode())
330: .append(this .getVendorZipCode(),
331: va.getVendorZipCode())
332: .append(this .getVendorCountryCode(),
333: va.getVendorCountryCode())
334: .append(this .getVendorAttentionName(),
335: va.getVendorAttentionName())
336: .append(
337: this
338: .getVendorAddressInternationalProvinceName(),
339: va
340: .getVendorAddressInternationalProvinceName())
341: .append(this .getVendorAddressEmailAddress(),
342: va.getVendorAddressEmailAddress())
343: .append(
344: this
345: .getVendorBusinessToBusinessUrlAddress(),
346: va.getVendorBusinessToBusinessUrlAddress())
347: .append(this .getVendorFaxNumber(),
348: va.getVendorFaxNumber()).append(
349: this .isVendorDefaultAddressIndicator(),
350: va.isVendorDefaultAddressIndicator())
351: .isEquals();
352: eq &= SpringContext.getBean(VendorService.class)
353: .equalMemberLists(this .getVendorDefaultAddresses(),
354: va.getVendorDefaultAddresses());
355: LOG.debug("Exiting isEqualForRouting.");
356: return eq;
357: }
358: }
359:
360: /**
361: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
362: */
363: protected LinkedHashMap toStringMapper() {
364: LinkedHashMap m = new LinkedHashMap();
365: if (this .vendorAddressGeneratedIdentifier != null) {
366: m.put("vendorAddressGeneratedIdentifier",
367: this.vendorAddressGeneratedIdentifier.toString());
368: }
369: return m;
370: }
371:
372: }
|