KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > business > customer > CustomerImpl


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: CustomerImpl.java,v 1.1 2004/08/16 09:33:11 slobodan Exp $
18  */

19
20 package com.lutris.airsent.business.customer;
21
22
23 import com.lutris.airsent.spec.AirSentException;
24
25 import com.lutris.airsent.business.*;
26
27 import com.lutris.airsent.spec.customer.Customer;
28
29 import com.lutris.airsent.business.address.*;
30
31 import com.lutris.airsent.spec.address.Address;
32
33
34 import com.lutris.airsent.data.person.*;
35 import com.lutris.appserver.server.sql.DatabaseManagerException;
36 import com.lutris.appserver.server.sql.ObjectIdException;
37 import com.lutris.dods.builder.generator.query.DataObjectException;
38
39
40 /**
41  * Customer implementation
42  */

43 public class CustomerImpl
44     implements Customer, java.io.Serializable JavaDoc {
45
46     CustomerDO customerDO = null;
47     PersonDO personDO = null;
48
49     /**
50      * Create a new customer
51      *
52      * @exception if an error occurs
53      */

54     CustomerImpl()
55         throws AirSentException {
56     try {
57             customerDO = CustomerDO.createVirgin();
58             personDO = PersonDO.createVirgin();
59             
60             AddressManager af = HomeManagerImpl.getInstance().getAddressManager();
61             
62             AddressImpl addr = af.create();
63             
64             personDO.setAddressID(addr.getDataObject());
65         customerDO.setPersonID(personDO);
66     } catch (Exception JavaDoc e) {
67         throw new AirSentException(e);
68     }
69     }
70
71     /**
72      * Create an existing customer
73      *
74      * @param customer customer data object
75      * @exception if an error occurs
76      */

77     public CustomerImpl(CustomerDO customer)
78         throws AirSentException {
79     try {
80         customerDO = customer;
81         personDO = customerDO.getPersonID();
82     } catch (Exception JavaDoc e) {
83         throw new AirSentException(e);
84     }
85     }
86
87     /**
88      * Gets the customer handle.
89      *
90      * @return database id
91      * @exception if an error occurs
92      */

93     public String JavaDoc getHandle()
94         throws AirSentException {
95     try {
96         return customerDO.getHandle();
97     } catch (Exception JavaDoc e) {
98         throw new AirSentException(e);
99     }
100     }
101     
102     /**
103      * Gets the first name.
104      *
105      * @exception if an error occurs
106      */

107     public String JavaDoc getFirstName()
108         throws AirSentException {
109     try {
110         return personDO.getFirstName();
111     } catch (Exception JavaDoc e) {
112         throw new AirSentException(e);
113     }
114     }
115
116     /**
117      * Sets the first name.
118      *
119      * @exception if an error occurs
120      */

121     public void setFirstName(String JavaDoc first)
122         throws AirSentException, AirSentBusinessException {
123         if (first.length() > Customer.MAX_FIRST_NAME) {
124             throw new AirSentBusinessException("Exceeds maximum size");
125         }
126     try {
127         personDO.setFirstName(first);
128     } catch (Exception JavaDoc e) {
129         throw new AirSentException(e);
130     }
131     }
132
133     /**
134      * Gets the last name.
135      *
136      * @return last name
137      * @exception if an error occurs
138      */

139     public String JavaDoc getLastName()
140         throws AirSentException {
141     try {
142         return personDO.getLastName();
143     } catch (Exception JavaDoc e) {
144         throw new AirSentException(e);
145     }
146     }
147
148     /**
149      * Set the last name.
150      *
151      * @param last last name
152      * @exception if an error occurs
153      */

154     public void setLastName(String JavaDoc last)
155         throws AirSentException, AirSentBusinessException {
156         if (last.length() > Customer.MAX_LAST_NAME) {
157             throw new AirSentBusinessException("Exceeds maximum size");
158         }
159     try {
160         personDO.setLastName(last);
161     } catch (Exception JavaDoc e) {
162         throw new AirSentException(e);
163     }
164     }
165
166     /**
167      * Gets the email.
168      *
169      * @return email address
170      * @exception if an error occurs
171      */

172     public String JavaDoc getEmail()
173         throws AirSentException {
174     try {
175         return personDO.getEmail();
176     } catch (Exception JavaDoc e) {
177         throw new AirSentException(e);
178     }
179     }
180
181     /**
182      * Sets the email.
183      *
184      * @param email email address
185      * @exception if an error occurs
186      */

187     public void setEmail(String JavaDoc email)
188         throws AirSentException, AirSentBusinessException {
189         if (email.length() > Customer.MAX_EMAIL) {
190             throw new AirSentBusinessException("Exceeds maximum size");
191         }
192     try {
193         personDO.setEmail(email);
194     } catch (Exception JavaDoc e) {
195         throw new AirSentException(e);
196     }
197     }
198
199     /**
200      * Gets the address.
201      *
202      * @return address
203      * @exception if an error occurs
204      */

205     public Address getAddress()
206         throws AirSentException {
207     try {
208             AddressManager af = HomeManagerImpl.getInstance().getAddressManager();
209             return af.create(personDO.getAddressID());
210     } catch (Exception JavaDoc e) {
211         throw new AirSentException(e);
212     }
213     }
214
215     /**
216      * Gets the business.
217      *
218      * @return business
219      * @exception if an error occurs
220      */

221     public String JavaDoc getBusiness()
222         throws AirSentException {
223     try {
224         return customerDO.getBusiness();
225     } catch (Exception JavaDoc e) {
226         throw new AirSentException(e);
227     }
228     }
229
230     /**
231      * Sets the business.
232      *
233      * @param business business
234      * @exception if an error occurs
235      */

236     public void setBusiness(String JavaDoc business)
237         throws AirSentException, AirSentBusinessException {
238         if (business.length() > Customer.MAX_BUSINESS) {
239             throw new AirSentBusinessException("Exceeds maximum size");
240         }
241     try {
242         customerDO.setBusiness(business);
243     } catch (Exception JavaDoc e) {
244         throw new AirSentException(e);
245     }
246     }
247
248     /**
249      * Gets the login.
250      *
251      * @return login name
252      * @exception if an error occurs
253      */

254     public String JavaDoc getLogin()
255         throws AirSentException {
256     try {
257         return customerDO.getLogin();
258     } catch (Exception JavaDoc e) {
259         throw new AirSentException(e);
260     }
261     }
262
263     /**
264      * Sets the login.
265      *
266      * @param login login name
267      * @exception if an error occurs
268      */

269     public void setLogin(String JavaDoc login)
270         throws AirSentException, AirSentBusinessException {
271         if (login.length() > Customer.MAX_LOGIN) {
272             throw new AirSentBusinessException("Exceeds maximum size");
273         }
274     try {
275         customerDO.setLogin(login);
276     } catch (Exception JavaDoc e) {
277         throw new AirSentException(e);
278     }
279     }
280
281     /**
282      * Gets the password.
283      *
284      * @return password
285      * @exception if an error occurs
286      */

287     public String JavaDoc getPassword()
288         throws AirSentException {
289     try {
290         return customerDO.getPassword();
291     } catch (Exception JavaDoc e) {
292         throw new AirSentException(e);
293     }
294     }
295
296     /**
297      * Sets the password.
298      *
299      * @param password password
300      * @exception if an error occurs
301      */

302     public void setPassword(String JavaDoc password)
303         throws AirSentException, AirSentBusinessException {
304         if (password.length() > Customer.MAX_PASSWORD) {
305             throw new AirSentBusinessException("Exceeds maximum size");
306         }
307     try {
308         customerDO.setPassword(password);
309     } catch (Exception JavaDoc e) {
310         throw new AirSentException(e);
311     }
312     }
313
314     /**
315      * Saves the customer.
316      *
317      * @exception if an error occurs
318      */

319     public void save()
320         throws AirSentException {
321     try {
322         customerDO.commit();
323     } catch (Exception JavaDoc e) {
324         throw new AirSentException(e);
325     }
326     }
327
328     /**
329      * Deletes the customer.
330      *
331      * @exception if an error occurs
332      */

333     public void delete()
334         throws AirSentException {
335     try {
336         customerDO.delete();
337     } catch (Exception JavaDoc e) {
338         throw new AirSentException(e);
339     }
340     }
341 }
342
343
Popular Tags