KickJava   Java API By Example, From Geeks To Geeks.

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


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  */

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

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

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

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

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

219     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
220         throws TorqueException
221     {
222                                                               // check for conversion from boolean to int
223
if (criteria.containsKey(DELETED))
224         {
225             Object JavaDoc possibleBoolean = criteria.get(DELETED);
226             if (possibleBoolean instanceof Boolean JavaDoc)
227             {
228                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
229             }
230          }
231             
232         setDbName(criteria);
233
234         if (con == null)
235         {
236             return BasePeer.doInsert(criteria);
237         }
238         else
239         {
240             return BasePeer.doInsert(criteria, con);
241         }
242     }
243
244     /**
245      * Add all the columns needed to create a new object.
246      *
247      * @param criteria object containing the columns to add.
248      * @throws TorqueException Any exceptions caught during processing will be
249      * rethrown wrapped into a TorqueException.
250      */

251     public static void addSelectColumns(Criteria criteria)
252             throws TorqueException
253     {
254           criteria.addSelectColumn(REPORT_ID);
255           criteria.addSelectColumn(USER_ID);
256           criteria.addSelectColumn(MODULE_ID);
257           criteria.addSelectColumn(ISSUE_TYPE_ID);
258           criteria.addSelectColumn(NAME);
259           criteria.addSelectColumn(DESCRIPTION);
260           criteria.addSelectColumn(QUERY_STRING);
261           criteria.addSelectColumn(SCOPE_ID);
262           criteria.addSelectColumn(DELETED);
263           criteria.addSelectColumn(CREATED_DATE);
264       }
265
266     /**
267      * Create a new object of type cls from a resultset row starting
268      * from a specified offset. This is done so that you can select
269      * other rows than just those needed for this object. You may
270      * for example want to create two objects from the same row.
271      *
272      * @throws TorqueException Any exceptions caught during processing will be
273      * rethrown wrapped into a TorqueException.
274      */

275     public static Report row2Object(Record row,
276                                              int offset,
277                                              Class JavaDoc cls)
278         throws TorqueException
279     {
280         try
281         {
282             Report obj = (Report) cls.newInstance();
283             ReportPeer.populateObject(row, offset, obj);
284                   obj.setModified(false);
285               obj.setNew(false);
286
287             return obj;
288         }
289         catch (InstantiationException JavaDoc e)
290         {
291             throw new TorqueException(e);
292         }
293         catch (IllegalAccessException JavaDoc e)
294         {
295             throw new TorqueException(e);
296         }
297     }
298
299     /**
300      * Populates an object from a resultset row starting
301      * from a specified offset. This is done so that you can select
302      * other rows than just those needed for this object. You may
303      * for example want to create two objects from the same row.
304      *
305      * @throws TorqueException Any exceptions caught during processing will be
306      * rethrown wrapped into a TorqueException.
307      */

308     public static void populateObject(Record row,
309                                       int offset,
310                                       Report obj)
311         throws TorqueException
312     {
313         try
314         {
315                 obj.setReportId(row.getValue(offset + 0).asIntegerObj());
316                   obj.setUserId(row.getValue(offset + 1).asIntegerObj());
317                   obj.setModuleId(row.getValue(offset + 2).asIntegerObj());
318                   obj.setIssueTypeId(row.getValue(offset + 3).asIntegerObj());
319                   obj.setName(row.getValue(offset + 4).asString());
320                   obj.setDescription(row.getValue(offset + 5).asString());
321                   obj.setQueryString(row.getValue(offset + 6).asString());
322                   obj.setScopeId(row.getValue(offset + 7).asIntegerObj());
323                   obj.setDeleted(row.getValue(offset + 8).asBoolean());
324                   obj.setCreatedDate(row.getValue(offset + 9).asUtilDate());
325               }
326         catch (DataSetException e)
327         {
328             throw new TorqueException(e);
329         }
330     }
331
332     /**
333      * Method to do selects.
334      *
335      * @param criteria object used to create the SELECT statement.
336      * @return List of selected Objects
337      * @throws TorqueException Any exceptions caught during processing will be
338      * rethrown wrapped into a TorqueException.
339      */

340     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
341     {
342         return populateObjects(doSelectVillageRecords(criteria));
343     }
344
345     /**
346      * Method to do selects within a transaction.
347      *
348      * @param criteria object used to create the SELECT statement.
349      * @param con the connection to use
350      * @return List of selected Objects
351      * @throws TorqueException Any exceptions caught during processing will be
352      * rethrown wrapped into a TorqueException.
353      */

354     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
355         throws TorqueException
356     {
357         return populateObjects(doSelectVillageRecords(criteria, con));
358     }
359
360     /**
361      * Grabs the raw Village records to be formed into objects.
362      * This method handles connections internally. The Record objects
363      * returned by this method should be considered readonly. Do not
364      * alter the data and call save(), your results may vary, but are
365      * certainly likely to result in hard to track MT bugs.
366      *
367      * @throws TorqueException Any exceptions caught during processing will be
368      * rethrown wrapped into a TorqueException.
369      */

370     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
371         throws TorqueException
372     {
373         return BaseReportPeer
374             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
375     }
376
377     /**
378      * Grabs the raw Village records to be formed into objects.
379      * This method should be used for transactions
380      *
381      * @param criteria object used to create the SELECT statement.
382      * @param con the connection to use
383      * @throws TorqueException Any exceptions caught during processing will be
384      * rethrown wrapped into a TorqueException.
385      */

386     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
387         throws TorqueException
388     {
389         if (criteria.getSelectColumns().size() == 0)
390         {
391             addSelectColumns(criteria);
392         }
393
394                                                               // check for conversion from boolean to int
395
if (criteria.containsKey(DELETED))
396         {
397             Object JavaDoc possibleBoolean = criteria.get(DELETED);
398             if (possibleBoolean instanceof Boolean JavaDoc)
399             {
400                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
401             }
402          }
403             
404         setDbName(criteria);
405
406         // BasePeer returns a List of Value (Village) arrays. The array
407
// order follows the order columns were placed in the Select clause.
408
if (con == null)
409         {
410             return BasePeer.doSelect(criteria);
411         }
412         else
413         {
414             return BasePeer.doSelect(criteria, con);
415         }
416     }
417
418     /**
419      * The returned List will contain objects of the default type or
420      * objects that inherit from the default.
421      *
422      * @throws TorqueException Any exceptions caught during processing will be
423      * rethrown wrapped into a TorqueException.
424      */

425     public static List JavaDoc populateObjects(List JavaDoc records)
426         throws TorqueException
427     {
428         List JavaDoc results = new ArrayList JavaDoc(records.size());
429
430         // populate the object(s)
431
for (int i = 0; i < records.size(); i++)
432         {
433             Record row = (Record) records.get(i);
434               results.add(ReportPeer.row2Object(row, 1,
435                 ReportPeer.getOMClass()));
436           }
437         return results;
438     }
439  
440
441     /**
442      * The class that the Peer will make instances of.
443      * If the BO is abstract then you must implement this method
444      * in the BO.
445      *
446      * @throws TorqueException Any exceptions caught during processing will be
447      * rethrown wrapped into a TorqueException.
448      */

449     public static Class JavaDoc getOMClass()
450         throws TorqueException
451     {
452         return CLASS_DEFAULT;
453     }
454
455     /**
456      * Method to do updates.
457      *
458      * @param criteria object containing data that is used to create the UPDATE
459      * statement.
460      * @throws TorqueException Any exceptions caught during processing will be
461      * rethrown wrapped into a TorqueException.
462      */

463     public static void doUpdate(Criteria criteria) throws TorqueException
464     {
465          BaseReportPeer
466             .doUpdate(criteria, (Connection JavaDoc) null);
467     }
468
469     /**
470      * Method to do updates. This method is to be used during a transaction,
471      * otherwise use the doUpdate(Criteria) method. It will take care of
472      * the connection details internally.
473      *
474      * @param criteria object containing data that is used to create the UPDATE
475      * statement.
476      * @param con the connection to use
477      * @throws TorqueException Any exceptions caught during processing will be
478      * rethrown wrapped into a TorqueException.
479      */

480     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
481         throws TorqueException
482     {
483         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
484                    selectCriteria.put(REPORT_ID, criteria.remove(REPORT_ID));
485                                                                                         // check for conversion from boolean to int
486
if (criteria.containsKey(DELETED))
487         {
488             Object JavaDoc possibleBoolean = criteria.get(DELETED);
489             if (possibleBoolean instanceof Boolean JavaDoc)
490             {
491                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
492             }
493          }
494                     
495         setDbName(criteria);
496
497         if (con == null)
498         {
499             BasePeer.doUpdate(selectCriteria, criteria);
500         }
501         else
502         {
503             BasePeer.doUpdate(selectCriteria, criteria, con);
504         }
505     }
506
507     /**
508      * Method to do deletes.
509      *
510      * @param criteria object containing data that is used DELETE from database.
511      * @throws TorqueException Any exceptions caught during processing will be
512      * rethrown wrapped into a TorqueException.
513      */

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

530      public static void doDelete(Criteria criteria, Connection JavaDoc con)
531         throws TorqueException
532      {
533                                                               // check for conversion from boolean to int
534
if (criteria.containsKey(DELETED))
535         {
536             Object JavaDoc possibleBoolean = criteria.get(DELETED);
537             if (possibleBoolean instanceof Boolean JavaDoc)
538             {
539                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
540             }
541          }
542             
543         setDbName(criteria);
544
545         if (con == null)
546         {
547             BasePeer.doDelete(criteria);
548         }
549         else
550         {
551             BasePeer.doDelete(criteria, con);
552         }
553      }
554
555     /**
556      * Method to do selects
557      *
558      * @throws TorqueException Any exceptions caught during processing will be
559      * rethrown wrapped into a TorqueException.
560      */

561     public static List JavaDoc doSelect(Report obj) throws TorqueException
562     {
563         return doSelect(buildSelectCriteria(obj));
564     }
565
566     /**
567      * Method to do inserts
568      *
569      * @throws TorqueException Any exceptions caught during processing will be
570      * rethrown wrapped into a TorqueException.
571      */

572     public static void doInsert(Report obj) throws TorqueException
573     {
574           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
575           obj.setNew(false);
576         obj.setModified(false);
577     }
578
579     /**
580      * @param obj the data object to update in the database.
581      * @throws TorqueException Any exceptions caught during processing will be
582      * rethrown wrapped into a TorqueException.
583      */

584     public static void doUpdate(Report obj) throws TorqueException
585     {
586         doUpdate(buildCriteria(obj));
587         obj.setModified(false);
588     }
589
590     /**
591      * @param obj the data object to delete in the database.
592      * @throws TorqueException Any exceptions caught during processing will be
593      * rethrown wrapped into a TorqueException.
594      */

595     public static void doDelete(Report obj) throws TorqueException
596     {
597         doDelete(buildSelectCriteria(obj));
598     }
599
600     /**
601      * Method to do inserts. This method is to be used during a transaction,
602      * otherwise use the doInsert(Report) method. It will take
603      * care of the connection details internally.
604      *
605      * @param obj the data object to insert into the database.
606      * @param con the connection to use
607      * @throws TorqueException Any exceptions caught during processing will be
608      * rethrown wrapped into a TorqueException.
609      */

610     public static void doInsert(Report obj, Connection JavaDoc con)
611         throws TorqueException
612     {
613           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
614           obj.setNew(false);
615         obj.setModified(false);
616     }
617
618     /**
619      * Method to do update. This method is to be used during a transaction,
620      * otherwise use the doUpdate(Report) method. It will take
621      * care of the connection details internally.
622      *
623      * @param obj the data object to update in the database.
624      * @param con the connection to use
625      * @throws TorqueException Any exceptions caught during processing will be
626      * rethrown wrapped into a TorqueException.
627      */

628     public static void doUpdate(Report obj, Connection JavaDoc con)
629         throws TorqueException
630     {
631         doUpdate(buildCriteria(obj), con);
632         obj.setModified(false);
633     }
634
635     /**
636      * Method to delete. This method is to be used during a transaction,
637      * otherwise use the doDelete(Report) method. It will take
638      * care of the connection details internally.
639      *
640      * @param obj the data object to delete in the database.
641      * @param con the connection to use
642      * @throws TorqueException Any exceptions caught during processing will be
643      * rethrown wrapped into a TorqueException.
644      */

645     public static void doDelete(Report obj, Connection JavaDoc con)
646         throws TorqueException
647     {
648         doDelete(buildSelectCriteria(obj), con);
649     }
650
651     /**
652      * Method to do deletes.
653      *
654      * @param pk ObjectKey that is used DELETE from database.
655      * @throws TorqueException Any exceptions caught during processing will be
656      * rethrown wrapped into a TorqueException.
657      */

658     public static void doDelete(ObjectKey pk) throws TorqueException
659     {
660         BaseReportPeer
661            .doDelete(pk, (Connection JavaDoc) null);
662     }
663
664     /**
665      * Method to delete. This method is to be used during a transaction,
666      * otherwise use the doDelete(ObjectKey) method. It will take
667      * care of the connection details internally.
668      *
669      * @param pk the primary key for the object to delete in the database.
670      * @param con the connection to use
671      * @throws TorqueException Any exceptions caught during processing will be
672      * rethrown wrapped into a TorqueException.
673      */

674     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
675         throws TorqueException
676     {
677         doDelete(buildCriteria(pk), con);
678     }
679
680     /** Build a Criteria object from an ObjectKey */
681     public static Criteria buildCriteria( ObjectKey pk )
682     {
683         Criteria criteria = new Criteria();
684               criteria.add(REPORT_ID, pk);
685           return criteria;
686      }
687
688     /** Build a Criteria object from the data object for this peer */
689     public static Criteria buildCriteria( Report obj )
690     {
691         Criteria criteria = new Criteria(DATABASE_NAME);
692               if (!obj.isNew())
693             criteria.add(REPORT_ID, obj.getReportId());
694               criteria.add(USER_ID, obj.getUserId());
695               criteria.add(MODULE_ID, obj.getModuleId());
696               criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
697               criteria.add(NAME, obj.getName());
698               criteria.add(DESCRIPTION, obj.getDescription());
699               criteria.add(QUERY_STRING, obj.getQueryString());
700               criteria.add(SCOPE_ID, obj.getScopeId());
701               criteria.add(DELETED, obj.getDeleted());
702               criteria.add(CREATED_DATE, obj.getCreatedDate());
703           return criteria;
704     }
705
706     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
707     public static Criteria buildSelectCriteria( Report obj )
708     {
709         Criteria criteria = new Criteria(DATABASE_NAME);
710               if (!obj.isNew())
711                     criteria.add(REPORT_ID, obj.getReportId());
712                           criteria.add(USER_ID, obj.getUserId());
713                           criteria.add(MODULE_ID, obj.getModuleId());
714                           criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
715                           criteria.add(NAME, obj.getName());
716                           criteria.add(DESCRIPTION, obj.getDescription());
717                           criteria.add(QUERY_STRING, obj.getQueryString());
718                           criteria.add(SCOPE_ID, obj.getScopeId());
719                           criteria.add(DELETED, obj.getDeleted());
720                           criteria.add(CREATED_DATE, obj.getCreatedDate());
721               return criteria;
722     }
723  
724     
725         /**
726      * Retrieve a single object by pk
727      *
728      * @param pk the primary key
729      * @throws TorqueException Any exceptions caught during processing will be
730      * rethrown wrapped into a TorqueException.
731      * @throws NoRowsException Primary key was not found in database.
732      * @throws TooManyRowsException Primary key was not found in database.
733      */

734     public static Report retrieveByPK(Integer JavaDoc pk)
735         throws TorqueException, NoRowsException, TooManyRowsException
736     {
737         return retrieveByPK(SimpleKey.keyFor(pk));
738     }
739
740     /**
741      * Retrieve a single object by pk
742      *
743      * @param pk the primary key
744      * @param con the connection to use
745      * @throws TorqueException Any exceptions caught during processing will be
746      * rethrown wrapped into a TorqueException.
747      * @throws NoRowsException Primary key was not found in database.
748      * @throws TooManyRowsException Primary key was not found in database.
749      */

750     public static Report retrieveByPK(Integer JavaDoc pk, Connection JavaDoc con)
751         throws TorqueException, NoRowsException, TooManyRowsException
752     {
753         return retrieveByPK(SimpleKey.keyFor(pk), con);
754     }
755   
756     /**
757      * Retrieve a single object by pk
758      *
759      * @param pk the primary key
760      * @throws TorqueException Any exceptions caught during processing will be
761      * rethrown wrapped into a TorqueException.
762      * @throws NoRowsException Primary key was not found in database.
763      * @throws TooManyRowsException Primary key was not found in database.
764      */

765     public static Report retrieveByPK(ObjectKey pk)
766         throws TorqueException, NoRowsException, TooManyRowsException
767     {
768         Connection JavaDoc db = null;
769         Report retVal = null;
770         try
771         {
772             db = Torque.getConnection(DATABASE_NAME);
773             retVal = retrieveByPK(pk, db);
774         }
775         finally
776         {
777             Torque.closeConnection(db);
778         }
779         return(retVal);
780     }
781
782     /**
783      * Retrieve a single object by pk
784      *
785      * @param pk the primary key
786      * @param con the connection to use
787      * @throws TorqueException Any exceptions caught during processing will be
788      * rethrown wrapped into a TorqueException.
789      * @throws NoRowsException Primary key was not found in database.
790      * @throws TooManyRowsException Primary key was not found in database.
791      */

792     public static Report retrieveByPK(ObjectKey pk, Connection JavaDoc con)
793         throws TorqueException, NoRowsException, TooManyRowsException
794     {
795         Criteria criteria = buildCriteria(pk);
796         List JavaDoc v = doSelect(criteria, con);
797         if (v.size() == 0)
798         {
799             throw new NoRowsException("Failed to select a row.");
800         }
801         else if (v.size() > 1)
802         {
803             throw new TooManyRowsException("Failed to select only one row.");
804         }
805         else
806         {
807             return (Report)v.get(0);
808         }
809     }
810
811     /**
812      * Retrieve a multiple objects by pk
813      *
814      * @param pks List of primary keys
815      * @throws TorqueException Any exceptions caught during processing will be
816      * rethrown wrapped into a TorqueException.
817      */

818     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
819         throws TorqueException
820     {
821         Connection JavaDoc db = null;
822         List JavaDoc retVal = null;
823         try
824         {
825            db = Torque.getConnection(DATABASE_NAME);
826            retVal = retrieveByPKs(pks, db);
827         }
828         finally
829         {
830             Torque.closeConnection(db);
831         }
832         return(retVal);
833     }
834
835     /**
836      * Retrieve a multiple objects by pk
837      *
838      * @param pks List of primary keys
839      * @param dbcon the connection to use
840      * @throws TorqueException Any exceptions caught during processing will be
841      * rethrown wrapped into a TorqueException.
842      */

843     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
844         throws TorqueException
845     {
846         List JavaDoc objs = null;
847         if (pks == null || pks.size() == 0)
848         {
849             objs = new LinkedList JavaDoc();
850         }
851         else
852         {
853             Criteria criteria = new Criteria();
854               criteria.addIn( REPORT_ID, pks );
855           objs = doSelect(criteria, dbcon);
856         }
857         return objs;
858     }
859
860  
861
862
863
864                 
865                                               
866                 
867                 
868
869     /**
870      * selects a collection of Report objects pre-filled with their
871      * IssueType objects.
872      *
873      * This method is protected by default in order to keep the public
874      * api reasonable. You can provide public methods for those you
875      * actually need in ReportPeer.
876      *
877      * @throws TorqueException Any exceptions caught during processing will be
878      * rethrown wrapped into a TorqueException.
879      */

880     protected static List JavaDoc doSelectJoinIssueType(Criteria criteria)
881         throws TorqueException
882     {
883         setDbName(criteria);
884
885         ReportPeer.addSelectColumns(criteria);
886         int offset = numColumns + 1;
887         IssueTypePeer.addSelectColumns(criteria);
888
889
890                         criteria.addJoin(ReportPeer.ISSUE_TYPE_ID,
891             IssueTypePeer.ISSUE_TYPE_ID);
892         
893
894                                                                                                                                                                           // check for conversion from boolean to int
895
if (criteria.containsKey(DELETED))
896         {
897             Object JavaDoc possibleBoolean = criteria.get(DELETED);
898             if (possibleBoolean instanceof Boolean JavaDoc)
899             {
900                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
901             }
902          }
903                                     
904         List JavaDoc rows = BasePeer.doSelect(criteria);
905         List JavaDoc results = new ArrayList JavaDoc();
906
907         for (int i = 0; i < rows.size(); i++)
908         {
909             Record row = (Record) rows.get(i);
910
911                             Class JavaDoc omClass = ReportPeer.getOMClass();
912                     Report obj1 = (Report) ReportPeer
913                 .row2Object(row, 1, omClass);
914                      omClass = IssueTypePeer.getOMClass();
915                     IssueType obj2 = (IssueType)IssueTypePeer
916                 .row2Object(row, offset, omClass);
917
918             boolean newObject = true;
919             for (int j = 0; j < results.size(); j++)
920             {
921                 Report temp_obj1 = (Report)results.get(j);
922                 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
923                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
924                 {
925                     newObject = false;
926                               temp_obj2.addReport(obj1);
927                               break;
928                 }
929             }
930                       if (newObject)
931             {
932                 obj2.initReports();
933                 obj2.addReport(obj1);
934             }
935                       results.add(obj1);
936         }
937         return results;
938     }
939                                                             
940                         
941                 
942
943     /**
944      * selects a collection of Report objects pre-filled with their
945      * ScarabUserImpl objects.
946      *
947      * This method is protected by default in order to keep the public
948      * api reasonable. You can provide public methods for those you
949      * actually need in ReportPeer.
950      *
951      * @throws TorqueException Any exceptions caught during processing will be
952      * rethrown wrapped into a TorqueException.
953      */

954     protected static List JavaDoc doSelectJoinScarabUserImpl(Criteria criteria)
955         throws TorqueException
956     {
957         setDbName(criteria);
958
959         ReportPeer.addSelectColumns(criteria);
960         int offset = numColumns + 1;
961         ScarabUserImplPeer.addSelectColumns(criteria);
962
963
964                         criteria.addJoin(ReportPeer.USER_ID,
965             ScarabUserImplPeer.USER_ID);
966         
967
968                                                                                                                                                                           // check for conversion from boolean to int
969
if (criteria.containsKey(DELETED))
970         {
971             Object JavaDoc possibleBoolean = criteria.get(DELETED);
972             if (possibleBoolean instanceof Boolean JavaDoc)
973             {
974                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
975             }
976          }
977                                     
978         List JavaDoc rows = BasePeer.doSelect(criteria);
979         List JavaDoc results = new ArrayList JavaDoc();
980
981         for (int i = 0; i < rows.size(); i++)
982         {
983             Record row = (Record) rows.get(i);
984
985                             Class JavaDoc omClass = ReportPeer.getOMClass();
986                     Report obj1 = (Report) ReportPeer
987                 .row2Object(row, 1, omClass);
988                      omClass = ScarabUserImplPeer.getOMClass();
989                     ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
990                 .row2Object(row, offset, omClass);
991
992             boolean newObject = true;
993             for (int j = 0; j < results.size(); j++)
994             {
995                 Report temp_obj1 = (Report)results.get(j);
996                 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
997                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
998                 {
999                     newObject = false;
1000                              temp_obj2.addReport(obj1);
1001                              break;
1002                }
1003            }
1004                      if (newObject)
1005            {
1006                obj2.initReports();
1007                obj2.addReport(obj1);
1008            }
1009                      results.add(obj1);
1010        }
1011        return results;
1012    }
1013                                                            
1014                        
1015                
1016
1017    /**
1018     * selects a collection of Report objects pre-filled with their
1019     * ScarabModule objects.
1020     *
1021     * This method is protected by default in order to keep the public
1022     * api reasonable. You can provide public methods for those you
1023     * actually need in ReportPeer.
1024     *
1025     * @throws TorqueException Any exceptions caught during processing will be
1026     * rethrown wrapped into a TorqueException.
1027     */

1028    protected static List JavaDoc doSelectJoinScarabModule(Criteria criteria)
1029        throws TorqueException
1030    {
1031        setDbName(criteria);
1032
1033        ReportPeer.addSelectColumns(criteria);
1034        int offset = numColumns + 1;
1035        ScarabModulePeer.addSelectColumns(criteria);
1036
1037
1038                        criteria.addJoin(ReportPeer.MODULE_ID,
1039            ScarabModulePeer.MODULE_ID);
1040        
1041
1042                                                                                                                                                                          // check for conversion from boolean to int
1043
if (criteria.containsKey(DELETED))
1044        {
1045            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1046            if (possibleBoolean instanceof Boolean JavaDoc)
1047            {
1048                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1049            }
1050         }
1051                                    
1052        List JavaDoc rows = BasePeer.doSelect(criteria);
1053        List JavaDoc results = new ArrayList JavaDoc();
1054
1055        for (int i = 0; i < rows.size(); i++)
1056        {
1057            Record row = (Record) rows.get(i);
1058
1059                            Class JavaDoc omClass = ReportPeer.getOMClass();
1060                    Report obj1 = (Report) ReportPeer
1061                .row2Object(row, 1, omClass);
1062                     omClass = ScarabModulePeer.getOMClass(row, offset);
1063                    ScarabModule obj2 = (ScarabModule)ScarabModulePeer
1064                .row2Object(row, offset, omClass);
1065
1066            boolean newObject = true;
1067            for (int j = 0; j < results.size(); j++)
1068            {
1069                Report temp_obj1 = (Report)results.get(j);
1070                ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
1071                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1072                {
1073                    newObject = false;
1074                              temp_obj2.addReport(obj1);
1075                              break;
1076                }
1077            }
1078                      if (newObject)
1079            {
1080                obj2.initReports();
1081                obj2.addReport(obj1);
1082            }
1083                      results.add(obj1);
1084        }
1085        return results;
1086    }
1087                                                            
1088                
1089                
1090
1091    /**
1092     * selects a collection of Report objects pre-filled with their
1093     * Scope objects.
1094     *
1095     * This method is protected by default in order to keep the public
1096     * api reasonable. You can provide public methods for those you
1097     * actually need in ReportPeer.
1098     *
1099     * @throws TorqueException Any exceptions caught during processing will be
1100     * rethrown wrapped into a TorqueException.
1101     */

1102    protected static List JavaDoc doSelectJoinScope(Criteria criteria)
1103        throws TorqueException
1104    {
1105        setDbName(criteria);
1106
1107        ReportPeer.addSelectColumns(criteria);
1108        int offset = numColumns + 1;
1109        ScopePeer.addSelectColumns(criteria);
1110
1111
1112                        criteria.addJoin(ReportPeer.SCOPE_ID,
1113            ScopePeer.SCOPE_ID);
1114        
1115
1116                                                                                                                                                                          // check for conversion from boolean to int
1117
if (criteria.containsKey(DELETED))
1118        {
1119            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1120            if (possibleBoolean instanceof Boolean JavaDoc)
1121            {
1122                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1123            }
1124         }
1125                                    
1126        List JavaDoc rows = BasePeer.doSelect(criteria);
1127        List JavaDoc results = new ArrayList JavaDoc();
1128
1129        for (int i = 0; i < rows.size(); i++)
1130        {
1131            Record row = (Record) rows.get(i);
1132
1133                            Class JavaDoc omClass = ReportPeer.getOMClass();
1134                    Report obj1 = (Report) ReportPeer
1135                .row2Object(row, 1, omClass);
1136                     omClass = ScopePeer.getOMClass();
1137                    Scope obj2 = (Scope)ScopePeer
1138                .row2Object(row, offset, omClass);
1139
1140            boolean newObject = true;
1141            for (int j = 0; j < results.size(); j++)
1142            {
1143                Report temp_obj1 = (Report)results.get(j);
1144                Scope temp_obj2 = (Scope)temp_obj1.getScope();
1145                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1146                {
1147                    newObject = false;
1148                              temp_obj2.addReport(obj1);
1149                              break;
1150                }
1151            }
1152                      if (newObject)
1153            {
1154                obj2.initReports();
1155                obj2.addReport(obj1);
1156            }
1157                      results.add(obj1);
1158        }
1159        return results;
1160    }
1161                    
1162  
1163                                              
1164          
1165        
1166                                  
1167                
1168
1169    /**
1170     * selects a collection of Report objects pre-filled with
1171     * all related objects.
1172     *
1173     * This method is protected by default in order to keep the public
1174     * api reasonable. You can provide public methods for those you
1175     * actually need in ReportPeer.
1176     *
1177     * @throws TorqueException Any exceptions caught during processing will be
1178     * rethrown wrapped into a TorqueException.
1179     */

1180    protected static List JavaDoc doSelectJoinAllExceptIssueType(Criteria criteria)
1181        throws TorqueException
1182    {
1183        setDbName(criteria);
1184
1185        addSelectColumns(criteria);
1186        int offset2 = numColumns + 1;
1187                                    
1188                                                  
1189                    ScarabUserImplPeer.addSelectColumns(criteria);
1190        int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1191                                                                
1192                    ScarabModulePeer.addSelectColumns(criteria);
1193        int offset4 = offset3 + ScarabModulePeer.numColumns;
1194                                                                
1195                    ScopePeer.addSelectColumns(criteria);
1196        int offset5 = offset4 + ScopePeer.numColumns;
1197                                                                                                                                                                                                                      // check for conversion from boolean to int
1198
if (criteria.containsKey(DELETED))
1199        {
1200            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1201            if (possibleBoolean instanceof Boolean JavaDoc)
1202            {
1203                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1204            }
1205         }
1206                                    
1207        List JavaDoc rows = BasePeer.doSelect(criteria);
1208        List JavaDoc results = new ArrayList JavaDoc();
1209
1210        for (int i = 0; i < rows.size(); i++)
1211        {
1212            Record row = (Record)rows.get(i);
1213
1214                            Class JavaDoc omClass = ReportPeer.getOMClass();
1215                    Report obj1 = (Report)ReportPeer
1216                .row2Object(row, 1, omClass);
1217                                                
1218                                                                              
1219                                                        
1220                            
1221              
1222                           omClass = ScarabUserImplPeer.getOMClass();
1223                          ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1224                .row2Object( row, offset2, omClass);
1225
1226               boolean newObject = true;
1227            for (int j = 0; j < results.size(); j++)
1228            {
1229                Report temp_obj1 = (Report)results.get(j);
1230                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
1231                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1232                {
1233                    newObject = false;
1234                                    temp_obj2.addReport(obj1);
1235                                    break;
1236                }
1237            }
1238                            if (newObject)
1239            {
1240                obj2.initReports();
1241                obj2.addReport(obj1);
1242            }
1243                                                                                                
1244                                                        
1245                            
1246              
1247                           omClass = ScarabModulePeer.getOMClass(row, offset3);
1248                          ScarabModule obj3 = (ScarabModule)ScarabModulePeer
1249                .row2Object( row, offset3, omClass);
1250
1251               newObject = true;
1252            for (int j = 0; j < results.size(); j++)
1253            {
1254                Report temp_obj1 = (Report)results.get(j);
1255                ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule();
1256                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1257                {
1258                    newObject = false;
1259                                    temp_obj3.addReport(obj1);
1260                                    break;
1261                }
1262            }
1263                            if (newObject)
1264            {
1265                obj3.initReports();
1266                obj3.addReport(obj1);
1267            }
1268                                                                                    
1269                                                        
1270                            
1271              
1272                           omClass = ScopePeer.getOMClass();
1273                          Scope obj4 = (Scope)ScopePeer
1274                .row2Object( row, offset4, omClass);
1275
1276               newObject = true;
1277            for (int j = 0; j < results.size(); j++)
1278            {
1279                Report temp_obj1 = (Report)results.get(j);
1280                Scope temp_obj4 = (Scope)temp_obj1.getScope();
1281                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1282                {
1283                    newObject = false;
1284                                    temp_obj4.addReport(obj1);
1285                                    break;
1286                }
1287            }
1288                            if (newObject)
1289            {
1290                obj4.initReports();
1291                obj4.addReport(obj1);
1292            }
1293                                                                results.add(obj1);
1294        }
1295        return results;
1296    }
1297        
1298        
1299                                  
1300                
1301
1302    /**
1303     * selects a collection of Report objects pre-filled with
1304     * all related objects.
1305     *
1306     * This method is protected by default in order to keep the public
1307     * api reasonable. You can provide public methods for those you
1308     * actually need in ReportPeer.
1309     *
1310     * @throws TorqueException Any exceptions caught during processing will be
1311     * rethrown wrapped into a TorqueException.
1312     */

1313    protected static List JavaDoc doSelectJoinAllExceptScarabUserImpl(Criteria criteria)
1314        throws TorqueException
1315    {
1316        setDbName(criteria);
1317
1318        addSelectColumns(criteria);
1319        int offset2 = numColumns + 1;
1320                                    
1321                    IssueTypePeer.addSelectColumns(criteria);
1322        int offset3 = offset2 + IssueTypePeer.numColumns;
1323                                                                
1324                                                  
1325                    ScarabModulePeer.addSelectColumns(criteria);
1326        int offset4 = offset3 + ScarabModulePeer.numColumns;
1327                                                                
1328                    ScopePeer.addSelectColumns(criteria);
1329        int offset5 = offset4 + ScopePeer.numColumns;
1330                                                                                                                                                                                                                      // check for conversion from boolean to int
1331
if (criteria.containsKey(DELETED))
1332        {
1333            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1334            if (possibleBoolean instanceof Boolean JavaDoc)
1335            {
1336                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1337            }
1338         }
1339                                    
1340        List JavaDoc rows = BasePeer.doSelect(criteria);
1341        List JavaDoc results = new ArrayList JavaDoc();
1342
1343        for (int i = 0; i < rows.size(); i++)
1344        {
1345            Record row = (Record)rows.get(i);
1346
1347                            Class JavaDoc omClass = ReportPeer.getOMClass();
1348                    Report obj1 = (Report)ReportPeer
1349                .row2Object(row, 1, omClass);
1350                                                
1351                                                        
1352                            
1353              
1354                           omClass = IssueTypePeer.getOMClass();
1355                          IssueType obj2 = (IssueType)IssueTypePeer
1356                .row2Object( row, offset2, omClass);
1357
1358               boolean newObject = true;
1359            for (int j = 0; j < results.size(); j++)
1360            {
1361                Report temp_obj1 = (Report)results.get(j);
1362                IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
1363                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1364                {
1365                    newObject = false;
1366                                    temp_obj2.addReport(obj1);
1367                                    break;
1368                }
1369            }
1370                            if (newObject)
1371            {
1372                obj2.initReports();
1373                obj2.addReport(obj1);
1374            }
1375                                                                                                
1376                                                                              
1377                                                        
1378                            
1379              
1380                           omClass = ScarabModulePeer.getOMClass(row, offset3);
1381                          ScarabModule obj3 = (ScarabModule)ScarabModulePeer
1382                .row2Object( row, offset3, omClass);
1383
1384               newObject = true;
1385            for (int j = 0; j < results.size(); j++)
1386            {
1387                Report temp_obj1 = (Report)results.get(j);
1388                ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule();
1389                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1390                {
1391                    newObject = false;
1392                                    temp_obj3.addReport(obj1);
1393                                    break;
1394                }
1395            }
1396                            if (newObject)
1397            {
1398                obj3.initReports();
1399                obj3.addReport(obj1);
1400            }
1401                                                                                    
1402                                                        
1403                            
1404              
1405                           omClass = ScopePeer.getOMClass();
1406                          Scope obj4 = (Scope)ScopePeer
1407                .row2Object( row, offset4, omClass);
1408
1409               newObject = true;
1410            for (int j = 0; j < results.size(); j++)
1411            {
1412                Report temp_obj1 = (Report)results.get(j);
1413                Scope temp_obj4 = (Scope)temp_obj1.getScope();
1414                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1415                {
1416                    newObject = false;
1417                                    temp_obj4.addReport(obj1);
1418                                    break;
1419                }
1420            }
1421                            if (newObject)
1422            {
1423                obj4.initReports();
1424                obj4.addReport(obj1);
1425            }
1426                                                                results.add(obj1);
1427        }
1428        return results;
1429    }
1430        
1431        
1432                                  
1433                
1434
1435    /**
1436     * selects a collection of Report objects pre-filled with
1437     * all related objects.
1438     *
1439     * This method is protected by default in order to keep the public
1440     * api reasonable. You can provide public methods for those you
1441     * actually need in ReportPeer.
1442     *
1443     * @throws TorqueException Any exceptions caught during processing will be
1444     * rethrown wrapped into a TorqueException.
1445     */

1446    protected static List JavaDoc doSelectJoinAllExceptScarabModule(Criteria criteria)
1447        throws TorqueException
1448    {
1449        setDbName(criteria);
1450
1451        addSelectColumns(criteria);
1452        int offset2 = numColumns + 1;
1453                                    
1454                    IssueTypePeer.addSelectColumns(criteria);
1455        int offset3 = offset2 + IssueTypePeer.numColumns;
1456                                                                
1457                    ScarabUserImplPeer.addSelectColumns(criteria);
1458        int offset4 = offset3 + ScarabUserImplPeer.numColumns;
1459                                                                
1460                                                  
1461                    ScopePeer.addSelectColumns(criteria);
1462        int offset5 = offset4 + ScopePeer.numColumns;
1463                                                                                                                                                                                                                      // check for conversion from boolean to int
1464
if (criteria.containsKey(DELETED))
1465        {
1466            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1467            if (possibleBoolean instanceof Boolean JavaDoc)
1468            {
1469                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1470            }
1471         }
1472                                    
1473        List JavaDoc rows = BasePeer.doSelect(criteria);
1474        List JavaDoc results = new ArrayList JavaDoc();
1475
1476        for (int i = 0; i < rows.size(); i++)
1477        {
1478            Record row = (Record)rows.get(i);
1479
1480                            Class JavaDoc omClass = ReportPeer.getOMClass();
1481                    Report obj1 = (Report)ReportPeer
1482                .row2Object(row, 1, omClass);
1483                                                
1484                                                        
1485                            
1486              
1487                           omClass = IssueTypePeer.getOMClass();
1488                          IssueType obj2 = (IssueType)IssueTypePeer
1489                .row2Object( row, offset2, omClass);
1490
1491               boolean newObject = true;
1492            for (int j = 0; j < results.size(); j++)
1493            {
1494                Report temp_obj1 = (Report)results.get(j);
1495                IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
1496                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1497                {
1498                    newObject = false;
1499                                    temp_obj2.addReport(obj1);
1500                                    break;
1501                }
1502            }
1503                            if (newObject)
1504            {
1505                obj2.initReports();
1506                obj2.addReport(obj1);
1507            }
1508                                                                                                
1509                                                        
1510                            
1511              
1512                           omClass = ScarabUserImplPeer.getOMClass();
1513                          ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer
1514                .row2Object( row, offset3, omClass);
1515
1516               newObject = true;
1517            for (int j = 0; j < results.size(); j++)
1518            {
1519                Report temp_obj1 = (Report)results.get(j);
1520                ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser();
1521                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1522                {
1523                    newObject = false;
1524                                    temp_obj3.addReport(obj1);
1525                                    break;
1526                }
1527            }
1528                            if (newObject)
1529            {
1530                obj3.initReports();
1531                obj3.addReport(obj1);
1532            }
1533                                                                                                
1534                                                                  
1535                                                        
1536                            
1537              
1538                           omClass = ScopePeer.getOMClass();
1539                          Scope obj4 = (Scope)ScopePeer
1540                .row2Object( row, offset4, omClass);
1541
1542               newObject = true;
1543            for (int j = 0; j < results.size(); j++)
1544            {
1545                Report temp_obj1 = (Report)results.get(j);
1546                Scope temp_obj4 = (Scope)temp_obj1.getScope();
1547                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1548                {
1549                    newObject = false;
1550                                    temp_obj4.addReport(obj1);
1551                                    break;
1552                }
1553            }
1554                            if (newObject)
1555            {
1556                obj4.initReports();
1557                obj4.addReport(obj1);
1558            }
1559                                                                results.add(obj1);
1560        }
1561        return results;
1562    }
1563        
1564        
1565                                  
1566                
1567
1568    /**
1569     * selects a collection of Report objects pre-filled with
1570     * all related objects.
1571     *
1572     * This method is protected by default in order to keep the public
1573     * api reasonable. You can provide public methods for those you
1574     * actually need in ReportPeer.
1575     *
1576     * @throws TorqueException Any exceptions caught during processing will be
1577     * rethrown wrapped into a TorqueException.
1578     */

1579    protected static List JavaDoc doSelectJoinAllExceptScope(Criteria criteria)
1580        throws TorqueException
1581    {
1582        setDbName(criteria);
1583
1584        addSelectColumns(criteria);
1585        int offset2 = numColumns + 1;
1586                                    
1587                    IssueTypePeer.addSelectColumns(criteria);
1588        int offset3 = offset2 + IssueTypePeer.numColumns;
1589                                                                
1590                    ScarabUserImplPeer.addSelectColumns(criteria);
1591        int offset4 = offset3 + ScarabUserImplPeer.numColumns;
1592                                                                
1593                    ScarabModulePeer.addSelectColumns(criteria);
1594        int offset5 = offset4 + ScarabModulePeer.numColumns;
1595                                                                
1596                                                                                                                                                                                                        // check for conversion from boolean to int
1597
if (criteria.containsKey(DELETED))
1598        {
1599            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1600            if (possibleBoolean instanceof Boolean JavaDoc)
1601            {
1602                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1603            }
1604         }
1605                                    
1606        List JavaDoc rows = BasePeer.doSelect(criteria);
1607        List JavaDoc results = new ArrayList JavaDoc();
1608
1609        for (int i = 0; i < rows.size(); i++)
1610        {
1611            Record row = (Record)rows.get(i);
1612
1613                            Class JavaDoc omClass = ReportPeer.getOMClass();
1614                    Report obj1 = (Report)ReportPeer
1615                .row2Object(row, 1, omClass);
1616                                                
1617                                                        
1618                            
1619              
1620                           omClass = IssueTypePeer.getOMClass();
1621                          IssueType obj2 = (IssueType)IssueTypePeer
1622                .row2Object( row, offset2, omClass);
1623
1624               boolean newObject = true;
1625            for (int j = 0; j < results.size(); j++)
1626            {
1627                Report temp_obj1 = (Report)results.get(j);
1628                IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
1629                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1630                {
1631                    newObject = false;
1632                                    temp_obj2.addReport(obj1);
1633                                    break;
1634                }
1635            }
1636                            if (newObject)
1637            {
1638                obj2.initReports();
1639                obj2.addReport(obj1);
1640            }
1641                                                                                                
1642                                                        
1643                            
1644              
1645                           omClass = ScarabUserImplPeer.getOMClass();
1646                          ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer
1647                .row2Object( row, offset3, omClass);
1648
1649               newObject = true;
1650            for (int j = 0; j < results.size(); j++)
1651            {
1652                Report temp_obj1 = (Report)results.get(j);
1653                ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser();
1654                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1655                {
1656                    newObject = false;
1657                                    temp_obj3.addReport(obj1);
1658                                    break;
1659                }
1660            }
1661                            if (newObject)
1662            {
1663                obj3.initReports();
1664                obj3.addReport(obj1);
1665            }
1666                                                                                                
1667                                                        
1668                            
1669              
1670                           omClass = ScarabModulePeer.getOMClass(row, offset4);
1671                          ScarabModule obj4 = (ScarabModule)ScarabModulePeer
1672                .row2Object( row, offset4, omClass);
1673
1674               newObject = true;
1675            for (int j = 0; j < results.size(); j++)
1676            {
1677                Report temp_obj1 = (Report)results.get(j);
1678                ScarabModule temp_obj4 = (ScarabModule)temp_obj1.getModule();
1679                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1680                {
1681                    newObject = false;
1682                                    temp_obj4.addReport(obj1);
1683                                    break;
1684                }
1685            }
1686                            if (newObject)
1687            {
1688                obj4.initReports();
1689                obj4.addReport(obj1);
1690            }
1691                                                                                    
1692                                              results.add(obj1);
1693        }
1694        return results;
1695    }
1696                    
1697  
1698      /**
1699     * Returns the TableMap related to this peer. This method is not
1700     * needed for general use but a specific application could have a need.
1701     *
1702     * @throws TorqueException Any exceptions caught during processing will be
1703     * rethrown wrapped into a TorqueException.
1704     */

1705    protected static TableMap getTableMap()
1706        throws TorqueException
1707    {
1708        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1709    }
1710   
1711    private static void setDbName(Criteria crit)
1712    {
1713        // Set the correct dbName if it has not been overridden
1714
// crit.getDbName will return the same object if not set to
1715
// another value so == check is okay and faster
1716
if (crit.getDbName() == Torque.getDefaultDB())
1717        {
1718            crit.setDbName(DATABASE_NAME);
1719        }
1720    }
1721}
1722
Popular Tags