-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostalAddressDelegate.java
161 lines (135 loc) · 5.09 KB
/
PostalAddressDelegate.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
* Copyright © 2008, Benecard, All Rights Reserved
* Unless otherwise indicated, all source code is the copyright of Benecard
* and is protected by applicable US and international copyright laws,
* all rights reserved. No part of this material may be used for any purpose
* without prior written permission. This material and all source codes may
* not be reproduced in any form without permission in writing from Benecard.
* Use for any purpose without written permission from Benecard is expressly
* prohibited by law, and may result in civil and criminal penalties.
* All rights reserved. No part of this file may be reproduced in any form
* or by any electronic or mechanical means, including the use of information
* storage and retrieval systems, without permission in writing from
* the copyright owner.
*/
package com.benecard.service.delegate.postalAddress;
import java.util.Map;
import java.util.Set;
import com.benecard.commons.IConstants;
import com.benecard.commons.security.Credentials;
import com.benecard.core.service.ServiceResponse;
import com.benecard.pbm.model.City;
import com.benecard.pbm.model.County;
import com.benecard.pbm.model.PostalAddress;
import com.benecard.pbm.model.PostalCode;
import com.benecard.service.delegate.DelegateBase;
import com.benecard.service.ejb.postaladdress.IPostalAddressServiceLocal;
/**
* PostalAddressDelegate class.
*
* @author edata_rm
* @date 08/25/2009
*/
public class PostalAddressDelegate extends DelegateBase
{
@SuppressWarnings("unchecked")
public Set<City> selectCities( String cityName, Credentials credentials ) throws Exception
{
Set<City> cities = null;
ServiceResponse response = (ServiceResponse) getSessionFacadeRemote().executeService( IConstants.POSTAL_ADDRESS_SERVICE_NAME, IConstants.SELECT_CITIES, new Object[] { cityName }, credentials );
if ( response.getResponseStatus().isSuccess() )
{
cities = (Set<City>) response.getResponseResultObject();
}
else
{
evaluateError( response );
}
return cities;
}
public Set<City> selectCities( String cityName ) throws Exception
{
return selectCities( cityName, null );
}
@SuppressWarnings("unchecked")
public Set<County> selectCounties( PostalAddress postalAddress, Credentials credentials ) throws Exception
{
Set<County> counties = null;
ServiceResponse response = (ServiceResponse) getSessionFacadeRemote().executeService( IConstants.POSTAL_ADDRESS_SERVICE_NAME, IConstants.SELECT_COUNTIES, new Object[] { postalAddress }, credentials );
if ( response.getResponseStatus().isSuccess() )
{
counties = (Set<County>) response.getResponseResultObject();
}
else
{
evaluateError( response );
}
return counties;
}
public Set<County> selectCounties( PostalAddress postalAddress ) throws Exception
{
return selectCounties( postalAddress, null );
}
@SuppressWarnings("unchecked")
public Set<PostalCode> selectZipCodes( PostalAddress postalAddress, Credentials credentials ) throws Exception
{
Set<PostalCode> postCodes = null;
ServiceResponse response = (ServiceResponse) getSessionFacadeRemote().executeService( IConstants.POSTAL_ADDRESS_SERVICE_NAME, IConstants.SELECT_ZIPCODES, new Object[] { postalAddress }, credentials );
if ( response.getResponseStatus().isSuccess() )
{
postCodes = (Set<PostalCode>) response.getResponseResultObject();
}
else
{
evaluateError( response );
}
return postCodes;
}
public Set<PostalCode> selectZipCodes( PostalAddress postalAddress ) throws Exception
{
return selectZipCodes( postalAddress, null );
}
@SuppressWarnings("unchecked")
public Map<String, Boolean> validateAddress( PostalAddress postalAddress, Credentials credentials ) throws Exception
{
Map<String, Boolean> result = null;
ServiceResponse response = (ServiceResponse) getSessionFacadeRemote().executeService( IConstants.POSTAL_ADDRESS_SERVICE_NAME, IConstants.VALIDATE_ADR, new Object[] { postalAddress }, credentials );
if ( response.getResponseStatus().isSuccess() )
{
result = (Map<String, Boolean>) response.getResponseResultObject();
}
else
{
evaluateError( response );
}
return result;
}
public Map<String, Boolean> validateAddress( PostalAddress postalAddress ) throws Exception
{
return validateAddress( postalAddress, null );
}
/**
* Method gets State and cities for the zipcode passed.
*
* @param zipcode
* String
* @param credentials
* Credentials
* @return Object[]
* @throws Exception
*/
public Object[] getStateAndCities( String zipcode, Credentials credentials ) throws Exception
{
Object[] result = null;
ServiceResponse response = (ServiceResponse) getSessionFacadeRemote().executeService( IConstants.POSTAL_ADDRESS_SERVICE_NAME, IPostalAddressServiceLocal.GET_STATE_AND_CITIES, new Object[] { zipcode }, credentials );
if ( response.getResponseStatus().isSuccess() )
{
result = (Object[]) response.getResponseResultObject();
}
else
{
evaluateError( response );
}
return result;
}
}