KickJava   Java API By Example, From Geeks To Geeks.

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


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: Person.java,v 1.3 2005/02/21 08:34:42 slobodan Exp $
22  */

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

38 public class Person {
39    /**
40     * The DO of the Person.
41     */

42    protected PersonDO myDO = null;
43
44    /**
45     * The public constructor.
46     */

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

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

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

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

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

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

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

153    public void setLogin(String JavaDoc login) throws DiscRackBusinessException {
154       try {
155          myDO.setLogin(login);
156       } catch(DataObjectException ex) {
157          throw new DiscRackBusinessException("Error setting user's login name", ex);
158       }
159    }
160
161    /**
162     * Sets the password for the person.
163     *
164     * @param the password.
165     * @exception DiscRackBusinessException if an error occurs
166     * setting the data (usually due to an underlying data layer
167     * error).
168     */

169    public void setPassword(String JavaDoc password) throws DiscRackBusinessException {
170       try {
171          myDO.setPassword(password);
172       } catch(DataObjectException ex) {
173          throw new DiscRackBusinessException("Error setting user's password", ex);
174       }
175    }
176
177    /**
178     * Sets the firstname for the person.
179     *
180     * @param the firstname.
181     * @exception DiscRackBusinessException if an error occurs
182     * setting the data (usually due to an underlying data layer
183     * error).
184     */

185    public void setFirstname(String JavaDoc firstname) throws DiscRackBusinessException {
186       try {
187          myDO.setFirstname(firstname);
188       } catch(DataObjectException ex) {
189          throw new DiscRackBusinessException("Error setting user's first name", ex);
190       }
191    }
192
193    /**
194     * Sets the lastname for the person.
195     *
196     * @param the lastname.
197     * @exception DiscRackBusinessException if an error occurs
198     * setting the data (usually due to an underlying data layer
199     * error).
200     */

201    public void setLastname(String JavaDoc lastname) throws DiscRackBusinessException {
202       try {
203          myDO.setLastname(lastname);
204       } catch(DataObjectException ex) {
205          throw new DiscRackBusinessException("Error setting user's last name", ex);
206       }
207    }
208
209    /**
210     * Commits all changes to the database.
211     *
212     * @exception DiscRackBusinessException if an error occurs
213     * retrieving data (usually due to an underlying data layer
214     * error).
215     */

216    public void save() throws DiscRackBusinessException, AssertionDataObjectException {
217       try {
218          //this.myDO.commit();
219
this.myDO.save();
220       } catch(AssertionDataObjectException ex) {
221          throw new AssertionDataObjectException("DML opertions not allowed.", ex);
222       } catch(Exception JavaDoc ex) {
223          throw new DiscRackBusinessException("Error saving person", ex);
224       }
225    }
226 }
227
Popular Tags