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: Disc.java,v 1.1 2006-09-11 12:30:36 sinisa Exp $
022: */
023:
024: package barracudaDiscRack.business.disc;
025:
026: import barracudaDiscRack.business.DiscRackBusinessException;
027: import barracudaDiscRack.business.person.Person;
028: import barracudaDiscRack.data.person.PersonDO;
029: import barracudaDiscRack.data.disc.DiscDO;
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 disc.
036: */
037: public class Disc {
038: /**
039: * The DO of the disc.
040: */
041: protected DiscDO myDO = null;
042:
043: /**
044: * The public constructor.
045: */
046: public Disc() throws DiscRackBusinessException {
047: try {
048: this .myDO = DiscDO.createVirgin();
049: } catch (DatabaseManagerException ex) {
050: throw new DiscRackBusinessException(
051: "Error creating empty Disc", ex);
052: } catch (ObjectIdException ex) {
053: throw new DiscRackBusinessException(
054: "Error creating empty Disc", ex);
055: }
056: }
057:
058: /** The protected constructor
059: *
060: * @param theDisc. The data object of the disc.
061: */
062: protected Disc(DiscDO theDisc) throws DiscRackBusinessException {
063: this .myDO = theDisc;
064: }
065:
066: /**
067: * Gets the object id for the disc
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 disc's handle", ex);
080: }
081: }
082:
083: /**
084: * Gets the title for the disc
085: *
086: * @return the title.
087: * @exception DiscRackBusinessException if an error occurs
088: * retrieving data (usually due to an underlying data layer
089: * error).
090: */
091: public String getTitle() throws DiscRackBusinessException {
092: try {
093: return myDO.getTitle();
094: } catch (DataObjectException ex) {
095: throw new DiscRackBusinessException(
096: "Error getting disc's title", ex);
097: }
098: }
099:
100: /**
101: * Gets the artist for the disc
102: *
103: * @return the artist.
104: * @exception DiscRackBusinessException if an error occurs
105: * retrieving data (usually due to an underlying data layer
106: * error).
107: */
108: public String getArtist() throws DiscRackBusinessException {
109: try {
110: return myDO.getArtist();
111: } catch (DataObjectException ex) {
112: throw new DiscRackBusinessException(
113: "Error getting disc's artist", ex);
114: }
115: }
116:
117: /**
118: * Gets the genre for the disc
119: *
120: * @return the genre.
121: * @exception DiscRackBusinessException if an error occurs
122: * retrieving data (usually due to an underlying data layer
123: * error).
124: */
125: public String getGenre() throws DiscRackBusinessException {
126: try {
127: return myDO.getGenre();
128: } catch (DataObjectException ex) {
129: throw new DiscRackBusinessException(
130: "Error getting disc's genre", ex);
131: }
132: }
133:
134: /**
135: * Gets the preference for the disc
136: *
137: * @return true if like the disc, false if not
138: * @exception DiscRackBusinessException if an error occurs
139: * retrieving data (usually due to an underlying data layer
140: * error).
141: */
142: public boolean isLiked() throws DiscRackBusinessException {
143: try {
144: return myDO.getIsLiked();
145: } catch (DataObjectException ex) {
146: throw new DiscRackBusinessException(
147: "Error getting disc's likedness", ex);
148: }
149: }
150:
151: /**
152: * Sets the title for the disc.
153: *
154: * @param the title.
155: * @exception DiscRackBusinessException if an error occurs
156: * setting the data (usually due to an underlying data layer
157: * error).
158: */
159: public void setTitle(String title) throws DiscRackBusinessException {
160: try {
161: this .myDO.setTitle(title);
162: } catch (DataObjectException ex) {
163: throw new DiscRackBusinessException(
164: "Error setting disc's title", ex);
165: }
166: }
167:
168: /**
169: * Sets the artist for the disc.
170: *
171: * @param the artist.
172: * @exception DiscRackBusinessException if an error occurs
173: * setting the data (usually due to an underlying data layer
174: * error).
175: */
176: public void setArtist(String artist)
177: throws DiscRackBusinessException {
178: try {
179: this .myDO.setArtist(artist);
180: } catch (DataObjectException ex) {
181: throw new DiscRackBusinessException(
182: "Error setting disc's artist", ex);
183: }
184: }
185:
186: /**
187: * Sets the genre for the disc.
188: *
189: * @param the genre.
190: * @exception DiscRackBusinessException if an error occurs
191: * setting the data (usually due to an underlying data layer
192: * error).
193: */
194: public void setGenre(String genre) throws DiscRackBusinessException {
195: try {
196: this .myDO.setGenre(genre);
197: } catch (DataObjectException ex) {
198: throw new DiscRackBusinessException(
199: "Error setting disc's genre", ex);
200: }
201: }
202:
203: /**
204: * Sets the owner for the disc.
205: *
206: * @param the owner.
207: * @exception DiscRackBusinessException if an error occurs
208: * setting the data (usually due to an underlying data layer
209: * error).
210: */
211: public void setOwner(Person owner) throws DiscRackBusinessException {
212: try {
213: this .myDO.setOwner(PersonDO.createExisting(owner
214: .getHandle()));
215: } catch (DataObjectException ex) {
216: throw new DiscRackBusinessException(
217: "Error setting disc's owner", ex);
218: }
219: }
220:
221: /**
222: * Sets the preference for the disc.
223: *
224: * @param the preference.
225: * @exception DiscRackBusinessException if an error occurs
226: * setting the data (usually due to an underlying data layer
227: * error).
228: */
229: public void setLiked(boolean isLiked)
230: throws DiscRackBusinessException {
231: try {
232: this .myDO.setIsLiked(isLiked);
233: } catch (DataObjectException ex) {
234: throw new DiscRackBusinessException(
235: "Error setting disc's likedness", ex);
236: }
237: }
238:
239: /**
240: * Commits all changes to the database.
241: *
242: * @exception DiscRackBusinessException if an error occurs
243: * retrieving data (usually due to an underlying data layer
244: * error).
245: */
246: public void save() throws DiscRackBusinessException {
247: try {
248: this .myDO.commit();
249: } catch (Exception ex) {
250: throw new DiscRackBusinessException("Error saving disc", ex);
251: }
252: }
253:
254: /**
255: * Deletes the disc from the database.
256: *
257: * @exception DiscRackBusinessException if an error occurs
258: * deleting data (usually due to an underlying data layer
259: * error).
260: */
261: public void delete() throws DiscRackBusinessException {
262: try {
263: this .myDO.delete();
264: } catch (Exception ex) {
265: throw new DiscRackBusinessException("Error deleting disc",
266: ex);
267: }
268: }
269: }
|