001 package biz.wedoit4u.ejb.entity;
002
003 import java.sql.SQLException;
004 import java.util.Date;
005 import javax.ejb.CreateException;
006 import javax.naming.NamingException;
007 import biz.wedoit4u.databeans.DatabaseHelper;
008
009 /**
010 * The implementation of the entity bean that represents a record in the
011 * <code>contents</code> table.
012 *
013 * <p>Copyright 2003, Rakesh Vidyadharan</p>
014 *
015 * @author Rakesh Vidyadharan on 9<sup><small>th</small></sup> September 2003
016 * @version $Id: ContentBean.java,v 1.4 2004/05/26 11:42:33 rakesh Exp $
017 */
018 public abstract class ContentBean extends EntityBeanAdapter
019 {
020 /**
021 * Return the value in the <code>content_id</code> column.
022 *
023 * @return int - The column value.
024 */
025 public abstract int getContentId();
026
027 /**
028 * Set the value in the <code>content_id</code> column.
029 *
030 * @param contentId - The column value.
031 */
032 public abstract void setContentId( int contentId );
033
034 /**
035 * Return the value in the <code>category_id</code> column as a
036 * reference to the {@link Category} entity bean instance representing
037 * the value.
038 *
039 * @return Category - The appropriate entity bean instance.
040 */
041 public abstract Category getCategory();
042
043 /**
044 * Set the value of the <code>category_id</code> column.
045 *
046 * @param category - The value to set.
047 */
048 public abstract void setCategory( Category category );
049
050 /**
051 * Return the value in the <code>title</code> column.
052 *
053 * @return String - The column value.
054 */
055 public abstract String getTitle();
056
057 /**
058 * Set the value in the <code>title</code> column.
059 *
060 * @param title - The value to set.
061 */
062 public abstract void setTitle( String title );
063
064 /**
065 * Return the value in the <code>picture</code> column.
066 *
067 * @return String - The column value.
068 */
069 public abstract String getBrief();
070
071 /**
072 * Set the value in the <code>picture</code> column.
073 *
074 * @param picture - The value to set.
075 */
076 public abstract void setBrief( String picture );
077
078 /**
079 * Return the value in the <code>picture</code> column.
080 *
081 * @return String - The column value.
082 */
083 public abstract String getPicture();
084
085 /**
086 * Set the value in the <code>picture</code> column.
087 *
088 * @param picture - The value to set.
089 */
090 public abstract void setPicture( String picture );
091
092 /**
093 * Return the value in the <code>body</code> column.
094 *
095 * @return String - The column value.
096 */
097 public abstract String getBody();
098
099 /**
100 * Set the value in the <code>body</code> column.
101 *
102 * @param body - The value to set.
103 */
104 public abstract void setBody( String body );
105
106 /**
107 * Return the value in the <code>creation_date</code> column.
108 *
109 * @return Date - The value in the column.
110 */
111 public abstract Date getCreationDate();
112
113 /**
114 * Return the value in the <code>creation_date</code> column.
115 *
116 * @param creationDate The value in the column.
117 */
118 public abstract void setCreationDate( Date creationDate );
119
120 /**
121 * Return the value in the <code>modification_date</code> column.
122 *
123 * @return Date - The value in the column.
124 */
125 public abstract Date getModificationDate();
126
127 /**
128 * Return the value in the <code>modification_date</code> column.
129 *
130 * @param modificationDate The value to set.
131 */
132 public abstract void setModificationDate( Date modificationDate );
133
134 /**
135 * Create a new record in the <code>content</code> table with just
136 * the required columns.
137 *
138 * @param category - The <code>category_id</code> to use
139 * for the new content.
140 * @param title - The <code>title</code> value to set.
141 * @return Integer - The primary key value of the newly created bean.
142 * @throws CreateException - If errors are encountered while
143 * creating the new record.
144 */
145 public Integer ejbCreate( Category category, String title )
146 throws CreateException
147 {
148 try
149 {
150 setContentId( DatabaseHelper.getNextSequenceValue( "sequence_content_id" ) );
151 }
152 catch ( NamingException nex )
153 {
154 CreateException cex = new CreateException( nex.toString() );
155 cex.setStackTrace( nex.getStackTrace() );
156 throw cex;
157 }
158 catch ( SQLException sex )
159 {
160 CreateException cex = new CreateException( sex.toString() );
161 cex.setStackTrace( sex.getStackTrace() );
162 throw cex;
163 }
164
165 setCategory( category );
166 setTitle( title );
167
168 return null;
169 }
170
171 /**
172 * Mandatory matching <code>postCreate</code> method to the
173 * {@link #ejbCreate( Category, String )} method. No
174 * special handling required after the new record is created.
175 *
176 * @param category - The <code>category_id</code> to use
177 * for the new content.
178 * @param title - The <code>title</code> value to set.
179 */
180 public void ejbPostCreate( Category category, String title ) {}
181
182 /**
183 * Create a new record in the <code>content</code> table with all
184 * the columns specified.
185 *
186 * @param category - The <code>category_id</code> to use
187 * for the new content.
188 * @param title - The <code>title</code> value to set.
189 * @param brief - The <code>brief</code> value to set.
190 * @param picture - The <code>picture</code> value to set.
191 * @param body - The <code>body</code> value to set.
192 * @return Integer - The primary key value of the newly created bean.
193 * @throws CreateException - If errors are encountered while
194 * creating the new record.
195 */
196 public Integer ejbCreate( Category category, String title,
197 String brief, String picture, String body ) throws CreateException
198 {
199 try
200 {
201 setContentId( DatabaseHelper.getNextSequenceValue( "sequence_content_id" ) );
202 }
203 catch ( NamingException nex )
204 {
205 CreateException cex = new CreateException( nex.toString() );
206 cex.setStackTrace( nex.getStackTrace() );
207 throw cex;
208 }
209 catch ( SQLException sex )
210 {
211 CreateException cex = new CreateException( sex.toString() );
212 cex.setStackTrace( sex.getStackTrace() );
213 throw cex;
214 }
215
216 setCategory( category );
217 setTitle( title );
218 setBrief( brief );
219 setPicture( picture );
220 setBody( body );
221
222 return null;
223 }
224
225 /**
226 * Mandatory matching <code>postCreate</code> method to the
227 * {@link #ejbCreate( Category, String )} method. No
228 * special handling required after the new record is created.
229 *
230 * @param category - The <code>category_id</code> to use
231 * for the new content.
232 * @param title - The <code>title</code> value to set.
233 * @param brief - The <code>brief</code> value to set.
234 * @param picture - The <code>picture</code> value to set.
235 * @param body - The <code>body</code> value to set.
236 */
237 public void ejbPostCreate( Category category, String title,
238 String brief, String picture, String body ) {}
239
240 /**
241 * Create a new record in the <code>content</code> table with all
242 * the columns specified.
243 *
244 * @param category - The <code>category_id</code> to use
245 * for the new content.
246 * @param title - The <code>title</code> value to set.
247 * @param brief - The <code>brief</code> value to set.
248 * @param picture - The <code>picture</code> value to set.
249 * @param body - The <code>body</code> value to set.
250 * @param creationDate - The <code>creation_date</code> value
251 * to set.
252 * @param modificationDate - The <code>modification_date</code>
253 * value to set.
254 * @return Integer - The primary key value of the newly created bean.
255 * @throws CreateException - If errors are encountered while
256 * creating the new record.
257 */
258 public Integer ejbCreate( Category category, String title,
259 String brief, String picture, String body, Date creationDate,
260 Date modificationDate ) throws CreateException
261 {
262 try
263 {
264 setContentId( DatabaseHelper.getNextSequenceValue( "sequence_content_id" ) );
265 }
266 catch ( NamingException nex )
267 {
268 CreateException cex = new CreateException( nex.toString() );
269 cex.setStackTrace( nex.getStackTrace() );
270 throw cex;
271 }
272 catch ( SQLException sex )
273 {
274 CreateException cex = new CreateException( sex.toString() );
275 cex.setStackTrace( sex.getStackTrace() );
276 throw cex;
277 }
278
279 setCategory( category );
280 setTitle( title );
281 setBrief( brief );
282 setPicture( picture );
283 setBody( body );
284 setCreationDate( creationDate );
285 setModificationDate( modificationDate );
286
287 return null;
288 }
289
290 /**
291 * Mandatory matching <code>postCreate</code> method to the
292 * {@link #ejbCreate( Category, String )} method. No
293 * special handling required after the new record is created.
294 *
295 * @param category - The <code>category_id</code> to use
296 * for the new content.
297 * @param title - The <code>title</code> value to set.
298 * @param brief - The <code>brief</code> value to set.
299 * @param picture - The <code>picture</code> value to set.
300 * @param body - The <code>body</code> value to set.
301 * @param creationDate - The <code>creation_date</code> value
302 * to set.
303 * @param modificationDate - The <code>modification_date</code>
304 * value to set.
305 */
306 public void ejbPostCreate( Category category, String title,
307 String brief, String picture, String body, Date creationDate,
308 Date modificationDate ) {}
309 }