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