1 package org.tigris.scarab.om; 2 3 import java.math.BigDecimal ; 4 import java.sql.Connection ; 5 import java.sql.SQLException ; 6 import java.util.ArrayList ; 7 import java.util.Date ; 8 import java.util.Iterator ; 9 import java.util.LinkedList ; 10 import java.util.List ; 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 import org.tigris.scarab.om.map.*; 32 33 34 35 36 37 38 39 41 public abstract class BaseConditionPeer 42 extends BasePeer 43 { 44 45 46 public static final String DATABASE_NAME = "scarab"; 47 48 49 public static final String TABLE_NAME = "SCARAB_CONDITION"; 50 51 56 public static MapBuilder getMapBuilder() 57 throws TorqueException 58 { 59 return getMapBuilder(ConditionMapBuilder.CLASS_NAME); 60 } 61 62 63 public static final String CONDITION_ID; 64 65 public static final String TRANSITION_ID; 66 67 public static final String MODULE_ID; 68 69 public static final String ISSUE_TYPE_ID; 70 71 public static final String ATTRIBUTE_ID; 72 73 public static final String OPTION_ID; 74 75 static 76 { 77 CONDITION_ID = "SCARAB_CONDITION.CONDITION_ID"; 78 TRANSITION_ID = "SCARAB_CONDITION.TRANSITION_ID"; 79 MODULE_ID = "SCARAB_CONDITION.MODULE_ID"; 80 ISSUE_TYPE_ID = "SCARAB_CONDITION.ISSUE_TYPE_ID"; 81 ATTRIBUTE_ID = "SCARAB_CONDITION.ATTRIBUTE_ID"; 82 OPTION_ID = "SCARAB_CONDITION.OPTION_ID"; 83 if (Torque.isInit()) 84 { 85 try 86 { 87 getMapBuilder(ConditionMapBuilder.CLASS_NAME); 88 } 89 catch (Exception e) 90 { 91 log.error("Could not initialize Peer", e); 92 } 93 } 94 else 95 { 96 Torque.registerMapBuilder(ConditionMapBuilder.CLASS_NAME); 97 } 98 } 99 100 101 public static final int numColumns = 6; 102 103 104 protected static final String CLASSNAME_DEFAULT = 105 "org.tigris.scarab.om.Condition"; 106 107 108 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 109 110 116 private static Class initClass(String className) 117 { 118 Class c = null; 119 try 120 { 121 c = Class.forName(className); 122 } 123 catch (Throwable t) 124 { 125 log.error("A FATAL ERROR has occurred which should not " 126 + "have happened under any circumstance. Please notify " 127 + "the Torque developers <torque-dev@db.apache.org> " 128 + "and give as many details as possible (including the error " 129 + "stack trace).", t); 130 131 if (t instanceof Error ) 133 { 134 throw (Error ) t.fillInStackTrace(); 135 } 136 } 137 return c; 138 } 139 140 150 public static List resultSet2Objects(java.sql.ResultSet results) 151 throws TorqueException 152 { 153 try 154 { 155 QueryDataSet qds = null; 156 List rows = null; 157 try 158 { 159 qds = new QueryDataSet(results); 160 rows = getSelectResults(qds); 161 } 162 finally 163 { 164 if (qds != null) 165 { 166 qds.close(); 167 } 168 } 169 170 return populateObjects(rows); 171 } 172 catch (SQLException e) 173 { 174 throw new TorqueException(e); 175 } 176 catch (DataSetException e) 177 { 178 throw new TorqueException(e); 179 } 180 } 181 182 183 184 191 public static ObjectKey doInsert(Criteria criteria) 192 throws TorqueException 193 { 194 return BaseConditionPeer 195 .doInsert(criteria, (Connection ) null); 196 } 197 198 208 public static ObjectKey doInsert(Criteria criteria, Connection con) 209 throws TorqueException 210 { 211 212 setDbName(criteria); 213 214 if (con == null) 215 { 216 return BasePeer.doInsert(criteria); 217 } 218 else 219 { 220 return BasePeer.doInsert(criteria, con); 221 } 222 } 223 224 231 public static void addSelectColumns(Criteria criteria) 232 throws TorqueException 233 { 234 criteria.addSelectColumn(CONDITION_ID); 235 criteria.addSelectColumn(TRANSITION_ID); 236 criteria.addSelectColumn(MODULE_ID); 237 criteria.addSelectColumn(ISSUE_TYPE_ID); 238 criteria.addSelectColumn(ATTRIBUTE_ID); 239 criteria.addSelectColumn(OPTION_ID); 240 } 241 242 251 public static Condition row2Object(Record row, 252 int offset, 253 Class cls) 254 throws TorqueException 255 { 256 try 257 { 258 Condition obj = (Condition) cls.newInstance(); 259 ConditionPeer.populateObject(row, offset, obj); 260 obj.setModified(false); 261 obj.setNew(false); 262 263 return obj; 264 } 265 catch (InstantiationException e) 266 { 267 throw new TorqueException(e); 268 } 269 catch (IllegalAccessException e) 270 { 271 throw new TorqueException(e); 272 } 273 } 274 275 284 public static void populateObject(Record row, 285 int offset, 286 Condition obj) 287 throws TorqueException 288 { 289 try 290 { 291 obj.setConditionId(row.getValue(offset + 0).asLongObj()); 292 obj.setTransitionId(row.getValue(offset + 1).asIntegerObj()); 293 obj.setModuleId(row.getValue(offset + 2).asIntegerObj()); 294 obj.setIssueTypeId(row.getValue(offset + 3).asIntegerObj()); 295 obj.setAttributeId(row.getValue(offset + 4).asIntegerObj()); 296 obj.setOptionId(row.getValue(offset + 5).asIntegerObj()); 297 } 298 catch (DataSetException e) 299 { 300 throw new TorqueException(e); 301 } 302 } 303 304 312 public static List doSelect(Criteria criteria) throws TorqueException 313 { 314 return populateObjects(doSelectVillageRecords(criteria)); 315 } 316 317 326 public static List doSelect(Criteria criteria, Connection con) 327 throws TorqueException 328 { 329 return populateObjects(doSelectVillageRecords(criteria, con)); 330 } 331 332 342 public static List doSelectVillageRecords(Criteria criteria) 343 throws TorqueException 344 { 345 return BaseConditionPeer 346 .doSelectVillageRecords(criteria, (Connection ) null); 347 } 348 349 358 public static List doSelectVillageRecords(Criteria criteria, Connection con) 359 throws TorqueException 360 { 361 if (criteria.getSelectColumns().size() == 0) 362 { 363 addSelectColumns(criteria); 364 } 365 366 367 setDbName(criteria); 368 369 if (con == null) 372 { 373 return BasePeer.doSelect(criteria); 374 } 375 else 376 { 377 return BasePeer.doSelect(criteria, con); 378 } 379 } 380 381 388 public static List populateObjects(List records) 389 throws TorqueException 390 { 391 List results = new ArrayList (records.size()); 392 393 for (int i = 0; i < records.size(); i++) 395 { 396 Record row = (Record) records.get(i); 397 results.add(ConditionPeer.row2Object(row, 1, 398 ConditionPeer.getOMClass())); 399 } 400 return results; 401 } 402 403 404 412 public static Class getOMClass() 413 throws TorqueException 414 { 415 return CLASS_DEFAULT; 416 } 417 418 426 public static void doUpdate(Criteria criteria) throws TorqueException 427 { 428 BaseConditionPeer 429 .doUpdate(criteria, (Connection ) null); 430 } 431 432 443 public static void doUpdate(Criteria criteria, Connection con) 444 throws TorqueException 445 { 446 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 447 selectCriteria.put(CONDITION_ID, criteria.remove(CONDITION_ID)); 448 449 setDbName(criteria); 450 451 if (con == null) 452 { 453 BasePeer.doUpdate(selectCriteria, criteria); 454 } 455 else 456 { 457 BasePeer.doUpdate(selectCriteria, criteria, con); 458 } 459 } 460 461 468 public static void doDelete(Criteria criteria) throws TorqueException 469 { 470 ConditionPeer 471 .doDelete(criteria, (Connection ) null); 472 } 473 474 484 public static void doDelete(Criteria criteria, Connection con) 485 throws TorqueException 486 { 487 488 setDbName(criteria); 489 490 if (con == null) 491 { 492 BasePeer.doDelete(criteria); 493 } 494 else 495 { 496 BasePeer.doDelete(criteria, con); 497 } 498 } 499 500 506 public static List doSelect(Condition obj) throws TorqueException 507 { 508 return doSelect(buildSelectCriteria(obj)); 509 } 510 511 517 public static void doInsert(Condition obj) throws TorqueException 518 { 519 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 520 obj.setNew(false); 521 obj.setModified(false); 522 } 523 524 529 public static void doUpdate(Condition obj) throws TorqueException 530 { 531 doUpdate(buildCriteria(obj)); 532 obj.setModified(false); 533 } 534 535 540 public static void doDelete(Condition obj) throws TorqueException 541 { 542 doDelete(buildSelectCriteria(obj)); 543 } 544 545 555 public static void doInsert(Condition obj, Connection con) 556 throws TorqueException 557 { 558 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 559 obj.setNew(false); 560 obj.setModified(false); 561 } 562 563 573 public static void doUpdate(Condition obj, Connection con) 574 throws TorqueException 575 { 576 doUpdate(buildCriteria(obj), con); 577 obj.setModified(false); 578 } 579 580 590 public static void doDelete(Condition obj, Connection con) 591 throws TorqueException 592 { 593 doDelete(buildSelectCriteria(obj), con); 594 } 595 596 603 public static void doDelete(ObjectKey pk) throws TorqueException 604 { 605 BaseConditionPeer 606 .doDelete(pk, (Connection ) null); 607 } 608 609 619 public static void doDelete(ObjectKey pk, Connection con) 620 throws TorqueException 621 { 622 doDelete(buildCriteria(pk), con); 623 } 624 625 626 public static Criteria buildCriteria( ObjectKey pk ) 627 { 628 Criteria criteria = new Criteria(); 629 criteria.add(CONDITION_ID, pk); 630 return criteria; 631 } 632 633 634 public static Criteria buildCriteria( Condition obj ) 635 { 636 Criteria criteria = new Criteria(DATABASE_NAME); 637 if (!obj.isNew()) 638 criteria.add(CONDITION_ID, obj.getConditionId()); 639 criteria.add(TRANSITION_ID, obj.getTransitionId()); 640 criteria.add(MODULE_ID, obj.getModuleId()); 641 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 642 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 643 criteria.add(OPTION_ID, obj.getOptionId()); 644 return criteria; 645 } 646 647 648 public static Criteria buildSelectCriteria( Condition obj ) 649 { 650 Criteria criteria = new Criteria(DATABASE_NAME); 651 if (!obj.isNew()) 652 criteria.add(CONDITION_ID, obj.getConditionId()); 653 criteria.add(TRANSITION_ID, obj.getTransitionId()); 654 criteria.add(MODULE_ID, obj.getModuleId()); 655 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 656 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 657 criteria.add(OPTION_ID, obj.getOptionId()); 658 return criteria; 659 } 660 661 662 671 public static Condition retrieveByPK(Long pk) 672 throws TorqueException, NoRowsException, TooManyRowsException 673 { 674 return retrieveByPK(SimpleKey.keyFor(pk)); 675 } 676 677 687 public static Condition retrieveByPK(Long pk, Connection con) 688 throws TorqueException, NoRowsException, TooManyRowsException 689 { 690 return retrieveByPK(SimpleKey.keyFor(pk), con); 691 } 692 693 702 public static Condition retrieveByPK(ObjectKey pk) 703 throws TorqueException, NoRowsException, TooManyRowsException 704 { 705 Connection db = null; 706 Condition retVal = null; 707 try 708 { 709 db = Torque.getConnection(DATABASE_NAME); 710 retVal = retrieveByPK(pk, db); 711 } 712 finally 713 { 714 Torque.closeConnection(db); 715 } 716 return(retVal); 717 } 718 719 729 public static Condition retrieveByPK(ObjectKey pk, Connection con) 730 throws TorqueException, NoRowsException, TooManyRowsException 731 { 732 Criteria criteria = buildCriteria(pk); 733 List v = doSelect(criteria, con); 734 if (v.size() == 0) 735 { 736 throw new NoRowsException("Failed to select a row."); 737 } 738 else if (v.size() > 1) 739 { 740 throw new TooManyRowsException("Failed to select only one row."); 741 } 742 else 743 { 744 return (Condition)v.get(0); 745 } 746 } 747 748 755 public static List retrieveByPKs(List pks) 756 throws TorqueException 757 { 758 Connection db = null; 759 List retVal = null; 760 try 761 { 762 db = Torque.getConnection(DATABASE_NAME); 763 retVal = retrieveByPKs(pks, db); 764 } 765 finally 766 { 767 Torque.closeConnection(db); 768 } 769 return(retVal); 770 } 771 772 780 public static List retrieveByPKs( List pks, Connection dbcon ) 781 throws TorqueException 782 { 783 List objs = null; 784 if (pks == null || pks.size() == 0) 785 { 786 objs = new LinkedList (); 787 } 788 else 789 { 790 Criteria criteria = new Criteria(); 791 criteria.addIn( CONDITION_ID, pks ); 792 objs = doSelect(criteria, dbcon); 793 } 794 return objs; 795 } 796 797 798 799 800 801 802 803 804 805 806 817 protected static List doSelectJoinRModuleAttribute(Criteria criteria) 818 throws TorqueException 819 { 820 setDbName(criteria); 821 822 ConditionPeer.addSelectColumns(criteria); 823 int offset = numColumns + 1; 824 RModuleAttributePeer.addSelectColumns(criteria); 825 826 827 criteria.addJoin(ConditionPeer.MODULE_ID, 828 RModuleAttributePeer.MODULE_ID); 829 criteria.addJoin(ConditionPeer.ATTRIBUTE_ID, 830 RModuleAttributePeer.ATTRIBUTE_ID); 831 criteria.addJoin(ConditionPeer.ISSUE_TYPE_ID, 832 RModuleAttributePeer.ISSUE_TYPE_ID); 833 834 835 836 List rows = BasePeer.doSelect(criteria); 837 List results = new ArrayList (); 838 839 for (int i = 0; i < rows.size(); i++) 840 { 841 Record row = (Record) rows.get(i); 842 843 Class omClass = ConditionPeer.getOMClass(); 844 Condition obj1 = (Condition) ConditionPeer 845 .row2Object(row, 1, omClass); 846 omClass = RModuleAttributePeer.getOMClass(); 847 RModuleAttribute obj2 = (RModuleAttribute)RModuleAttributePeer 848 .row2Object(row, offset, omClass); 849 850 boolean newObject = true; 851 for (int j = 0; j < results.size(); j++) 852 { 853 Condition temp_obj1 = (Condition)results.get(j); 854 RModuleAttribute temp_obj2 = (RModuleAttribute)temp_obj1.getRModuleAttribute(); 855 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 856 { 857 newObject = false; 858 temp_obj2.addCondition(obj1); 859 break; 860 } 861 } 862 if (newObject) 863 { 864 obj2.initConditions(); 865 obj2.addCondition(obj1); 866 } 867 results.add(obj1); 868 } 869 return results; 870 } 871 872 873 874 875 886 protected static List doSelectJoinTransition(Criteria criteria) 887 throws TorqueException 888 { 889 setDbName(criteria); 890 891 ConditionPeer.addSelectColumns(criteria); 892 int offset = numColumns + 1; 893 TransitionPeer.addSelectColumns(criteria); 894 895 896 criteria.addJoin(ConditionPeer.TRANSITION_ID, 897 TransitionPeer.TRANSITION_ID); 898 899 900 901 List rows = BasePeer.doSelect(criteria); 902 List results = new ArrayList (); 903 904 for (int i = 0; i < rows.size(); i++) 905 { 906 Record row = (Record) rows.get(i); 907 908 Class omClass = ConditionPeer.getOMClass(); 909 Condition obj1 = (Condition) ConditionPeer 910 .row2Object(row, 1, omClass); 911 omClass = TransitionPeer.getOMClass(); 912 Transition obj2 = (Transition)TransitionPeer 913 .row2Object(row, offset, omClass); 914 915 boolean newObject = true; 916 for (int j = 0; j < results.size(); j++) 917 { 918 Condition temp_obj1 = (Condition)results.get(j); 919 Transition temp_obj2 = (Transition)temp_obj1.getTransition(); 920 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 921 { 922 newObject = false; 923 temp_obj2.addCondition(obj1); 924 break; 925 } 926 } 927 if (newObject) 928 { 929 obj2.initConditions(); 930 obj2.addCondition(obj1); 931 } 932 results.add(obj1); 933 } 934 return results; 935 } 936 937 938 939 940 951 protected static List doSelectJoinAttribute(Criteria criteria) 952 throws TorqueException 953 { 954 setDbName(criteria); 955 956 ConditionPeer.addSelectColumns(criteria); 957 int offset = numColumns + 1; 958 AttributePeer.addSelectColumns(criteria); 959 960 961 criteria.addJoin(ConditionPeer.ATTRIBUTE_ID, 962 AttributePeer.ATTRIBUTE_ID); 963 964 965 966 List rows = BasePeer.doSelect(criteria); 967 List results = new ArrayList (); 968 969 for (int i = 0; i < rows.size(); i++) 970 { 971 Record row = (Record) rows.get(i); 972 973 Class omClass = ConditionPeer.getOMClass(); 974 Condition obj1 = (Condition) ConditionPeer 975 .row2Object(row, 1, omClass); 976 omClass = AttributePeer.getOMClass(); 977 Attribute obj2 = (Attribute)AttributePeer 978 .row2Object(row, offset, omClass); 979 980 boolean newObject = true; 981 for (int j = 0; j < results.size(); j++) 982 { 983 Condition temp_obj1 = (Condition)results.get(j); 984 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 985 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 986 { 987 newObject = false; 988 temp_obj2.addCondition(obj1); 989 break; 990 } 991 } 992 if (newObject) 993 { 994 obj2.initConditions(); 995 obj2.addCondition(obj1); 996 } 997 results.add(obj1); 998 } 999 return results; 1000 } 1001 1002 1003 1004 1005 1016 protected static List doSelectJoinAttributeOption(Criteria criteria) 1017 throws TorqueException 1018 { 1019 setDbName(criteria); 1020 1021 ConditionPeer.addSelectColumns(criteria); 1022 int offset = numColumns + 1; 1023 AttributeOptionPeer.addSelectColumns(criteria); 1024 1025 1026 criteria.addJoin(ConditionPeer.OPTION_ID, 1027 AttributeOptionPeer.OPTION_ID); 1028 1029 1030 1031 List rows = BasePeer.doSelect(criteria); 1032 List results = new ArrayList (); 1033 1034 for (int i = 0; i < rows.size(); i++) 1035 { 1036 Record row = (Record) rows.get(i); 1037 1038 Class omClass = ConditionPeer.getOMClass(); 1039 Condition obj1 = (Condition) ConditionPeer 1040 .row2Object(row, 1, omClass); 1041 omClass = AttributeOptionPeer.getOMClass(); 1042 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1043 .row2Object(row, offset, omClass); 1044 1045 boolean newObject = true; 1046 for (int j = 0; j < results.size(); j++) 1047 { 1048 Condition temp_obj1 = (Condition)results.get(j); 1049 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 1050 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1051 { 1052 newObject = false; 1053 temp_obj2.addCondition(obj1); 1054 break; 1055 } 1056 } 1057 if (newObject) 1058 { 1059 obj2.initConditions(); 1060 obj2.addCondition(obj1); 1061 } 1062 results.add(obj1); 1063 } 1064 return results; 1065 } 1066 1067 1068 1069 1070 1081 protected static List doSelectJoinRModuleIssueType(Criteria criteria) 1082 throws TorqueException 1083 { 1084 setDbName(criteria); 1085 1086 ConditionPeer.addSelectColumns(criteria); 1087 int offset = numColumns + 1; 1088 RModuleIssueTypePeer.addSelectColumns(criteria); 1089 1090 1091 criteria.addJoin(ConditionPeer.MODULE_ID, 1092 RModuleIssueTypePeer.MODULE_ID); 1093 criteria.addJoin(ConditionPeer.ISSUE_TYPE_ID, 1094 RModuleIssueTypePeer.ISSUE_TYPE_ID); 1095 1096 1097 1098 List rows = BasePeer.doSelect(criteria); 1099 List results = new ArrayList (); 1100 1101 for (int i = 0; i < rows.size(); i++) 1102 { 1103 Record row = (Record) rows.get(i); 1104 1105 Class omClass = ConditionPeer.getOMClass(); 1106 Condition obj1 = (Condition) ConditionPeer 1107 .row2Object(row, 1, omClass); 1108 omClass = RModuleIssueTypePeer.getOMClass(); 1109 RModuleIssueType obj2 = (RModuleIssueType)RModuleIssueTypePeer 1110 .row2Object(row, offset, omClass); 1111 1112 boolean newObject = true; 1113 for (int j = 0; j < results.size(); j++) 1114 { 1115 Condition temp_obj1 = (Condition)results.get(j); 1116 RModuleIssueType temp_obj2 = (RModuleIssueType)temp_obj1.getRModuleIssueType(); 1117 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1118 { 1119 newObject = false; 1120 temp_obj2.addCondition(obj1); 1121 break; 1122 } 1123 } 1124 if (newObject) 1125 { 1126 obj2.initConditions(); 1127 obj2.addCondition(obj1); 1128 } 1129 results.add(obj1); 1130 } 1131 return results; 1132 } 1133 1134 1135 1136 1137 1138 1139 1140 1141 1152 protected static List doSelectJoinAllExceptRModuleAttribute(Criteria criteria) 1153 throws TorqueException 1154 { 1155 setDbName(criteria); 1156 1157 addSelectColumns(criteria); 1158 int offset2 = numColumns + 1; 1159 1160 1161 TransitionPeer.addSelectColumns(criteria); 1162 int offset3 = offset2 + TransitionPeer.numColumns; 1163 1164 AttributePeer.addSelectColumns(criteria); 1165 int offset4 = offset3 + AttributePeer.numColumns; 1166 1167 AttributeOptionPeer.addSelectColumns(criteria); 1168 int offset5 = offset4 + AttributeOptionPeer.numColumns; 1169 1170 RModuleIssueTypePeer.addSelectColumns(criteria); 1171 int offset6 = offset5 + RModuleIssueTypePeer.numColumns; 1172 1173 List rows = BasePeer.doSelect(criteria); 1174 List results = new ArrayList (); 1175 1176 for (int i = 0; i < rows.size(); i++) 1177 { 1178 Record row = (Record)rows.get(i); 1179 1180 Class omClass = ConditionPeer.getOMClass(); 1181 Condition obj1 = (Condition)ConditionPeer 1182 .row2Object(row, 1, omClass); 1183 1184 1185 1186 1187 1188 omClass = TransitionPeer.getOMClass(); 1189 Transition obj2 = (Transition)TransitionPeer 1190 .row2Object( row, offset2, omClass); 1191 1192 boolean newObject = true; 1193 for (int j = 0; j < results.size(); j++) 1194 { 1195 Condition temp_obj1 = (Condition)results.get(j); 1196 Transition temp_obj2 = (Transition)temp_obj1.getTransition(); 1197 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1198 { 1199 newObject = false; 1200 temp_obj2.addCondition(obj1); 1201 break; 1202 } 1203 } 1204 if (newObject) 1205 { 1206 obj2.initConditions(); 1207 obj2.addCondition(obj1); 1208 } 1209 1210 1211 1212 1213 omClass = AttributePeer.getOMClass(); 1214 Attribute obj3 = (Attribute)AttributePeer 1215 .row2Object( row, offset3, omClass); 1216 1217 newObject = true; 1218 for (int j = 0; j < results.size(); j++) 1219 { 1220 Condition temp_obj1 = (Condition)results.get(j); 1221 Attribute temp_obj3 = (Attribute)temp_obj1.getAttribute(); 1222 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1223 { 1224 newObject = false; 1225 temp_obj3.addCondition(obj1); 1226 break; 1227 } 1228 } 1229 if (newObject) 1230 { 1231 obj3.initConditions(); 1232 obj3.addCondition(obj1); 1233 } 1234 1235 1236 1237 1238 omClass = AttributeOptionPeer.getOMClass(); 1239 AttributeOption obj4 = (AttributeOption)AttributeOptionPeer 1240 .row2Object( row, offset4, omClass); 1241 1242 newObject = true; 1243 for (int j = 0; j < results.size(); j++) 1244 { 1245 Condition temp_obj1 = (Condition)results.get(j); 1246 AttributeOption temp_obj4 = (AttributeOption)temp_obj1.getAttributeOption(); 1247 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1248 { 1249 newObject = false; 1250 temp_obj4.addCondition(obj1); 1251 break; 1252 } 1253 } 1254 if (newObject) 1255 { 1256 obj4.initConditions(); 1257 obj4.addCondition(obj1); 1258 } 1259 1260 1261 1262 1263 omClass = RModuleIssueTypePeer.getOMClass(); 1264 RModuleIssueType obj5 = (RModuleIssueType)RModuleIssueTypePeer 1265 .row2Object( row, offset5, omClass); 1266 1267 newObject = true; 1268 for (int j = 0; j < results.size(); j++) 1269 { 1270 Condition temp_obj1 = (Condition)results.get(j); 1271 RModuleIssueType temp_obj5 = (RModuleIssueType)temp_obj1.getRModuleIssueType(); 1272 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1273 { 1274 newObject = false; 1275 temp_obj5.addCondition(obj1); 1276 break; 1277 } 1278 } 1279 if (newObject) 1280 { 1281 obj5.initConditions(); 1282 obj5.addCondition(obj1); 1283 } 1284 results.add(obj1); 1285 } 1286 return results; 1287 } 1288 1289 1290 1291 1292 1293 1304 protected static List doSelectJoinAllExceptTransition(Criteria criteria) 1305 throws TorqueException 1306 { 1307 setDbName(criteria); 1308 1309 addSelectColumns(criteria); 1310 int offset2 = numColumns + 1; 1311 1312 RModuleAttributePeer.addSelectColumns(criteria); 1313 int offset3 = offset2 + RModuleAttributePeer.numColumns; 1314 1315 1316 AttributePeer.addSelectColumns(criteria); 1317 int offset4 = offset3 + AttributePeer.numColumns; 1318 1319 AttributeOptionPeer.addSelectColumns(criteria); 1320 int offset5 = offset4 + AttributeOptionPeer.numColumns; 1321 1322 RModuleIssueTypePeer.addSelectColumns(criteria); 1323 int offset6 = offset5 + RModuleIssueTypePeer.numColumns; 1324 1325 List rows = BasePeer.doSelect(criteria); 1326 List results = new ArrayList (); 1327 1328 for (int i = 0; i < rows.size(); i++) 1329 { 1330 Record row = (Record)rows.get(i); 1331 1332 Class omClass = ConditionPeer.getOMClass(); 1333 Condition obj1 = (Condition)ConditionPeer 1334 .row2Object(row, 1, omClass); 1335 1336 1337 1338 1339 omClass = RModuleAttributePeer.getOMClass(); 1340 RModuleAttribute obj2 = (RModuleAttribute)RModuleAttributePeer 1341 .row2Object( row, offset2, omClass); 1342 1343 boolean newObject = true; 1344 for (int j = 0; j < results.size(); j++) 1345 { 1346 Condition temp_obj1 = (Condition)results.get(j); 1347 RModuleAttribute temp_obj2 = (RModuleAttribute)temp_obj1.getRModuleAttribute(); 1348 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1349 { 1350 newObject = false; 1351 temp_obj2.addCondition(obj1); 1352 break; 1353 } 1354 } 1355 if (newObject) 1356 { 1357 obj2.initConditions(); 1358 obj2.addCondition(obj1); 1359 } 1360 1361 1362 1363 1364 1365 omClass = AttributePeer.getOMClass(); 1366 Attribute obj3 = (Attribute)AttributePeer 1367 .row2Object( row, offset3, omClass); 1368 1369 newObject = true; 1370 for (int j = 0; j < results.size(); j++) 1371 { 1372 Condition temp_obj1 = (Condition)results.get(j); 1373 Attribute temp_obj3 = (Attribute)temp_obj1.getAttribute(); 1374 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1375 { 1376 newObject = false; 1377 temp_obj3.addCondition(obj1); 1378 break; 1379 } 1380 } 1381 if (newObject) 1382 { 1383 obj3.initConditions(); 1384 obj3.addCondition(obj1); 1385 } 1386 1387 1388 1389 1390 omClass = AttributeOptionPeer.getOMClass(); 1391 AttributeOption obj4 = (AttributeOption)AttributeOptionPeer 1392 .row2Object( row, offset4, omClass); 1393 1394 newObject = true; 1395 for (int j = 0; j < results.size(); j++) 1396 { 1397 Condition temp_obj1 = (Condition)results.get(j); 1398 AttributeOption temp_obj4 = (AttributeOption)temp_obj1.getAttributeOption(); 1399 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1400 { 1401 newObject = false; 1402 temp_obj4.addCondition(obj1); 1403 break; 1404 } 1405 } 1406 if (newObject) 1407 { 1408 obj4.initConditions(); 1409 obj4.addCondition(obj1); 1410 } 1411 1412 1413 1414 1415 omClass = RModuleIssueTypePeer.getOMClass(); 1416 RModuleIssueType obj5 = (RModuleIssueType)RModuleIssueTypePeer 1417 .row2Object( row, offset5, omClass); 1418 1419 newObject = true; 1420 for (int j = 0; j < results.size(); j++) 1421 { 1422 Condition temp_obj1 = (Condition)results.get(j); 1423 RModuleIssueType temp_obj5 = (RModuleIssueType)temp_obj1.getRModuleIssueType(); 1424 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1425 { 1426 newObject = false; 1427 temp_obj5.addCondition(obj1); 1428 break; 1429 } 1430 } 1431 if (newObject) 1432 { 1433 obj5.initConditions(); 1434 obj5.addCondition(obj1); 1435 } 1436 results.add(obj1); 1437 } 1438 return results; 1439 } 1440 1441 1442 1443 1444 1445 1456 protected static List doSelectJoinAllExceptAttribute(Criteria criteria) 1457 throws TorqueException 1458 { 1459 setDbName(criteria); 1460 1461 addSelectColumns(criteria); 1462 int offset2 = numColumns + 1; 1463 1464 RModuleAttributePeer.addSelectColumns(criteria); 1465 int offset3 = offset2 + RModuleAttributePeer.numColumns; 1466 1467 TransitionPeer.addSelectColumns(criteria); 1468 int offset4 = offset3 + TransitionPeer.numColumns; 1469 1470 1471 AttributeOptionPeer.addSelectColumns(criteria); 1472 int offset5 = offset4 + AttributeOptionPeer.numColumns; 1473 1474 RModuleIssueTypePeer.addSelectColumns(criteria); 1475 int offset6 = offset5 + RModuleIssueTypePeer.numColumns; 1476 1477 List rows = BasePeer.doSelect(criteria); 1478 List results = new ArrayList (); 1479 1480 for (int i = 0; i < rows.size(); i++) 1481 { 1482 Record row = (Record)rows.get(i); 1483 1484 Class omClass = ConditionPeer.getOMClass(); 1485 Condition obj1 = (Condition)ConditionPeer 1486 .row2Object(row, 1, omClass); 1487 1488 1489 1490 1491 omClass = RModuleAttributePeer.getOMClass(); 1492 RModuleAttribute obj2 = (RModuleAttribute)RModuleAttributePeer 1493 .row2Object( row, offset2, omClass); 1494 1495 boolean newObject = true; 1496 for (int j = 0; j < results.size(); j++) 1497 { 1498 Condition temp_obj1 = (Condition)results.get(j); 1499 RModuleAttribute temp_obj2 = (RModuleAttribute)temp_obj1.getRModuleAttribute(); 1500 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1501 { 1502 newObject = false; 1503 temp_obj2.addCondition(obj1); 1504 break; 1505 } 1506 } 1507 if (newObject) 1508 { 1509 obj2.initConditions(); 1510 obj2.addCondition(obj1); 1511 } 1512 1513 1514 1515 1516 omClass = TransitionPeer.getOMClass(); 1517 Transition obj3 = (Transition)TransitionPeer 1518 .row2Object( row, offset3, omClass); 1519 1520 newObject = true; 1521 for (int j = 0; j < results.size(); j++) 1522 { 1523 Condition temp_obj1 = (Condition)results.get(j); 1524 Transition temp_obj3 = (Transition)temp_obj1.getTransition(); 1525 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1526 { 1527 newObject = false; 1528 temp_obj3.addCondition(obj1); 1529 break; 1530 } 1531 } 1532 if (newObject) 1533 { 1534 obj3.initConditions(); 1535 obj3.addCondition(obj1); 1536 } 1537 1538 1539 1540 1541 1542 omClass = AttributeOptionPeer.getOMClass(); 1543 AttributeOption obj4 = (AttributeOption)AttributeOptionPeer 1544 .row2Object( row, offset4, omClass); 1545 1546 newObject = true; 1547 for (int j = 0; j < results.size(); j++) 1548 { 1549 Condition temp_obj1 = (Condition)results.get(j); 1550 AttributeOption temp_obj4 = (AttributeOption)temp_obj1.getAttributeOption(); 1551 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1552 { 1553 newObject = false; 1554 temp_obj4.addCondition(obj1); 1555 break; 1556 } 1557 } 1558 if (newObject) 1559 { 1560 obj4.initConditions(); 1561 obj4.addCondition(obj1); 1562 } 1563 1564 1565 1566 1567 omClass = RModuleIssueTypePeer.getOMClass(); 1568 RModuleIssueType obj5 = (RModuleIssueType)RModuleIssueTypePeer 1569 .row2Object( row, offset5, omClass); 1570 1571 newObject = true; 1572 for (int j = 0; j < results.size(); j++) 1573 { 1574 Condition temp_obj1 = (Condition)results.get(j); 1575 RModuleIssueType temp_obj5 = (RModuleIssueType)temp_obj1.getRModuleIssueType(); 1576 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1577 { 1578 newObject = false; 1579 temp_obj5.addCondition(obj1); 1580 break; 1581 } 1582 } 1583 if (newObject) 1584 { 1585 obj5.initConditions(); 1586 obj5.addCondition(obj1); 1587 } 1588 results.add(obj1); 1589 } 1590 return results; 1591 } 1592 1593 1594 1595 1596 1597 1608 protected static List doSelectJoinAllExceptAttributeOption(Criteria criteria) 1609 throws TorqueException 1610 { 1611 setDbName(criteria); 1612 1613 addSelectColumns(criteria); 1614 int offset2 = numColumns + 1; 1615 1616 RModuleAttributePeer.addSelectColumns(criteria); 1617 int offset3 = offset2 + RModuleAttributePeer.numColumns; 1618 1619 TransitionPeer.addSelectColumns(criteria); 1620 int offset4 = offset3 + TransitionPeer.numColumns; 1621 1622 AttributePeer.addSelectColumns(criteria); 1623 int offset5 = offset4 + AttributePeer.numColumns; 1624 1625 1626 RModuleIssueTypePeer.addSelectColumns(criteria); 1627 int offset6 = offset5 + RModuleIssueTypePeer.numColumns; 1628 1629 List rows = BasePeer.doSelect(criteria); 1630 List results = new ArrayList (); 1631 1632 for (int i = 0; i < rows.size(); i++) 1633 { 1634 Record row = (Record)rows.get(i); 1635 1636 Class omClass = ConditionPeer.getOMClass(); 1637 Condition obj1 = (Condition)ConditionPeer 1638 .row2Object(row, 1, omClass); 1639 1640 1641 1642 1643 omClass = RModuleAttributePeer.getOMClass(); 1644 RModuleAttribute obj2 = (RModuleAttribute)RModuleAttributePeer 1645 .row2Object( row, offset2, omClass); 1646 1647 boolean newObject = true; 1648 for (int j = 0; j < results.size(); j++) 1649 { 1650 Condition temp_obj1 = (Condition)results.get(j); 1651 RModuleAttribute temp_obj2 = (RModuleAttribute)temp_obj1.getRModuleAttribute(); 1652 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1653 { 1654 newObject = false; 1655 temp_obj2.addCondition(obj1); 1656 break; 1657 } 1658 } 1659 if (newObject) 1660 { 1661 obj2.initConditions(); 1662 obj2.addCondition(obj1); 1663 } 1664 1665 1666 1667 1668 omClass = TransitionPeer.getOMClass(); 1669 Transition obj3 = (Transition)TransitionPeer 1670 .row2Object( row, offset3, omClass); 1671 1672 newObject = true; 1673 for (int j = 0; j < results.size(); j++) 1674 { 1675 Condition temp_obj1 = (Condition)results.get(j); 1676 Transition temp_obj3 = (Transition)temp_obj1.getTransition(); 1677 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1678 { 1679 newObject = false; 1680 temp_obj3.addCondition(obj1); 1681 break; 1682 } 1683 } 1684 if (newObject) 1685 { 1686 obj3.initConditions(); 1687 obj3.addCondition(obj1); 1688 } 1689 1690 1691 1692 1693 omClass = AttributePeer.getOMClass(); 1694 Attribute obj4 = (Attribute)AttributePeer 1695 .row2Object( row, offset4, omClass); 1696 1697 newObject = true; 1698 for (int j = 0; j < results.size(); j++) 1699 { 1700 Condition temp_obj1 = (Condition)results.get(j); 1701 Attribute temp_obj4 = (Attribute)temp_obj1.getAttribute(); 1702 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1703 { 1704 newObject = false; 1705 temp_obj4.addCondition(obj1); 1706 break; 1707 } 1708 } 1709 if (newObject) 1710 { 1711 obj4.initConditions(); 1712 obj4.addCondition(obj1); 1713 } 1714 1715 1716 1717 1718 1719 omClass = RModuleIssueTypePeer.getOMClass(); 1720 RModuleIssueType obj5 = (RModuleIssueType)RModuleIssueTypePeer 1721 .row2Object( row, offset5, omClass); 1722 1723 newObject = true; 1724 for (int j = 0; j < results.size(); j++) 1725 { 1726 Condition temp_obj1 = (Condition)results.get(j); 1727 RModuleIssueType temp_obj5 = (RModuleIssueType)temp_obj1.getRModuleIssueType(); 1728 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1729 { 1730 newObject = false; 1731 temp_obj5.addCondition(obj1); 1732 break; 1733 } 1734 } 1735 if (newObject) 1736 { 1737 obj5.initConditions(); 1738 obj5.addCondition(obj1); 1739 } 1740 results.add(obj1); 1741 } 1742 return results; 1743 } 1744 1745 1746 1747 1748 1749 1760 protected static List doSelectJoinAllExceptRModuleIssueType(Criteria criteria) 1761 throws TorqueException 1762 { 1763 setDbName(criteria); 1764 1765 addSelectColumns(criteria); 1766 int offset2 = numColumns + 1; 1767 1768 RModuleAttributePeer.addSelectColumns(criteria); 1769 int offset3 = offset2 + RModuleAttributePeer.numColumns; 1770 1771 TransitionPeer.addSelectColumns(criteria); 1772 int offset4 = offset3 + TransitionPeer.numColumns; 1773 1774 AttributePeer.addSelectColumns(criteria); 1775 int offset5 = offset4 + AttributePeer.numColumns; 1776 1777 AttributeOptionPeer.addSelectColumns(criteria); 1778 int offset6 = offset5 + AttributeOptionPeer.numColumns; 1779 1780 1781 List rows = BasePeer.doSelect(criteria); 1782 List results = new ArrayList (); 1783 1784 for (int i = 0; i < rows.size(); i++) 1785 { 1786 Record row = (Record)rows.get(i); 1787 1788 Class omClass = ConditionPeer.getOMClass(); 1789 Condition obj1 = (Condition)ConditionPeer 1790 .row2Object(row, 1, omClass); 1791 1792 1793 1794 1795 omClass = RModuleAttributePeer.getOMClass(); 1796 RModuleAttribute obj2 = (RModuleAttribute)RModuleAttributePeer 1797 .row2Object( row, offset2, omClass); 1798 1799 boolean newObject = true; 1800 for (int j = 0; j < results.size(); j++) 1801 { 1802 Condition temp_obj1 = (Condition)results.get(j); 1803 RModuleAttribute temp_obj2 = (RModuleAttribute)temp_obj1.getRModuleAttribute(); 1804 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1805 { 1806 newObject = false; 1807 temp_obj2.addCondition(obj1); 1808 break; 1809 } 1810 } 1811 if (newObject) 1812 { 1813 obj2.initConditions(); 1814 obj2.addCondition(obj1); 1815 } 1816 1817 1818 1819 1820 omClass = TransitionPeer.getOMClass(); 1821 Transition obj3 = (Transition)TransitionPeer 1822 .row2Object( row, offset3, omClass); 1823 1824 newObject = true; 1825 for (int j = 0; j < results.size(); j++) 1826 { 1827 Condition temp_obj1 = (Condition)results.get(j); 1828 Transition temp_obj3 = (Transition)temp_obj1.getTransition(); 1829 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1830 { 1831 newObject = false; 1832 temp_obj3.addCondition(obj1); 1833 break; 1834 } 1835 } 1836 if (newObject) 1837 { 1838 obj3.initConditions(); 1839 obj3.addCondition(obj1); 1840 } 1841 1842 1843 1844 1845 omClass = AttributePeer.getOMClass(); 1846 Attribute obj4 = (Attribute)AttributePeer 1847 .row2Object( row, offset4, omClass); 1848 1849 newObject = true; 1850 for (int j = 0; j < results.size(); j++) 1851 { 1852 Condition temp_obj1 = (Condition)results.get(j); 1853 Attribute temp_obj4 = (Attribute)temp_obj1.getAttribute(); 1854 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1855 { 1856 newObject = false; 1857 temp_obj4.addCondition(obj1); 1858 break; 1859 } 1860 } 1861 if (newObject) 1862 { 1863 obj4.initConditions(); 1864 obj4.addCondition(obj1); 1865 } 1866 1867 1868 1869 1870 omClass = AttributeOptionPeer.getOMClass(); 1871 AttributeOption obj5 = (AttributeOption)AttributeOptionPeer 1872 .row2Object( row, offset5, omClass); 1873 1874 newObject = true; 1875 for (int j = 0; j < results.size(); j++) 1876 { 1877 Condition temp_obj1 = (Condition)results.get(j); 1878 AttributeOption temp_obj5 = (AttributeOption)temp_obj1.getAttributeOption(); 1879 if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) 1880 { 1881 newObject = false; 1882 temp_obj5.addCondition(obj1); 1883 break; 1884 } 1885 } 1886 if (newObject) 1887 { 1888 obj5.initConditions(); 1889 obj5.addCondition(obj1); 1890 } 1891 1892 results.add(obj1); 1893 } 1894 return results; 1895 } 1896 1897 1898 1905 protected static TableMap getTableMap() 1906 throws TorqueException 1907 { 1908 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1909 } 1910 1911 private static void setDbName(Criteria crit) 1912 { 1913 if (crit.getDbName() == Torque.getDefaultDB()) 1917 { 1918 crit.setDbName(DATABASE_NAME); 1919 } 1920 } 1921} 1922 | Popular Tags |