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 2004/09/03 13:41:25 sinisa Exp $
022: */
023:
024: package discRack.business.person;
025:
026: import discRack.business.DiscRackBusinessException;
027: import discRack.data.person.*;
028: import discRack.data.disc.DiscDO;
029: import discRack.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: import org.enhydra.dods.exceptions.AssertionDataObjectException;
034:
035: /**
036: * Represents a person.
037: */
038: public class Person {
039: /**
040: * The DO of the Person.
041: */
042: protected PersonDO myDO = null;
043:
044: /**
045: * The public constructor.
046: */
047: public Person() throws DiscRackBusinessException {
048: try {
049: this .myDO = PersonDO.createVirgin();
050: } catch (DatabaseManagerException ex) {
051: throw new DiscRackBusinessException(
052: "Error creating empty person", ex);
053: } catch (ObjectIdException ex) {
054: throw new DiscRackBusinessException(
055: "Error creating object ID for person", ex);
056: }
057: }
058:
059: /** The public constructor
060: *
061: * @param thePerson. The data object of the person.
062: */
063: public Person(PersonDO thePerson) {
064: this .myDO = thePerson;
065: }
066:
067: /**
068: * Gets the object id for the person
069: *
070: * @return the object id.
071: * @exception DiscRackBusinessException if an error occurs
072: * retrieving data (usually due to an underlying data layer
073: * error).
074: */
075: public String getHandle() throws DiscRackBusinessException {
076: try {
077: return this .myDO.getHandle();
078: } catch (DatabaseManagerException ex) {
079: throw new DiscRackBusinessException(
080: "Error getting handle for person", ex);
081: }
082: }
083:
084: /**
085: * Gets the login name for the person
086: *
087: * @return the login name.
088: * @exception DiscRackBusinessException if an error occurs
089: * retrieving data (usually due to an underlying data layer
090: * error).
091: */
092: public String getLogin() throws DiscRackBusinessException {
093: try {
094: return myDO.getLogin();
095: } catch (DataObjectException ex) {
096: throw new DiscRackBusinessException(
097: "Error getting user's login name", ex);
098: }
099: }
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 getPassword() throws DiscRackBusinessException {
110: try {
111: return myDO.getPassword();
112: } catch (DataObjectException ex) {
113: throw new DiscRackBusinessException(
114: "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 getFirstname() throws DiscRackBusinessException {
127: try {
128: return myDO.getFirstname();
129: } catch (DataObjectException ex) {
130: throw new DiscRackBusinessException(
131: "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 getLastname() throws DiscRackBusinessException {
144: try {
145: return myDO.getLastname();
146: } catch (DataObjectException ex) {
147: throw new DiscRackBusinessException(
148: "Error getting user's last name", ex);
149: }
150: }
151:
152: /**
153: * Sets the login name for the person.
154: *
155: * @param the 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 login) throws DiscRackBusinessException {
161: try {
162: myDO.setLogin(login);
163: } catch (DataObjectException ex) {
164: throw new DiscRackBusinessException(
165: "Error setting user's login name", ex);
166: }
167: }
168:
169: /**
170: * Sets the password for the person.
171: *
172: * @param the 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 password)
178: throws DiscRackBusinessException {
179: try {
180: myDO.setPassword(password);
181: } catch (DataObjectException ex) {
182: throw new DiscRackBusinessException(
183: "Error setting user's password", ex);
184: }
185: }
186:
187: /**
188: * Sets the firstname for the person.
189: *
190: * @param the firstname.
191: * @exception DiscRackBusinessException if an error occurs
192: * setting the data (usually due to an underlying data layer
193: * error).
194: */
195: public void setFirstname(String firstname)
196: throws DiscRackBusinessException {
197: try {
198: myDO.setFirstname(firstname);
199: } catch (DataObjectException ex) {
200: throw new DiscRackBusinessException(
201: "Error setting user's first name", ex);
202: }
203: }
204:
205: /**
206: * Sets the lastname for the person.
207: *
208: * @param the lastname.
209: * @exception DiscRackBusinessException if an error occurs
210: * setting the data (usually due to an underlying data layer
211: * error).
212: */
213: public void setLastname(String lastname)
214: throws DiscRackBusinessException {
215: try {
216: myDO.setLastname(lastname);
217: } catch (DataObjectException ex) {
218: throw new DiscRackBusinessException(
219: "Error setting user's last name", ex);
220: }
221: }
222:
223: /**
224: * Commits all changes to the database.
225: *
226: * @exception DiscRackBusinessException if an error occurs
227: * retrieving data (usually due to an underlying data layer
228: * error).
229: */
230: public void save() throws DiscRackBusinessException,
231: AssertionDataObjectException {
232: try {
233: //this.myDO.commit();
234: this .myDO.save();
235: } catch (AssertionDataObjectException ex) {
236: throw new AssertionDataObjectException(
237: "DML opertions not allowed.", ex);
238: } catch (Exception ex) {
239: throw new DiscRackBusinessException("Error saving person",
240: ex);
241: }
242: }
243: }
|