1 package olr.om;
2
3 import java.sql.Connection;
4 import java.sql.SQLException;
5 import java.util.ArrayList;
6 import java.util.Iterator;
7 import java.util.LinkedList;
8 import java.util.List;
9
10 import olr.om.map.RdfToolbarMapBuilder;
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.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.util.BasePeer;
21 import org.apache.torque.util.Criteria;
22
23 import com.workingdogs.village.DataSetException;
24 import com.workingdogs.village.QueryDataSet;
25 import com.workingdogs.village.Record;
26
27
28
29 /***
30 * This class was autogenerated by Torque on:
31 *
32 * [Tue Jul 13 14:47:47 CEST 2004]
33 *
34 */
35 public abstract class BaseRdfToolbarPeer
36 extends BasePeer
37 {
38
39 /*** the default database name for this class */
40 public static final String DATABASE_NAME = "default";
41
42 /*** the table name for this class */
43 public static final String TABLE_NAME = "rdf_toolbar";
44
45 /***
46 * @return the map builder for this peer
47 * @throws TorqueException Any exceptions caught during processing will be
48 * rethrown wrapped into a TorqueException.
49 */
50 public static MapBuilder getMapBuilder()
51 throws TorqueException
52 {
53 return getMapBuilder(RdfToolbarMapBuilder.CLASS_NAME);
54 }
55
56 /*** the column name for the URI field */
57 public static final String URI;
58 /*** the column name for the TITLE field */
59 public static final String TITLE;
60 /*** the column name for the USR field */
61 public static final String USR;
62 /*** the column name for the IS_SCHEMA field */
63 public static final String IS_SCHEMA;
64
65 static
66 {
67 URI = "rdf_toolbar.URI";
68 TITLE = "rdf_toolbar.TITLE";
69 USR = "rdf_toolbar.USR";
70 IS_SCHEMA = "rdf_toolbar.IS_SCHEMA";
71 if (Torque.isInit())
72 {
73 try
74 {
75 getMapBuilder(RdfToolbarMapBuilder.CLASS_NAME);
76 }
77 catch (Exception e)
78 {
79 log.error("Could not initialize Peer", e);
80 }
81 }
82 else
83 {
84 Torque.registerMapBuilder(RdfToolbarMapBuilder.CLASS_NAME);
85 }
86 }
87
88 /*** number of columns for this peer */
89 public static final int numColumns = 4;
90
91 /*** A class that can be returned by this peer. */
92 protected static final String CLASSNAME_DEFAULT =
93 "olr.om.RdfToolbar";
94
95 /*** A class that can be returned by this peer. */
96 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
97
98 /***
99 * Class object initialization method.
100 *
101 * @param className name of the class to initialize
102 * @return the initialized class
103 */
104 private static Class initClass(String className)
105 {
106 Class c = null;
107 try
108 {
109 c = Class.forName(className);
110 }
111 catch (Throwable t)
112 {
113 log.error("A FATAL ERROR has occurred which should not "
114 + "have happened under any circumstance. Please notify "
115 + "the Torque developers <torque-dev@db.apache.org> "
116 + "and give as many details as possible (including the error "
117 + "stack trace).", t);
118
119
120 if (t instanceof Error)
121 {
122 throw (Error) t.fillInStackTrace();
123 }
124 }
125 return c;
126 }
127
128 /***
129 * Get the list of objects for a ResultSet. Please not that your
130 * resultset MUST return columns in the right order. You can use
131 * getFieldNames() in BaseObject to get the correct sequence.
132 *
133 * @param results the ResultSet
134 * @return the list of objects
135 * @throws TorqueException Any exceptions caught during processing will be
136 * rethrown wrapped into a TorqueException.
137 */
138 public static List resultSet2Objects(java.sql.ResultSet results)
139 throws TorqueException
140 {
141 try
142 {
143 QueryDataSet qds = null;
144 List rows = null;
145 try
146 {
147 qds = new QueryDataSet(results);
148 rows = getSelectResults(qds);
149 }
150 finally
151 {
152 if (qds != null)
153 {
154 qds.close();
155 }
156 }
157
158 return populateObjects(rows);
159 }
160 catch (SQLException e)
161 {
162 throw new TorqueException(e);
163 }
164 catch (DataSetException e)
165 {
166 throw new TorqueException(e);
167 }
168 }
169
170
171
172 /***
173 * Method to do inserts.
174 *
175 * @param criteria object used to create the INSERT statement.
176 * @throws TorqueException Any exceptions caught during processing will be
177 * rethrown wrapped into a TorqueException.
178 */
179 public static ObjectKey doInsert(Criteria criteria)
180 throws TorqueException
181 {
182 return BaseRdfToolbarPeer
183 .doInsert(criteria, (Connection) null);
184 }
185
186 /***
187 * Method to do inserts. This method is to be used during a transaction,
188 * otherwise use the doInsert(Criteria) method. It will take care of
189 * the connection details internally.
190 *
191 * @param criteria object used to create the INSERT statement.
192 * @param con the connection to use
193 * @throws TorqueException Any exceptions caught during processing will be
194 * rethrown wrapped into a TorqueException.
195 */
196 public static ObjectKey doInsert(Criteria criteria, Connection con)
197 throws TorqueException
198 {
199
200 if (criteria.containsKey(IS_SCHEMA))
201 {
202 Object possibleBoolean = criteria.get(IS_SCHEMA);
203 if (possibleBoolean instanceof Boolean)
204 {
205 if (((Boolean) possibleBoolean).booleanValue())
206 {
207 criteria.add(IS_SCHEMA, 1);
208 }
209 else
210 {
211 criteria.add(IS_SCHEMA, 0);
212 }
213 }
214 }
215
216
217
218
219 if (criteria.getDbName() == Torque.getDefaultDB())
220 {
221 criteria.setDbName(DATABASE_NAME);
222 }
223 if (con == null)
224 {
225 return BasePeer.doInsert(criteria);
226 }
227 else
228 {
229 return BasePeer.doInsert(criteria, con);
230 }
231 }
232
233 /***
234 * Add all the columns needed to create a new object.
235 *
236 * @param criteria object containing the columns to add.
237 * @throws TorqueException Any exceptions caught during processing will be
238 * rethrown wrapped into a TorqueException.
239 */
240 public static void addSelectColumns(Criteria criteria)
241 throws TorqueException
242 {
243 criteria.addSelectColumn(URI);
244 criteria.addSelectColumn(TITLE);
245 criteria.addSelectColumn(USR);
246 criteria.addSelectColumn(IS_SCHEMA);
247 }
248
249 /***
250 * Create a new object of type cls from a resultset row starting
251 * from a specified offset. This is done so that you can select
252 * other rows than just those needed for this object. You may
253 * for example want to create two objects from the same row.
254 *
255 * @throws TorqueException Any exceptions caught during processing will be
256 * rethrown wrapped into a TorqueException.
257 */
258 public static RdfToolbar row2Object(Record row,
259 int offset,
260 Class cls)
261 throws TorqueException
262 {
263 try
264 {
265 RdfToolbar obj = (RdfToolbar) cls.newInstance();
266 RdfToolbarPeer.populateObject(row, offset, obj);
267 obj.setModified(false);
268 obj.setNew(false);
269
270 return obj;
271 }
272 catch (InstantiationException e)
273 {
274 throw new TorqueException(e);
275 }
276 catch (IllegalAccessException e)
277 {
278 throw new TorqueException(e);
279 }
280 }
281
282 /***
283 * Populates an object from a resultset row starting
284 * from a specified offset. This is done so that you can select
285 * other rows than just those needed for this object. You may
286 * for example want to create two objects from the same row.
287 *
288 * @throws TorqueException Any exceptions caught during processing will be
289 * rethrown wrapped into a TorqueException.
290 */
291 public static void populateObject(Record row,
292 int offset,
293 RdfToolbar obj)
294 throws TorqueException
295 {
296 try
297 {
298 obj.setUri(row.getValue(offset + 0).asString());
299 obj.setTitle(row.getValue(offset + 1).asString());
300 obj.setUsr(row.getValue(offset + 2).asInt());
301 obj.setIsSchema(row.getValue(offset + 3).asBoolean());
302 }
303 catch (DataSetException e)
304 {
305 throw new TorqueException(e);
306 }
307 }
308
309 /***
310 * Method to do selects.
311 *
312 * @param criteria object used to create the SELECT statement.
313 * @return List of selected Objects
314 * @throws TorqueException Any exceptions caught during processing will be
315 * rethrown wrapped into a TorqueException.
316 */
317 public static List doSelect(Criteria criteria) throws TorqueException
318 {
319 return populateObjects(doSelectVillageRecords(criteria));
320 }
321
322 /***
323 * Method to do selects within a transaction.
324 *
325 * @param criteria object used to create the SELECT statement.
326 * @param con the connection to use
327 * @return List of selected Objects
328 * @throws TorqueException Any exceptions caught during processing will be
329 * rethrown wrapped into a TorqueException.
330 */
331 public static List doSelect(Criteria criteria, Connection con)
332 throws TorqueException
333 {
334 return populateObjects(doSelectVillageRecords(criteria, con));
335 }
336
337 /***
338 * Grabs the raw Village records to be formed into objects.
339 * This method handles connections internally. The Record objects
340 * returned by this method should be considered readonly. Do not
341 * alter the data and call save(), your results may vary, but are
342 * certainly likely to result in hard to track MT bugs.
343 *
344 * @throws TorqueException Any exceptions caught during processing will be
345 * rethrown wrapped into a TorqueException.
346 */
347 public static List doSelectVillageRecords(Criteria criteria)
348 throws TorqueException
349 {
350 return BaseRdfToolbarPeer
351 .doSelectVillageRecords(criteria, (Connection) null);
352 }
353
354 /***
355 * Grabs the raw Village records to be formed into objects.
356 * This method should be used for transactions
357 *
358 * @param con the connection to use
359 * @throws TorqueException Any exceptions caught during processing will be
360 * rethrown wrapped into a TorqueException.
361 */
362 public static List doSelectVillageRecords(Criteria criteria, Connection con)
363 throws TorqueException
364 {
365 if (criteria.getSelectColumns().size() == 0)
366 {
367 addSelectColumns(criteria);
368 }
369
370
371 if (criteria.containsKey(IS_SCHEMA))
372 {
373 Object possibleBoolean = criteria.get(IS_SCHEMA);
374 if (possibleBoolean instanceof Boolean)
375 {
376 if (((Boolean) possibleBoolean).booleanValue())
377 {
378 criteria.add(IS_SCHEMA, 1);
379 }
380 else
381 {
382 criteria.add(IS_SCHEMA, 0);
383 }
384 }
385 }
386
387
388
389
390 if (criteria.getDbName() == Torque.getDefaultDB())
391 {
392 criteria.setDbName(DATABASE_NAME);
393 }
394
395
396 if (con == null)
397 {
398 return BasePeer.doSelect(criteria);
399 }
400 else
401 {
402 return BasePeer.doSelect(criteria, con);
403 }
404 }
405
406 /***
407 * The returned List will contain objects of the default type or
408 * objects that inherit from the default.
409 *
410 * @throws TorqueException Any exceptions caught during processing will be
411 * rethrown wrapped into a TorqueException.
412 */
413 public static List populateObjects(List records)
414 throws TorqueException
415 {
416 List results = new ArrayList(records.size());
417
418
419 for (int i = 0; i < records.size(); i++)
420 {
421 Record row = (Record) records.get(i);
422 results.add(RdfToolbarPeer.row2Object(row, 1,
423 RdfToolbarPeer.getOMClass()));
424 }
425 return results;
426 }
427
428
429 /***
430 * The class that the Peer will make instances of.
431 * If the BO is abstract then you must implement this method
432 * in the BO.
433 *
434 * @throws TorqueException Any exceptions caught during processing will be
435 * rethrown wrapped into a TorqueException.
436 */
437 public static Class getOMClass()
438 throws TorqueException
439 {
440 return CLASS_DEFAULT;
441 }
442
443 /***
444 * Method to do updates.
445 *
446 * @param criteria object containing data that is used to create the UPDATE
447 * statement.
448 * @throws TorqueException Any exceptions caught during processing will be
449 * rethrown wrapped into a TorqueException.
450 */
451 public static void doUpdate(Criteria criteria) throws TorqueException
452 {
453 BaseRdfToolbarPeer
454 .doUpdate(criteria, (Connection) null);
455 }
456
457 /***
458 * Method to do updates. This method is to be used during a transaction,
459 * otherwise use the doUpdate(Criteria) method. It will take care of
460 * the connection details internally.
461 *
462 * @param criteria object containing data that is used to create the UPDATE
463 * statement.
464 * @param con the connection to use
465 * @throws TorqueException Any exceptions caught during processing will be
466 * rethrown wrapped into a TorqueException.
467 */
468 public static void doUpdate(Criteria criteria, Connection con)
469 throws TorqueException
470 {
471 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
472 selectCriteria.put(URI, criteria.remove(URI));
473 selectCriteria.put(USR, criteria.remove(USR));
474
475 if (criteria.containsKey(IS_SCHEMA))
476 {
477 Object possibleBoolean = criteria.get(IS_SCHEMA);
478 if (possibleBoolean instanceof Boolean)
479 {
480 if (((Boolean) possibleBoolean).booleanValue())
481 {
482 criteria.add(IS_SCHEMA, 1);
483 }
484 else
485 {
486 criteria.add(IS_SCHEMA, 0);
487 }
488 }
489 }
490
491
492
493
494 if (criteria.getDbName() == Torque.getDefaultDB())
495 {
496 criteria.setDbName(DATABASE_NAME);
497 }
498 if (con == null)
499 {
500 BasePeer.doUpdate(selectCriteria, criteria);
501 }
502 else
503 {
504 BasePeer.doUpdate(selectCriteria, criteria, con);
505 }
506 }
507
508 /***
509 * Method to do deletes.
510 *
511 * @param criteria object containing data that is used DELETE from database.
512 * @throws TorqueException Any exceptions caught during processing will be
513 * rethrown wrapped into a TorqueException.
514 */
515 public static void doDelete(Criteria criteria) throws TorqueException
516 {
517 BaseRdfToolbarPeer
518 .doDelete(criteria, (Connection) null);
519 }
520
521 /***
522 * Method to do deletes. This method is to be used during a transaction,
523 * otherwise use the doDelete(Criteria) method. It will take care of
524 * the connection details internally.
525 *
526 * @param criteria object containing data that is used DELETE from database.
527 * @param con the connection to use
528 * @throws TorqueException Any exceptions caught during processing will be
529 * rethrown wrapped into a TorqueException.
530 */
531 public static void doDelete(Criteria criteria, Connection con)
532 throws TorqueException
533 {
534
535 if (criteria.containsKey(IS_SCHEMA))
536 {
537 Object possibleBoolean = criteria.get(IS_SCHEMA);
538 if (possibleBoolean instanceof Boolean)
539 {
540 if (((Boolean) possibleBoolean).booleanValue())
541 {
542 criteria.add(IS_SCHEMA, 1);
543 }
544 else
545 {
546 criteria.add(IS_SCHEMA, 0);
547 }
548 }
549 }
550
551
552
553
554 if (criteria.getDbName() == Torque.getDefaultDB())
555 {
556 criteria.setDbName(DATABASE_NAME);
557 }
558 if (con == null)
559 {
560 BasePeer.doDelete(criteria);
561 }
562 else
563 {
564 BasePeer.doDelete(criteria, con);
565 }
566 }
567
568 /***
569 * Method to do selects
570 *
571 * @throws TorqueException Any exceptions caught during processing will be
572 * rethrown wrapped into a TorqueException.
573 */
574 public static List doSelect(RdfToolbar obj) throws TorqueException
575 {
576 return doSelect(buildCriteria(obj));
577 }
578
579 /***
580 * Method to do inserts
581 *
582 * @throws TorqueException Any exceptions caught during processing will be
583 * rethrown wrapped into a TorqueException.
584 */
585 public static void doInsert(RdfToolbar obj) throws TorqueException
586 {
587 doInsert(buildCriteria(obj));
588 obj.setNew(false);
589 obj.setModified(false);
590 }
591
592 /***
593 * @param obj the data object to update in the database.
594 * @throws TorqueException Any exceptions caught during processing will be
595 * rethrown wrapped into a TorqueException.
596 */
597 public static void doUpdate(RdfToolbar obj) throws TorqueException
598 {
599 doUpdate(buildCriteria(obj));
600 obj.setModified(false);
601 }
602
603 /***
604 * @param obj the data object to delete in the database.
605 * @throws TorqueException Any exceptions caught during processing will be
606 * rethrown wrapped into a TorqueException.
607 */
608 public static void doDelete(RdfToolbar obj) throws TorqueException
609 {
610 doDelete(buildCriteria(obj));
611 }
612
613 /***
614 * Method to do inserts. This method is to be used during a transaction,
615 * otherwise use the doInsert(RdfToolbar) method. It will take
616 * care of the connection details internally.
617 *
618 * @param obj the data object to insert into the database.
619 * @param con the connection to use
620 * @throws TorqueException Any exceptions caught during processing will be
621 * rethrown wrapped into a TorqueException.
622 */
623 public static void doInsert(RdfToolbar obj, Connection con)
624 throws TorqueException
625 {
626 doInsert(buildCriteria(obj), con);
627 obj.setNew(false);
628 obj.setModified(false);
629 }
630
631 /***
632 * Method to do update. This method is to be used during a transaction,
633 * otherwise use the doUpdate(RdfToolbar) method. It will take
634 * care of the connection details internally.
635 *
636 * @param obj the data object to update in the database.
637 * @param con the connection to use
638 * @throws TorqueException Any exceptions caught during processing will be
639 * rethrown wrapped into a TorqueException.
640 */
641 public static void doUpdate(RdfToolbar obj, Connection con)
642 throws TorqueException
643 {
644 doUpdate(buildCriteria(obj), con);
645 obj.setModified(false);
646 }
647
648 /***
649 * Method to delete. This method is to be used during a transaction,
650 * otherwise use the doDelete(RdfToolbar) method. It will take
651 * care of the connection details internally.
652 *
653 * @param obj the data object to delete in the database.
654 * @param con the connection to use
655 * @throws TorqueException Any exceptions caught during processing will be
656 * rethrown wrapped into a TorqueException.
657 */
658 public static void doDelete(RdfToolbar obj, Connection con)
659 throws TorqueException
660 {
661 doDelete(buildCriteria(obj), con);
662 }
663
664 /***
665 * Method to do deletes.
666 *
667 * @param pk ObjectKey that is used DELETE from database.
668 * @throws TorqueException Any exceptions caught during processing will be
669 * rethrown wrapped into a TorqueException.
670 */
671 public static void doDelete(ObjectKey pk) throws TorqueException
672 {
673 BaseRdfToolbarPeer
674 .doDelete(pk, (Connection) null);
675 }
676
677 /***
678 * Method to delete. This method is to be used during a transaction,
679 * otherwise use the doDelete(ObjectKey) method. It will take
680 * care of the connection details internally.
681 *
682 * @param pk the primary key for the object to delete in the database.
683 * @param con the connection to use
684 * @throws TorqueException Any exceptions caught during processing will be
685 * rethrown wrapped into a TorqueException.
686 */
687 public static void doDelete(ObjectKey pk, Connection con)
688 throws TorqueException
689 {
690 doDelete(buildCriteria(pk), con);
691 }
692
693 /*** Build a Criteria object from an ObjectKey */
694 public static Criteria buildCriteria( ObjectKey pk )
695 {
696 Criteria criteria = new Criteria();
697 SimpleKey[] keys = (SimpleKey[])pk.getValue();
698 criteria.add(URI, keys[0]);
699 criteria.add(USR, keys[1]);
700 return criteria;
701 }
702
703 /*** Build a Criteria object from the data object for this peer */
704 public static Criteria buildCriteria( RdfToolbar obj )
705 {
706 Criteria criteria = new Criteria(DATABASE_NAME);
707 criteria.add(URI, obj.getUri());
708 criteria.add(TITLE, obj.getTitle());
709 criteria.add(USR, obj.getUsr());
710 criteria.add(IS_SCHEMA, obj.getIsSchema());
711 return criteria;
712 }
713
714
715
716 /***
717 * Retrieve a single object by pk
718 *
719 * @param pk the primary key
720 * @throws TorqueException Any exceptions caught during processing will be
721 * rethrown wrapped into a TorqueException.
722 * @throws NoRowsException Primary key was not found in database.
723 * @throws TooManyRowsException Primary key was not found in database.
724 */
725 public static RdfToolbar retrieveByPK(ObjectKey pk)
726 throws TorqueException, NoRowsException, TooManyRowsException
727 {
728 Connection db = null;
729 RdfToolbar retVal = null;
730 try
731 {
732 db = Torque.getConnection(DATABASE_NAME);
733 retVal = retrieveByPK(pk, db);
734 }
735 finally
736 {
737 Torque.closeConnection(db);
738 }
739 return(retVal);
740 }
741
742 /***
743 * Retrieve a single object by pk
744 *
745 * @param pk the primary key
746 * @param con the connection to use
747 * @throws TorqueException Any exceptions caught during processing will be
748 * rethrown wrapped into a TorqueException.
749 * @throws NoRowsException Primary key was not found in database.
750 * @throws TooManyRowsException Primary key was not found in database.
751 */
752 public static RdfToolbar retrieveByPK(ObjectKey pk, Connection con)
753 throws TorqueException, NoRowsException, TooManyRowsException
754 {
755 Criteria criteria = buildCriteria(pk);
756 List v = doSelect(criteria, con);
757 if (v.size() == 0)
758 {
759 throw new NoRowsException("Failed to select a row.");
760 }
761 else if (v.size() > 1)
762 {
763 throw new TooManyRowsException("Failed to select only one row.");
764 }
765 else
766 {
767 return (RdfToolbar)v.get(0);
768 }
769 }
770
771 /***
772 * Retrieve a multiple objects by pk
773 *
774 * @param pks List of primary keys
775 * @throws TorqueException Any exceptions caught during processing will be
776 * rethrown wrapped into a TorqueException.
777 */
778 public static List retrieveByPKs(List pks)
779 throws TorqueException
780 {
781 Connection db = null;
782 List retVal = null;
783 try
784 {
785 db = Torque.getConnection(DATABASE_NAME);
786 retVal = retrieveByPKs(pks, db);
787 }
788 finally
789 {
790 Torque.closeConnection(db);
791 }
792 return(retVal);
793 }
794
795 /***
796 * Retrieve a multiple objects by pk
797 *
798 * @param pks List of primary keys
799 * @param dbcon the connection to use
800 * @throws TorqueException Any exceptions caught during processing will be
801 * rethrown wrapped into a TorqueException.
802 */
803 public static List retrieveByPKs( List pks, Connection dbcon )
804 throws TorqueException
805 {
806 List objs = null;
807 if (pks == null || pks.size() == 0)
808 {
809 objs = new LinkedList();
810 }
811 else
812 {
813 Criteria criteria = new Criteria();
814 Iterator iter = pks.iterator();
815 while (iter.hasNext())
816 {
817 ObjectKey pk = (ObjectKey)iter.next();
818 SimpleKey[] keys = (SimpleKey[])pk.getValue();
819 Criteria.Criterion c0 = criteria.getNewCriterion(
820 URI, keys[0], Criteria.EQUAL);
821 Criteria.Criterion c1 = criteria.getNewCriterion(
822 USR, keys[1], Criteria.EQUAL);
823 c0.and(c1);
824 criteria.or(c0);
825 }
826 objs = doSelect(criteria, dbcon);
827 }
828 return objs;
829 }
830
831
832 /***
833 * retrieve object using using pk values.
834 *
835 * @param uri String
836 * @param usr int
837 */
838 public static RdfToolbar retrieveByPK(
839 String uri
840 , int usr
841 ) throws TorqueException
842 {
843 Connection db = null;
844 RdfToolbar retVal = null;
845 try
846 {
847 db = Torque.getConnection(DATABASE_NAME);
848 retVal = retrieveByPK(
849 uri
850 , usr
851 , db);
852 }
853 finally
854 {
855 Torque.closeConnection(db);
856 }
857 return(retVal);
858 }
859
860 /***
861 * retrieve object using using pk values.
862 *
863 * @param uri String
864 * @param usr int
865 * @param Connection con
866 */
867 public static RdfToolbar retrieveByPK(
868 String uri
869 , int usr
870 ,Connection con) throws TorqueException
871 {
872
873 Criteria criteria = new Criteria(5);
874 criteria.add(URI, uri);
875 criteria.add(USR, usr);
876 List v = doSelect(criteria, con);
877 if (v.size() != 1)
878 {
879 throw new TorqueException("Failed to select one and only one row.");
880 }
881 else
882 {
883 return (RdfToolbar) v.get(0);
884 }
885 }
886
887
888
889
890
891
892
893
894 /***
895 * selects a collection of RdfToolbar objects pre-filled with their
896 * RdfUser objects.
897 *
898 * This method is protected by default in order to keep the public
899 * api reasonable. You can provide public methods for those you
900 * actually need in RdfToolbarPeer.
901 *
902 * @throws TorqueException Any exceptions caught during processing will be
903 * rethrown wrapped into a TorqueException.
904 */
905 protected static List doSelectJoinRdfUser(Criteria c)
906 throws TorqueException
907 {
908
909
910
911 if (c.getDbName() == Torque.getDefaultDB())
912 {
913 c.setDbName(DATABASE_NAME);
914 }
915
916 RdfToolbarPeer.addSelectColumns(c);
917 int offset = numColumns + 1;
918 RdfUserPeer.addSelectColumns(c);
919
920
921 c.addJoin(RdfToolbarPeer.USR,
922 RdfUserPeer.ID);
923
924
925
926 if (c.containsKey(IS_SCHEMA))
927 {
928 Object possibleBoolean = c.get(IS_SCHEMA);
929 if (possibleBoolean instanceof Boolean)
930 {
931 if (((Boolean) possibleBoolean).booleanValue())
932 {
933 c.add(IS_SCHEMA, 1);
934 }
935 else
936 {
937 c.add(IS_SCHEMA, 0);
938 }
939 }
940 }
941
942 List rows = BasePeer.doSelect(c);
943 List results = new ArrayList();
944
945 for (int i = 0; i < rows.size(); i++)
946 {
947 Record row = (Record) rows.get(i);
948
949 Class omClass = RdfToolbarPeer.getOMClass();
950 RdfToolbar obj1 = (RdfToolbar) RdfToolbarPeer
951 .row2Object(row, 1, omClass);
952 omClass = RdfUserPeer.getOMClass();
953 RdfUser obj2 = (RdfUser)RdfUserPeer
954 .row2Object(row, offset, omClass);
955
956 boolean newObject = true;
957 for (int j = 0; j < results.size(); j++)
958 {
959 RdfToolbar temp_obj1 = (RdfToolbar)results.get(j);
960 RdfUser temp_obj2 = (RdfUser)temp_obj1.getRdfUser();
961 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
962 {
963 newObject = false;
964 temp_obj2.addRdfToolbar(obj1);
965 break;
966 }
967 }
968 if (newObject)
969 {
970 obj2.initRdfToolbars();
971 obj2.addRdfToolbar(obj1);
972 }
973 results.add(obj1);
974 }
975 return results;
976 }
977
978
979
980
981 /***
982 * Returns the TableMap related to this peer. This method is not
983 * needed for general use but a specific application could have a need.
984 *
985 * @throws TorqueException Any exceptions caught during processing will be
986 * rethrown wrapped into a TorqueException.
987 */
988 protected static TableMap getTableMap()
989 throws TorqueException
990 {
991 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
992 }
993 }