KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > discRack > biz > disc > Disc


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: Disc.java,v 1.4 2004/02/05 10:24:48 slobodan Exp $
22  */

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

36 public class Disc {
37     /**
38      * The DO of the disc.
39      */

40     protected DiscDO myDO = null;
41
42     /**
43      * The public constructor.
44      */

45     public Disc() throws DiscRackBusinessException {
46         try {
47             this.myDO = DiscDO.createVirgin();
48         } catch(DatabaseManagerException ex) {
49             throw new DiscRackBusinessException("Error creating empty Disc", ex);
50         } catch(ObjectIdException ex) {
51             throw new DiscRackBusinessException("Error creating empty Disc", ex);
52         }
53     }
54
55     /** The protected constructor
56      *
57      * @param theDisc. The data object of the disc.
58      */

59     protected Disc(DiscDO theDisc)
60         throws DiscRackBusinessException {
61         this.myDO = theDisc;
62     }
63
64     /**
65      * Gets the object id for the disc
66      *
67      * @return the object id.
68      * @exception DiscRackBusinessException if an error occurs
69      * retrieving data (usually due to an underlying data layer
70      * error).
71      */

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

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

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

123     public String JavaDoc getGenre()
124         throws DiscRackBusinessException {
125         try {
126             return myDO.getGenre();
127         } catch(DataObjectException ex) {
128             throw new DiscRackBusinessException("Error getting disc's genre", ex);
129         }
130     }
131     
132     /**
133      * Gets the preference for the disc
134      *
135      * @return true if like the disc, false if not
136      * @exception DiscRackBusinessException if an error occurs
137      * retrieving data (usually due to an underlying data layer
138      * error).
139      */

140     public boolean isLiked()
141         throws DiscRackBusinessException {
142         try {
143             return myDO.getIsLiked();
144         } catch(DataObjectException ex) {
145             throw new DiscRackBusinessException("Error getting disc's likedness", ex);
146         }
147     }
148     
149     /**
150      * Sets the title for the disc.
151      *
152      * @param the title.
153      * @exception DiscRackBusinessException if an error occurs
154      * setting the data (usually due to an underlying data layer
155      * error).
156      */

157     public void setTitle(String JavaDoc title)
158         throws DiscRackBusinessException {
159         try {
160             this.myDO .setTitle(title);
161         } catch(DataObjectException ex) {
162             throw new DiscRackBusinessException("Error setting disc's title", ex);
163         }
164     }
165     
166     /**
167      * Sets the artist for the disc.
168      *
169      * @param the artist.
170      * @exception DiscRackBusinessException if an error occurs
171      * setting the data (usually due to an underlying data layer
172      * error).
173      */

174     public void setArtist(String JavaDoc artist)
175         throws DiscRackBusinessException {
176         try {
177             this.myDO.setArtist(artist);
178         } catch(DataObjectException ex) {
179             throw new DiscRackBusinessException("Error setting disc's artist", ex);
180         }
181     }
182     
183     /**
184      * Sets the genre for the disc.
185      *
186      * @param the genre.
187      * @exception DiscRackBusinessException if an error occurs
188      * setting the data (usually due to an underlying data layer
189      * error).
190      */

191     public void setGenre(String JavaDoc genre)
192         throws DiscRackBusinessException {
193         try {
194             this.myDO.setGenre(genre);
195         } catch(DataObjectException ex) {
196             throw new DiscRackBusinessException("Error setting disc's genre", ex);
197         }
198     }
199     
200     /**
201      * Sets the owner for the disc.
202      *
203      * @param the owner.
204      * @exception DiscRackBusinessException if an error occurs
205      * setting the data (usually due to an underlying data layer
206      * error).
207      */

208     public void setOwner(Person owner)
209         throws DiscRackBusinessException
210     {
211         try {
212             this.myDO.setOwner(PersonDO.createExisting(owner.getHandle()));
213         } catch(DataObjectException ex) {
214             throw new DiscRackBusinessException("Error setting disc's owner", ex);
215         }
216     }
217     
218     /**
219      * Sets the preference for the disc.
220      *
221      * @param the preference.
222      * @exception DiscRackBusinessException if an error occurs
223      * setting the data (usually due to an underlying data layer
224      * error).
225      */

226     public void setLiked(boolean isLiked)
227         throws DiscRackBusinessException {
228         try {
229             this.myDO.setIsLiked(isLiked);
230         } catch(DataObjectException ex) {
231             throw new DiscRackBusinessException("Error setting disc's likedness", ex);
232         }
233     }
234     
235
236     /**
237      * Commits all changes to the database.
238      *
239      * @exception DiscRackBusinessException if an error occurs
240      * retrieving data (usually due to an underlying data layer
241      * error).
242      */

243     public void save()
244         throws DiscRackBusinessException {
245         try {
246             this.myDO.commit();
247         } catch(Exception JavaDoc ex) {
248             throw new DiscRackBusinessException("Error saving disc", ex);
249         }
250     }
251     
252     /**
253      * Deletes the disc from the database.
254      *
255      * @exception DiscRackBusinessException if an error occurs
256      * deleting data (usually due to an underlying data layer
257      * error).
258      */

259     public void delete()
260         throws DiscRackBusinessException {
261         try {
262             this.myDO.delete();
263         } catch(Exception JavaDoc ex) {
264             throw new DiscRackBusinessException("Error deleting disc", ex);
265         }
266     }
267 }
268
Popular Tags