001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: Person.java,v 1.1 2006-09-11 12:30:36 sinisa Exp $
022: */
023:
024: package barracudaDiscRack.business.person;
025:
026: import barracudaDiscRack.business.DiscRackBusinessException;
027: import barracudaDiscRack.data.person.*;
028: import barracudaDiscRack.data.disc.DiscDO;
029: import barracudaDiscRack.business.disc.Disc;
030: import com.lutris.appserver.server.sql.DatabaseManagerException;
031: import com.lutris.appserver.server.sql.ObjectIdException;
032: import com.lutris.dods.builder.generator.query.DataObjectException;
033:
034: /**
035: * Represents a person.
036: */
037: public class Person {
038: /**
039: * The DO of the Person.
040: */
041: protected PersonDO myDO = null;
042:
043: /**
044: * The public constructor.
045: */
046: public Person() throws DiscRackBusinessException {
047: try {
048: this .myDO = PersonDO.createVirgin();
049: } catch (DatabaseManagerException ex) {
050: throw new DiscRackBusinessException(
051: "Error creating empty person", ex);
052: } catch (ObjectIdException ex) {
053: throw new DiscRackBusinessException(
054: "Error creating object ID for person", ex);
055: }
056: }
057:
058: /** The public constructor
059: *
060: * @param thePerson. The data object of the person.
061: */
062: public Person(PersonDO thePerson) {
063: this .myDO = thePerson;
064: }
065:
066: /**
067: * Gets the object id for the person
068: *
069: * @return the object id.
070: * @exception DiscRackBusinessException if an error occurs
071: * retrieving data (usually due to an underlying data layer
072: * error).
073: */
074: public String getHandle() throws DiscRackBusinessException {
075: try {
076: return this .myDO.getHandle();
077: } catch (DatabaseManagerException ex) {
078: throw new DiscRackBusinessException(
079: "Error getting handle for person", ex);
080: }
081: }
082:
083: /**
084: * Gets the login name for the person
085: *
086: * @return the login name.
087: * @exception DiscRackBusinessException if an error occurs
088: * retrieving data (usually due to an underlying data layer
089: * error).
090: */
091: public String getLogin() throws DiscRackBusinessException {
092: try {
093: return myDO.getLogin();
094: } catch (DataObjectException ex) {
095: throw new DiscRackBusinessException(
096: "Error getting user's login name", ex);
097: }
098: }
099:
100: /**
101: * Gets the password for the person
102: *
103: * @return the password.
104: * @exception DiscRackBusinessException if an error occurs
105: * retrieving data (usually due to an underlying data layer
106: * error).
107: */
108: public String getPassword() throws DiscRackBusinessException {
109: try {
110: return myDO.getPassword();
111: } catch (DataObjectException ex) {
112: throw new DiscRackBusinessException(
113: "Error getting user's password", ex);
114: }
115: }
116:
117: /**
118: * Gets the firstname for the person
119: *
120: * @return the firstname.
121: * @exception DiscRackBusinessException if an error occurs
122: * retrieving data (usually due to an underlying data layer
123: * error).
124: */
125: public String getFirstname() throws DiscRackBusinessException {
126: try {
127: return myDO.getFirstname();
128: } catch (DataObjectException ex) {
129: throw new DiscRackBusinessException(
130: "Error getting user's first name", ex);
131: }
132: }
133:
134: /**
135: * Gets the lastname for the person
136: *
137: * @return the lastname.
138: * @exception DiscRackBusinessException if an error occurs
139: * retrieving data (usually due to an underlying data layer
140: * error).
141: */
142: public String getLastname() throws DiscRackBusinessException {
143: try {
144: return myDO.getLastname();
145: } catch (DataObjectException ex) {
146: throw new DiscRackBusinessException(
147: "Error getting user's last name", ex);
148: }
149: }
150:
151: /**
152: * Sets the login name for the person.
153: *
154: * @param the login name.
155: * @exception DiscRackBusinessException if an error occurs
156: * setting the data (usually due to an underlying data layer
157: * error).
158: */
159: public void setLogin(String login) throws DiscRackBusinessException {
160: try {
161: myDO.setLogin(login);
162: } catch (DataObjectException ex) {
163: throw new DiscRackBusinessException(
164: "Error setting user's login name", ex);
165: }
166: }
167:
168: /**
169: * Sets the password for the person.
170: *
171: * @param the password.
172: * @exception DiscRackBusinessException if an error occurs
173: * setting the data (usually due to an underlying data layer
174: * error).
175: */
176: public void setPassword(String password)
177: throws DiscRackBusinessException {
178: try {
179: myDO.setPassword(password);
180: } catch (DataObjectException ex) {
181: throw new DiscRackBusinessException(
182: "Error setting user's password", ex);
183: }
184: }
185:
186: /**
187: * Sets the firstname for the person.
188: *
189: * @param the 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 firstname)
195: throws DiscRackBusinessException {
196: try {
197: myDO.setFirstname(firstname);
198: } catch (DataObjectException ex) {
199: throw new DiscRackBusinessException(
200: "Error setting user's first name", ex);
201: }
202: }
203:
204: /**
205: * Sets the lastname for the person.
206: *
207: * @param the lastname.
208: * @exception DiscRackBusinessException if an error occurs
209: * setting the data (usually due to an underlying data layer
210: * error).
211: */
212: public void setLastname(String lastname)
213: throws DiscRackBusinessException {
214: try {
215: myDO.setLastname(lastname);
216: } catch (DataObjectException ex) {
217: throw new DiscRackBusinessException(
218: "Error setting user's last name", ex);
219: }
220: }
221:
222: /**
223: * Commits all changes to the database.
224: *
225: * @exception DiscRackBusinessException if an error occurs
226: * retrieving data (usually due to an underlying data layer
227: * error).
228: */
229: public void save() throws DiscRackBusinessException {
230: try {
231: this .myDO.commit();
232: } catch (Exception ex) {
233: throw new DiscRackBusinessException("Error saving person",
234: ex);
235: }
236: }
237: }
|