1 package org.apache.jetspeed.om.dbpsml;
2
3
4 import java.math.BigDecimal;
5 import java.sql.Connection;
6 import java.util.ArrayList;
7 import java.util.Collections;
8 import java.util.Date;
9 import java.util.List;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.torque.TorqueException;
13 import org.apache.torque.om.BaseObject;
14 import org.apache.torque.om.ComboKey;
15 import org.apache.torque.om.DateKey;
16 import org.apache.torque.om.NumberKey;
17 import org.apache.torque.om.ObjectKey;
18 import org.apache.torque.om.SimpleKey;
19 import org.apache.torque.om.StringKey;
20 import org.apache.torque.om.Persistent;
21 import org.apache.torque.util.Criteria;
22 import org.apache.torque.util.Transaction;
23
24
25 /***
26 * This class was autogenerated by Torque on:
27 *
28 * [Thu Apr 22 23:12:36 EDT 2004]
29 *
30 * You should not use this class directly. It should not even be
31 * extended all references should be to JetspeedGroupProfile
32 */
33 public abstract class BaseJetspeedGroupProfile extends BaseObject
34 {
35 /*** The Peer class */
36 private static final JetspeedGroupProfilePeer peer =
37 new JetspeedGroupProfilePeer();
38
39
40 /*** The value for the psmlId field */
41 private int psmlId;
42
43 /*** The value for the groupName field */
44 private String groupName;
45
46 /*** The value for the mediaType field */
47 private String mediaType;
48
49 /*** The value for the language field */
50 private String language;
51
52 /*** The value for the country field */
53 private String country;
54
55 /*** The value for the page field */
56 private String page;
57
58 /*** The value for the profile field */
59 private byte[] profile;
60
61
62 /***
63 * Get the PsmlId
64 * @return int
65 */
66 public int getPsmlId()
67 {
68 return psmlId;
69 }
70
71
72 /***
73 * Set the value of PsmlId
74 */
75 public void setPsmlId(int v )
76 {
77
78 if (this.psmlId != v)
79 {
80 this.psmlId = v;
81 setModified(true);
82 }
83
84
85 }
86
87
88 /***
89 * Get the GroupName
90 * @return String
91 */
92 public String getGroupName()
93 {
94 return groupName;
95 }
96
97
98 /***
99 * Set the value of GroupName
100 */
101 public void setGroupName(String v )
102 {
103
104 if (!ObjectUtils.equals(this.groupName, v))
105 {
106 this.groupName = v;
107 setModified(true);
108 }
109
110
111 }
112
113
114 /***
115 * Get the MediaType
116 * @return String
117 */
118 public String getMediaType()
119 {
120 return mediaType;
121 }
122
123
124 /***
125 * Set the value of MediaType
126 */
127 public void setMediaType(String v )
128 {
129
130 if (!ObjectUtils.equals(this.mediaType, v))
131 {
132 this.mediaType = v;
133 setModified(true);
134 }
135
136
137 }
138
139
140 /***
141 * Get the Language
142 * @return String
143 */
144 public String getLanguage()
145 {
146 return language;
147 }
148
149
150 /***
151 * Set the value of Language
152 */
153 public void setLanguage(String v )
154 {
155
156 if (!ObjectUtils.equals(this.language, v))
157 {
158 this.language = v;
159 setModified(true);
160 }
161
162
163 }
164
165
166 /***
167 * Get the Country
168 * @return String
169 */
170 public String getCountry()
171 {
172 return country;
173 }
174
175
176 /***
177 * Set the value of Country
178 */
179 public void setCountry(String v )
180 {
181
182 if (!ObjectUtils.equals(this.country, v))
183 {
184 this.country = v;
185 setModified(true);
186 }
187
188
189 }
190
191
192 /***
193 * Get the Page
194 * @return String
195 */
196 public String getPage()
197 {
198 return page;
199 }
200
201
202 /***
203 * Set the value of Page
204 */
205 public void setPage(String v )
206 {
207
208 if (!ObjectUtils.equals(this.page, v))
209 {
210 this.page = v;
211 setModified(true);
212 }
213
214
215 }
216
217
218 /***
219 * Get the Profile
220 * @return byte[]
221 */
222 public byte[] getProfile()
223 {
224 return profile;
225 }
226
227
228 /***
229 * Set the value of Profile
230 */
231 public void setProfile(byte[] v )
232 {
233
234 if (!ObjectUtils.equals(this.profile, v))
235 {
236 this.profile = v;
237 setModified(true);
238 }
239
240
241 }
242
243
244
245
246 private static List fieldNames = null;
247
248 /***
249 * Generate a list of field names.
250 */
251 public static synchronized List getFieldNames()
252 {
253 if (fieldNames == null)
254 {
255 fieldNames = new ArrayList();
256 fieldNames.add("PsmlId");
257 fieldNames.add("GroupName");
258 fieldNames.add("MediaType");
259 fieldNames.add("Language");
260 fieldNames.add("Country");
261 fieldNames.add("Page");
262 fieldNames.add("Profile");
263 fieldNames = Collections.unmodifiableList(fieldNames);
264 }
265 return fieldNames;
266 }
267
268 /***
269 * Retrieves a field from the object by name passed in
270 * as a String.
271 */
272 public Object getByName(String name)
273 {
274 if (name.equals("PsmlId"))
275 {
276 return new Integer(getPsmlId());
277 }
278 if (name.equals("GroupName"))
279 {
280 return getGroupName();
281 }
282 if (name.equals("MediaType"))
283 {
284 return getMediaType();
285 }
286 if (name.equals("Language"))
287 {
288 return getLanguage();
289 }
290 if (name.equals("Country"))
291 {
292 return getCountry();
293 }
294 if (name.equals("Page"))
295 {
296 return getPage();
297 }
298 if (name.equals("Profile"))
299 {
300 return getProfile();
301 }
302 return null;
303 }
304
305 /***
306 * Retrieves a field from the object by name passed in
307 * as a String. The String must be one of the static
308 * Strings defined in this Class' Peer.
309 */
310 public Object getByPeerName(String name)
311 {
312 if (name.equals(JetspeedGroupProfilePeer.PSML_ID ))
313 {
314 return new Integer(getPsmlId());
315 }
316 if (name.equals(JetspeedGroupProfilePeer.GROUP_NAME ))
317 {
318 return getGroupName();
319 }
320 if (name.equals(JetspeedGroupProfilePeer.MEDIA_TYPE ))
321 {
322 return getMediaType();
323 }
324 if (name.equals(JetspeedGroupProfilePeer.LANGUAGE ))
325 {
326 return getLanguage();
327 }
328 if (name.equals(JetspeedGroupProfilePeer.COUNTRY ))
329 {
330 return getCountry();
331 }
332 if (name.equals(JetspeedGroupProfilePeer.PAGE ))
333 {
334 return getPage();
335 }
336 if (name.equals(JetspeedGroupProfilePeer.PROFILE ))
337 {
338 return getProfile();
339 }
340 return null;
341 }
342
343 /***
344 * Retrieves a field from the object by Position as specified
345 * in the xml schema. Zero-based.
346 */
347 public Object getByPosition(int pos)
348 {
349 if ( pos == 0 )
350 {
351 return new Integer(getPsmlId());
352 }
353 if ( pos == 1 )
354 {
355 return getGroupName();
356 }
357 if ( pos == 2 )
358 {
359 return getMediaType();
360 }
361 if ( pos == 3 )
362 {
363 return getLanguage();
364 }
365 if ( pos == 4 )
366 {
367 return getCountry();
368 }
369 if ( pos == 5 )
370 {
371 return getPage();
372 }
373 if ( pos == 6 )
374 {
375 return getProfile();
376 }
377 return null;
378 }
379
380 /***
381 * Stores the object in the database. If the object is new,
382 * it inserts it; otherwise an update is performed.
383 */
384 public void save() throws Exception
385 {
386 save(JetspeedGroupProfilePeer.getMapBuilder()
387 .getDatabaseMap().getName());
388 }
389
390 /***
391 * Stores the object in the database. If the object is new,
392 * it inserts it; otherwise an update is performed.
393 * Note: this code is here because the method body is
394 * auto-generated conditionally and therefore needs to be
395 * in this file instead of in the super class, BaseObject.
396 */
397 public void save(String dbName) throws TorqueException
398 {
399 Connection con = null;
400 try
401 {
402 con = Transaction.begin(dbName);
403 save(con);
404 Transaction.commit(con);
405 }
406 catch(TorqueException e)
407 {
408 Transaction.safeRollback(con);
409 throw e;
410 }
411 }
412
413 /*** flag to prevent endless save loop, if this object is referenced
414 by another object which falls in this transaction. */
415 private boolean alreadyInSave = false;
416 /***
417 * Stores the object in the database. If the object is new,
418 * it inserts it; otherwise an update is performed. This method
419 * is meant to be used as part of a transaction, otherwise use
420 * the save() method and the connection details will be handled
421 * internally
422 */
423 public void save(Connection con) throws TorqueException
424 {
425 if (!alreadyInSave)
426 {
427 alreadyInSave = true;
428
429
430
431
432 if (isModified())
433 {
434 if (isNew())
435 {
436 JetspeedGroupProfilePeer.doInsert((JetspeedGroupProfile)this, con);
437 setNew(false);
438 }
439 else
440 {
441 JetspeedGroupProfilePeer.doUpdate((JetspeedGroupProfile)this, con);
442 }
443
444 if (isCacheOnSave())
445 {
446 JetspeedGroupProfileManager.putInstance(this);
447 }
448 }
449
450 alreadyInSave = false;
451 }
452 }
453
454 /***
455 * Specify whether to cache the object after saving to the db.
456 * This method returns false
457 */
458 protected boolean isCacheOnSave()
459 {
460 return true;
461 }
462
463
464 /***
465 * Set the PrimaryKey using ObjectKey.
466 *
467 * @param ObjectKey psmlId
468 */
469 public void setPrimaryKey(ObjectKey psmlId)
470 {
471 setPsmlId(((NumberKey)psmlId).intValue());
472 }
473
474 /***
475 * Set the PrimaryKey using a String.
476 */
477 public void setPrimaryKey(String key)
478 {
479 setPsmlId(Integer.parseInt(key));
480 }
481
482
483 /***
484 * returns an id that differentiates this object from others
485 * of its class.
486 */
487 public ObjectKey getPrimaryKey()
488 {
489 return SimpleKey.keyFor(getPsmlId());
490 }
491
492
493 /***
494 * Makes a copy of this object.
495 * It creates a new object filling in the simple attributes.
496 * It then fills all the association collections.
497 */
498 public JetspeedGroupProfile copy() throws TorqueException
499 {
500 JetspeedGroupProfile copyObj = new JetspeedGroupProfile();
501 copyObj.setPsmlId(psmlId);
502 copyObj.setGroupName(groupName);
503 copyObj.setMediaType(mediaType);
504 copyObj.setLanguage(language);
505 copyObj.setCountry(country);
506 copyObj.setPage(page);
507 copyObj.setProfile(profile);
508
509 copyObj.setPsmlId(0);
510
511 return copyObj;
512 }
513
514 /***
515 * returns a peer instance associated with this om. Since Peer classes
516 * are not to have any instance attributes, this method returns the
517 * same instance for all member of this class. The method could therefore
518 * be static, but this would prevent one from overriding the behavior.
519 */
520 public JetspeedGroupProfilePeer getPeer()
521 {
522 return peer;
523 }
524 }