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 39 public abstract class BaseRModuleOptionPeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_R_MODULE_OPTION"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(RModuleOptionMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String MODULE_ID; 62 63 public static final String ISSUE_TYPE_ID; 64 65 public static final String OPTION_ID; 66 67 public static final String DISPLAY_VALUE; 68 69 public static final String ACTIVE; 70 71 public static final String PREFERRED_ORDER; 72 73 public static final String WEIGHT; 74 75 static 76 { 77 MODULE_ID = "SCARAB_R_MODULE_OPTION.MODULE_ID"; 78 ISSUE_TYPE_ID = "SCARAB_R_MODULE_OPTION.ISSUE_TYPE_ID"; 79 OPTION_ID = "SCARAB_R_MODULE_OPTION.OPTION_ID"; 80 DISPLAY_VALUE = "SCARAB_R_MODULE_OPTION.DISPLAY_VALUE"; 81 ACTIVE = "SCARAB_R_MODULE_OPTION.ACTIVE"; 82 PREFERRED_ORDER = "SCARAB_R_MODULE_OPTION.PREFERRED_ORDER"; 83 WEIGHT = "SCARAB_R_MODULE_OPTION.WEIGHT"; 84 if (Torque.isInit()) 85 { 86 try 87 { 88 getMapBuilder(RModuleOptionMapBuilder.CLASS_NAME); 89 } 90 catch (Exception e) 91 { 92 log.error("Could not initialize Peer", e); 93 } 94 } 95 else 96 { 97 Torque.registerMapBuilder(RModuleOptionMapBuilder.CLASS_NAME); 98 } 99 } 100 101 102 public static final int numColumns = 7; 103 104 105 protected static final String CLASSNAME_DEFAULT = 106 "org.tigris.scarab.om.RModuleOption"; 107 108 109 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 110 111 117 private static Class initClass(String className) 118 { 119 Class c = null; 120 try 121 { 122 c = Class.forName(className); 123 } 124 catch (Throwable t) 125 { 126 log.error("A FATAL ERROR has occurred which should not " 127 + "have happened under any circumstance. Please notify " 128 + "the Torque developers <torque-dev@db.apache.org> " 129 + "and give as many details as possible (including the error " 130 + "stack trace).", t); 131 132 if (t instanceof Error ) 134 { 135 throw (Error ) t.fillInStackTrace(); 136 } 137 } 138 return c; 139 } 140 141 151 public static List resultSet2Objects(java.sql.ResultSet results) 152 throws TorqueException 153 { 154 try 155 { 156 QueryDataSet qds = null; 157 List rows = null; 158 try 159 { 160 qds = new QueryDataSet(results); 161 rows = getSelectResults(qds); 162 } 163 finally 164 { 165 if (qds != null) 166 { 167 qds.close(); 168 } 169 } 170 171 return populateObjects(rows); 172 } 173 catch (SQLException e) 174 { 175 throw new TorqueException(e); 176 } 177 catch (DataSetException e) 178 { 179 throw new TorqueException(e); 180 } 181 } 182 183 184 185 192 public static ObjectKey doInsert(Criteria criteria) 193 throws TorqueException 194 { 195 return BaseRModuleOptionPeer 196 .doInsert(criteria, (Connection ) null); 197 } 198 199 209 public static ObjectKey doInsert(Criteria criteria, Connection con) 210 throws TorqueException 211 { 212 if (criteria.containsKey(ACTIVE)) 214 { 215 Object possibleBoolean = criteria.get(ACTIVE); 216 if (possibleBoolean instanceof Boolean ) 217 { 218 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 219 } 220 } 221 222 setDbName(criteria); 223 224 if (con == null) 225 { 226 return BasePeer.doInsert(criteria); 227 } 228 else 229 { 230 return BasePeer.doInsert(criteria, con); 231 } 232 } 233 234 241 public static void addSelectColumns(Criteria criteria) 242 throws TorqueException 243 { 244 criteria.addSelectColumn(MODULE_ID); 245 criteria.addSelectColumn(ISSUE_TYPE_ID); 246 criteria.addSelectColumn(OPTION_ID); 247 criteria.addSelectColumn(DISPLAY_VALUE); 248 criteria.addSelectColumn(ACTIVE); 249 criteria.addSelectColumn(PREFERRED_ORDER); 250 criteria.addSelectColumn(WEIGHT); 251 } 252 253 262 public static RModuleOption row2Object(Record row, 263 int offset, 264 Class cls) 265 throws TorqueException 266 { 267 try 268 { 269 RModuleOption obj = (RModuleOption) cls.newInstance(); 270 RModuleOptionPeer.populateObject(row, offset, obj); 271 obj.setModified(false); 272 obj.setNew(false); 273 274 return obj; 275 } 276 catch (InstantiationException e) 277 { 278 throw new TorqueException(e); 279 } 280 catch (IllegalAccessException e) 281 { 282 throw new TorqueException(e); 283 } 284 } 285 286 295 public static void populateObject(Record row, 296 int offset, 297 RModuleOption obj) 298 throws TorqueException 299 { 300 try 301 { 302 obj.setModuleId(row.getValue(offset + 0).asIntegerObj()); 303 obj.setIssueTypeId(row.getValue(offset + 1).asIntegerObj()); 304 obj.setOptionId(row.getValue(offset + 2).asIntegerObj()); 305 obj.setDisplayValue(row.getValue(offset + 3).asString()); 306 obj.setActive(row.getValue(offset + 4).asBoolean()); 307 obj.setOrder(row.getValue(offset + 5).asInt()); 308 obj.setWeight(row.getValue(offset + 6).asInt()); 309 } 310 catch (DataSetException e) 311 { 312 throw new TorqueException(e); 313 } 314 } 315 316 324 public static List doSelect(Criteria criteria) throws TorqueException 325 { 326 return populateObjects(doSelectVillageRecords(criteria)); 327 } 328 329 338 public static List doSelect(Criteria criteria, Connection con) 339 throws TorqueException 340 { 341 return populateObjects(doSelectVillageRecords(criteria, con)); 342 } 343 344 354 public static List doSelectVillageRecords(Criteria criteria) 355 throws TorqueException 356 { 357 return BaseRModuleOptionPeer 358 .doSelectVillageRecords(criteria, (Connection ) null); 359 } 360 361 370 public static List doSelectVillageRecords(Criteria criteria, Connection con) 371 throws TorqueException 372 { 373 if (criteria.getSelectColumns().size() == 0) 374 { 375 addSelectColumns(criteria); 376 } 377 378 if (criteria.containsKey(ACTIVE)) 380 { 381 Object possibleBoolean = criteria.get(ACTIVE); 382 if (possibleBoolean instanceof Boolean ) 383 { 384 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 385 } 386 } 387 388 setDbName(criteria); 389 390 if (con == null) 393 { 394 return BasePeer.doSelect(criteria); 395 } 396 else 397 { 398 return BasePeer.doSelect(criteria, con); 399 } 400 } 401 402 409 public static List populateObjects(List records) 410 throws TorqueException 411 { 412 List results = new ArrayList (records.size()); 413 414 for (int i = 0; i < records.size(); i++) 416 { 417 Record row = (Record) records.get(i); 418 results.add(RModuleOptionPeer.row2Object(row, 1, 419 RModuleOptionPeer.getOMClass())); 420 } 421 return results; 422 } 423 424 425 433 public static Class getOMClass() 434 throws TorqueException 435 { 436 return CLASS_DEFAULT; 437 } 438 439 447 public static void doUpdate(Criteria criteria) throws TorqueException 448 { 449 BaseRModuleOptionPeer 450 .doUpdate(criteria, (Connection ) null); 451 } 452 453 464 public static void doUpdate(Criteria criteria, Connection con) 465 throws TorqueException 466 { 467 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 468 selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID)); 469 selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID)); 470 selectCriteria.put(OPTION_ID, criteria.remove(OPTION_ID)); 471 if (criteria.containsKey(ACTIVE)) 473 { 474 Object possibleBoolean = criteria.get(ACTIVE); 475 if (possibleBoolean instanceof Boolean ) 476 { 477 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 478 } 479 } 480 481 setDbName(criteria); 482 483 if (con == null) 484 { 485 BasePeer.doUpdate(selectCriteria, criteria); 486 } 487 else 488 { 489 BasePeer.doUpdate(selectCriteria, criteria, con); 490 } 491 } 492 493 500 public static void doDelete(Criteria criteria) throws TorqueException 501 { 502 RModuleOptionPeer 503 .doDelete(criteria, (Connection ) null); 504 } 505 506 516 public static void doDelete(Criteria criteria, Connection con) 517 throws TorqueException 518 { 519 if (criteria.containsKey(ACTIVE)) 521 { 522 Object possibleBoolean = criteria.get(ACTIVE); 523 if (possibleBoolean instanceof Boolean ) 524 { 525 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 526 } 527 } 528 529 setDbName(criteria); 530 531 if (con == null) 532 { 533 BasePeer.doDelete(criteria); 534 } 535 else 536 { 537 BasePeer.doDelete(criteria, con); 538 } 539 } 540 541 547 public static List doSelect(RModuleOption obj) throws TorqueException 548 { 549 return doSelect(buildSelectCriteria(obj)); 550 } 551 552 558 public static void doInsert(RModuleOption obj) throws TorqueException 559 { 560 doInsert(buildCriteria(obj)); 561 obj.setNew(false); 562 obj.setModified(false); 563 } 564 565 570 public static void doUpdate(RModuleOption obj) throws TorqueException 571 { 572 doUpdate(buildCriteria(obj)); 573 obj.setModified(false); 574 } 575 576 581 public static void doDelete(RModuleOption obj) throws TorqueException 582 { 583 doDelete(buildSelectCriteria(obj)); 584 } 585 586 596 public static void doInsert(RModuleOption obj, Connection con) 597 throws TorqueException 598 { 599 doInsert(buildCriteria(obj), con); 600 obj.setNew(false); 601 obj.setModified(false); 602 } 603 604 614 public static void doUpdate(RModuleOption obj, Connection con) 615 throws TorqueException 616 { 617 doUpdate(buildCriteria(obj), con); 618 obj.setModified(false); 619 } 620 621 631 public static void doDelete(RModuleOption obj, Connection con) 632 throws TorqueException 633 { 634 doDelete(buildSelectCriteria(obj), con); 635 } 636 637 644 public static void doDelete(ObjectKey pk) throws TorqueException 645 { 646 BaseRModuleOptionPeer 647 .doDelete(pk, (Connection ) null); 648 } 649 650 660 public static void doDelete(ObjectKey pk, Connection con) 661 throws TorqueException 662 { 663 doDelete(buildCriteria(pk), con); 664 } 665 666 667 public static Criteria buildCriteria( ObjectKey pk ) 668 { 669 Criteria criteria = new Criteria(); 670 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 671 criteria.add(MODULE_ID, keys[0]); 672 criteria.add(ISSUE_TYPE_ID, keys[1]); 673 criteria.add(OPTION_ID, keys[2]); 674 return criteria; 675 } 676 677 678 public static Criteria buildCriteria( RModuleOption obj ) 679 { 680 Criteria criteria = new Criteria(DATABASE_NAME); 681 criteria.add(MODULE_ID, obj.getModuleId()); 682 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 683 criteria.add(OPTION_ID, obj.getOptionId()); 684 criteria.add(DISPLAY_VALUE, obj.getDisplayValue()); 685 criteria.add(ACTIVE, obj.getActive()); 686 criteria.add(PREFERRED_ORDER, obj.getOrder()); 687 criteria.add(WEIGHT, obj.getWeight()); 688 return criteria; 689 } 690 691 692 public static Criteria buildSelectCriteria( RModuleOption obj ) 693 { 694 Criteria criteria = new Criteria(DATABASE_NAME); 695 criteria.add(MODULE_ID, obj.getModuleId()); 696 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 697 criteria.add(OPTION_ID, obj.getOptionId()); 698 criteria.add(DISPLAY_VALUE, obj.getDisplayValue()); 699 criteria.add(ACTIVE, obj.getActive()); 700 criteria.add(PREFERRED_ORDER, obj.getOrder()); 701 criteria.add(WEIGHT, obj.getWeight()); 702 return criteria; 703 } 704 705 706 707 716 public static RModuleOption retrieveByPK(ObjectKey pk) 717 throws TorqueException, NoRowsException, TooManyRowsException 718 { 719 Connection db = null; 720 RModuleOption retVal = null; 721 try 722 { 723 db = Torque.getConnection(DATABASE_NAME); 724 retVal = retrieveByPK(pk, db); 725 } 726 finally 727 { 728 Torque.closeConnection(db); 729 } 730 return(retVal); 731 } 732 733 743 public static RModuleOption retrieveByPK(ObjectKey pk, Connection con) 744 throws TorqueException, NoRowsException, TooManyRowsException 745 { 746 Criteria criteria = buildCriteria(pk); 747 List v = doSelect(criteria, con); 748 if (v.size() == 0) 749 { 750 throw new NoRowsException("Failed to select a row."); 751 } 752 else if (v.size() > 1) 753 { 754 throw new TooManyRowsException("Failed to select only one row."); 755 } 756 else 757 { 758 return (RModuleOption)v.get(0); 759 } 760 } 761 762 769 public static List retrieveByPKs(List pks) 770 throws TorqueException 771 { 772 Connection db = null; 773 List retVal = null; 774 try 775 { 776 db = Torque.getConnection(DATABASE_NAME); 777 retVal = retrieveByPKs(pks, db); 778 } 779 finally 780 { 781 Torque.closeConnection(db); 782 } 783 return(retVal); 784 } 785 786 794 public static List retrieveByPKs( List pks, Connection dbcon ) 795 throws TorqueException 796 { 797 List objs = null; 798 if (pks == null || pks.size() == 0) 799 { 800 objs = new LinkedList (); 801 } 802 else 803 { 804 Criteria criteria = new Criteria(); 805 Iterator iter = pks.iterator(); 806 while (iter.hasNext()) 807 { 808 ObjectKey pk = (ObjectKey)iter.next(); 809 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 810 Criteria.Criterion c0 = criteria.getNewCriterion( 811 MODULE_ID, keys[0], Criteria.EQUAL); 812 Criteria.Criterion c1 = criteria.getNewCriterion( 813 ISSUE_TYPE_ID, keys[1], Criteria.EQUAL); 814 c0.and(c1); 815 Criteria.Criterion c2 = criteria.getNewCriterion( 816 OPTION_ID, keys[2], Criteria.EQUAL); 817 c1.and(c2); 818 criteria.or(c0); 819 } 820 objs = doSelect(criteria, dbcon); 821 } 822 return objs; 823 } 824 825 826 833 public static RModuleOption retrieveByPK( 834 Integer module_id 835 , Integer issue_type_id 836 , Integer option_id 837 ) throws TorqueException 838 { 839 Connection db = null; 840 RModuleOption retVal = null; 841 try 842 { 843 db = Torque.getConnection(DATABASE_NAME); 844 retVal = retrieveByPK( 845 module_id 846 , issue_type_id 847 , option_id 848 , db); 849 } 850 finally 851 { 852 Torque.closeConnection(db); 853 } 854 return(retVal); 855 } 856 857 865 public static RModuleOption retrieveByPK( 866 Integer module_id 867 , Integer issue_type_id 868 , Integer option_id 869 ,Connection con) throws TorqueException 870 { 871 872 Criteria criteria = new Criteria(5); 873 criteria.add(MODULE_ID, module_id); 874 criteria.add(ISSUE_TYPE_ID, issue_type_id); 875 criteria.add(OPTION_ID, option_id); 876 List v = doSelect(criteria, con); 877 if (v.size() != 1) 878 { 879 throw new TorqueException("Failed to select one and only one row."); 880 } 881 else 882 { 883 return (RModuleOption) v.get(0); 884 } 885 } 886 887 888 889 890 891 892 893 894 905 protected static List doSelectJoinAttributeOption(Criteria criteria) 906 throws TorqueException 907 { 908 setDbName(criteria); 909 910 RModuleOptionPeer.addSelectColumns(criteria); 911 int offset = numColumns + 1; 912 AttributeOptionPeer.addSelectColumns(criteria); 913 914 915 criteria.addJoin(RModuleOptionPeer.OPTION_ID, 916 AttributeOptionPeer.OPTION_ID); 917 918 919 if (criteria.containsKey(ACTIVE)) 921 { 922 Object possibleBoolean = criteria.get(ACTIVE); 923 if (possibleBoolean instanceof Boolean ) 924 { 925 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 926 } 927 } 928 929 List rows = BasePeer.doSelect(criteria); 930 List results = new ArrayList (); 931 932 for (int i = 0; i < rows.size(); i++) 933 { 934 Record row = (Record) rows.get(i); 935 936 Class omClass = RModuleOptionPeer.getOMClass(); 937 RModuleOption obj1 = (RModuleOption) RModuleOptionPeer 938 .row2Object(row, 1, omClass); 939 omClass = AttributeOptionPeer.getOMClass(); 940 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 941 .row2Object(row, offset, omClass); 942 943 boolean newObject = true; 944 for (int j = 0; j < results.size(); j++) 945 { 946 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 947 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 948 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 949 { 950 newObject = false; 951 temp_obj2.addRModuleOption(obj1); 952 break; 953 } 954 } 955 if (newObject) 956 { 957 obj2.initRModuleOptions(); 958 obj2.addRModuleOption(obj1); 959 } 960 results.add(obj1); 961 } 962 return results; 963 } 964 965 966 967 968 979 protected static List doSelectJoinScarabModule(Criteria criteria) 980 throws TorqueException 981 { 982 setDbName(criteria); 983 984 RModuleOptionPeer.addSelectColumns(criteria); 985 int offset = numColumns + 1; 986 ScarabModulePeer.addSelectColumns(criteria); 987 988 989 criteria.addJoin(RModuleOptionPeer.MODULE_ID, 990 ScarabModulePeer.MODULE_ID); 991 992 993 if (criteria.containsKey(ACTIVE)) 995 { 996 Object possibleBoolean = criteria.get(ACTIVE); 997 if (possibleBoolean instanceof Boolean ) 998 { 999 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1000 } 1001 } 1002 1003 List rows = BasePeer.doSelect(criteria); 1004 List results = new ArrayList (); 1005 1006 for (int i = 0; i < rows.size(); i++) 1007 { 1008 Record row = (Record) rows.get(i); 1009 1010 Class omClass = RModuleOptionPeer.getOMClass(); 1011 RModuleOption obj1 = (RModuleOption) RModuleOptionPeer 1012 .row2Object(row, 1, omClass); 1013 omClass = ScarabModulePeer.getOMClass(row, offset); 1014 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1015 .row2Object(row, offset, omClass); 1016 1017 boolean newObject = true; 1018 for (int j = 0; j < results.size(); j++) 1019 { 1020 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1021 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1022 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1023 { 1024 newObject = false; 1025 temp_obj2.addRModuleOption(obj1); 1026 break; 1027 } 1028 } 1029 if (newObject) 1030 { 1031 obj2.initRModuleOptions(); 1032 obj2.addRModuleOption(obj1); 1033 } 1034 results.add(obj1); 1035 } 1036 return results; 1037 } 1038 1039 1040 1041 1042 1053 protected static List doSelectJoinIssueType(Criteria criteria) 1054 throws TorqueException 1055 { 1056 setDbName(criteria); 1057 1058 RModuleOptionPeer.addSelectColumns(criteria); 1059 int offset = numColumns + 1; 1060 IssueTypePeer.addSelectColumns(criteria); 1061 1062 1063 criteria.addJoin(RModuleOptionPeer.ISSUE_TYPE_ID, 1064 IssueTypePeer.ISSUE_TYPE_ID); 1065 1066 1067 if (criteria.containsKey(ACTIVE)) 1069 { 1070 Object possibleBoolean = criteria.get(ACTIVE); 1071 if (possibleBoolean instanceof Boolean ) 1072 { 1073 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1074 } 1075 } 1076 1077 List rows = BasePeer.doSelect(criteria); 1078 List results = new ArrayList (); 1079 1080 for (int i = 0; i < rows.size(); i++) 1081 { 1082 Record row = (Record) rows.get(i); 1083 1084 Class omClass = RModuleOptionPeer.getOMClass(); 1085 RModuleOption obj1 = (RModuleOption) RModuleOptionPeer 1086 .row2Object(row, 1, omClass); 1087 omClass = IssueTypePeer.getOMClass(); 1088 IssueType obj2 = (IssueType)IssueTypePeer 1089 .row2Object(row, offset, omClass); 1090 1091 boolean newObject = true; 1092 for (int j = 0; j < results.size(); j++) 1093 { 1094 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1095 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1096 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1097 { 1098 newObject = false; 1099 temp_obj2.addRModuleOption(obj1); 1100 break; 1101 } 1102 } 1103 if (newObject) 1104 { 1105 obj2.initRModuleOptions(); 1106 obj2.addRModuleOption(obj1); 1107 } 1108 results.add(obj1); 1109 } 1110 return results; 1111 } 1112 1113 1114 1115 1116 1117 1118 1119 1120 1131 protected static List doSelectJoinAllExceptAttributeOption(Criteria criteria) 1132 throws TorqueException 1133 { 1134 setDbName(criteria); 1135 1136 addSelectColumns(criteria); 1137 int offset2 = numColumns + 1; 1138 1139 1140 ScarabModulePeer.addSelectColumns(criteria); 1141 int offset3 = offset2 + ScarabModulePeer.numColumns; 1142 1143 IssueTypePeer.addSelectColumns(criteria); 1144 int offset4 = offset3 + IssueTypePeer.numColumns; 1145 if (criteria.containsKey(ACTIVE)) 1147 { 1148 Object possibleBoolean = criteria.get(ACTIVE); 1149 if (possibleBoolean instanceof Boolean ) 1150 { 1151 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1152 } 1153 } 1154 1155 List rows = BasePeer.doSelect(criteria); 1156 List results = new ArrayList (); 1157 1158 for (int i = 0; i < rows.size(); i++) 1159 { 1160 Record row = (Record)rows.get(i); 1161 1162 Class omClass = RModuleOptionPeer.getOMClass(); 1163 RModuleOption obj1 = (RModuleOption)RModuleOptionPeer 1164 .row2Object(row, 1, omClass); 1165 1166 1167 1168 1169 1170 omClass = ScarabModulePeer.getOMClass(row, offset2); 1171 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1172 .row2Object( row, offset2, omClass); 1173 1174 boolean newObject = true; 1175 for (int j = 0; j < results.size(); j++) 1176 { 1177 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1178 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1179 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1180 { 1181 newObject = false; 1182 temp_obj2.addRModuleOption(obj1); 1183 break; 1184 } 1185 } 1186 if (newObject) 1187 { 1188 obj2.initRModuleOptions(); 1189 obj2.addRModuleOption(obj1); 1190 } 1191 1192 1193 1194 1195 omClass = IssueTypePeer.getOMClass(); 1196 IssueType obj3 = (IssueType)IssueTypePeer 1197 .row2Object( row, offset3, omClass); 1198 1199 newObject = true; 1200 for (int j = 0; j < results.size(); j++) 1201 { 1202 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1203 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1204 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1205 { 1206 newObject = false; 1207 temp_obj3.addRModuleOption(obj1); 1208 break; 1209 } 1210 } 1211 if (newObject) 1212 { 1213 obj3.initRModuleOptions(); 1214 obj3.addRModuleOption(obj1); 1215 } 1216 results.add(obj1); 1217 } 1218 return results; 1219 } 1220 1221 1222 1223 1224 1225 1236 protected static List doSelectJoinAllExceptScarabModule(Criteria criteria) 1237 throws TorqueException 1238 { 1239 setDbName(criteria); 1240 1241 addSelectColumns(criteria); 1242 int offset2 = numColumns + 1; 1243 1244 AttributeOptionPeer.addSelectColumns(criteria); 1245 int offset3 = offset2 + AttributeOptionPeer.numColumns; 1246 1247 1248 IssueTypePeer.addSelectColumns(criteria); 1249 int offset4 = offset3 + IssueTypePeer.numColumns; 1250 if (criteria.containsKey(ACTIVE)) 1252 { 1253 Object possibleBoolean = criteria.get(ACTIVE); 1254 if (possibleBoolean instanceof Boolean ) 1255 { 1256 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1257 } 1258 } 1259 1260 List rows = BasePeer.doSelect(criteria); 1261 List results = new ArrayList (); 1262 1263 for (int i = 0; i < rows.size(); i++) 1264 { 1265 Record row = (Record)rows.get(i); 1266 1267 Class omClass = RModuleOptionPeer.getOMClass(); 1268 RModuleOption obj1 = (RModuleOption)RModuleOptionPeer 1269 .row2Object(row, 1, omClass); 1270 1271 1272 1273 1274 omClass = AttributeOptionPeer.getOMClass(); 1275 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1276 .row2Object( row, offset2, omClass); 1277 1278 boolean newObject = true; 1279 for (int j = 0; j < results.size(); j++) 1280 { 1281 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1282 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 1283 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1284 { 1285 newObject = false; 1286 temp_obj2.addRModuleOption(obj1); 1287 break; 1288 } 1289 } 1290 if (newObject) 1291 { 1292 obj2.initRModuleOptions(); 1293 obj2.addRModuleOption(obj1); 1294 } 1295 1296 1297 1298 1299 1300 omClass = IssueTypePeer.getOMClass(); 1301 IssueType obj3 = (IssueType)IssueTypePeer 1302 .row2Object( row, offset3, omClass); 1303 1304 newObject = true; 1305 for (int j = 0; j < results.size(); j++) 1306 { 1307 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1308 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1309 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1310 { 1311 newObject = false; 1312 temp_obj3.addRModuleOption(obj1); 1313 break; 1314 } 1315 } 1316 if (newObject) 1317 { 1318 obj3.initRModuleOptions(); 1319 obj3.addRModuleOption(obj1); 1320 } 1321 results.add(obj1); 1322 } 1323 return results; 1324 } 1325 1326 1327 1328 1329 1330 1341 protected static List doSelectJoinAllExceptIssueType(Criteria criteria) 1342 throws TorqueException 1343 { 1344 setDbName(criteria); 1345 1346 addSelectColumns(criteria); 1347 int offset2 = numColumns + 1; 1348 1349 AttributeOptionPeer.addSelectColumns(criteria); 1350 int offset3 = offset2 + AttributeOptionPeer.numColumns; 1351 1352 ScarabModulePeer.addSelectColumns(criteria); 1353 int offset4 = offset3 + ScarabModulePeer.numColumns; 1354 1355 if (criteria.containsKey(ACTIVE)) 1357 { 1358 Object possibleBoolean = criteria.get(ACTIVE); 1359 if (possibleBoolean instanceof Boolean ) 1360 { 1361 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1362 } 1363 } 1364 1365 List rows = BasePeer.doSelect(criteria); 1366 List results = new ArrayList (); 1367 1368 for (int i = 0; i < rows.size(); i++) 1369 { 1370 Record row = (Record)rows.get(i); 1371 1372 Class omClass = RModuleOptionPeer.getOMClass(); 1373 RModuleOption obj1 = (RModuleOption)RModuleOptionPeer 1374 .row2Object(row, 1, omClass); 1375 1376 1377 1378 1379 omClass = AttributeOptionPeer.getOMClass(); 1380 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1381 .row2Object( row, offset2, omClass); 1382 1383 boolean newObject = true; 1384 for (int j = 0; j < results.size(); j++) 1385 { 1386 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1387 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 1388 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1389 { 1390 newObject = false; 1391 temp_obj2.addRModuleOption(obj1); 1392 break; 1393 } 1394 } 1395 if (newObject) 1396 { 1397 obj2.initRModuleOptions(); 1398 obj2.addRModuleOption(obj1); 1399 } 1400 1401 1402 1403 1404 omClass = ScarabModulePeer.getOMClass(row, offset3); 1405 ScarabModule obj3 = (ScarabModule)ScarabModulePeer 1406 .row2Object( row, offset3, omClass); 1407 1408 newObject = true; 1409 for (int j = 0; j < results.size(); j++) 1410 { 1411 RModuleOption temp_obj1 = (RModuleOption)results.get(j); 1412 ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule(); 1413 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1414 { 1415 newObject = false; 1416 temp_obj3.addRModuleOption(obj1); 1417 break; 1418 } 1419 } 1420 if (newObject) 1421 { 1422 obj3.initRModuleOptions(); 1423 obj3.addRModuleOption(obj1); 1424 } 1425 1426 results.add(obj1); 1427 } 1428 return results; 1429 } 1430 1431 1432 1439 protected static TableMap getTableMap() 1440 throws TorqueException 1441 { 1442 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1443 } 1444 1445 private static void setDbName(Criteria crit) 1446 { 1447 if (crit.getDbName() == Torque.getDefaultDB()) 1451 { 1452 crit.setDbName(DATABASE_NAME); 1453 } 1454 } 1455} 1456 | Popular Tags |