1packageorg.apache.jetspeed.om.security.turbine;
234import java.math.BigDecimal;
5import java.sql.Connection;
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Date;
9import java.util.List;
1011import org.apache.commons.lang.ObjectUtils;
12import org.apache.torque.TorqueException;
13import org.apache.torque.om.BaseObject;
14import org.apache.torque.om.ComboKey;
15import org.apache.torque.om.DateKey;
16import org.apache.torque.om.NumberKey;
17import org.apache.torque.om.ObjectKey;
18import org.apache.torque.om.SimpleKey;
19import org.apache.torque.om.StringKey;
20import org.apache.torque.om.Persistent;
21import org.apache.torque.util.Criteria;
22import org.apache.torque.util.Transaction;
232425/***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 be31 * extended all references should be to TurbinePermission32 */33publicabstractclassBaseTurbinePermissionextends BaseObject
34 {
35/*** The Peer class */36privatestaticfinalTurbinePermissionPeer peer =
37newTurbinePermissionPeer();
383940/*** The value for the permissionId field */41privateint permissionId;
4243/*** The value for the permissionName field */44private String permissionName;
4546/*** The value for the objectdata field */47private byte[] objectdata;
484950/***51 * Get the PermissionId52 * @return int53 */54publicint getPermissionId()
55 {
56return permissionId;
57 }
585960/***61 * Set the value of PermissionId62 */63publicvoid setPermissionId(int v ) throws TorqueException
64 {
6566if (this.permissionId != v)
67 {
68this.permissionId = v;
69 setModified(true);
70 }
71727374// update associated TurbineRolePermission75if (collTurbineRolePermissions != null )
76 {
77for (int i = 0; i < collTurbineRolePermissions.size(); i++)
78 {
79 ((TurbineRolePermission)collTurbineRolePermissions.get(i))
80 .setPermissionId(v);
81 }
82 }
83 }
848586/***87 * Get the PermissionName88 * @return String89 */90public String getPermissionName()
91 {
92return permissionName;
93 }
949596/***97 * Set the value of PermissionName98 */99publicvoid setPermissionName(String v )
100 {
101102if (!ObjectUtils.equals(this.permissionName, v))
103 {
104this.permissionName = v;
105 setModified(true);
106 }
107108109 }
110111112/***113 * Get the Objectdata114 * @return byte[]115 */116public byte[] getObjectdata()
117 {
118return objectdata;
119 }
120121122/***123 * Set the value of Objectdata124 */125publicvoid setObjectdata(byte[] v )
126 {
127128if (!ObjectUtils.equals(this.objectdata, v))
129 {
130this.objectdata = v;
131 setModified(true);
132 }
133134135 }
136137138139140141/***142 * Collection to store aggregation of collTurbineRolePermissions143 */144protected List collTurbineRolePermissions;
145146/***147 * Temporary storage of collTurbineRolePermissions to save a possible db hit in148 * the event objects are add to the collection, but the149 * complete collection is never requested.150 */151protectedvoid initTurbineRolePermissions()
152 {
153if (collTurbineRolePermissions == null)
154 {
155 collTurbineRolePermissions = new ArrayList();
156 }
157 }
158159160/***161 * Method called to associate a TurbineRolePermission object to this object162 * through the TurbineRolePermission foreign key attribute163 *164 * @param TurbineRolePermission l165 */166publicvoid addTurbineRolePermission(TurbineRolePermission l) throws TorqueException
167 {
168 getTurbineRolePermissions().add(l);
169 l.setTurbinePermission((TurbinePermission)this);
170 }
171172/***173 * The criteria used to select the current contents of collTurbineRolePermissions174 */175private Criteria lastTurbineRolePermissionsCriteria = null;
176177/***178 * If this collection has already been initialized, returns179 * the collection. Otherwise returns the results of180 * getTurbineRolePermissions(new Criteria())181 */182public List getTurbineRolePermissions() throws TorqueException
183 {
184if (collTurbineRolePermissions == null)
185 {
186 collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10));
187 }
188return collTurbineRolePermissions;
189 }
190191/***192 * If this collection has already been initialized with193 * an identical criteria, it returns the collection.194 * Otherwise if this TurbinePermission has previously195 * been saved, it will retrieve related TurbineRolePermissions from storage.196 * If this TurbinePermission is new, it will return197 * an empty collection or the current collection, the criteria198 * is ignored on a new object.199 */200public List getTurbineRolePermissions(Criteria criteria) throws TorqueException
201 {
202if (collTurbineRolePermissions == null)
203 {
204if (isNew())
205 {
206 collTurbineRolePermissions = new ArrayList();
207 }
208else209 {
210 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
211 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
212 }
213 }
214else215 {
216// criteria has no effect for a new object217if (!isNew())
218 {
219// the following code is to determine if a new query is220// called for. If the criteria is the same as the last221// one, just return the collection.222 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
223if (!lastTurbineRolePermissionsCriteria.equals(criteria))
224 {
225 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
226 }
227 }
228 }
229 lastTurbineRolePermissionsCriteria = criteria;
230231return collTurbineRolePermissions;
232 }
233234/***235 * If this collection has already been initialized, returns236 * the collection. Otherwise returns the results of237 * getTurbineRolePermissions(new Criteria(),Connection)238 * This method takes in the Connection also as input so that239 * referenced objects can also be obtained using a Connection240 * that is taken as input241 */242public List getTurbineRolePermissions(Connection con) throws TorqueException
243 {
244if (collTurbineRolePermissions == null)
245 {
246 collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10),con);
247 }
248return collTurbineRolePermissions;
249 }
250251/***252 * If this collection has already been initialized with253 * an identical criteria, it returns the collection.254 * Otherwise if this TurbinePermission has previously255 * been saved, it will retrieve related TurbineRolePermissions from storage.256 * If this TurbinePermission is new, it will return257 * an empty collection or the current collection, the criteria258 * is ignored on a new object.259 * This method takes in the Connection also as input so that260 * referenced objects can also be obtained using a Connection261 * that is taken as input262 */263public List getTurbineRolePermissions(Criteria criteria,Connection con) throws TorqueException
264 {
265if (collTurbineRolePermissions == null)
266 {
267if (isNew())
268 {
269 collTurbineRolePermissions = new ArrayList();
270 }
271else272 {
273 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
274 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria,con);
275 }
276 }
277else278 {
279// criteria has no effect for a new object280if (!isNew())
281 {
282// the following code is to determine if a new query is283// called for. If the criteria is the same as the last284// one, just return the collection.285 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
286if (!lastTurbineRolePermissionsCriteria.equals(criteria))
287 {
288 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria,con);
289 }
290 }
291 }
292 lastTurbineRolePermissionsCriteria = criteria;
293294return collTurbineRolePermissions;
295 }
296297298299300301302303304305306307308/***309 * If this collection has already been initialized with310 * an identical criteria, it returns the collection.311 * Otherwise if this TurbinePermission is new, it will return312 * an empty collection; or if this TurbinePermission has previously313 * been saved, it will retrieve related TurbineRolePermissions from storage.314 *315 * This method is protected by default in order to keep the public316 * api reasonable. You can provide public methods for those you317 * actually need in TurbinePermission.318 */319protected List getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
320 throws TorqueException
321 {
322if (collTurbineRolePermissions == null)
323 {
324if (isNew())
325 {
326 collTurbineRolePermissions = new ArrayList();
327 }
328else329 {
330 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
331 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
332 }
333 }
334else335 {
336// the following code is to determine if a new query is337// called for. If the criteria is the same as the last338// one, just return the collection.339boolean newCriteria = true;
340 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
341if (!lastTurbineRolePermissionsCriteria.equals(criteria))
342 {
343 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
344 }
345 }
346 lastTurbineRolePermissionsCriteria = criteria;
347348return collTurbineRolePermissions;
349 }
350351352353354355356357358359/***360 * If this collection has already been initialized with361 * an identical criteria, it returns the collection.362 * Otherwise if this TurbinePermission is new, it will return363 * an empty collection; or if this TurbinePermission has previously364 * been saved, it will retrieve related TurbineRolePermissions from storage.365 *366 * This method is protected by default in order to keep the public367 * api reasonable. You can provide public methods for those you368 * actually need in TurbinePermission.369 */370protected List getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
371 throws TorqueException
372 {
373if (collTurbineRolePermissions == null)
374 {
375if (isNew())
376 {
377 collTurbineRolePermissions = new ArrayList();
378 }
379else380 {
381 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
382 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
383 }
384 }
385else386 {
387// the following code is to determine if a new query is388// called for. If the criteria is the same as the last389// one, just return the collection.390boolean newCriteria = true;
391 criteria.add(TurbineRolePermissionPeer.PERMISSION_ID, getPermissionId() );
392if (!lastTurbineRolePermissionsCriteria.equals(criteria))
393 {
394 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
395 }
396 }
397 lastTurbineRolePermissionsCriteria = criteria;
398399return collTurbineRolePermissions;
400 }
401402403404405privatestatic List fieldNames = null;
406407/***408 * Generate a list of field names.409 */410publicstaticsynchronized List getFieldNames()
411 {
412if (fieldNames == null)
413 {
414 fieldNames = new ArrayList();
415 fieldNames.add("PermissionId");
416 fieldNames.add("PermissionName");
417 fieldNames.add("Objectdata");
418 fieldNames = Collections.unmodifiableList(fieldNames);
419 }
420return fieldNames;
421 }
422423/***424 * Retrieves a field from the object by name passed in425 * as a String.426 */427public Object getByName(String name)
428 {
429if (name.equals("PermissionId"))
430 {
431returnnew Integer(getPermissionId());
432 }
433if (name.equals("PermissionName"))
434 {
435return getPermissionName();
436 }
437if (name.equals("Objectdata"))
438 {
439return getObjectdata();
440 }
441returnnull;
442 }
443444/***445 * Retrieves a field from the object by name passed in446 * as a String. The String must be one of the static447 * Strings defined in this Class' Peer.448 */449public Object getByPeerName(String name)
450 {
451if (name.equals(TurbinePermissionPeer.PERMISSION_ID ))
452 {
453returnnew Integer(getPermissionId());
454 }
455if (name.equals(TurbinePermissionPeer.PERMISSION_NAME ))
456 {
457return getPermissionName();
458 }
459if (name.equals(TurbinePermissionPeer.OBJECTDATA ))
460 {
461return getObjectdata();
462 }
463returnnull;
464 }
465466/***467 * Retrieves a field from the object by Position as specified468 * in the xml schema. Zero-based.469 */470public Object getByPosition(int pos)
471 {
472if ( pos == 0 )
473 {
474returnnew Integer(getPermissionId());
475 }
476if ( pos == 1 )
477 {
478return getPermissionName();
479 }
480if ( pos == 2 )
481 {
482return getObjectdata();
483 }
484returnnull;
485 }
486487/***488 * Stores the object in the database. If the object is new,489 * it inserts it; otherwise an update is performed.490 */491publicvoid save() throws Exception
492 {
493 save(TurbinePermissionPeer.getMapBuilder()
494 .getDatabaseMap().getName());
495 }
496497/***498 * Stores the object in the database. If the object is new,499 * it inserts it; otherwise an update is performed.500 * Note: this code is here because the method body is501 * auto-generated conditionally and therefore needs to be502 * in this file instead of in the super class, BaseObject.503 */504publicvoid save(String dbName) throws TorqueException
505 {
506 Connection con = null;
507try508 {
509 con = Transaction.begin(dbName);
510 save(con);
511 Transaction.commit(con);
512 }
513catch(TorqueException e)
514 {
515 Transaction.safeRollback(con);
516throw e;
517 }
518 }
519520/*** flag to prevent endless save loop, if this object is referenced521 by another object which falls in this transaction. */522privateboolean alreadyInSave = false;
523/***524 * Stores the object in the database. If the object is new,525 * it inserts it; otherwise an update is performed. This method526 * is meant to be used as part of a transaction, otherwise use527 * the save() method and the connection details will be handled528 * internally529 */530publicvoid save(Connection con) throws TorqueException
531 {
532if (!alreadyInSave)
533 {
534 alreadyInSave = true;
535536537538// If this object has been modified, then save it to the database.539if (isModified())
540 {
541if (isNew())
542 {
543 TurbinePermissionPeer.doInsert((TurbinePermission)this, con);
544 setNew(false);
545 }
546else547 {
548 TurbinePermissionPeer.doUpdate((TurbinePermission)this, con);
549 }
550551if (isCacheOnSave())
552 {
553 TurbinePermissionManager.putInstance(this);
554 }
555 }
556557558if (collTurbineRolePermissions != null )
559 {
560for (int i = 0; i < collTurbineRolePermissions.size(); i++)
561 {
562 ((TurbineRolePermission)collTurbineRolePermissions.get(i)).save(con);
563 }
564 }
565 alreadyInSave = false;
566 }
567 }
568569/***570 * Specify whether to cache the object after saving to the db.571 * This method returns false572 */573protectedboolean isCacheOnSave()
574 {
575returntrue;
576 }
577578579/***580 * Set the PrimaryKey using ObjectKey.581 *582 * @param ObjectKey permissionId583 */584publicvoid setPrimaryKey(ObjectKey permissionId)
585 throws TorqueException {
586 setPermissionId(((NumberKey)permissionId).intValue());
587 }
588589/***590 * Set the PrimaryKey using a String.591 */592publicvoid setPrimaryKey(String key) throws TorqueException
593 {
594 setPermissionId(Integer.parseInt(key));
595 }
596597598/***599 * returns an id that differentiates this object from others600 * of its class.601 */602public ObjectKey getPrimaryKey()
603 {
604return SimpleKey.keyFor(getPermissionId());
605 }
606607608/***609 * Makes a copy of this object.610 * It creates a new object filling in the simple attributes.611 * It then fills all the association collections.612 */613publicTurbinePermission copy() throws TorqueException
614 {
615TurbinePermission copyObj = newTurbinePermission();
616 copyObj.setPermissionId(permissionId);
617 copyObj.setPermissionName(permissionName);
618 copyObj.setObjectdata(objectdata);
619620 copyObj.setPermissionId(0);
621622623624 List v = getTurbineRolePermissions();
625for (int i = 0; i < v.size(); i++)
626 {
627TurbineRolePermission obj = (TurbineRolePermission) v.get(i);
628 copyObj.addTurbineRolePermission(obj.copy());
629 }
630return copyObj;
631 }
632633/***634 * returns a peer instance associated with this om. Since Peer classes635 * are not to have any instance attributes, this method returns the636 * same instance for all member of this class. The method could therefore637 * be static, but this would prevent one from overriding the behavior.638 */639publicTurbinePermissionPeer getPeer()
640 {
641return peer;
642 }
643 }