KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > BaseRModuleAttributePeer


1 package org.tigris.scarab.om;
2
3 import java.math.BigDecimal JavaDoc;
4 import java.sql.Connection JavaDoc;
5 import java.sql.SQLException JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Date JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.LinkedList JavaDoc;
10 import java.util.List JavaDoc;
11
12 import org.apache.torque.NoRowsException;
13 import org.apache.torque.TooManyRowsException;
14 import org.apache.torque.Torque;
15 import org.apache.torque.TorqueException;
16 import org.apache.torque.map.MapBuilder;
17 import org.apache.torque.map.TableMap;
18 import org.apache.torque.om.DateKey;
19 import org.apache.torque.om.NumberKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.ObjectKey;
22 import org.apache.torque.om.SimpleKey;
23 import org.apache.torque.util.BasePeer;
24 import org.apache.torque.util.Criteria;
25
26 import com.workingdogs.village.DataSetException;
27 import com.workingdogs.village.QueryDataSet;
28 import com.workingdogs.village.Record;
29
30 // Local classes
31
import org.tigris.scarab.om.map.*;
32
33
34   
35   
36   
37 /**
38  */

39 public abstract class BaseRModuleAttributePeer
40     extends BasePeer
41 {
42
43     /** the default database name for this class */
44     public static final String JavaDoc DATABASE_NAME = "scarab";
45
46      /** the table name for this class */
47     public static final String JavaDoc TABLE_NAME = "SCARAB_R_MODULE_ATTRIBUTE";
48
49     /**
50      * @return the map builder for this peer
51      * @throws TorqueException Any exceptions caught during processing will be
52      * rethrown wrapped into a TorqueException.
53      */

54     public static MapBuilder getMapBuilder()
55         throws TorqueException
56     {
57         return getMapBuilder(RModuleAttributeMapBuilder.CLASS_NAME);
58     }
59
60       /** the column name for the MODULE_ID field */
61     public static final String JavaDoc MODULE_ID;
62       /** the column name for the ATTRIBUTE_ID field */
63     public static final String JavaDoc ATTRIBUTE_ID;
64       /** the column name for the ISSUE_TYPE_ID field */
65     public static final String JavaDoc ISSUE_TYPE_ID;
66       /** the column name for the DISPLAY_VALUE field */
67     public static final String JavaDoc DISPLAY_VALUE;
68       /** the column name for the ACTIVE field */
69     public static final String JavaDoc ACTIVE;
70       /** the column name for the REQUIRED field */
71     public static final String JavaDoc REQUIRED;
72       /** the column name for the PREFERRED_ORDER field */
73     public static final String JavaDoc PREFERRED_ORDER;
74       /** the column name for the QUICK_SEARCH field */
75     public static final String JavaDoc QUICK_SEARCH;
76       /** the column name for the DEFAULT_TEXT_FLAG field */
77     public static final String JavaDoc DEFAULT_TEXT_FLAG;
78   
79     static
80     {
81           MODULE_ID = "SCARAB_R_MODULE_ATTRIBUTE.MODULE_ID";
82           ATTRIBUTE_ID = "SCARAB_R_MODULE_ATTRIBUTE.ATTRIBUTE_ID";
83           ISSUE_TYPE_ID = "SCARAB_R_MODULE_ATTRIBUTE.ISSUE_TYPE_ID";
84           DISPLAY_VALUE = "SCARAB_R_MODULE_ATTRIBUTE.DISPLAY_VALUE";
85           ACTIVE = "SCARAB_R_MODULE_ATTRIBUTE.ACTIVE";
86           REQUIRED = "SCARAB_R_MODULE_ATTRIBUTE.REQUIRED";
87           PREFERRED_ORDER = "SCARAB_R_MODULE_ATTRIBUTE.PREFERRED_ORDER";
88           QUICK_SEARCH = "SCARAB_R_MODULE_ATTRIBUTE.QUICK_SEARCH";
89           DEFAULT_TEXT_FLAG = "SCARAB_R_MODULE_ATTRIBUTE.DEFAULT_TEXT_FLAG";
90           if (Torque.isInit())
91         {
92             try
93             {
94                 getMapBuilder(RModuleAttributeMapBuilder.CLASS_NAME);
95             }
96             catch (Exception JavaDoc e)
97             {
98                 log.error("Could not initialize Peer", e);
99             }
100         }
101         else
102         {
103             Torque.registerMapBuilder(RModuleAttributeMapBuilder.CLASS_NAME);
104         }
105     }
106  
107     /** number of columns for this peer */
108     public static final int numColumns = 9;
109
110     /** A class that can be returned by this peer. */
111     protected static final String JavaDoc CLASSNAME_DEFAULT =
112         "org.tigris.scarab.om.RModuleAttribute";
113
114     /** A class that can be returned by this peer. */
115     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
116
117     /**
118      * Class object initialization method.
119      *
120      * @param className name of the class to initialize
121      * @return the initialized class
122      */

123     private static Class JavaDoc initClass(String JavaDoc className)
124     {
125         Class JavaDoc c = null;
126         try
127         {
128             c = Class.forName(className);
129         }
130         catch (Throwable JavaDoc t)
131         {
132             log.error("A FATAL ERROR has occurred which should not "
133                 + "have happened under any circumstance. Please notify "
134                 + "the Torque developers <torque-dev@db.apache.org> "
135                 + "and give as many details as possible (including the error "
136                 + "stack trace).", t);
137
138             // Error objects should always be propogated.
139
if (t instanceof Error JavaDoc)
140             {
141                 throw (Error JavaDoc) t.fillInStackTrace();
142             }
143         }
144         return c;
145     }
146
147     /**
148      * Get the list of objects for a ResultSet. Please not that your
149      * resultset MUST return columns in the right order. You can use
150      * getFieldNames() in BaseObject to get the correct sequence.
151      *
152      * @param results the ResultSet
153      * @return the list of objects
154      * @throws TorqueException Any exceptions caught during processing will be
155      * rethrown wrapped into a TorqueException.
156      */

157     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
158             throws TorqueException
159     {
160         try
161         {
162             QueryDataSet qds = null;
163             List JavaDoc rows = null;
164             try
165             {
166                 qds = new QueryDataSet(results);
167                 rows = getSelectResults(qds);
168             }
169             finally
170             {
171                 if (qds != null)
172                 {
173                     qds.close();
174                 }
175             }
176
177             return populateObjects(rows);
178         }
179         catch (SQLException JavaDoc e)
180         {
181             throw new TorqueException(e);
182         }
183         catch (DataSetException e)
184         {
185             throw new TorqueException(e);
186         }
187     }
188
189
190   
191     /**
192      * Method to do inserts.
193      *
194      * @param criteria object used to create the INSERT statement.
195      * @throws TorqueException Any exceptions caught during processing will be
196      * rethrown wrapped into a TorqueException.
197      */

198     public static ObjectKey doInsert(Criteria criteria)
199         throws TorqueException
200     {
201         return BaseRModuleAttributePeer
202             .doInsert(criteria, (Connection JavaDoc) null);
203     }
204
205     /**
206      * Method to do inserts. This method is to be used during a transaction,
207      * otherwise use the doInsert(Criteria) method. It will take care of
208      * the connection details internally.
209      *
210      * @param criteria object used to create the INSERT statement.
211      * @param con the connection to use
212      * @throws TorqueException Any exceptions caught during processing will be
213      * rethrown wrapped into a TorqueException.
214      */

215     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
216         throws TorqueException
217     {
218                                       // check for conversion from boolean to int
219
if (criteria.containsKey(ACTIVE))
220         {
221             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
222             if (possibleBoolean instanceof Boolean JavaDoc)
223             {
224                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
225             }
226          }
227                   // check for conversion from boolean to int
228
if (criteria.containsKey(REQUIRED))
229         {
230             Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
231             if (possibleBoolean instanceof Boolean JavaDoc)
232             {
233                 criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
234             }
235          }
236                         // check for conversion from boolean to int
237
if (criteria.containsKey(QUICK_SEARCH))
238         {
239             Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
240             if (possibleBoolean instanceof Boolean JavaDoc)
241             {
242                 criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
243             }
244          }
245                   // check for conversion from boolean to int
246
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
247         {
248             Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
249             if (possibleBoolean instanceof Boolean JavaDoc)
250             {
251                 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
252             }
253          }
254       
255         setDbName(criteria);
256
257         if (con == null)
258         {
259             return BasePeer.doInsert(criteria);
260         }
261         else
262         {
263             return BasePeer.doInsert(criteria, con);
264         }
265     }
266
267     /**
268      * Add all the columns needed to create a new object.
269      *
270      * @param criteria object containing the columns to add.
271      * @throws TorqueException Any exceptions caught during processing will be
272      * rethrown wrapped into a TorqueException.
273      */

274     public static void addSelectColumns(Criteria criteria)
275             throws TorqueException
276     {
277           criteria.addSelectColumn(MODULE_ID);
278           criteria.addSelectColumn(ATTRIBUTE_ID);
279           criteria.addSelectColumn(ISSUE_TYPE_ID);
280           criteria.addSelectColumn(DISPLAY_VALUE);
281           criteria.addSelectColumn(ACTIVE);
282           criteria.addSelectColumn(REQUIRED);
283           criteria.addSelectColumn(PREFERRED_ORDER);
284           criteria.addSelectColumn(QUICK_SEARCH);
285           criteria.addSelectColumn(DEFAULT_TEXT_FLAG);
286       }
287
288     /**
289      * Create a new object of type cls from a resultset row starting
290      * from a specified offset. This is done so that you can select
291      * other rows than just those needed for this object. You may
292      * for example want to create two objects from the same row.
293      *
294      * @throws TorqueException Any exceptions caught during processing will be
295      * rethrown wrapped into a TorqueException.
296      */

297     public static RModuleAttribute row2Object(Record row,
298                                              int offset,
299                                              Class JavaDoc cls)
300         throws TorqueException
301     {
302         try
303         {
304             RModuleAttribute obj = (RModuleAttribute) cls.newInstance();
305             RModuleAttributePeer.populateObject(row, offset, obj);
306                   obj.setModified(false);
307               obj.setNew(false);
308
309             return obj;
310         }
311         catch (InstantiationException JavaDoc e)
312         {
313             throw new TorqueException(e);
314         }
315         catch (IllegalAccessException JavaDoc e)
316         {
317             throw new TorqueException(e);
318         }
319     }
320
321     /**
322      * Populates an object from a resultset row starting
323      * from a specified offset. This is done so that you can select
324      * other rows than just those needed for this object. You may
325      * for example want to create two objects from the same row.
326      *
327      * @throws TorqueException Any exceptions caught during processing will be
328      * rethrown wrapped into a TorqueException.
329      */

330     public static void populateObject(Record row,
331                                       int offset,
332                                       RModuleAttribute obj)
333         throws TorqueException
334     {
335         try
336         {
337                 obj.setModuleId(row.getValue(offset + 0).asIntegerObj());
338                   obj.setAttributeId(row.getValue(offset + 1).asIntegerObj());
339                   obj.setIssueTypeId(row.getValue(offset + 2).asIntegerObj());
340                   obj.setDisplayValue(row.getValue(offset + 3).asString());
341                   obj.setActive(row.getValue(offset + 4).asBoolean());
342                   obj.setRequired(row.getValue(offset + 5).asBoolean());
343                   obj.setOrder(row.getValue(offset + 6).asInt());
344                   obj.setQuickSearch(row.getValue(offset + 7).asBoolean());
345                   obj.setDefaultTextFlag(row.getValue(offset + 8).asBoolean());
346               }
347         catch (DataSetException e)
348         {
349             throw new TorqueException(e);
350         }
351     }
352
353     /**
354      * Method to do selects.
355      *
356      * @param criteria object used to create the SELECT statement.
357      * @return List of selected Objects
358      * @throws TorqueException Any exceptions caught during processing will be
359      * rethrown wrapped into a TorqueException.
360      */

361     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
362     {
363         return populateObjects(doSelectVillageRecords(criteria));
364     }
365
366     /**
367      * Method to do selects within a transaction.
368      *
369      * @param criteria object used to create the SELECT statement.
370      * @param con the connection to use
371      * @return List of selected Objects
372      * @throws TorqueException Any exceptions caught during processing will be
373      * rethrown wrapped into a TorqueException.
374      */

375     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
376         throws TorqueException
377     {
378         return populateObjects(doSelectVillageRecords(criteria, con));
379     }
380
381     /**
382      * Grabs the raw Village records to be formed into objects.
383      * This method handles connections internally. The Record objects
384      * returned by this method should be considered readonly. Do not
385      * alter the data and call save(), your results may vary, but are
386      * certainly likely to result in hard to track MT bugs.
387      *
388      * @throws TorqueException Any exceptions caught during processing will be
389      * rethrown wrapped into a TorqueException.
390      */

391     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
392         throws TorqueException
393     {
394         return BaseRModuleAttributePeer
395             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
396     }
397
398     /**
399      * Grabs the raw Village records to be formed into objects.
400      * This method should be used for transactions
401      *
402      * @param criteria object used to create the SELECT statement.
403      * @param con the connection to use
404      * @throws TorqueException Any exceptions caught during processing will be
405      * rethrown wrapped into a TorqueException.
406      */

407     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
408         throws TorqueException
409     {
410         if (criteria.getSelectColumns().size() == 0)
411         {
412             addSelectColumns(criteria);
413         }
414
415                                       // check for conversion from boolean to int
416
if (criteria.containsKey(ACTIVE))
417         {
418             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
419             if (possibleBoolean instanceof Boolean JavaDoc)
420             {
421                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
422             }
423          }
424                   // check for conversion from boolean to int
425
if (criteria.containsKey(REQUIRED))
426         {
427             Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
428             if (possibleBoolean instanceof Boolean JavaDoc)
429             {
430                 criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
431             }
432          }
433                         // check for conversion from boolean to int
434
if (criteria.containsKey(QUICK_SEARCH))
435         {
436             Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
437             if (possibleBoolean instanceof Boolean JavaDoc)
438             {
439                 criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
440             }
441          }
442                   // check for conversion from boolean to int
443
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
444         {
445             Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
446             if (possibleBoolean instanceof Boolean JavaDoc)
447             {
448                 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
449             }
450          }
451       
452         setDbName(criteria);
453
454         // BasePeer returns a List of Value (Village) arrays. The array
455
// order follows the order columns were placed in the Select clause.
456
if (con == null)
457         {
458             return BasePeer.doSelect(criteria);
459         }
460         else
461         {
462             return BasePeer.doSelect(criteria, con);
463         }
464     }
465
466     /**
467      * The returned List will contain objects of the default type or
468      * objects that inherit from the default.
469      *
470      * @throws TorqueException Any exceptions caught during processing will be
471      * rethrown wrapped into a TorqueException.
472      */

473     public static List JavaDoc populateObjects(List JavaDoc records)
474         throws TorqueException
475     {
476         List JavaDoc results = new ArrayList JavaDoc(records.size());
477
478         // populate the object(s)
479
for (int i = 0; i < records.size(); i++)
480         {
481             Record row = (Record) records.get(i);
482               results.add(RModuleAttributePeer.row2Object(row, 1,
483                 RModuleAttributePeer.getOMClass()));
484           }
485         return results;
486     }
487  
488
489     /**
490      * The class that the Peer will make instances of.
491      * If the BO is abstract then you must implement this method
492      * in the BO.
493      *
494      * @throws TorqueException Any exceptions caught during processing will be
495      * rethrown wrapped into a TorqueException.
496      */

497     public static Class JavaDoc getOMClass()
498         throws TorqueException
499     {
500         return CLASS_DEFAULT;
501     }
502
503     /**
504      * Method to do updates.
505      *
506      * @param criteria object containing data that is used to create the UPDATE
507      * statement.
508      * @throws TorqueException Any exceptions caught during processing will be
509      * rethrown wrapped into a TorqueException.
510      */

511     public static void doUpdate(Criteria criteria) throws TorqueException
512     {
513          BaseRModuleAttributePeer
514             .doUpdate(criteria, (Connection JavaDoc) null);
515     }
516
517     /**
518      * Method to do updates. This method is to be used during a transaction,
519      * otherwise use the doUpdate(Criteria) method. It will take care of
520      * the connection details internally.
521      *
522      * @param criteria object containing data that is used to create the UPDATE
523      * statement.
524      * @param con the connection to use
525      * @throws TorqueException Any exceptions caught during processing will be
526      * rethrown wrapped into a TorqueException.
527      */

528     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
529         throws TorqueException
530     {
531         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
532                    selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID));
533                        selectCriteria.put(ATTRIBUTE_ID, criteria.remove(ATTRIBUTE_ID));
534                        selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID));
535                             // check for conversion from boolean to int
536
if (criteria.containsKey(ACTIVE))
537         {
538             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
539             if (possibleBoolean instanceof Boolean JavaDoc)
540             {
541                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
542             }
543          }
544                       // check for conversion from boolean to int
545
if (criteria.containsKey(REQUIRED))
546         {
547             Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
548             if (possibleBoolean instanceof Boolean JavaDoc)
549             {
550                 criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
551             }
552          }
553                                 // check for conversion from boolean to int
554
if (criteria.containsKey(QUICK_SEARCH))
555         {
556             Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
557             if (possibleBoolean instanceof Boolean JavaDoc)
558             {
559                 criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
560             }
561          }
562                       // check for conversion from boolean to int
563
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
564         {
565             Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
566             if (possibleBoolean instanceof Boolean JavaDoc)
567             {
568                 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
569             }
570          }
571           
572         setDbName(criteria);
573
574         if (con == null)
575         {
576             BasePeer.doUpdate(selectCriteria, criteria);
577         }
578         else
579         {
580             BasePeer.doUpdate(selectCriteria, criteria, con);
581         }
582     }
583
584     /**
585      * Method to do deletes.
586      *
587      * @param criteria object containing data that is used DELETE from database.
588      * @throws TorqueException Any exceptions caught during processing will be
589      * rethrown wrapped into a TorqueException.
590      */

591      public static void doDelete(Criteria criteria) throws TorqueException
592      {
593          RModuleAttributePeer
594             .doDelete(criteria, (Connection JavaDoc) null);
595      }
596
597     /**
598      * Method to do deletes. This method is to be used during a transaction,
599      * otherwise use the doDelete(Criteria) method. It will take care of
600      * the connection details internally.
601      *
602      * @param criteria object containing data that is used DELETE from database.
603      * @param con the connection to use
604      * @throws TorqueException Any exceptions caught during processing will be
605      * rethrown wrapped into a TorqueException.
606      */

607      public static void doDelete(Criteria criteria, Connection JavaDoc con)
608         throws TorqueException
609      {
610                                       // check for conversion from boolean to int
611
if (criteria.containsKey(ACTIVE))
612         {
613             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
614             if (possibleBoolean instanceof Boolean JavaDoc)
615             {
616                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
617             }
618          }
619                   // check for conversion from boolean to int
620
if (criteria.containsKey(REQUIRED))
621         {
622             Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
623             if (possibleBoolean instanceof Boolean JavaDoc)
624             {
625                 criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
626             }
627          }
628                         // check for conversion from boolean to int
629
if (criteria.containsKey(QUICK_SEARCH))
630         {
631             Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
632             if (possibleBoolean instanceof Boolean JavaDoc)
633             {
634                 criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
635             }
636          }
637                   // check for conversion from boolean to int
638
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
639         {
640             Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
641             if (possibleBoolean instanceof Boolean JavaDoc)
642             {
643                 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
644             }
645          }
646       
647         setDbName(criteria);
648
649         if (con == null)
650         {
651             BasePeer.doDelete(criteria);
652         }
653         else
654         {
655             BasePeer.doDelete(criteria, con);
656         }
657      }
658
659     /**
660      * Method to do selects
661      *
662      * @throws TorqueException Any exceptions caught during processing will be
663      * rethrown wrapped into a TorqueException.
664      */

665     public static List JavaDoc doSelect(RModuleAttribute obj) throws TorqueException
666     {
667         return doSelect(buildSelectCriteria(obj));
668     }
669
670     /**
671      * Method to do inserts
672      *
673      * @throws TorqueException Any exceptions caught during processing will be
674      * rethrown wrapped into a TorqueException.
675      */

676     public static void doInsert(RModuleAttribute obj) throws TorqueException
677     {
678           doInsert(buildCriteria(obj));
679           obj.setNew(false);
680         obj.setModified(false);
681     }
682
683     /**
684      * @param obj the data object to update in the database.
685      * @throws TorqueException Any exceptions caught during processing will be
686      * rethrown wrapped into a TorqueException.
687      */

688     public static void doUpdate(RModuleAttribute obj) throws TorqueException
689     {
690         doUpdate(buildCriteria(obj));
691         obj.setModified(false);
692     }
693
694     /**
695      * @param obj the data object to delete in the database.
696      * @throws TorqueException Any exceptions caught during processing will be
697      * rethrown wrapped into a TorqueException.
698      */

699     public static void doDelete(RModuleAttribute obj) throws TorqueException
700     {
701         doDelete(buildSelectCriteria(obj));
702     }
703
704     /**
705      * Method to do inserts. This method is to be used during a transaction,
706      * otherwise use the doInsert(RModuleAttribute) method. It will take
707      * care of the connection details internally.
708      *
709      * @param obj the data object to insert into the database.
710      * @param con the connection to use
711      * @throws TorqueException Any exceptions caught during processing will be
712      * rethrown wrapped into a TorqueException.
713      */

714     public static void doInsert(RModuleAttribute obj, Connection JavaDoc con)
715         throws TorqueException
716     {
717           doInsert(buildCriteria(obj), con);
718           obj.setNew(false);
719         obj.setModified(false);
720     }
721
722     /**
723      * Method to do update. This method is to be used during a transaction,
724      * otherwise use the doUpdate(RModuleAttribute) method. It will take
725      * care of the connection details internally.
726      *
727      * @param obj the data object to update in the database.
728      * @param con the connection to use
729      * @throws TorqueException Any exceptions caught during processing will be
730      * rethrown wrapped into a TorqueException.
731      */

732     public static void doUpdate(RModuleAttribute obj, Connection JavaDoc con)
733         throws TorqueException
734     {
735         doUpdate(buildCriteria(obj), con);
736         obj.setModified(false);
737     }
738
739     /**
740      * Method to delete. This method is to be used during a transaction,
741      * otherwise use the doDelete(RModuleAttribute) method. It will take
742      * care of the connection details internally.
743      *
744      * @param obj the data object to delete in the database.
745      * @param con the connection to use
746      * @throws TorqueException Any exceptions caught during processing will be
747      * rethrown wrapped into a TorqueException.
748      */

749     public static void doDelete(RModuleAttribute obj, Connection JavaDoc con)
750         throws TorqueException
751     {
752         doDelete(buildSelectCriteria(obj), con);
753     }
754
755     /**
756      * Method to do deletes.
757      *
758      * @param pk ObjectKey that is used DELETE from database.
759      * @throws TorqueException Any exceptions caught during processing will be
760      * rethrown wrapped into a TorqueException.
761      */

762     public static void doDelete(ObjectKey pk) throws TorqueException
763     {
764         BaseRModuleAttributePeer
765            .doDelete(pk, (Connection JavaDoc) null);
766     }
767
768     /**
769      * Method to delete. This method is to be used during a transaction,
770      * otherwise use the doDelete(ObjectKey) method. It will take
771      * care of the connection details internally.
772      *
773      * @param pk the primary key for the object to delete in the database.
774      * @param con the connection to use
775      * @throws TorqueException Any exceptions caught during processing will be
776      * rethrown wrapped into a TorqueException.
777      */

778     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
779         throws TorqueException
780     {
781         doDelete(buildCriteria(pk), con);
782     }
783
784     /** Build a Criteria object from an ObjectKey */
785     public static Criteria buildCriteria( ObjectKey pk )
786     {
787         Criteria criteria = new Criteria();
788           SimpleKey[] keys = (SimpleKey[])pk.getValue();
789                     criteria.add(MODULE_ID, keys[0]);
790                       criteria.add(ATTRIBUTE_ID, keys[1]);
791                       criteria.add(ISSUE_TYPE_ID, keys[2]);
792                     return criteria;
793      }
794
795     /** Build a Criteria object from the data object for this peer */
796     public static Criteria buildCriteria( RModuleAttribute obj )
797     {
798         Criteria criteria = new Criteria(DATABASE_NAME);
799               criteria.add(MODULE_ID, obj.getModuleId());
800               criteria.add(ATTRIBUTE_ID, obj.getAttributeId());
801               criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
802               criteria.add(DISPLAY_VALUE, obj.getDisplayValue());
803               criteria.add(ACTIVE, obj.getActive());
804               criteria.add(REQUIRED, obj.getRequired());
805               criteria.add(PREFERRED_ORDER, obj.getOrder());
806               criteria.add(QUICK_SEARCH, obj.getQuickSearch());
807               criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag());
808           return criteria;
809     }
810
811     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
812     public static Criteria buildSelectCriteria( RModuleAttribute obj )
813     {
814         Criteria criteria = new Criteria(DATABASE_NAME);
815                       criteria.add(MODULE_ID, obj.getModuleId());
816                           criteria.add(ATTRIBUTE_ID, obj.getAttributeId());
817                           criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
818                           criteria.add(DISPLAY_VALUE, obj.getDisplayValue());
819                           criteria.add(ACTIVE, obj.getActive());
820                           criteria.add(REQUIRED, obj.getRequired());
821                           criteria.add(PREFERRED_ORDER, obj.getOrder());
822                           criteria.add(QUICK_SEARCH, obj.getQuickSearch());
823                           criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag());
824               return criteria;
825     }
826  
827     
828     
829     /**
830      * Retrieve a single object by pk
831      *
832      * @param pk the primary key
833      * @throws TorqueException Any exceptions caught during processing will be
834      * rethrown wrapped into a TorqueException.
835      * @throws NoRowsException Primary key was not found in database.
836      * @throws TooManyRowsException Primary key was not found in database.
837      */

838     public static RModuleAttribute retrieveByPK(ObjectKey pk)
839         throws TorqueException, NoRowsException, TooManyRowsException
840     {
841         Connection JavaDoc db = null;
842         RModuleAttribute retVal = null;
843         try
844         {
845             db = Torque.getConnection(DATABASE_NAME);
846             retVal = retrieveByPK(pk, db);
847         }
848         finally
849         {
850             Torque.closeConnection(db);
851         }
852         return(retVal);
853     }
854
855     /**
856      * Retrieve a single object by pk
857      *
858      * @param pk the primary key
859      * @param con the connection to use
860      * @throws TorqueException Any exceptions caught during processing will be
861      * rethrown wrapped into a TorqueException.
862      * @throws NoRowsException Primary key was not found in database.
863      * @throws TooManyRowsException Primary key was not found in database.
864      */

865     public static RModuleAttribute retrieveByPK(ObjectKey pk, Connection JavaDoc con)
866         throws TorqueException, NoRowsException, TooManyRowsException
867     {
868         Criteria criteria = buildCriteria(pk);
869         List JavaDoc v = doSelect(criteria, con);
870         if (v.size() == 0)
871         {
872             throw new NoRowsException("Failed to select a row.");
873         }
874         else if (v.size() > 1)
875         {
876             throw new TooManyRowsException("Failed to select only one row.");
877         }
878         else
879         {
880             return (RModuleAttribute)v.get(0);
881         }
882     }
883
884     /**
885      * Retrieve a multiple objects by pk
886      *
887      * @param pks List of primary keys
888      * @throws TorqueException Any exceptions caught during processing will be
889      * rethrown wrapped into a TorqueException.
890      */

891     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
892         throws TorqueException
893     {
894         Connection JavaDoc db = null;
895         List JavaDoc retVal = null;
896         try
897         {
898            db = Torque.getConnection(DATABASE_NAME);
899            retVal = retrieveByPKs(pks, db);
900         }
901         finally
902         {
903             Torque.closeConnection(db);
904         }
905         return(retVal);
906     }
907
908     /**
909      * Retrieve a multiple objects by pk
910      *
911      * @param pks List of primary keys
912      * @param dbcon the connection to use
913      * @throws TorqueException Any exceptions caught during processing will be
914      * rethrown wrapped into a TorqueException.
915      */

916     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
917         throws TorqueException
918     {
919         List JavaDoc objs = null;
920         if (pks == null || pks.size() == 0)
921         {
922             objs = new LinkedList JavaDoc();
923         }
924         else
925         {
926             Criteria criteria = new Criteria();
927               Iterator JavaDoc iter = pks.iterator();
928             while (iter.hasNext())
929             {
930                 ObjectKey pk = (ObjectKey)iter.next();
931                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
932                             Criteria.Criterion c0 = criteria.getNewCriterion(
933                         MODULE_ID, keys[0], Criteria.EQUAL);
934                                     Criteria.Criterion c1 = criteria.getNewCriterion(
935                         ATTRIBUTE_ID, keys[1], Criteria.EQUAL);
936                                     c0.and(c1);
937                               Criteria.Criterion c2 = criteria.getNewCriterion(
938                         ISSUE_TYPE_ID, keys[2], Criteria.EQUAL);
939                                     c1.and(c2);
940                           criteria.or(c0);
941             }
942           objs = doSelect(criteria, dbcon);
943         }
944         return objs;
945     }
946
947  
948     /**
949      * retrieve object using using pk values.
950      *
951        * @param module_id Integer
952        * @param attribute_id Integer
953        * @param issue_type_id Integer
954        */

955     public static RModuleAttribute retrieveByPK(
956        Integer JavaDoc module_id
957           , Integer JavaDoc attribute_id
958           , Integer JavaDoc issue_type_id
959               ) throws TorqueException
960     {
961         Connection JavaDoc db = null;
962         RModuleAttribute retVal = null;
963         try
964         {
965            db = Torque.getConnection(DATABASE_NAME);
966            retVal = retrieveByPK(
967          module_id
968           , attribute_id
969           , issue_type_id
970                      , db);
971         }
972         finally
973         {
974             Torque.closeConnection(db);
975         }
976         return(retVal);
977     }
978
979       /**
980      * retrieve object using using pk values.
981      *
982        * @param module_id Integer
983        * @param attribute_id Integer
984        * @param issue_type_id Integer
985        * @param con Connection
986      */

987     public static RModuleAttribute retrieveByPK(
988        Integer JavaDoc module_id
989           , Integer JavaDoc attribute_id
990           , Integer JavaDoc issue_type_id
991              ,Connection JavaDoc con) throws TorqueException
992     {
993
994         Criteria criteria = new Criteria(5);
995           criteria.add(MODULE_ID, module_id);
996           criteria.add(ATTRIBUTE_ID, attribute_id);
997           criteria.add(ISSUE_TYPE_ID, issue_type_id);
998           List JavaDoc v = doSelect(criteria, con);
999         if (v.size() != 1)
1000        {
1001            throw new TorqueException("Failed to select one and only one row.");
1002        }
1003        else
1004        {
1005            return (RModuleAttribute) v.get(0);
1006        }
1007    }
1008
1009
1010
1011              
1012                                              
1013                
1014                
1015
1016    /**
1017     * selects a collection of RModuleAttribute objects pre-filled with their
1018     * Attribute objects.
1019     *
1020     * This method is protected by default in order to keep the public
1021     * api reasonable. You can provide public methods for those you
1022     * actually need in RModuleAttributePeer.
1023     *
1024     * @throws TorqueException Any exceptions caught during processing will be
1025     * rethrown wrapped into a TorqueException.
1026     */

1027    protected static List JavaDoc doSelectJoinAttribute(Criteria criteria)
1028        throws TorqueException
1029    {
1030        setDbName(criteria);
1031
1032        RModuleAttributePeer.addSelectColumns(criteria);
1033        int offset = numColumns + 1;
1034        AttributePeer.addSelectColumns(criteria);
1035
1036
1037                        criteria.addJoin(RModuleAttributePeer.ATTRIBUTE_ID,
1038            AttributePeer.ATTRIBUTE_ID);
1039        
1040
1041                                                                                                  // check for conversion from boolean to int
1042
if (criteria.containsKey(ACTIVE))
1043        {
1044            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1045            if (possibleBoolean instanceof Boolean JavaDoc)
1046            {
1047                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1048            }
1049         }
1050                                    // check for conversion from boolean to int
1051
if (criteria.containsKey(REQUIRED))
1052        {
1053            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1054            if (possibleBoolean instanceof Boolean JavaDoc)
1055            {
1056                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1057            }
1058         }
1059                                                      // check for conversion from boolean to int
1060
if (criteria.containsKey(QUICK_SEARCH))
1061        {
1062            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1063            if (possibleBoolean instanceof Boolean JavaDoc)
1064            {
1065                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1066            }
1067         }
1068                                    // check for conversion from boolean to int
1069
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1070        {
1071            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1072            if (possibleBoolean instanceof Boolean JavaDoc)
1073            {
1074                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1075            }
1076         }
1077                  
1078        List JavaDoc rows = BasePeer.doSelect(criteria);
1079        List JavaDoc results = new ArrayList JavaDoc();
1080
1081        for (int i = 0; i < rows.size(); i++)
1082        {
1083            Record row = (Record) rows.get(i);
1084
1085                            Class JavaDoc omClass = RModuleAttributePeer.getOMClass();
1086                    RModuleAttribute obj1 = (RModuleAttribute) RModuleAttributePeer
1087                .row2Object(row, 1, omClass);
1088                     omClass = AttributePeer.getOMClass();
1089                    Attribute obj2 = (Attribute)AttributePeer
1090                .row2Object(row, offset, omClass);
1091
1092            boolean newObject = true;
1093            for (int j = 0; j < results.size(); j++)
1094            {
1095                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1096                Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute();
1097                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1098                {
1099                    newObject = false;
1100                              temp_obj2.addRModuleAttribute(obj1);
1101                              break;
1102                }
1103            }
1104                      if (newObject)
1105            {
1106                obj2.initRModuleAttributes();
1107                obj2.addRModuleAttribute(obj1);
1108            }
1109                      results.add(obj1);
1110        }
1111        return results;
1112    }
1113                                                            
1114                        
1115                
1116
1117    /**
1118     * selects a collection of RModuleAttribute objects pre-filled with their
1119     * ScarabModule objects.
1120     *
1121     * This method is protected by default in order to keep the public
1122     * api reasonable. You can provide public methods for those you
1123     * actually need in RModuleAttributePeer.
1124     *
1125     * @throws TorqueException Any exceptions caught during processing will be
1126     * rethrown wrapped into a TorqueException.
1127     */

1128    protected static List JavaDoc doSelectJoinScarabModule(Criteria criteria)
1129        throws TorqueException
1130    {
1131        setDbName(criteria);
1132
1133        RModuleAttributePeer.addSelectColumns(criteria);
1134        int offset = numColumns + 1;
1135        ScarabModulePeer.addSelectColumns(criteria);
1136
1137
1138                        criteria.addJoin(RModuleAttributePeer.MODULE_ID,
1139            ScarabModulePeer.MODULE_ID);
1140        
1141
1142                                                                                                  // check for conversion from boolean to int
1143
if (criteria.containsKey(ACTIVE))
1144        {
1145            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1146            if (possibleBoolean instanceof Boolean JavaDoc)
1147            {
1148                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1149            }
1150         }
1151                                    // check for conversion from boolean to int
1152
if (criteria.containsKey(REQUIRED))
1153        {
1154            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1155            if (possibleBoolean instanceof Boolean JavaDoc)
1156            {
1157                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1158            }
1159         }
1160                                                      // check for conversion from boolean to int
1161
if (criteria.containsKey(QUICK_SEARCH))
1162        {
1163            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1164            if (possibleBoolean instanceof Boolean JavaDoc)
1165            {
1166                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1167            }
1168         }
1169                                    // check for conversion from boolean to int
1170
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1171        {
1172            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1173            if (possibleBoolean instanceof Boolean JavaDoc)
1174            {
1175                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1176            }
1177         }
1178                  
1179        List JavaDoc rows = BasePeer.doSelect(criteria);
1180        List JavaDoc results = new ArrayList JavaDoc();
1181
1182        for (int i = 0; i < rows.size(); i++)
1183        {
1184            Record row = (Record) rows.get(i);
1185
1186                            Class JavaDoc omClass = RModuleAttributePeer.getOMClass();
1187                    RModuleAttribute obj1 = (RModuleAttribute) RModuleAttributePeer
1188                .row2Object(row, 1, omClass);
1189                     omClass = ScarabModulePeer.getOMClass(row, offset);
1190                    ScarabModule obj2 = (ScarabModule)ScarabModulePeer
1191                .row2Object(row, offset, omClass);
1192
1193            boolean newObject = true;
1194            for (int j = 0; j < results.size(); j++)
1195            {
1196                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1197                ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
1198                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1199                {
1200                    newObject = false;
1201                              temp_obj2.addRModuleAttribute(obj1);
1202                              break;
1203                }
1204            }
1205                      if (newObject)
1206            {
1207                obj2.initRModuleAttributes();
1208                obj2.addRModuleAttribute(obj1);
1209            }
1210                      results.add(obj1);
1211        }
1212        return results;
1213    }
1214                                                            
1215                
1216                
1217
1218    /**
1219     * selects a collection of RModuleAttribute objects pre-filled with their
1220     * IssueType objects.
1221     *
1222     * This method is protected by default in order to keep the public
1223     * api reasonable. You can provide public methods for those you
1224     * actually need in RModuleAttributePeer.
1225     *
1226     * @throws TorqueException Any exceptions caught during processing will be
1227     * rethrown wrapped into a TorqueException.
1228     */

1229    protected static List JavaDoc doSelectJoinIssueType(Criteria criteria)
1230        throws TorqueException
1231    {
1232        setDbName(criteria);
1233
1234        RModuleAttributePeer.addSelectColumns(criteria);
1235        int offset = numColumns + 1;
1236        IssueTypePeer.addSelectColumns(criteria);
1237
1238
1239                        criteria.addJoin(RModuleAttributePeer.ISSUE_TYPE_ID,
1240            IssueTypePeer.ISSUE_TYPE_ID);
1241        
1242
1243                                                                                                  // check for conversion from boolean to int
1244
if (criteria.containsKey(ACTIVE))
1245        {
1246            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1247            if (possibleBoolean instanceof Boolean JavaDoc)
1248            {
1249                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1250            }
1251         }
1252                                    // check for conversion from boolean to int
1253
if (criteria.containsKey(REQUIRED))
1254        {
1255            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1256            if (possibleBoolean instanceof Boolean JavaDoc)
1257            {
1258                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1259            }
1260         }
1261                                                      // check for conversion from boolean to int
1262
if (criteria.containsKey(QUICK_SEARCH))
1263        {
1264            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1265            if (possibleBoolean instanceof Boolean JavaDoc)
1266            {
1267                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1268            }
1269         }
1270                                    // check for conversion from boolean to int
1271
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1272        {
1273            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1274            if (possibleBoolean instanceof Boolean JavaDoc)
1275            {
1276                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1277            }
1278         }
1279                  
1280        List JavaDoc rows = BasePeer.doSelect(criteria);
1281        List JavaDoc results = new ArrayList JavaDoc();
1282
1283        for (int i = 0; i < rows.size(); i++)
1284        {
1285            Record row = (Record) rows.get(i);
1286
1287                            Class JavaDoc omClass = RModuleAttributePeer.getOMClass();
1288                    RModuleAttribute obj1 = (RModuleAttribute) RModuleAttributePeer
1289                .row2Object(row, 1, omClass);
1290                     omClass = IssueTypePeer.getOMClass();
1291                    IssueType obj2 = (IssueType)IssueTypePeer
1292                .row2Object(row, offset, omClass);
1293
1294            boolean newObject = true;
1295            for (int j = 0; j < results.size(); j++)
1296            {
1297                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1298                IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
1299                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1300                {
1301                    newObject = false;
1302                              temp_obj2.addRModuleAttribute(obj1);
1303                              break;
1304                }
1305            }
1306                      if (newObject)
1307            {
1308                obj2.initRModuleAttributes();
1309                obj2.addRModuleAttribute(obj1);
1310            }
1311                      results.add(obj1);
1312        }
1313        return results;
1314    }
1315                    
1316  
1317                                    
1318          
1319        
1320                                  
1321                
1322
1323    /**
1324     * selects a collection of RModuleAttribute objects pre-filled with
1325     * all related objects.
1326     *
1327     * This method is protected by default in order to keep the public
1328     * api reasonable. You can provide public methods for those you
1329     * actually need in RModuleAttributePeer.
1330     *
1331     * @throws TorqueException Any exceptions caught during processing will be
1332     * rethrown wrapped into a TorqueException.
1333     */

1334    protected static List JavaDoc doSelectJoinAllExceptAttribute(Criteria criteria)
1335        throws TorqueException
1336    {
1337        setDbName(criteria);
1338
1339        addSelectColumns(criteria);
1340        int offset2 = numColumns + 1;
1341                                    
1342                                                  
1343                    ScarabModulePeer.addSelectColumns(criteria);
1344        int offset3 = offset2 + ScarabModulePeer.numColumns;
1345                                                                
1346                    IssueTypePeer.addSelectColumns(criteria);
1347        int offset4 = offset3 + IssueTypePeer.numColumns;
1348                                                                                                                                              // check for conversion from boolean to int
1349
if (criteria.containsKey(ACTIVE))
1350        {
1351            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1352            if (possibleBoolean instanceof Boolean JavaDoc)
1353            {
1354                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1355            }
1356         }
1357                                    // check for conversion from boolean to int
1358
if (criteria.containsKey(REQUIRED))
1359        {
1360            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1361            if (possibleBoolean instanceof Boolean JavaDoc)
1362            {
1363                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1364            }
1365         }
1366                                                      // check for conversion from boolean to int
1367
if (criteria.containsKey(QUICK_SEARCH))
1368        {
1369            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1370            if (possibleBoolean instanceof Boolean JavaDoc)
1371            {
1372                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1373            }
1374         }
1375                                    // check for conversion from boolean to int
1376
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1377        {
1378            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1379            if (possibleBoolean instanceof Boolean JavaDoc)
1380            {
1381                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1382            }
1383         }
1384                  
1385        List JavaDoc rows = BasePeer.doSelect(criteria);
1386        List JavaDoc results = new ArrayList JavaDoc();
1387
1388        for (int i = 0; i < rows.size(); i++)
1389        {
1390            Record row = (Record)rows.get(i);
1391
1392                            Class JavaDoc omClass = RModuleAttributePeer.getOMClass();
1393                    RModuleAttribute obj1 = (RModuleAttribute)RModuleAttributePeer
1394                .row2Object(row, 1, omClass);
1395                                                
1396                                                                              
1397                                                        
1398                            
1399              
1400                           omClass = ScarabModulePeer.getOMClass(row, offset2);
1401                          ScarabModule obj2 = (ScarabModule)ScarabModulePeer
1402                .row2Object( row, offset2, omClass);
1403
1404               boolean newObject = true;
1405            for (int j = 0; j < results.size(); j++)
1406            {
1407                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1408                ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
1409                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1410                {
1411                    newObject = false;
1412                                    temp_obj2.addRModuleAttribute(obj1);
1413                                    break;
1414                }
1415            }
1416                            if (newObject)
1417            {
1418                obj2.initRModuleAttributes();
1419                obj2.addRModuleAttribute(obj1);
1420            }
1421                                                                                    
1422                                                        
1423                            
1424              
1425                           omClass = IssueTypePeer.getOMClass();
1426                          IssueType obj3 = (IssueType)IssueTypePeer
1427                .row2Object( row, offset3, omClass);
1428
1429               newObject = true;
1430            for (int j = 0; j < results.size(); j++)
1431            {
1432                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1433                IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType();
1434                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1435                {
1436                    newObject = false;
1437                                    temp_obj3.addRModuleAttribute(obj1);
1438                                    break;
1439                }
1440            }
1441                            if (newObject)
1442            {
1443                obj3.initRModuleAttributes();
1444                obj3.addRModuleAttribute(obj1);
1445            }
1446                                                                results.add(obj1);
1447        }
1448        return results;
1449    }
1450        
1451        
1452                                  
1453                
1454
1455    /**
1456     * selects a collection of RModuleAttribute objects pre-filled with
1457     * all related objects.
1458     *
1459     * This method is protected by default in order to keep the public
1460     * api reasonable. You can provide public methods for those you
1461     * actually need in RModuleAttributePeer.
1462     *
1463     * @throws TorqueException Any exceptions caught during processing will be
1464     * rethrown wrapped into a TorqueException.
1465     */

1466    protected static List JavaDoc doSelectJoinAllExceptScarabModule(Criteria criteria)
1467        throws TorqueException
1468    {
1469        setDbName(criteria);
1470
1471        addSelectColumns(criteria);
1472        int offset2 = numColumns + 1;
1473                                    
1474                    AttributePeer.addSelectColumns(criteria);
1475        int offset3 = offset2 + AttributePeer.numColumns;
1476                                                                
1477                                                  
1478                    IssueTypePeer.addSelectColumns(criteria);
1479        int offset4 = offset3 + IssueTypePeer.numColumns;
1480                                                                                                                                              // check for conversion from boolean to int
1481
if (criteria.containsKey(ACTIVE))
1482        {
1483            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1484            if (possibleBoolean instanceof Boolean JavaDoc)
1485            {
1486                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1487            }
1488         }
1489                                    // check for conversion from boolean to int
1490
if (criteria.containsKey(REQUIRED))
1491        {
1492            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1493            if (possibleBoolean instanceof Boolean JavaDoc)
1494            {
1495                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1496            }
1497         }
1498                                                      // check for conversion from boolean to int
1499
if (criteria.containsKey(QUICK_SEARCH))
1500        {
1501            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1502            if (possibleBoolean instanceof Boolean JavaDoc)
1503            {
1504                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1505            }
1506         }
1507                                    // check for conversion from boolean to int
1508
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1509        {
1510            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1511            if (possibleBoolean instanceof Boolean JavaDoc)
1512            {
1513                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1514            }
1515         }
1516                  
1517        List JavaDoc rows = BasePeer.doSelect(criteria);
1518        List JavaDoc results = new ArrayList JavaDoc();
1519
1520        for (int i = 0; i < rows.size(); i++)
1521        {
1522            Record row = (Record)rows.get(i);
1523
1524                            Class JavaDoc omClass = RModuleAttributePeer.getOMClass();
1525                    RModuleAttribute obj1 = (RModuleAttribute)RModuleAttributePeer
1526                .row2Object(row, 1, omClass);
1527                                                
1528                                                        
1529                            
1530              
1531                           omClass = AttributePeer.getOMClass();
1532                          Attribute obj2 = (Attribute)AttributePeer
1533                .row2Object( row, offset2, omClass);
1534
1535               boolean newObject = true;
1536            for (int j = 0; j < results.size(); j++)
1537            {
1538                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1539                Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute();
1540                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1541                {
1542                    newObject = false;
1543                                    temp_obj2.addRModuleAttribute(obj1);
1544                                    break;
1545                }
1546            }
1547                            if (newObject)
1548            {
1549                obj2.initRModuleAttributes();
1550                obj2.addRModuleAttribute(obj1);
1551            }
1552                                                                                                
1553                                                                  
1554                                                        
1555                            
1556              
1557                           omClass = IssueTypePeer.getOMClass();
1558                          IssueType obj3 = (IssueType)IssueTypePeer
1559                .row2Object( row, offset3, omClass);
1560
1561               newObject = true;
1562            for (int j = 0; j < results.size(); j++)
1563            {
1564                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1565                IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType();
1566                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1567                {
1568                    newObject = false;
1569                                    temp_obj3.addRModuleAttribute(obj1);
1570                                    break;
1571                }
1572            }
1573                            if (newObject)
1574            {
1575                obj3.initRModuleAttributes();
1576                obj3.addRModuleAttribute(obj1);
1577            }
1578                                                                results.add(obj1);
1579        }
1580        return results;
1581    }
1582        
1583        
1584                                  
1585                
1586
1587    /**
1588     * selects a collection of RModuleAttribute objects pre-filled with
1589     * all related objects.
1590     *
1591     * This method is protected by default in order to keep the public
1592     * api reasonable. You can provide public methods for those you
1593     * actually need in RModuleAttributePeer.
1594     *
1595     * @throws TorqueException Any exceptions caught during processing will be
1596     * rethrown wrapped into a TorqueException.
1597     */

1598    protected static List JavaDoc doSelectJoinAllExceptIssueType(Criteria criteria)
1599        throws TorqueException
1600    {
1601        setDbName(criteria);
1602
1603        addSelectColumns(criteria);
1604        int offset2 = numColumns + 1;
1605                                    
1606                    AttributePeer.addSelectColumns(criteria);
1607        int offset3 = offset2 + AttributePeer.numColumns;
1608                                                                
1609                    ScarabModulePeer.addSelectColumns(criteria);
1610        int offset4 = offset3 + ScarabModulePeer.numColumns;
1611                                                                
1612                                                                                                                                // check for conversion from boolean to int
1613
if (criteria.containsKey(ACTIVE))
1614        {
1615            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1616            if (possibleBoolean instanceof Boolean JavaDoc)
1617            {
1618                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1619            }
1620         }
1621                                    // check for conversion from boolean to int
1622
if (criteria.containsKey(REQUIRED))
1623        {
1624            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1625            if (possibleBoolean instanceof Boolean JavaDoc)
1626            {
1627                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1628            }
1629         }
1630                                                      // check for conversion from boolean to int
1631
if (criteria.containsKey(QUICK_SEARCH))
1632        {
1633            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1634            if (possibleBoolean instanceof Boolean JavaDoc)
1635            {
1636                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1637            }
1638         }
1639                                    // check for conversion from boolean to int
1640
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1641        {
1642            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1643            if (possibleBoolean instanceof Boolean JavaDoc)
1644            {
1645                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1646            }
1647         }
1648                  
1649        List JavaDoc rows = BasePeer.doSelect(criteria);
1650        List JavaDoc results = new ArrayList JavaDoc();
1651
1652        for (int i = 0; i < rows.size(); i++)
1653        {
1654            Record row = (Record)rows.get(i);
1655
1656                            Class JavaDoc omClass = RModuleAttributePeer.getOMClass();
1657                    RModuleAttribute obj1 = (RModuleAttribute)RModuleAttributePeer
1658                .row2Object(row, 1, omClass);
1659                                                
1660                                                        
1661                            
1662              
1663                           omClass = AttributePeer.getOMClass();
1664                          Attribute obj2 = (Attribute)AttributePeer
1665                .row2Object( row, offset2, omClass);
1666
1667               boolean newObject = true;
1668            for (int j = 0; j < results.size(); j++)
1669            {
1670                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1671                Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute();
1672                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1673                {
1674                    newObject = false;
1675                                    temp_obj2.addRModuleAttribute(obj1);
1676                                    break;
1677                }
1678            }
1679                            if (newObject)
1680            {
1681                obj2.initRModuleAttributes();
1682                obj2.addRModuleAttribute(obj1);
1683            }
1684                                                                                                
1685                                                        
1686                            
1687              
1688                           omClass = ScarabModulePeer.getOMClass(row, offset3);
1689                          ScarabModule obj3 = (ScarabModule)ScarabModulePeer
1690                .row2Object( row, offset3, omClass);
1691
1692               newObject = true;
1693            for (int j = 0; j < results.size(); j++)
1694            {
1695                RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j);
1696                ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule();
1697                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1698                {
1699                    newObject = false;
1700                                    temp_obj3.addRModuleAttribute(obj1);
1701                                    break;
1702                }
1703            }
1704                            if (newObject)
1705            {
1706                obj3.initRModuleAttributes();
1707                obj3.addRModuleAttribute(obj1);
1708            }
1709                                                                                    
1710                                              results.add(obj1);
1711        }
1712        return results;
1713    }
1714                    
1715  
1716      /**
1717     * Returns the TableMap related to this peer. This method is not
1718     * needed for general use but a specific application could have a need.
1719     *
1720     * @throws TorqueException Any exceptions caught during processing will be
1721     * rethrown wrapped into a TorqueException.
1722     */

1723    protected static TableMap getTableMap()
1724        throws TorqueException
1725    {
1726        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1727    }
1728   
1729    private static void setDbName(Criteria crit)
1730    {
1731        // Set the correct dbName if it has not been overridden
1732
// crit.getDbName will return the same object if not set to
1733
// another value so == check is okay and faster
1734
if (crit.getDbName() == Torque.getDefaultDB())
1735        {
1736            crit.setDbName(DATABASE_NAME);
1737        }
1738    }
1739}
1740
Popular Tags