-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostalAddressService.java
153 lines (138 loc) · 5.45 KB
/
PostalAddressService.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
/*
* 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.ejb.postaladdress;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import javax.sql.DataSource;
import com.benecard.commons.ILogUtil;
import com.benecard.commons.LogUtil;
import com.benecard.commons.exceptions.BenecardException;
import com.benecard.dal.PostalAddressDAL;
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.ejb.BaseService;
/**
* Enter the description for the class.
*
*
* @author edata_rc
* @date Dec 16, 2008
*
*/
@Stateless
public class PostalAddressService extends BaseService implements
IPostalAddressServiceLocal,
IPostalAddressServiceRemote
{
private transient static ILogUtil logger = LogUtil.getInstance( PostalAddressService.class );
@Resource( name = "PBMDS", type = javax.sql.DataSource.class )
private DataSource dataSource;
@Resource
private SessionContext sessionContext;
public final Set<City> getCities( final String cityName ) throws BenecardException
{
Connection connection = null;
try
{
connection = getConnection( dataSource );
String userName = sessionContext.getCallerPrincipal().getName();
return new PostalAddressDAL( connection, userName ).getCities( connection, cityName );
}
finally
{
closeConnection( connection );
}
}
public final Set<County> getCounties( final PostalAddress postalAddress ) throws BenecardException
{
Connection connection = null;
try
{
connection = getConnection( dataSource );
String userName = sessionContext.getCallerPrincipal().getName();
return new PostalAddressDAL( connection, userName ).getCounties( connection, postalAddress );
}
finally
{
closeConnection( connection );
}
}
public final List<PostalAddress> getCityCountyStateCountryByZipCode( final String zipCode )
throws BenecardException
{
Connection connection = null;
try
{
connection = getConnection( dataSource );
String userName = sessionContext.getCallerPrincipal().getName();
return new PostalAddressDAL( connection, userName ).getCityCountyStateCountryByZipCode( zipCode );
}
finally
{
closeConnection( connection );
}
}
public final Set<PostalCode> getPostalCodes( final PostalAddress postalAddress ) throws BenecardException
{
Connection connection = null;
try
{
connection = getConnection( dataSource );
String userName = sessionContext.getCallerPrincipal().getName();
return new PostalAddressDAL( connection, userName ).getPostalCodes( connection, postalAddress );
}
finally
{
closeConnection( connection );
}
}
public final Map<String, Boolean> validateAddressFields( final PostalAddress postalAddress )
throws BenecardException
{
Connection connection = null;
try
{
connection = getConnection( dataSource );
String userName = sessionContext.getCallerPrincipal().getName();
return new PostalAddressDAL( connection, userName ).validateAddressFields( connection, postalAddress );
}
finally
{
closeConnection( connection );
}
}
public Object[] getStateAndCities( final String zipcode ) throws BenecardException
{
Connection connection = null;
try
{
connection = getConnection( dataSource );
String userName = sessionContext.getCallerPrincipal().getName();
return new PostalAddressDAL( connection, userName ).getStateAndCities( connection, zipcode );
}
finally
{
closeConnection( connection );
}
}
public Object[] test1( int[] a, List<String, List<Map<String, String>>> b) { return new Object[0]; }
}