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: PersonImpl.java,v 1.1 2006-09-11 12:31:47 sinisa Exp $
022: */
023:
024: package discRack.business.person;
025:
026: import discRack.data.person.PersonDO;
027: import discRack.data.disc.DiscDO;
028: import discRack.spec.Person;
029: import discRack.business.DiscRackBusinessException;
030:
031: import com.lutris.appserver.server.sql.DatabaseManagerException;
032: import com.lutris.appserver.server.sql.ObjectIdException;
033: import com.lutris.dods.builder.generator.query.DataObjectException;
034: import org.enhydra.dods.exceptions.AssertionDataObjectException;
035:
036: /**
037: * Represents a person.
038: */
039: public class PersonImpl implements Person, java.io.Serializable {
040: /**
041: * The DO of the Person.
042: */
043: protected PersonDO myDO = null;
044:
045: /**
046: * The public constructor.
047: */
048: public PersonImpl() throws DiscRackBusinessException {
049: try {
050: this .myDO = PersonDO.createVirgin();
051: } catch (DatabaseManagerException ex) {
052: throw new DiscRackBusinessException(
053: "Error creating empty person", ex);
054: } catch (ObjectIdException ex) {
055: throw new DiscRackBusinessException(
056: "Error creating object ID for person", ex);
057: }
058: }
059:
060: /** The public constructor
061: *
062: * @param thePerson The data object of the person.
063: */
064: public PersonImpl(PersonDO thePerson) {
065: this .myDO = thePerson;
066: }
067:
068: /**
069: * Gets the object id for the person
070: *
071: * @return the object id.
072: * @exception DiscRackBusinessException if an error occurs
073: * retrieving data (usually due to an underlying data layer
074: * error).
075: */
076: public String getHandle() throws DiscRackBusinessException {
077: try {
078: return this .myDO.getHandle();
079: } catch (DatabaseManagerException ex) {
080: throw new DiscRackBusinessException(
081: "Error getting handle for person", ex);
082: }
083: }
084:
085: /**
086: * Gets the login name for the person
087: *
088: * @return the login name.
089: * @exception DiscRackBusinessException if an error occurs
090: * retrieving data (usually due to an underlying data layer
091: * error).
092: */
093: public String getLogin() throws DiscRackBusinessException {
094: try {
095: return myDO.getLogin();
096: } catch (DataObjectException ex) {
097: throw new DiscRackBusinessException(
098: "Error getting user's login name", ex);
099: }
100: }
101:
102: /**
103: * Gets the password for the person
104: *
105: * @return the password.
106: * @exception DiscRackBusinessException if an error occurs
107: * retrieving data (usually due to an underlying data layer
108: * error).
109: */
110: public String getPassword() throws DiscRackBusinessException {
111: try {
112: return myDO.getPassword();
113: } catch (DataObjectException ex) {
114: throw new DiscRackBusinessException(
115: "Error getting user's password", ex);
116: }
117: }
118:
119: /**
120: * Gets the firstname for the person
121: *
122: * @return the firstname.
123: * @exception DiscRackBusinessException if an error occurs
124: * retrieving data (usually due to an underlying data layer
125: * error).
126: */
127: public String getFirstname() throws DiscRackBusinessException {
128: try {
129: return myDO.getFirstname();
130: } catch (DataObjectException ex) {
131: throw new DiscRackBusinessException(
132: "Error getting user's first name", ex);
133: }
134: }
135:
136: /**
137: * Gets the lastname for the person
138: *
139: * @return the lastname.
140: * @exception DiscRackBusinessException if an error occurs
141: * retrieving data (usually due to an underlying data layer
142: * error).
143: */
144: public String getLastname() throws DiscRackBusinessException {
145: try {
146: return myDO.getLastname();
147: } catch (DataObjectException ex) {
148: throw new DiscRackBusinessException(
149: "Error getting user's last name", ex);
150: }
151: }
152:
153: /**
154: * Sets the login name for the person.
155: *
156: * @param login login name.
157: * @exception DiscRackBusinessException if an error occurs
158: * setting the data (usually due to an underlying data layer
159: * error).
160: */
161: public void setLogin(String login) throws DiscRackBusinessException {
162: try {
163: myDO.setLogin(login);
164: } catch (DataObjectException ex) {
165: throw new DiscRackBusinessException(
166: "Error setting user's login name", ex);
167: }
168: }
169:
170: /**
171: * Sets the password for the person.
172: *
173: * @param password
174: * @exception DiscRackBusinessException if an error occurs
175: * setting the data (usually due to an underlying data layer
176: * error).
177: */
178: public void setPassword(String password)
179: throws DiscRackBusinessException {
180: try {
181: myDO.setPassword(password);
182: } catch (DataObjectException ex) {
183: throw new DiscRackBusinessException(
184: "Error setting user's password", ex);
185: }
186: }
187:
188: /**
189: * Sets the firstname for the person.
190: *
191: * @param firstname
192: * @exception DiscRackBusinessException if an error occurs
193: * setting the data (usually due to an underlying data layer
194: * error).
195: */
196: public void setFirstname(String firstname)
197: throws DiscRackBusinessException {
198: try {
199: myDO.setFirstname(firstname);
200: } catch (DataObjectException ex) {
201: throw new DiscRackBusinessException(
202: "Error setting user's first name", ex);
203: }
204: }
205:
206: /**
207: * Sets the lastname for the person.
208: *
209: * @param lastname
210: * @exception DiscRackBusinessException if an error occurs
211: * setting the data (usually due to an underlying data layer
212: * error).
213: */
214: public void setLastname(String lastname)
215: throws DiscRackBusinessException {
216: try {
217: myDO.setLastname(lastname);
218: } catch (DataObjectException ex) {
219: throw new DiscRackBusinessException(
220: "Error setting user's last name", ex);
221: }
222: }
223:
224: /**
225: * Commits all changes to the database.
226: *
227: * @exception DiscRackBusinessException if an error occurs
228: * retrieving data (usually due to an underlying data layer
229: * error).
230: */
231: public void save() throws DiscRackBusinessException,
232: AssertionDataObjectException {
233: try {
234: this .myDO.commit();
235: } catch (AssertionDataObjectException ex) {
236: throw new AssertionDataObjectException(
237: "Read-only table: DML operations not allowed", ex);
238: } catch (Exception ex) {
239: throw new DiscRackBusinessException("Error saving person",
240: ex);
241: }
242: }
243: }
|