KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > discRack > business > person > PersonImpl


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  * $Id: PersonImpl.java,v 1.1 2004/08/16 09:39:19 slobodan Exp $
22  */

23
24 package discRack.business.person;
25
26  
27 import discRack.data.person.PersonDO;
28 import discRack.data.disc.DiscDO;
29 import discRack.spec.Person;
30 import discRack.business.DiscRackBusinessException;
31
32 import com.lutris.appserver.server.sql.DatabaseManagerException;
33 import com.lutris.appserver.server.sql.ObjectIdException;
34 import com.lutris.dods.builder.generator.query.DataObjectException;
35 import org.enhydra.dods.exceptions.AssertionDataObjectException;
36         
37 /**
38  * Represents a person.
39  */

40 public class PersonImpl implements Person,java.io.Serializable JavaDoc {
41     /**
42      * The DO of the Person.
43      */

44     protected PersonDO myDO = null;
45     
46     /**
47      * The public constructor.
48      */

49     public PersonImpl() throws DiscRackBusinessException {
50         try {
51             this.myDO = PersonDO.createVirgin();
52         } catch(DatabaseManagerException ex) {
53             throw new DiscRackBusinessException("Error creating empty person", ex);
54         } catch(ObjectIdException ex) {
55             throw new DiscRackBusinessException("Error creating object ID for person", ex);
56         }
57     }
58     
59     /** The public constructor
60      *
61      * @param thePerson The data object of the person.
62      */

63     public PersonImpl(PersonDO thePerson) {
64         this.myDO = thePerson;
65     }
66     
67     /**
68      * Gets the object id for the person
69      *
70      * @return the object id.
71      * @exception DiscRackBusinessException if an error occurs
72      * retrieving data (usually due to an underlying data layer
73      * error).
74      */

75     public String JavaDoc getHandle()
76         throws DiscRackBusinessException {
77         try {
78             return this.myDO.getHandle();
79         } catch(DatabaseManagerException ex) {
80             throw new DiscRackBusinessException("Error getting handle for person", ex);
81         }
82     }
83     
84     /**
85      * Gets the login name for the person
86      *
87      * @return the login name.
88      * @exception DiscRackBusinessException if an error occurs
89      * retrieving data (usually due to an underlying data layer
90      * error).
91      */

92     public String JavaDoc getLogin()
93         throws DiscRackBusinessException {
94         try {
95             return myDO.getLogin();
96         } catch(DataObjectException ex) {
97             throw new DiscRackBusinessException("Error getting user's login name", ex);
98         }
99     }
100     
101     /**
102      * Gets the password for the person
103      *
104      * @return the password.
105      * @exception DiscRackBusinessException if an error occurs
106      * retrieving data (usually due to an underlying data layer
107      * error).
108      */

109     public String JavaDoc getPassword()
110         throws DiscRackBusinessException {
111         try {
112             return myDO.getPassword();
113         } catch(DataObjectException ex) {
114             throw new DiscRackBusinessException("Error getting user's password", ex);
115         }
116     }
117     
118     /**
119      * Gets the firstname for the person
120      *
121      * @return the firstname.
122      * @exception DiscRackBusinessException if an error occurs
123      * retrieving data (usually due to an underlying data layer
124      * error).
125      */

126     public String JavaDoc getFirstname()
127         throws DiscRackBusinessException {
128         try {
129             return myDO.getFirstname();
130         } catch(DataObjectException ex) {
131             throw new DiscRackBusinessException("Error getting user's first name", ex);
132         }
133     }
134     
135     /**
136      * Gets the lastname for the person
137      *
138      * @return the lastname.
139      * @exception DiscRackBusinessException if an error occurs
140      * retrieving data (usually due to an underlying data layer
141      * error).
142      */

143     public String JavaDoc getLastname()
144         throws DiscRackBusinessException {
145         try {
146             return myDO.getLastname();
147         } catch(DataObjectException ex) {
148             throw new DiscRackBusinessException("Error getting user's last name", ex);
149         }
150     }
151     
152     /**
153      * Sets the login name for the person.
154      *
155      * @param login login name.
156      * @exception DiscRackBusinessException if an error occurs
157      * setting the data (usually due to an underlying data layer
158      * error).
159      */

160     public void setLogin(String JavaDoc login)
161         throws DiscRackBusinessException {
162         try {
163             myDO.setLogin(login);
164         } catch(DataObjectException ex) {
165             throw new DiscRackBusinessException("Error setting user's login name", ex);
166         }
167     }
168     
169     /**
170      * Sets the password for the person.
171      *
172      * @param password
173      * @exception DiscRackBusinessException if an error occurs
174      * setting the data (usually due to an underlying data layer
175      * error).
176      */

177     public void setPassword(String JavaDoc password)
178         throws DiscRackBusinessException {
179         try {
180             myDO.setPassword(password);
181         } catch(DataObjectException ex) {
182             throw new DiscRackBusinessException("Error setting user's password", ex);
183         }
184     }
185     
186     /**
187      * Sets the firstname for the person.
188      *
189      * @param firstname
190      * @exception DiscRackBusinessException if an error occurs
191      * setting the data (usually due to an underlying data layer
192      * error).
193      */

194     public void setFirstname(String JavaDoc firstname)
195         throws DiscRackBusinessException {
196         try {
197             myDO.setFirstname(firstname);
198         } catch(DataObjectException ex) {
199             throw new DiscRackBusinessException("Error setting user's first name", ex);
200         }
201     }
202     
203     /**
204      * Sets the lastname for the person.
205      *
206      * @param lastname
207      * @exception DiscRackBusinessException if an error occurs
208      * setting the data (usually due to an underlying data layer
209      * error).
210      */

211     public void setLastname(String JavaDoc lastname)
212         throws DiscRackBusinessException {
213         try {
214             myDO.setLastname(lastname);
215         } catch(DataObjectException ex) {
216             throw new DiscRackBusinessException("Error setting user's last name", ex);
217         }
218     }
219     
220     /**
221      * Commits all changes to the database.
222      *
223      * @exception DiscRackBusinessException if an error occurs
224      * retrieving data (usually due to an underlying data layer
225      * error).
226      */

227     public void save() throws DiscRackBusinessException, AssertionDataObjectException {
228         try {
229             this.myDO.commit();
230         }
231         catch (AssertionDataObjectException ex) {
232             throw new AssertionDataObjectException("Read-only table: DML operations not allowed", ex);
233         }
234         catch(Exception JavaDoc ex) {
235             throw new DiscRackBusinessException("Error saving person", ex);
236         }
237     }
238 }
239
Popular Tags