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