KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

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

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

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

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

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

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

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

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

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

485     public static List JavaDoc populateObjects(List JavaDoc records)
486         throws TorqueException
487     {
488         List JavaDoc results = new ArrayList JavaDoc(records.size());
489
490         // populate the object(s)
491
for (int i = 0; i < records.size(); i++)
492         {
493             Record row = (Record) records.get(i);
494               results.add(RIssueTypeAttributePeer.row2Object(row, 1,
495                 RIssueTypeAttributePeer.getOMClass()));
496           }
497         return results;
498     }
499  
500
501     /**
502      * The class that the Peer will make instances of.
503      * If the BO is abstract then you must implement this method
504      * in the BO.
505      *
506      * @throws TorqueException Any exceptions caught during processing will be
507      * rethrown wrapped into a TorqueException.
508      */

509     public static Class JavaDoc getOMClass()
510         throws TorqueException
511     {
512         return CLASS_DEFAULT;
513     }
514
515     /**
516      * Method to do updates.
517      *
518      * @param criteria object containing data that is used to create the UPDATE
519      * statement.
520      * @throws TorqueException Any exceptions caught during processing will be
521      * rethrown wrapped into a TorqueException.
522      */

523     public static void doUpdate(Criteria criteria) throws TorqueException
524     {
525          BaseRIssueTypeAttributePeer
526             .doUpdate(criteria, (Connection JavaDoc) null);
527     }
528
529     /**
530      * Method to do updates. This method is to be used during a transaction,
531      * otherwise use the doUpdate(Criteria) method. It will take care of
532      * the connection details internally.
533      *
534      * @param criteria object containing data that is used to create the UPDATE
535      * statement.
536      * @param con the connection to use
537      * @throws TorqueException Any exceptions caught during processing will be
538      * rethrown wrapped into a TorqueException.
539      */

540     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
541         throws TorqueException
542     {
543         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
544                    selectCriteria.put(ATTRIBUTE_ID, criteria.remove(ATTRIBUTE_ID));
545                        selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID));
546                   // check for conversion from boolean to int
547
if (criteria.containsKey(ACTIVE))
548         {
549             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
550             if (possibleBoolean instanceof Boolean JavaDoc)
551             {
552                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
553             }
554          }
555                       // check for conversion from boolean to int
556
if (criteria.containsKey(REQUIRED))
557         {
558             Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
559             if (possibleBoolean instanceof Boolean JavaDoc)
560             {
561                 criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
562             }
563          }
564                                 // check for conversion from boolean to int
565
if (criteria.containsKey(QUICK_SEARCH))
566         {
567             Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
568             if (possibleBoolean instanceof Boolean JavaDoc)
569             {
570                 criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
571             }
572          }
573                       // check for conversion from boolean to int
574
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
575         {
576             Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
577             if (possibleBoolean instanceof Boolean JavaDoc)
578             {
579                 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
580             }
581          }
582                       // check for conversion from boolean to int
583
if (criteria.containsKey(LOCKED))
584         {
585             Object JavaDoc possibleBoolean = criteria.get(LOCKED);
586             if (possibleBoolean instanceof Boolean JavaDoc)
587             {
588                 criteria.add(LOCKED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
589             }
590          }
591           
592         setDbName(criteria);
593
594         if (con == null)
595         {
596             BasePeer.doUpdate(selectCriteria, criteria);
597         }
598         else
599         {
600             BasePeer.doUpdate(selectCriteria, criteria, con);
601         }
602     }
603
604     /**
605      * Method to do deletes.
606      *
607      * @param criteria object containing data that is used DELETE from database.
608      * @throws TorqueException Any exceptions caught during processing will be
609      * rethrown wrapped into a TorqueException.
610      */

611      public static void doDelete(Criteria criteria) throws TorqueException
612      {
613          RIssueTypeAttributePeer
614             .doDelete(criteria, (Connection JavaDoc) null);
615      }
616
617     /**
618      * Method to do deletes. This method is to be used during a transaction,
619      * otherwise use the doDelete(Criteria) method. It will take care of
620      * the connection details internally.
621      *
622      * @param criteria object containing data that is used DELETE from database.
623      * @param con the connection to use
624      * @throws TorqueException Any exceptions caught during processing will be
625      * rethrown wrapped into a TorqueException.
626      */

627      public static void doDelete(Criteria criteria, Connection JavaDoc con)
628         throws TorqueException
629      {
630                           // check for conversion from boolean to int
631
if (criteria.containsKey(ACTIVE))
632         {
633             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
634             if (possibleBoolean instanceof Boolean JavaDoc)
635             {
636                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
637             }
638          }
639                   // check for conversion from boolean to int
640
if (criteria.containsKey(REQUIRED))
641         {
642             Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
643             if (possibleBoolean instanceof Boolean JavaDoc)
644             {
645                 criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
646             }
647          }
648                         // check for conversion from boolean to int
649
if (criteria.containsKey(QUICK_SEARCH))
650         {
651             Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
652             if (possibleBoolean instanceof Boolean JavaDoc)
653             {
654                 criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
655             }
656          }
657                   // check for conversion from boolean to int
658
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
659         {
660             Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
661             if (possibleBoolean instanceof Boolean JavaDoc)
662             {
663                 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
664             }
665          }
666                   // check for conversion from boolean to int
667
if (criteria.containsKey(LOCKED))
668         {
669             Object JavaDoc possibleBoolean = criteria.get(LOCKED);
670             if (possibleBoolean instanceof Boolean JavaDoc)
671             {
672                 criteria.add(LOCKED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
673             }
674          }
675       
676         setDbName(criteria);
677
678         if (con == null)
679         {
680             BasePeer.doDelete(criteria);
681         }
682         else
683         {
684             BasePeer.doDelete(criteria, con);
685         }
686      }
687
688     /**
689      * Method to do selects
690      *
691      * @throws TorqueException Any exceptions caught during processing will be
692      * rethrown wrapped into a TorqueException.
693      */

694     public static List JavaDoc doSelect(RIssueTypeAttribute obj) throws TorqueException
695     {
696         return doSelect(buildSelectCriteria(obj));
697     }
698
699     /**
700      * Method to do inserts
701      *
702      * @throws TorqueException Any exceptions caught during processing will be
703      * rethrown wrapped into a TorqueException.
704      */

705     public static void doInsert(RIssueTypeAttribute obj) throws TorqueException
706     {
707           doInsert(buildCriteria(obj));
708           obj.setNew(false);
709         obj.setModified(false);
710     }
711
712     /**
713      * @param obj the data object to update in the database.
714      * @throws TorqueException Any exceptions caught during processing will be
715      * rethrown wrapped into a TorqueException.
716      */

717     public static void doUpdate(RIssueTypeAttribute obj) throws TorqueException
718     {
719         doUpdate(buildCriteria(obj));
720         obj.setModified(false);
721     }
722
723     /**
724      * @param obj the data object to delete in the database.
725      * @throws TorqueException Any exceptions caught during processing will be
726      * rethrown wrapped into a TorqueException.
727      */

728     public static void doDelete(RIssueTypeAttribute obj) throws TorqueException
729     {
730         doDelete(buildSelectCriteria(obj));
731     }
732
733     /**
734      * Method to do inserts. This method is to be used during a transaction,
735      * otherwise use the doInsert(RIssueTypeAttribute) method. It will take
736      * care of the connection details internally.
737      *
738      * @param obj the data object to insert into the database.
739      * @param con the connection to use
740      * @throws TorqueException Any exceptions caught during processing will be
741      * rethrown wrapped into a TorqueException.
742      */

743     public static void doInsert(RIssueTypeAttribute obj, Connection JavaDoc con)
744         throws TorqueException
745     {
746           doInsert(buildCriteria(obj), con);
747           obj.setNew(false);
748         obj.setModified(false);
749     }
750
751     /**
752      * Method to do update. This method is to be used during a transaction,
753      * otherwise use the doUpdate(RIssueTypeAttribute) method. It will take
754      * care of the connection details internally.
755      *
756      * @param obj the data object to update in the database.
757      * @param con the connection to use
758      * @throws TorqueException Any exceptions caught during processing will be
759      * rethrown wrapped into a TorqueException.
760      */

761     public static void doUpdate(RIssueTypeAttribute obj, Connection JavaDoc con)
762         throws TorqueException
763     {
764         doUpdate(buildCriteria(obj), con);
765         obj.setModified(false);
766     }
767
768     /**
769      * Method to delete. This method is to be used during a transaction,
770      * otherwise use the doDelete(RIssueTypeAttribute) method. It will take
771      * care of the connection details internally.
772      *
773      * @param obj the data 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(RIssueTypeAttribute obj, Connection JavaDoc con)
779         throws TorqueException
780     {
781         doDelete(buildSelectCriteria(obj), con);
782     }
783
784     /**
785      * Method to do deletes.
786      *
787      * @param pk ObjectKey that is used DELETE from database.
788      * @throws TorqueException Any exceptions caught during processing will be
789      * rethrown wrapped into a TorqueException.
790      */

791     public static void doDelete(ObjectKey pk) throws TorqueException
792     {
793         BaseRIssueTypeAttributePeer
794            .doDelete(pk, (Connection JavaDoc) null);
795     }
796
797     /**
798      * Method to delete. This method is to be used during a transaction,
799      * otherwise use the doDelete(ObjectKey) method. It will take
800      * care of the connection details internally.
801      *
802      * @param pk the primary key for the object to delete in the database.
803      * @param con the connection to use
804      * @throws TorqueException Any exceptions caught during processing will be
805      * rethrown wrapped into a TorqueException.
806      */

807     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
808         throws TorqueException
809     {
810         doDelete(buildCriteria(pk), con);
811     }
812
813     /** Build a Criteria object from an ObjectKey */
814     public static Criteria buildCriteria( ObjectKey pk )
815     {
816         Criteria criteria = new Criteria();
817           SimpleKey[] keys = (SimpleKey[])pk.getValue();
818                     criteria.add(ATTRIBUTE_ID, keys[0]);
819                       criteria.add(ISSUE_TYPE_ID, keys[1]);
820                     return criteria;
821      }
822
823     /** Build a Criteria object from the data object for this peer */
824     public static Criteria buildCriteria( RIssueTypeAttribute obj )
825     {
826         Criteria criteria = new Criteria(DATABASE_NAME);
827               criteria.add(ATTRIBUTE_ID, obj.getAttributeId());
828               criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
829               criteria.add(ACTIVE, obj.getActive());
830               criteria.add(REQUIRED, obj.getRequired());
831               criteria.add(PREFERRED_ORDER, obj.getOrder());
832               criteria.add(QUICK_SEARCH, obj.getQuickSearch());
833               criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag());
834               criteria.add(LOCKED, obj.getLocked());
835           return criteria;
836     }
837
838     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
839     public static Criteria buildSelectCriteria( RIssueTypeAttribute obj )
840     {
841         Criteria criteria = new Criteria(DATABASE_NAME);
842                       criteria.add(ATTRIBUTE_ID, obj.getAttributeId());
843                           criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
844                           criteria.add(ACTIVE, obj.getActive());
845                           criteria.add(REQUIRED, obj.getRequired());
846                           criteria.add(PREFERRED_ORDER, obj.getOrder());
847                           criteria.add(QUICK_SEARCH, obj.getQuickSearch());
848                           criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag());
849                           criteria.add(LOCKED, obj.getLocked());
850               return criteria;
851     }
852  
853     
854     
855     /**
856      * Retrieve a single object by pk
857      *
858      * @param pk the primary key
859      * @throws TorqueException Any exceptions caught during processing will be
860      * rethrown wrapped into a TorqueException.
861      * @throws NoRowsException Primary key was not found in database.
862      * @throws TooManyRowsException Primary key was not found in database.
863      */

864     public static RIssueTypeAttribute retrieveByPK(ObjectKey pk)
865         throws TorqueException, NoRowsException, TooManyRowsException
866     {
867         Connection JavaDoc db = null;
868         RIssueTypeAttribute retVal = null;
869         try
870         {
871             db = Torque.getConnection(DATABASE_NAME);
872             retVal = retrieveByPK(pk, db);
873         }
874         finally
875         {
876             Torque.closeConnection(db);
877         }
878         return(retVal);
879     }
880
881     /**
882      * Retrieve a single object by pk
883      *
884      * @param pk the primary key
885      * @param con the connection to use
886      * @throws TorqueException Any exceptions caught during processing will be
887      * rethrown wrapped into a TorqueException.
888      * @throws NoRowsException Primary key was not found in database.
889      * @throws TooManyRowsException Primary key was not found in database.
890      */

891     public static RIssueTypeAttribute retrieveByPK(ObjectKey pk, Connection JavaDoc con)
892         throws TorqueException, NoRowsException, TooManyRowsException
893     {
894         Criteria criteria = buildCriteria(pk);
895         List JavaDoc v = doSelect(criteria, con);
896         if (v.size() == 0)
897         {
898             throw new NoRowsException("Failed to select a row.");
899         }
900         else if (v.size() > 1)
901         {
902             throw new TooManyRowsException("Failed to select only one row.");
903         }
904         else
905         {
906             return (RIssueTypeAttribute)v.get(0);
907         }
908     }
909
910     /**
911      * Retrieve a multiple objects by pk
912      *
913      * @param pks List of primary keys
914      * @throws TorqueException Any exceptions caught during processing will be
915      * rethrown wrapped into a TorqueException.
916      */

917     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
918         throws TorqueException
919     {
920         Connection JavaDoc db = null;
921         List JavaDoc retVal = null;
922         try
923         {
924            db = Torque.getConnection(DATABASE_NAME);
925            retVal = retrieveByPKs(pks, db);
926         }
927         finally
928         {
929             Torque.closeConnection(db);
930         }
931         return(retVal);
932     }
933
934     /**
935      * Retrieve a multiple objects by pk
936      *
937      * @param pks List of primary keys
938      * @param dbcon the connection to use
939      * @throws TorqueException Any exceptions caught during processing will be
940      * rethrown wrapped into a TorqueException.
941      */

942     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
943         throws TorqueException
944     {
945         List JavaDoc objs = null;
946         if (pks == null || pks.size() == 0)
947         {
948             objs = new LinkedList JavaDoc();
949         }
950         else
951         {
952             Criteria criteria = new Criteria();
953               Iterator JavaDoc iter = pks.iterator();
954             while (iter.hasNext())
955             {
956                 ObjectKey pk = (ObjectKey)iter.next();
957                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
958                             Criteria.Criterion c0 = criteria.getNewCriterion(
959                         ATTRIBUTE_ID, keys[0], Criteria.EQUAL);
960                                     Criteria.Criterion c1 = criteria.getNewCriterion(
961                         ISSUE_TYPE_ID, keys[1], Criteria.EQUAL);
962                                     c0.and(c1);
963                           criteria.or(c0);
964             }
965           objs = doSelect(criteria, dbcon);
966         }
967         return objs;
968     }
969
970  
971     /**
972      * retrieve object using using pk values.
973      *
974        * @param attribute_id Integer
975        * @param issue_type_id Integer
976        */

977     public static RIssueTypeAttribute retrieveByPK(
978        Integer JavaDoc attribute_id
979           , Integer JavaDoc issue_type_id
980               ) throws TorqueException
981     {
982         Connection JavaDoc db = null;
983         RIssueTypeAttribute retVal = null;
984         try
985         {
986            db = Torque.getConnection(DATABASE_NAME);
987            retVal = retrieveByPK(
988          attribute_id
989           , issue_type_id
990                      , db);
991         }
992         finally
993         {
994             Torque.closeConnection(db);
995         }
996         return(retVal);
997     }
998
999       /**
1000     * retrieve object using using pk values.
1001     *
1002       * @param attribute_id Integer
1003       * @param issue_type_id Integer
1004       * @param con Connection
1005     */

1006    public static RIssueTypeAttribute retrieveByPK(
1007       Integer JavaDoc attribute_id
1008          , Integer JavaDoc issue_type_id
1009             ,Connection JavaDoc con) throws TorqueException
1010    {
1011
1012        Criteria criteria = new Criteria(5);
1013          criteria.add(ATTRIBUTE_ID, attribute_id);
1014          criteria.add(ISSUE_TYPE_ID, issue_type_id);
1015          List JavaDoc v = doSelect(criteria, con);
1016        if (v.size() != 1)
1017        {
1018            throw new TorqueException("Failed to select one and only one row.");
1019        }
1020        else
1021        {
1022            return (RIssueTypeAttribute) v.get(0);
1023        }
1024    }
1025
1026
1027
1028            
1029                                              
1030                
1031                
1032
1033    /**
1034     * selects a collection of RIssueTypeAttribute objects pre-filled with their
1035     * Attribute objects.
1036     *
1037     * This method is protected by default in order to keep the public
1038     * api reasonable. You can provide public methods for those you
1039     * actually need in RIssueTypeAttributePeer.
1040     *
1041     * @throws TorqueException Any exceptions caught during processing will be
1042     * rethrown wrapped into a TorqueException.
1043     */

1044    protected static List JavaDoc doSelectJoinAttribute(Criteria criteria)
1045        throws TorqueException
1046    {
1047        setDbName(criteria);
1048
1049        RIssueTypeAttributePeer.addSelectColumns(criteria);
1050        int offset = numColumns + 1;
1051        AttributePeer.addSelectColumns(criteria);
1052
1053
1054                        criteria.addJoin(RIssueTypeAttributePeer.ATTRIBUTE_ID,
1055            AttributePeer.ATTRIBUTE_ID);
1056        
1057
1058                                                              // check for conversion from boolean to int
1059
if (criteria.containsKey(ACTIVE))
1060        {
1061            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1062            if (possibleBoolean instanceof Boolean JavaDoc)
1063            {
1064                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1065            }
1066         }
1067                                    // check for conversion from boolean to int
1068
if (criteria.containsKey(REQUIRED))
1069        {
1070            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1071            if (possibleBoolean instanceof Boolean JavaDoc)
1072            {
1073                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1074            }
1075         }
1076                                                      // check for conversion from boolean to int
1077
if (criteria.containsKey(QUICK_SEARCH))
1078        {
1079            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1080            if (possibleBoolean instanceof Boolean JavaDoc)
1081            {
1082                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1083            }
1084         }
1085                                    // check for conversion from boolean to int
1086
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1087        {
1088            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1089            if (possibleBoolean instanceof Boolean JavaDoc)
1090            {
1091                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1092            }
1093         }
1094                                    // check for conversion from boolean to int
1095
if (criteria.containsKey(LOCKED))
1096        {
1097            Object JavaDoc possibleBoolean = criteria.get(LOCKED);
1098            if (possibleBoolean instanceof Boolean JavaDoc)
1099            {
1100                criteria.add(LOCKED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1101            }
1102         }
1103                  
1104        List JavaDoc rows = BasePeer.doSelect(criteria);
1105        List JavaDoc results = new ArrayList JavaDoc();
1106
1107        for (int i = 0; i < rows.size(); i++)
1108        {
1109            Record row = (Record) rows.get(i);
1110
1111                            Class JavaDoc omClass = RIssueTypeAttributePeer.getOMClass();
1112                    RIssueTypeAttribute obj1 = (RIssueTypeAttribute) RIssueTypeAttributePeer
1113                .row2Object(row, 1, omClass);
1114                     omClass = AttributePeer.getOMClass();
1115                    Attribute obj2 = (Attribute)AttributePeer
1116                .row2Object(row, offset, omClass);
1117
1118            boolean newObject = true;
1119            for (int j = 0; j < results.size(); j++)
1120            {
1121                RIssueTypeAttribute temp_obj1 = (RIssueTypeAttribute)results.get(j);
1122                Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute();
1123                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1124                {
1125                    newObject = false;
1126                              temp_obj2.addRIssueTypeAttribute(obj1);
1127                              break;
1128                }
1129            }
1130                      if (newObject)
1131            {
1132                obj2.initRIssueTypeAttributes();
1133                obj2.addRIssueTypeAttribute(obj1);
1134            }
1135                      results.add(obj1);
1136        }
1137        return results;
1138    }
1139                                                            
1140                
1141                
1142
1143    /**
1144     * selects a collection of RIssueTypeAttribute objects pre-filled with their
1145     * IssueType objects.
1146     *
1147     * This method is protected by default in order to keep the public
1148     * api reasonable. You can provide public methods for those you
1149     * actually need in RIssueTypeAttributePeer.
1150     *
1151     * @throws TorqueException Any exceptions caught during processing will be
1152     * rethrown wrapped into a TorqueException.
1153     */

1154    protected static List JavaDoc doSelectJoinIssueType(Criteria criteria)
1155        throws TorqueException
1156    {
1157        setDbName(criteria);
1158
1159        RIssueTypeAttributePeer.addSelectColumns(criteria);
1160        int offset = numColumns + 1;
1161        IssueTypePeer.addSelectColumns(criteria);
1162
1163
1164                        criteria.addJoin(RIssueTypeAttributePeer.ISSUE_TYPE_ID,
1165            IssueTypePeer.ISSUE_TYPE_ID);
1166        
1167
1168                                                              // check for conversion from boolean to int
1169
if (criteria.containsKey(ACTIVE))
1170        {
1171            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1172            if (possibleBoolean instanceof Boolean JavaDoc)
1173            {
1174                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1175            }
1176         }
1177                                    // check for conversion from boolean to int
1178
if (criteria.containsKey(REQUIRED))
1179        {
1180            Object JavaDoc possibleBoolean = criteria.get(REQUIRED);
1181            if (possibleBoolean instanceof Boolean JavaDoc)
1182            {
1183                criteria.add(REQUIRED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1184            }
1185         }
1186                                                      // check for conversion from boolean to int
1187
if (criteria.containsKey(QUICK_SEARCH))
1188        {
1189            Object JavaDoc possibleBoolean = criteria.get(QUICK_SEARCH);
1190            if (possibleBoolean instanceof Boolean JavaDoc)
1191            {
1192                criteria.add(QUICK_SEARCH, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1193            }
1194         }
1195                                    // check for conversion from boolean to int
1196
if (criteria.containsKey(DEFAULT_TEXT_FLAG))
1197        {
1198            Object JavaDoc possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG);
1199            if (possibleBoolean instanceof Boolean JavaDoc)
1200            {
1201                criteria.add(DEFAULT_TEXT_FLAG, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1202            }
1203         }
1204                                    // check for conversion from boolean to int
1205
if (criteria.containsKey(LOCKED))
1206        {
1207            Object JavaDoc possibleBoolean = criteria.get(LOCKED);
1208            if (possibleBoolean instanceof Boolean JavaDoc)
1209            {
1210                criteria.add(LOCKED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1211            }
1212         }
1213                  
1214        List JavaDoc rows = BasePeer.doSelect(criteria);
1215        List JavaDoc results = new ArrayList JavaDoc();
1216
1217        for (int i = 0; i < rows.size(); i++)
1218        {
1219            Record row = (Record) rows.get(i);
1220
1221                            Class JavaDoc omClass = RIssueTypeAttributePeer.getOMClass();
1222                    RIssueTypeAttribute obj1 = (RIssueTypeAttribute) RIssueTypeAttributePeer
1223                .row2Object(row, 1, omClass);
1224                     omClass = IssueTypePeer.getOMClass();
1225                    IssueType obj2 = (IssueType)IssueTypePeer
1226                .row2Object(row, offset, omClass);
1227
1228            boolean newObject = true;
1229            for (int j = 0; j < results.size(); j++)
1230            {
1231                RIssueTypeAttribute temp_obj1 = (RIssueTypeAttribute)results.get(j);
1232                IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
1233                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1234                {
1235                    newObject = false;
1236                              temp_obj2.addRIssueTypeAttribute(obj1);
1237                              break;
1238                }
1239            }
1240                      if (newObject)
1241            {
1242                obj2.initRIssueTypeAttributes();
1243                obj2.addRIssueTypeAttribute(obj1);
1244            }
1245                      results.add(obj1);
1246        }
1247        return results;
1248    }
1249                    
1250  
1251    
1252  
1253      /**
1254     * Returns the TableMap related to this peer. This method is not
1255     * needed for general use but a specific application could have a need.
1256     *
1257     * @throws TorqueException Any exceptions caught during processing will be
1258     * rethrown wrapped into a TorqueException.
1259     */

1260    protected static TableMap getTableMap()
1261        throws TorqueException
1262    {
1263        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1264    }
1265   
1266    private static void setDbName(Criteria crit)
1267    {
1268        // Set the correct dbName if it has not been overridden
1269
// crit.getDbName will return the same object if not set to
1270
// another value so == check is okay and faster
1271
if (crit.getDbName() == Torque.getDefaultDB())
1272        {
1273            crit.setDbName(DATABASE_NAME);
1274        }
1275    }
1276}
1277
Popular Tags