1 package olr.om;
2
3
4 import java.sql.Connection;
5 import java.util.ArrayList;
6 import java.util.Collections;
7 import java.util.Date;
8 import java.util.List;
9
10 import org.apache.commons.lang.ObjectUtils;
11 import org.apache.torque.TorqueException;
12 import org.apache.torque.om.BaseObject;
13 import org.apache.torque.om.NumberKey;
14 import org.apache.torque.om.ObjectKey;
15 import org.apache.torque.om.SimpleKey;
16 import org.apache.torque.util.Criteria;
17 import org.apache.torque.util.Transaction;
18
19
20
21
22
23
24
25 /***
26 * This class was autogenerated by Torque on:
27 *
28 * [Tue Jul 13 14:47:47 CEST 2004]
29 *
30 * You should not use this class directly. It should not even be
31 * extended all references should be to RdfStatement
32 */
33 public abstract class BaseRdfStatement extends BaseObject
34 {
35 /*** The Peer class */
36 private static final RdfStatementPeer peer =
37 new RdfStatementPeer();
38
39
40 /*** The value for the id field */
41 private int id;
42
43 /*** The value for the subject field */
44 private int subject;
45
46 /*** The value for the predicate field */
47 private int predicate;
48
49 /*** The value for the objResource field */
50 private int objResource;
51
52 /*** The value for the objLiteral field */
53 private int objLiteral;
54
55 /*** The value for the res field */
56 private String res;
57
58 /*** The value for the usr field */
59 private int usr;
60
61 /*** The value for the ispublic field */
62 private String ispublic = "Y";
63
64 /*** The value for the modified field */
65 private Date modified;
66
67 /*** The value for the garbage field */
68 private long garbage = 0;
69
70
71 /***
72 * Get the Id
73 *
74 * @return int
75 */
76 public int getId()
77 {
78 return id;
79 }
80
81
82 /***
83 * Set the value of Id
84 *
85 * @param v new value
86 */
87 public void setId(int v) throws TorqueException
88 {
89
90 if (this.id != v)
91 {
92 this.id = v;
93 setModified(true);
94 }
95
96
97
98
99 if (collModelStatements != null)
100 {
101 for (int i = 0; i < collModelStatements.size(); i++)
102 {
103 ((ModelStatement) collModelStatements.get(i))
104 .setStatementId(v);
105 }
106 }
107 }
108
109 /***
110 * Get the Subject
111 *
112 * @return int
113 */
114 public int getSubject()
115 {
116 return subject;
117 }
118
119
120 /***
121 * Set the value of Subject
122 *
123 * @param v new value
124 */
125 public void setSubject(int v) throws TorqueException
126 {
127
128 if (this.subject != v)
129 {
130 this.subject = v;
131 setModified(true);
132 }
133
134
135 if (aRdfResourceRelatedBySubject != null && !(aRdfResourceRelatedBySubject.getId() == v))
136 {
137 aRdfResourceRelatedBySubject = null;
138 }
139
140 }
141
142 /***
143 * Get the Predicate
144 *
145 * @return int
146 */
147 public int getPredicate()
148 {
149 return predicate;
150 }
151
152
153 /***
154 * Set the value of Predicate
155 *
156 * @param v new value
157 */
158 public void setPredicate(int v) throws TorqueException
159 {
160
161 if (this.predicate != v)
162 {
163 this.predicate = v;
164 setModified(true);
165 }
166
167
168 if (aRdfResourceRelatedByPredicate != null && !(aRdfResourceRelatedByPredicate.getId() == v))
169 {
170 aRdfResourceRelatedByPredicate = null;
171 }
172
173 }
174
175 /***
176 * Get the ObjResource
177 *
178 * @return int
179 */
180 public int getObjResource()
181 {
182 return objResource;
183 }
184
185
186 /***
187 * Set the value of ObjResource
188 *
189 * @param v new value
190 */
191 public void setObjResource(int v) throws TorqueException
192 {
193
194 if (this.objResource != v)
195 {
196 this.objResource = v;
197 setModified(true);
198 }
199
200
201 if (aRdfResourceRelatedByObjResource != null && !(aRdfResourceRelatedByObjResource.getId() == v))
202 {
203 aRdfResourceRelatedByObjResource = null;
204 }
205
206 }
207
208 /***
209 * Get the ObjLiteral
210 *
211 * @return int
212 */
213 public int getObjLiteral()
214 {
215 return objLiteral;
216 }
217
218
219 /***
220 * Set the value of ObjLiteral
221 *
222 * @param v new value
223 */
224 public void setObjLiteral(int v) throws TorqueException
225 {
226
227 if (this.objLiteral != v)
228 {
229 this.objLiteral = v;
230 setModified(true);
231 }
232
233
234 if (aRdfLiteral != null && !(aRdfLiteral.getId() == v))
235 {
236 aRdfLiteral = null;
237 }
238
239 }
240
241 /***
242 * Get the Res
243 *
244 * @return String
245 */
246 public String getRes()
247 {
248 return res;
249 }
250
251
252 /***
253 * Set the value of Res
254 *
255 * @param v new value
256 */
257 public void setRes(String v)
258 {
259
260 if (!ObjectUtils.equals(this.res, v))
261 {
262 this.res = v;
263 setModified(true);
264 }
265
266
267 }
268
269 /***
270 * Get the Usr
271 *
272 * @return int
273 */
274 public int getUsr()
275 {
276 return usr;
277 }
278
279
280 /***
281 * Set the value of Usr
282 *
283 * @param v new value
284 */
285 public void setUsr(int v) throws TorqueException
286 {
287
288 if (this.usr != v)
289 {
290 this.usr = v;
291 setModified(true);
292 }
293
294
295 if (aRdfUser != null && !(aRdfUser.getId() == v))
296 {
297 aRdfUser = null;
298 }
299
300 }
301
302 /***
303 * Get the Ispublic
304 *
305 * @return String
306 */
307 public String getIspublic()
308 {
309 return ispublic;
310 }
311
312
313 /***
314 * Set the value of Ispublic
315 *
316 * @param v new value
317 */
318 public void setIspublic(String v)
319 {
320
321 if (!ObjectUtils.equals(this.ispublic, v))
322 {
323 this.ispublic = v;
324 setModified(true);
325 }
326
327
328 }
329
330 /***
331 * Get the Modified
332 *
333 * @return Date
334 */
335 public Date getModified()
336 {
337 return modified;
338 }
339
340
341 /***
342 * Set the value of Modified
343 *
344 * @param v new value
345 */
346 public void setModified(Date v)
347 {
348
349 if (!ObjectUtils.equals(this.modified, v))
350 {
351 this.modified = v;
352 setModified(true);
353 }
354
355
356 }
357
358 /***
359 * Get the Garbage
360 *
361 * @return long
362 */
363 public long getGarbage()
364 {
365 return garbage;
366 }
367
368
369 /***
370 * Set the value of Garbage
371 *
372 * @param v new value
373 */
374 public void setGarbage(long v)
375 {
376
377 if (this.garbage != v)
378 {
379 this.garbage = v;
380 setModified(true);
381 }
382
383
384 }
385
386
387
388
389
390 private RdfUser aRdfUser;
391
392 /***
393 * Declares an association between this object and a RdfUser object
394 *
395 * @param v RdfUser
396 * @throws TorqueException
397 */
398 public void setRdfUser(RdfUser v) throws TorqueException
399 {
400 if (v == null)
401 {
402 setUsr(0);
403 }
404 else
405 {
406 setUsr(v.getId());
407 }
408 aRdfUser = v;
409 }
410
411
412 /***
413 * Get the associated RdfUser object
414 *
415 * @return the associated RdfUser object
416 * @throws TorqueException
417 */
418 public RdfUser getRdfUser() throws TorqueException
419 {
420 if (aRdfUser == null && (this.usr > 0))
421 {
422 aRdfUser = RdfUserPeer.retrieveByPK(SimpleKey.keyFor(this.usr));
423
424
425
426
427
428
429
430
431
432
433 }
434 return aRdfUser;
435 }
436
437 /***
438 * Provides convenient way to set a relationship based on a
439 * ObjectKey. e.g.
440 * <code>bar.setFooKey(foo.getPrimaryKey())</code>
441 *
442 */
443 public void setRdfUserKey(ObjectKey key) throws TorqueException
444 {
445
446 setUsr(((NumberKey) key).intValue());
447 }
448
449
450
451
452 private RdfResource aRdfResourceRelatedByPredicate;
453
454 /***
455 * Declares an association between this object and a RdfResource object
456 *
457 * @param v RdfResource
458 * @throws TorqueException
459 */
460 public void setRdfResourceRelatedByPredicate(RdfResource v) throws TorqueException
461 {
462 if (v == null)
463 {
464 setPredicate(0);
465 }
466 else
467 {
468 setPredicate(v.getId());
469 }
470 aRdfResourceRelatedByPredicate = v;
471 }
472
473
474 /***
475 * Get the associated RdfResource object
476 *
477 * @return the associated RdfResource object
478 * @throws TorqueException
479 */
480 public RdfResource getRdfResourceRelatedByPredicate() throws TorqueException
481 {
482 if (aRdfResourceRelatedByPredicate == null && (this.predicate > 0))
483 {
484 aRdfResourceRelatedByPredicate = RdfResourcePeer.retrieveByPK(SimpleKey.keyFor(this.predicate));
485
486
487
488
489
490
491
492
493
494
495 }
496 return aRdfResourceRelatedByPredicate;
497 }
498
499 /***
500 * Provides convenient way to set a relationship based on a
501 * ObjectKey. e.g.
502 * <code>bar.setFooKey(foo.getPrimaryKey())</code>
503 *
504 */
505 public void setRdfResourceRelatedByPredicateKey(ObjectKey key) throws TorqueException
506 {
507
508 setPredicate(((NumberKey) key).intValue());
509 }
510
511
512
513
514 private RdfResource aRdfResourceRelatedByObjResource;
515
516 /***
517 * Declares an association between this object and a RdfResource object
518 *
519 * @param v RdfResource
520 * @throws TorqueException
521 */
522 public void setRdfResourceRelatedByObjResource(RdfResource v) throws TorqueException
523 {
524 if (v == null)
525 {
526 setObjResource(0);
527 }
528 else
529 {
530 setObjResource(v.getId());
531 }
532 aRdfResourceRelatedByObjResource = v;
533 }
534
535
536 /***
537 * Get the associated RdfResource object
538 *
539 * @return the associated RdfResource object
540 * @throws TorqueException
541 */
542 public RdfResource getRdfResourceRelatedByObjResource() throws TorqueException
543 {
544 if (aRdfResourceRelatedByObjResource == null && (this.objResource > 0))
545 {
546 aRdfResourceRelatedByObjResource = RdfResourcePeer.retrieveByPK(SimpleKey.keyFor(this.objResource));
547
548
549
550
551
552
553
554
555
556
557 }
558 return aRdfResourceRelatedByObjResource;
559 }
560
561 /***
562 * Provides convenient way to set a relationship based on a
563 * ObjectKey. e.g.
564 * <code>bar.setFooKey(foo.getPrimaryKey())</code>
565 *
566 */
567 public void setRdfResourceRelatedByObjResourceKey(ObjectKey key) throws TorqueException
568 {
569
570 setObjResource(((NumberKey) key).intValue());
571 }
572
573
574
575
576 private RdfResource aRdfResourceRelatedBySubject;
577
578 /***
579 * Declares an association between this object and a RdfResource object
580 *
581 * @param v RdfResource
582 * @throws TorqueException
583 */
584 public void setRdfResourceRelatedBySubject(RdfResource v) throws TorqueException
585 {
586 if (v == null)
587 {
588 setSubject(0);
589 }
590 else
591 {
592 setSubject(v.getId());
593 }
594 aRdfResourceRelatedBySubject = v;
595 }
596
597
598 /***
599 * Get the associated RdfResource object
600 *
601 * @return the associated RdfResource object
602 * @throws TorqueException
603 */
604 public RdfResource getRdfResourceRelatedBySubject() throws TorqueException
605 {
606 if (aRdfResourceRelatedBySubject == null && (this.subject > 0))
607 {
608 aRdfResourceRelatedBySubject = RdfResourcePeer.retrieveByPK(SimpleKey.keyFor(this.subject));
609
610
611
612
613
614
615
616
617
618
619 }
620 return aRdfResourceRelatedBySubject;
621 }
622
623 /***
624 * Provides convenient way to set a relationship based on a
625 * ObjectKey. e.g.
626 * <code>bar.setFooKey(foo.getPrimaryKey())</code>
627 *
628 */
629 public void setRdfResourceRelatedBySubjectKey(ObjectKey key) throws TorqueException
630 {
631
632 setSubject(((NumberKey) key).intValue());
633 }
634
635
636
637
638 private RdfLiteral aRdfLiteral;
639
640 /***
641 * Declares an association between this object and a RdfLiteral object
642 *
643 * @param v RdfLiteral
644 * @throws TorqueException
645 */
646 public void setRdfLiteral(RdfLiteral v) throws TorqueException
647 {
648 if (v == null)
649 {
650 setObjLiteral(0);
651 }
652 else
653 {
654 setObjLiteral(v.getId());
655 }
656 aRdfLiteral = v;
657 }
658
659
660 /***
661 * Get the associated RdfLiteral object
662 *
663 * @return the associated RdfLiteral object
664 * @throws TorqueException
665 */
666 public RdfLiteral getRdfLiteral() throws TorqueException
667 {
668 if (aRdfLiteral == null && (this.objLiteral > 0))
669 {
670 aRdfLiteral = RdfLiteralPeer.retrieveByPK(SimpleKey.keyFor(this.objLiteral));
671
672
673
674
675
676
677
678
679
680
681 }
682 return aRdfLiteral;
683 }
684
685 /***
686 * Provides convenient way to set a relationship based on a
687 * ObjectKey. e.g.
688 * <code>bar.setFooKey(foo.getPrimaryKey())</code>
689 *
690 */
691 public void setRdfLiteralKey(ObjectKey key) throws TorqueException
692 {
693
694 setObjLiteral(((NumberKey) key).intValue());
695 }
696
697
698
699 /***
700 * Collection to store aggregation of collModelStatements
701 */
702 protected List collModelStatements;
703
704 /***
705 * Temporary storage of collModelStatements to save a possible db hit in
706 * the event objects are add to the collection, but the
707 * complete collection is never requested.
708 */
709 protected void initModelStatements()
710 {
711 if (collModelStatements == null)
712 {
713 collModelStatements = new ArrayList();
714 }
715 }
716
717 /***
718 * Method called to associate a ModelStatement object to this object
719 * through the ModelStatement foreign key attribute
720 *
721 * @param l ModelStatement
722 * @throws TorqueException
723 */
724 public void addModelStatement(ModelStatement l) throws TorqueException
725 {
726 getModelStatements().add(l);
727 l.setRdfStatement((RdfStatement) this);
728 }
729
730 /***
731 * The criteria used to select the current contents of collModelStatements
732 */
733 private Criteria lastModelStatementsCriteria = null;
734
735 /***
736 * If this collection has already been initialized, returns
737 * the collection. Otherwise returns the results of
738 * getModelStatements(new Criteria())
739 *
740 * @throws TorqueException
741 */
742 public List getModelStatements() throws TorqueException
743 {
744 if (collModelStatements == null)
745 {
746 collModelStatements = getModelStatements(new Criteria(10));
747 }
748 return collModelStatements;
749 }
750
751 /***
752 * If this collection has already been initialized with
753 * an identical criteria, it returns the collection.
754 * Otherwise if this RdfStatement has previously
755 * been saved, it will retrieve related ModelStatements from storage.
756 * If this RdfStatement is new, it will return
757 * an empty collection or the current collection, the criteria
758 * is ignored on a new object.
759 *
760 * @throws TorqueException
761 */
762 public List getModelStatements(Criteria criteria) throws TorqueException
763 {
764 if (collModelStatements == null)
765 {
766 if (isNew())
767 {
768 collModelStatements = new ArrayList();
769 }
770 else
771 {
772 criteria.add(ModelStatementPeer.STATEMENT_ID, getId() );
773 collModelStatements = ModelStatementPeer.doSelect(criteria);
774 }
775 }
776 else
777 {
778
779 if (!isNew())
780 {
781
782
783
784 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
785 if (!lastModelStatementsCriteria.equals(criteria))
786 {
787 collModelStatements = ModelStatementPeer.doSelect(criteria);
788 }
789 }
790 }
791 lastModelStatementsCriteria = criteria;
792
793 return collModelStatements;
794 }
795
796 /***
797 * If this collection has already been initialized, returns
798 * the collection. Otherwise returns the results of
799 * getModelStatements(new Criteria(),Connection)
800 * This method takes in the Connection also as input so that
801 * referenced objects can also be obtained using a Connection
802 * that is taken as input
803 */
804 public List getModelStatements(Connection con) throws TorqueException
805 {
806 if (collModelStatements == null)
807 {
808 collModelStatements = getModelStatements(new Criteria(10), con);
809 }
810 return collModelStatements;
811 }
812
813 /***
814 * If this collection has already been initialized with
815 * an identical criteria, it returns the collection.
816 * Otherwise if this RdfStatement has previously
817 * been saved, it will retrieve related ModelStatements from storage.
818 * If this RdfStatement is new, it will return
819 * an empty collection or the current collection, the criteria
820 * is ignored on a new object.
821 * This method takes in the Connection also as input so that
822 * referenced objects can also be obtained using a Connection
823 * that is taken as input
824 */
825 public List getModelStatements(Criteria criteria, Connection con)
826 throws TorqueException
827 {
828 if (collModelStatements == null)
829 {
830 if (isNew())
831 {
832 collModelStatements = new ArrayList();
833 }
834 else
835 {
836 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
837 collModelStatements = ModelStatementPeer.doSelect(criteria, con);
838 }
839 }
840 else
841 {
842
843 if (!isNew())
844 {
845
846
847
848 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
849 if (!lastModelStatementsCriteria.equals(criteria))
850 {
851 collModelStatements = ModelStatementPeer.doSelect(criteria, con);
852 }
853 }
854 }
855 lastModelStatementsCriteria = criteria;
856
857 return collModelStatements;
858 }
859
860
861
862
863
864
865
866
867
868
869
870 /***
871 * If this collection has already been initialized with
872 * an identical criteria, it returns the collection.
873 * Otherwise if this RdfStatement is new, it will return
874 * an empty collection; or if this RdfStatement has previously
875 * been saved, it will retrieve related ModelStatements from storage.
876 *
877 * This method is protected by default in order to keep the public
878 * api reasonable. You can provide public methods for those you
879 * actually need in RdfStatement.
880 */
881 protected List getModelStatementsJoinRdfUser(Criteria criteria)
882 throws TorqueException
883 {
884 if (collModelStatements == null)
885 {
886 if (isNew())
887 {
888 collModelStatements = new ArrayList();
889 }
890 else
891 {
892 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
893 collModelStatements = ModelStatementPeer.doSelectJoinRdfUser(criteria);
894 }
895 }
896 else
897 {
898
899
900
901 boolean newCriteria = true;
902 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
903 if (!lastModelStatementsCriteria.equals(criteria))
904 {
905 collModelStatements = ModelStatementPeer.doSelectJoinRdfUser(criteria);
906 }
907 }
908 lastModelStatementsCriteria = criteria;
909
910 return collModelStatements;
911 }
912
913
914
915
916
917
918
919
920
921 /***
922 * If this collection has already been initialized with
923 * an identical criteria, it returns the collection.
924 * Otherwise if this RdfStatement is new, it will return
925 * an empty collection; or if this RdfStatement has previously
926 * been saved, it will retrieve related ModelStatements from storage.
927 *
928 * This method is protected by default in order to keep the public
929 * api reasonable. You can provide public methods for those you
930 * actually need in RdfStatement.
931 */
932 protected List getModelStatementsJoinModel(Criteria criteria)
933 throws TorqueException
934 {
935 if (collModelStatements == null)
936 {
937 if (isNew())
938 {
939 collModelStatements = new ArrayList();
940 }
941 else
942 {
943 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
944 collModelStatements = ModelStatementPeer.doSelectJoinModel(criteria);
945 }
946 }
947 else
948 {
949
950
951
952 boolean newCriteria = true;
953 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
954 if (!lastModelStatementsCriteria.equals(criteria))
955 {
956 collModelStatements = ModelStatementPeer.doSelectJoinModel(criteria);
957 }
958 }
959 lastModelStatementsCriteria = criteria;
960
961 return collModelStatements;
962 }
963
964
965
966
967
968
969
970
971
972 /***
973 * If this collection has already been initialized with
974 * an identical criteria, it returns the collection.
975 * Otherwise if this RdfStatement is new, it will return
976 * an empty collection; or if this RdfStatement has previously
977 * been saved, it will retrieve related ModelStatements from storage.
978 *
979 * This method is protected by default in order to keep the public
980 * api reasonable. You can provide public methods for those you
981 * actually need in RdfStatement.
982 */
983 protected List getModelStatementsJoinRdfStatement(Criteria criteria)
984 throws TorqueException
985 {
986 if (collModelStatements == null)
987 {
988 if (isNew())
989 {
990 collModelStatements = new ArrayList();
991 }
992 else
993 {
994 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
995 collModelStatements = ModelStatementPeer.doSelectJoinRdfStatement(criteria);
996 }
997 }
998 else
999 {
1000
1001
1002
1003 boolean newCriteria = true;
1004 criteria.add(ModelStatementPeer.STATEMENT_ID, getId());
1005 if (!lastModelStatementsCriteria.equals(criteria))
1006 {
1007 collModelStatements = ModelStatementPeer.doSelectJoinRdfStatement(criteria);
1008 }
1009 }
1010 lastModelStatementsCriteria = criteria;
1011
1012 return collModelStatements;
1013 }
1014
1015
1016
1017
1018 private static List fieldNames = null;
1019
1020 /***
1021 * Generate a list of field names.
1022 *
1023 * @return a list of field names
1024 */
1025 public static synchronized List getFieldNames()
1026 {
1027 if (fieldNames == null)
1028 {
1029 fieldNames = new ArrayList();
1030 fieldNames.add("Id");
1031 fieldNames.add("Subject");
1032 fieldNames.add("Predicate");
1033 fieldNames.add("ObjResource");
1034 fieldNames.add("ObjLiteral");
1035 fieldNames.add("Res");
1036 fieldNames.add("Usr");
1037 fieldNames.add("Ispublic");
1038 fieldNames.add("Modified");
1039 fieldNames.add("Garbage");
1040 fieldNames = Collections.unmodifiableList(fieldNames);
1041 }
1042 return fieldNames;
1043 }
1044
1045 /***
1046 * Retrieves a field from the object by name passed in as a String.
1047 *
1048 * @param name field name
1049 * @return value
1050 */
1051 public Object getByName(String name)
1052 {
1053 if (name.equals("Id"))
1054 {
1055 return new Integer(getId());
1056 }
1057 if (name.equals("Subject"))
1058 {
1059 return new Integer(getSubject());
1060 }
1061 if (name.equals("Predicate"))
1062 {
1063 return new Integer(getPredicate());
1064 }
1065 if (name.equals("ObjResource"))
1066 {
1067 return new Integer(getObjResource());
1068 }
1069 if (name.equals("ObjLiteral"))
1070 {
1071 return new Integer(getObjLiteral());
1072 }
1073 if (name.equals("Res"))
1074 {
1075 return getRes();
1076 }
1077 if (name.equals("Usr"))
1078 {
1079 return new Integer(getUsr());
1080 }
1081 if (name.equals("Ispublic"))
1082 {
1083 return getIspublic();
1084 }
1085 if (name.equals("Modified"))
1086 {
1087 return getModified();
1088 }
1089 if (name.equals("Garbage"))
1090 {
1091 return new Long(getGarbage());
1092 }
1093 return null;
1094 }
1095
1096 /***
1097 * Retrieves a field from the object by name passed in
1098 * as a String. The String must be one of the static
1099 * Strings defined in this Class' Peer.
1100 *
1101 * @param name peer name
1102 * @return value
1103 */
1104 public Object getByPeerName(String name)
1105 {
1106 if (name.equals(RdfStatementPeer.ID))
1107 {
1108 return new Integer(getId());
1109 }
1110 if (name.equals(RdfStatementPeer.SUBJECT))
1111 {
1112 return new Integer(getSubject());
1113 }
1114 if (name.equals(RdfStatementPeer.PREDICATE))
1115 {
1116 return new Integer(getPredicate());
1117 }
1118 if (name.equals(RdfStatementPeer.OBJ_RESOURCE))
1119 {
1120 return new Integer(getObjResource());
1121 }
1122 if (name.equals(RdfStatementPeer.OBJ_LITERAL))
1123 {
1124 return new Integer(getObjLiteral());
1125 }
1126 if (name.equals(RdfStatementPeer.RES))
1127 {
1128 return getRes();
1129 }
1130 if (name.equals(RdfStatementPeer.USR))
1131 {
1132 return new Integer(getUsr());
1133 }
1134 if (name.equals(RdfStatementPeer.ISPUBLIC))
1135 {
1136 return getIspublic();
1137 }
1138 if (name.equals(RdfStatementPeer.MODIFIED))
1139 {
1140 return getModified();
1141 }
1142 if (name.equals(RdfStatementPeer.GARBAGE))
1143 {
1144 return new Long(getGarbage());
1145 }
1146 return null;
1147 }
1148
1149 /***
1150 * Retrieves a field from the object by Position as specified
1151 * in the xml schema. Zero-based.
1152 *
1153 * @param pos position in xml schema
1154 * @return value
1155 */
1156 public Object getByPosition(int pos)
1157 {
1158 if (pos == 0)
1159 {
1160 return new Integer(getId());
1161 }
1162 if (pos == 1)
1163 {
1164 return new Integer(getSubject());
1165 }
1166 if (pos == 2)
1167 {
1168 return new Integer(getPredicate());
1169 }
1170 if (pos == 3)
1171 {
1172 return new Integer(getObjResource());
1173 }
1174 if (pos == 4)
1175 {
1176 return new Integer(getObjLiteral());
1177 }
1178 if (pos == 5)
1179 {
1180 return getRes();
1181 }
1182 if (pos == 6)
1183 {
1184 return new Integer(getUsr());
1185 }
1186 if (pos == 7)
1187 {
1188 return getIspublic();
1189 }
1190 if (pos == 8)
1191 {
1192 return getModified();
1193 }
1194 if (pos == 9)
1195 {
1196 return new Long(getGarbage());
1197 }
1198 return null;
1199 }
1200
1201 /***
1202 * Stores the object in the database. If the object is new,
1203 * it inserts it; otherwise an update is performed.
1204 *
1205 * @throws Exception
1206 */
1207 public void save() throws Exception
1208 {
1209 save(RdfStatementPeer.getMapBuilder()
1210 .getDatabaseMap().getName());
1211 }
1212
1213 /***
1214 * Stores the object in the database. If the object is new,
1215 * it inserts it; otherwise an update is performed.
1216 * Note: this code is here because the method body is
1217 * auto-generated conditionally and therefore needs to be
1218 * in this file instead of in the super class, BaseObject.
1219 *
1220 * @param dbName
1221 * @throws TorqueException
1222 */
1223 public void save(String dbName) throws TorqueException
1224 {
1225 Connection con = null;
1226 try
1227 {
1228 con = Transaction.begin(dbName);
1229 save(con);
1230 Transaction.commit(con);
1231 }
1232 catch(TorqueException e)
1233 {
1234 Transaction.safeRollback(con);
1235 throw e;
1236 }
1237 }
1238
1239 /*** flag to prevent endless save loop, if this object is referenced
1240 by another object which falls in this transaction. */
1241 private boolean alreadyInSave = false;
1242 /***
1243 * Stores the object in the database. If the object is new,
1244 * it inserts it; otherwise an update is performed. This method
1245 * is meant to be used as part of a transaction, otherwise use
1246 * the save() method and the connection details will be handled
1247 * internally
1248 *
1249 * @param con
1250 * @throws TorqueException
1251 */
1252 public void save(Connection con) throws TorqueException
1253 {
1254 if (!alreadyInSave)
1255 {
1256 alreadyInSave = true;
1257
1258
1259
1260
1261 if (isModified())
1262 {
1263 if (isNew())
1264 {
1265 RdfStatementPeer.doInsert((RdfStatement) this, con);
1266 setNew(false);
1267 }
1268 else
1269 {
1270 RdfStatementPeer.doUpdate((RdfStatement) this, con);
1271 }
1272 }
1273
1274
1275
1276 if (collModelStatements != null)
1277 {
1278 for (int i = 0; i < collModelStatements.size(); i++)
1279 {
1280 ((ModelStatement) collModelStatements.get(i)).save(con);
1281 }
1282 }
1283 alreadyInSave = false;
1284 }
1285 }
1286
1287
1288
1289 /***
1290 * Set the PrimaryKey using ObjectKey.
1291 *
1292 * @param id ObjectKey
1293 */
1294 public void setPrimaryKey(ObjectKey key)
1295 throws TorqueException
1296 {
1297 setId(((NumberKey) key).intValue());
1298 }
1299
1300 /***
1301 * Set the PrimaryKey using a String.
1302 *
1303 * @param key
1304 */
1305 public void setPrimaryKey(String key) throws TorqueException
1306 {
1307 setId(Integer.parseInt(key));
1308 }
1309
1310
1311 /***
1312 * returns an id that differentiates this object from others
1313 * of its class.
1314 */
1315 public ObjectKey getPrimaryKey()
1316 {
1317 return SimpleKey.keyFor(getId());
1318 }
1319
1320
1321
1322 /***
1323 * Makes a copy of this object.
1324 * It creates a new object filling in the simple attributes.
1325 * It then fills all the association collections and sets the
1326 * related objects to isNew=true.
1327 */
1328 public RdfStatement copy() throws TorqueException
1329 {
1330 return copyInto(new RdfStatement());
1331 }
1332
1333 protected RdfStatement copyInto(RdfStatement copyObj) throws TorqueException
1334 {
1335 copyObj.setId(id);
1336 copyObj.setSubject(subject);
1337 copyObj.setPredicate(predicate);
1338 copyObj.setObjResource(objResource);
1339 copyObj.setObjLiteral(objLiteral);
1340 copyObj.setRes(res);
1341 copyObj.setUsr(usr);
1342 copyObj.setIspublic(ispublic);
1343 copyObj.setModified(modified);
1344 copyObj.setGarbage(garbage);
1345
1346 copyObj.setId(0);
1347
1348
1349
1350 List v = getModelStatements();
1351 for (int i = 0; i < v.size(); i++)
1352 {
1353 ModelStatement obj = (ModelStatement) v.get(i);
1354 copyObj.addModelStatement(obj.copy());
1355 }
1356
1357 return copyObj;
1358 }
1359
1360 /***
1361 * returns a peer instance associated with this om. Since Peer classes
1362 * are not to have any instance attributes, this method returns the
1363 * same instance for all member of this class. The method could therefore
1364 * be static, but this would prevent one from overriding the behavior.
1365 */
1366 public RdfStatementPeer getPeer()
1367 {
1368 return peer;
1369 }
1370
1371 public String toString()
1372 {
1373 StringBuffer str = new StringBuffer();
1374 str.append("RdfStatement:\n");
1375 str.append("Id = ")
1376 .append(getId())
1377 .append("\n");
1378 str.append("Subject = ")
1379 .append(getSubject())
1380 .append("\n");
1381 str.append("Predicate = ")
1382 .append(getPredicate())
1383 .append("\n");
1384 str.append("ObjResource = ")
1385 .append(getObjResource())
1386 .append("\n");
1387 str.append("ObjLiteral = ")
1388 .append(getObjLiteral())
1389 .append("\n");
1390 str.append("Res = ")
1391 .append(getRes())
1392 .append("\n");
1393 str.append("Usr = ")
1394 .append(getUsr())
1395 .append("\n");
1396 str.append("Ispublic = ")
1397 .append(getIspublic())
1398 .append("\n");
1399 str.append("Modified = ")
1400 .append(getModified())
1401 .append("\n");
1402 str.append("Garbage = ")
1403 .append(getGarbage())
1404 .append("\n");
1405 return(str.toString());
1406 }
1407 }