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 38 public abstract class BaseRModuleIssueTypePeer 39 extends BasePeer 40 { 41 42 43 public static final String DATABASE_NAME = "scarab"; 44 45 46 public static final String TABLE_NAME = "SCARAB_R_MODULE_ISSUE_TYPE"; 47 48 53 public static MapBuilder getMapBuilder() 54 throws TorqueException 55 { 56 return getMapBuilder(RModuleIssueTypeMapBuilder.CLASS_NAME); 57 } 58 59 60 public static final String MODULE_ID; 61 62 public static final String ISSUE_TYPE_ID; 63 64 public static final String ACTIVE; 65 66 public static final String DISPLAY; 67 68 public static final String PREFERRED_ORDER; 69 70 public static final String DEDUPE; 71 72 public static final String HISTORY; 73 74 public static final String COMMENTS; 75 76 public static final String DISPLAY_NAME; 77 78 public static final String DISPLAY_DESCRIPTION; 79 80 static 81 { 82 MODULE_ID = "SCARAB_R_MODULE_ISSUE_TYPE.MODULE_ID"; 83 ISSUE_TYPE_ID = "SCARAB_R_MODULE_ISSUE_TYPE.ISSUE_TYPE_ID"; 84 ACTIVE = "SCARAB_R_MODULE_ISSUE_TYPE.ACTIVE"; 85 DISPLAY = "SCARAB_R_MODULE_ISSUE_TYPE.DISPLAY"; 86 PREFERRED_ORDER = "SCARAB_R_MODULE_ISSUE_TYPE.PREFERRED_ORDER"; 87 DEDUPE = "SCARAB_R_MODULE_ISSUE_TYPE.DEDUPE"; 88 HISTORY = "SCARAB_R_MODULE_ISSUE_TYPE.HISTORY"; 89 COMMENTS = "SCARAB_R_MODULE_ISSUE_TYPE.COMMENTS"; 90 DISPLAY_NAME = "SCARAB_R_MODULE_ISSUE_TYPE.DISPLAY_NAME"; 91 DISPLAY_DESCRIPTION = "SCARAB_R_MODULE_ISSUE_TYPE.DISPLAY_DESCRIPTION"; 92 if (Torque.isInit()) 93 { 94 try 95 { 96 getMapBuilder(RModuleIssueTypeMapBuilder.CLASS_NAME); 97 } 98 catch (Exception e) 99 { 100 log.error("Could not initialize Peer", e); 101 } 102 } 103 else 104 { 105 Torque.registerMapBuilder(RModuleIssueTypeMapBuilder.CLASS_NAME); 106 } 107 } 108 109 110 public static final int numColumns = 10; 111 112 113 protected static final String CLASSNAME_DEFAULT = 114 "org.tigris.scarab.om.RModuleIssueType"; 115 116 117 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 118 119 125 private static Class initClass(String className) 126 { 127 Class c = null; 128 try 129 { 130 c = Class.forName(className); 131 } 132 catch (Throwable t) 133 { 134 log.error("A FATAL ERROR has occurred which should not " 135 + "have happened under any circumstance. Please notify " 136 + "the Torque developers <torque-dev@db.apache.org> " 137 + "and give as many details as possible (including the error " 138 + "stack trace).", t); 139 140 if (t instanceof Error ) 142 { 143 throw (Error ) t.fillInStackTrace(); 144 } 145 } 146 return c; 147 } 148 149 159 public static List resultSet2Objects(java.sql.ResultSet results) 160 throws TorqueException 161 { 162 try 163 { 164 QueryDataSet qds = null; 165 List rows = null; 166 try 167 { 168 qds = new QueryDataSet(results); 169 rows = getSelectResults(qds); 170 } 171 finally 172 { 173 if (qds != null) 174 { 175 qds.close(); 176 } 177 } 178 179 return populateObjects(rows); 180 } 181 catch (SQLException e) 182 { 183 throw new TorqueException(e); 184 } 185 catch (DataSetException e) 186 { 187 throw new TorqueException(e); 188 } 189 } 190 191 192 193 200 public static ObjectKey doInsert(Criteria criteria) 201 throws TorqueException 202 { 203 return BaseRModuleIssueTypePeer 204 .doInsert(criteria, (Connection ) null); 205 } 206 207 217 public static ObjectKey doInsert(Criteria criteria, Connection con) 218 throws TorqueException 219 { 220 if (criteria.containsKey(ACTIVE)) 222 { 223 Object possibleBoolean = criteria.get(ACTIVE); 224 if (possibleBoolean instanceof Boolean ) 225 { 226 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 227 } 228 } 229 if (criteria.containsKey(DISPLAY)) 231 { 232 Object possibleBoolean = criteria.get(DISPLAY); 233 if (possibleBoolean instanceof Boolean ) 234 { 235 criteria.add(DISPLAY, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 236 } 237 } 238 if (criteria.containsKey(DEDUPE)) 240 { 241 Object possibleBoolean = criteria.get(DEDUPE); 242 if (possibleBoolean instanceof Boolean ) 243 { 244 criteria.add(DEDUPE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 245 } 246 } 247 248 setDbName(criteria); 249 250 if (con == null) 251 { 252 return BasePeer.doInsert(criteria); 253 } 254 else 255 { 256 return BasePeer.doInsert(criteria, con); 257 } 258 } 259 260 267 public static void addSelectColumns(Criteria criteria) 268 throws TorqueException 269 { 270 criteria.addSelectColumn(MODULE_ID); 271 criteria.addSelectColumn(ISSUE_TYPE_ID); 272 criteria.addSelectColumn(ACTIVE); 273 criteria.addSelectColumn(DISPLAY); 274 criteria.addSelectColumn(PREFERRED_ORDER); 275 criteria.addSelectColumn(DEDUPE); 276 criteria.addSelectColumn(HISTORY); 277 criteria.addSelectColumn(COMMENTS); 278 criteria.addSelectColumn(DISPLAY_NAME); 279 criteria.addSelectColumn(DISPLAY_DESCRIPTION); 280 } 281 282 291 public static RModuleIssueType row2Object(Record row, 292 int offset, 293 Class cls) 294 throws TorqueException 295 { 296 try 297 { 298 RModuleIssueType obj = (RModuleIssueType) cls.newInstance(); 299 RModuleIssueTypePeer.populateObject(row, offset, obj); 300 obj.setModified(false); 301 obj.setNew(false); 302 303 return obj; 304 } 305 catch (InstantiationException e) 306 { 307 throw new TorqueException(e); 308 } 309 catch (IllegalAccessException e) 310 { 311 throw new TorqueException(e); 312 } 313 } 314 315 324 public static void populateObject(Record row, 325 int offset, 326 RModuleIssueType obj) 327 throws TorqueException 328 { 329 try 330 { 331 obj.setModuleId(row.getValue(offset + 0).asIntegerObj()); 332 obj.setIssueTypeId(row.getValue(offset + 1).asIntegerObj()); 333 obj.setActive(row.getValue(offset + 2).asBoolean()); 334 obj.setDisplay(row.getValue(offset + 3).asBoolean()); 335 obj.setOrder(row.getValue(offset + 4).asInt()); 336 obj.setDedupe(row.getValue(offset + 5).asBoolean()); 337 obj.setHistory(row.getValue(offset + 6).asInt()); 338 obj.setComments(row.getValue(offset + 7).asInt()); 339 obj.setDisplayName(row.getValue(offset + 8).asString()); 340 obj.setDisplayDescription(row.getValue(offset + 9).asString()); 341 } 342 catch (DataSetException e) 343 { 344 throw new TorqueException(e); 345 } 346 } 347 348 356 public static List doSelect(Criteria criteria) throws TorqueException 357 { 358 return populateObjects(doSelectVillageRecords(criteria)); 359 } 360 361 370 public static List doSelect(Criteria criteria, Connection con) 371 throws TorqueException 372 { 373 return populateObjects(doSelectVillageRecords(criteria, con)); 374 } 375 376 386 public static List doSelectVillageRecords(Criteria criteria) 387 throws TorqueException 388 { 389 return BaseRModuleIssueTypePeer 390 .doSelectVillageRecords(criteria, (Connection ) null); 391 } 392 393 402 public static List doSelectVillageRecords(Criteria criteria, Connection con) 403 throws TorqueException 404 { 405 if (criteria.getSelectColumns().size() == 0) 406 { 407 addSelectColumns(criteria); 408 } 409 410 if (criteria.containsKey(ACTIVE)) 412 { 413 Object possibleBoolean = criteria.get(ACTIVE); 414 if (possibleBoolean instanceof Boolean ) 415 { 416 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 417 } 418 } 419 if (criteria.containsKey(DISPLAY)) 421 { 422 Object possibleBoolean = criteria.get(DISPLAY); 423 if (possibleBoolean instanceof Boolean ) 424 { 425 criteria.add(DISPLAY, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 426 } 427 } 428 if (criteria.containsKey(DEDUPE)) 430 { 431 Object possibleBoolean = criteria.get(DEDUPE); 432 if (possibleBoolean instanceof Boolean ) 433 { 434 criteria.add(DEDUPE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 435 } 436 } 437 438 setDbName(criteria); 439 440 if (con == null) 443 { 444 return BasePeer.doSelect(criteria); 445 } 446 else 447 { 448 return BasePeer.doSelect(criteria, con); 449 } 450 } 451 452 459 public static List populateObjects(List records) 460 throws TorqueException 461 { 462 List results = new ArrayList (records.size()); 463 464 for (int i = 0; i < records.size(); i++) 466 { 467 Record row = (Record) records.get(i); 468 results.add(RModuleIssueTypePeer.row2Object(row, 1, 469 RModuleIssueTypePeer.getOMClass())); 470 } 471 return results; 472 } 473 474 475 483 public static Class getOMClass() 484 throws TorqueException 485 { 486 return CLASS_DEFAULT; 487 } 488 489 497 public static void doUpdate(Criteria criteria) throws TorqueException 498 { 499 BaseRModuleIssueTypePeer 500 .doUpdate(criteria, (Connection ) null); 501 } 502 503 514 public static void doUpdate(Criteria criteria, Connection con) 515 throws TorqueException 516 { 517 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 518 selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID)); 519 selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID)); 520 if (criteria.containsKey(ACTIVE)) 522 { 523 Object possibleBoolean = criteria.get(ACTIVE); 524 if (possibleBoolean instanceof Boolean ) 525 { 526 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 527 } 528 } 529 if (criteria.containsKey(DISPLAY)) 531 { 532 Object possibleBoolean = criteria.get(DISPLAY); 533 if (possibleBoolean instanceof Boolean ) 534 { 535 criteria.add(DISPLAY, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 536 } 537 } 538 if (criteria.containsKey(DEDUPE)) 540 { 541 Object possibleBoolean = criteria.get(DEDUPE); 542 if (possibleBoolean instanceof Boolean ) 543 { 544 criteria.add(DEDUPE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 545 } 546 } 547 548 setDbName(criteria); 549 550 if (con == null) 551 { 552 BasePeer.doUpdate(selectCriteria, criteria); 553 } 554 else 555 { 556 BasePeer.doUpdate(selectCriteria, criteria, con); 557 } 558 } 559 560 567 public static void doDelete(Criteria criteria) throws TorqueException 568 { 569 RModuleIssueTypePeer 570 .doDelete(criteria, (Connection ) null); 571 } 572 573 583 public static void doDelete(Criteria criteria, Connection con) 584 throws TorqueException 585 { 586 if (criteria.containsKey(ACTIVE)) 588 { 589 Object possibleBoolean = criteria.get(ACTIVE); 590 if (possibleBoolean instanceof Boolean ) 591 { 592 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 593 } 594 } 595 if (criteria.containsKey(DISPLAY)) 597 { 598 Object possibleBoolean = criteria.get(DISPLAY); 599 if (possibleBoolean instanceof Boolean ) 600 { 601 criteria.add(DISPLAY, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 602 } 603 } 604 if (criteria.containsKey(DEDUPE)) 606 { 607 Object possibleBoolean = criteria.get(DEDUPE); 608 if (possibleBoolean instanceof Boolean ) 609 { 610 criteria.add(DEDUPE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 611 } 612 } 613 614 setDbName(criteria); 615 616 if (con == null) 617 { 618 BasePeer.doDelete(criteria); 619 } 620 else 621 { 622 BasePeer.doDelete(criteria, con); 623 } 624 } 625 626 632 public static List doSelect(RModuleIssueType obj) throws TorqueException 633 { 634 return doSelect(buildSelectCriteria(obj)); 635 } 636 637 643 public static void doInsert(RModuleIssueType obj) throws TorqueException 644 { 645 doInsert(buildCriteria(obj)); 646 obj.setNew(false); 647 obj.setModified(false); 648 } 649 650 655 public static void doUpdate(RModuleIssueType obj) throws TorqueException 656 { 657 doUpdate(buildCriteria(obj)); 658 obj.setModified(false); 659 } 660 661 666 public static void doDelete(RModuleIssueType obj) throws TorqueException 667 { 668 doDelete(buildSelectCriteria(obj)); 669 } 670 671 681 public static void doInsert(RModuleIssueType obj, Connection con) 682 throws TorqueException 683 { 684 doInsert(buildCriteria(obj), con); 685 obj.setNew(false); 686 obj.setModified(false); 687 } 688 689 699 public static void doUpdate(RModuleIssueType obj, Connection con) 700 throws TorqueException 701 { 702 doUpdate(buildCriteria(obj), con); 703 obj.setModified(false); 704 } 705 706 716 public static void doDelete(RModuleIssueType obj, Connection con) 717 throws TorqueException 718 { 719 doDelete(buildSelectCriteria(obj), con); 720 } 721 722 729 public static void doDelete(ObjectKey pk) throws TorqueException 730 { 731 BaseRModuleIssueTypePeer 732 .doDelete(pk, (Connection ) null); 733 } 734 735 745 public static void doDelete(ObjectKey pk, Connection con) 746 throws TorqueException 747 { 748 doDelete(buildCriteria(pk), con); 749 } 750 751 752 public static Criteria buildCriteria( ObjectKey pk ) 753 { 754 Criteria criteria = new Criteria(); 755 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 756 criteria.add(MODULE_ID, keys[0]); 757 criteria.add(ISSUE_TYPE_ID, keys[1]); 758 return criteria; 759 } 760 761 762 public static Criteria buildCriteria( RModuleIssueType obj ) 763 { 764 Criteria criteria = new Criteria(DATABASE_NAME); 765 criteria.add(MODULE_ID, obj.getModuleId()); 766 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 767 criteria.add(ACTIVE, obj.getActive()); 768 criteria.add(DISPLAY, obj.getDisplay()); 769 criteria.add(PREFERRED_ORDER, obj.getOrder()); 770 criteria.add(DEDUPE, obj.getDedupe()); 771 criteria.add(HISTORY, obj.getHistory()); 772 criteria.add(COMMENTS, obj.getComments()); 773 criteria.add(DISPLAY_NAME, obj.getDisplayName()); 774 criteria.add(DISPLAY_DESCRIPTION, obj.getDisplayDescription()); 775 return criteria; 776 } 777 778 779 public static Criteria buildSelectCriteria( RModuleIssueType obj ) 780 { 781 Criteria criteria = new Criteria(DATABASE_NAME); 782 criteria.add(MODULE_ID, obj.getModuleId()); 783 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 784 criteria.add(ACTIVE, obj.getActive()); 785 criteria.add(DISPLAY, obj.getDisplay()); 786 criteria.add(PREFERRED_ORDER, obj.getOrder()); 787 criteria.add(DEDUPE, obj.getDedupe()); 788 criteria.add(HISTORY, obj.getHistory()); 789 criteria.add(COMMENTS, obj.getComments()); 790 criteria.add(DISPLAY_NAME, obj.getDisplayName()); 791 criteria.add(DISPLAY_DESCRIPTION, obj.getDisplayDescription()); 792 return criteria; 793 } 794 795 796 797 806 public static RModuleIssueType retrieveByPK(ObjectKey pk) 807 throws TorqueException, NoRowsException, TooManyRowsException 808 { 809 Connection db = null; 810 RModuleIssueType retVal = null; 811 try 812 { 813 db = Torque.getConnection(DATABASE_NAME); 814 retVal = retrieveByPK(pk, db); 815 } 816 finally 817 { 818 Torque.closeConnection(db); 819 } 820 return(retVal); 821 } 822 823 833 public static RModuleIssueType retrieveByPK(ObjectKey pk, Connection con) 834 throws TorqueException, NoRowsException, TooManyRowsException 835 { 836 Criteria criteria = buildCriteria(pk); 837 List v = doSelect(criteria, con); 838 if (v.size() == 0) 839 { 840 throw new NoRowsException("Failed to select a row."); 841 } 842 else if (v.size() > 1) 843 { 844 throw new TooManyRowsException("Failed to select only one row."); 845 } 846 else 847 { 848 return (RModuleIssueType)v.get(0); 849 } 850 } 851 852 859 public static List retrieveByPKs(List pks) 860 throws TorqueException 861 { 862 Connection db = null; 863 List retVal = null; 864 try 865 { 866 db = Torque.getConnection(DATABASE_NAME); 867 retVal = retrieveByPKs(pks, db); 868 } 869 finally 870 { 871 Torque.closeConnection(db); 872 } 873 return(retVal); 874 } 875 876 884 public static List retrieveByPKs( List pks, Connection dbcon ) 885 throws TorqueException 886 { 887 List objs = null; 888 if (pks == null || pks.size() == 0) 889 { 890 objs = new LinkedList (); 891 } 892 else 893 { 894 Criteria criteria = new Criteria(); 895 Iterator iter = pks.iterator(); 896 while (iter.hasNext()) 897 { 898 ObjectKey pk = (ObjectKey)iter.next(); 899 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 900 Criteria.Criterion c0 = criteria.getNewCriterion( 901 MODULE_ID, keys[0], Criteria.EQUAL); 902 Criteria.Criterion c1 = criteria.getNewCriterion( 903 ISSUE_TYPE_ID, keys[1], Criteria.EQUAL); 904 c0.and(c1); 905 criteria.or(c0); 906 } 907 objs = doSelect(criteria, dbcon); 908 } 909 return objs; 910 } 911 912 913 919 public static RModuleIssueType retrieveByPK( 920 Integer module_id 921 , Integer issue_type_id 922 ) throws TorqueException 923 { 924 Connection db = null; 925 RModuleIssueType retVal = null; 926 try 927 { 928 db = Torque.getConnection(DATABASE_NAME); 929 retVal = retrieveByPK( 930 module_id 931 , issue_type_id 932 , db); 933 } 934 finally 935 { 936 Torque.closeConnection(db); 937 } 938 return(retVal); 939 } 940 941 948 public static RModuleIssueType retrieveByPK( 949 Integer module_id 950 , Integer issue_type_id 951 ,Connection con) throws TorqueException 952 { 953 954 Criteria criteria = new Criteria(5); 955 criteria.add(MODULE_ID, module_id); 956 criteria.add(ISSUE_TYPE_ID, issue_type_id); 957 List v = doSelect(criteria, con); 958 if (v.size() != 1) 959 { 960 throw new TorqueException("Failed to select one and only one row."); 961 } 962 else 963 { 964 return (RModuleIssueType) v.get(0); 965 } 966 } 967 968 969 970 971 972 973 974 975 986 protected static List doSelectJoinScarabModule(Criteria criteria) 987 throws TorqueException 988 { 989 setDbName(criteria); 990 991 RModuleIssueTypePeer.addSelectColumns(criteria); 992 int offset = numColumns + 1; 993 ScarabModulePeer.addSelectColumns(criteria); 994 995 996 criteria.addJoin(RModuleIssueTypePeer.MODULE_ID, 997 ScarabModulePeer.MODULE_ID); 998 999 1000 if (criteria.containsKey(ACTIVE)) 1002 { 1003 Object possibleBoolean = criteria.get(ACTIVE); 1004 if (possibleBoolean instanceof Boolean ) 1005 { 1006 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1007 } 1008 } 1009 if (criteria.containsKey(DISPLAY)) 1011 { 1012 Object possibleBoolean = criteria.get(DISPLAY); 1013 if (possibleBoolean instanceof Boolean ) 1014 { 1015 criteria.add(DISPLAY, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1016 } 1017 } 1018 if (criteria.containsKey(DEDUPE)) 1020 { 1021 Object possibleBoolean = criteria.get(DEDUPE); 1022 if (possibleBoolean instanceof Boolean ) 1023 { 1024 criteria.add(DEDUPE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1025 } 1026 } 1027 1028 List rows = BasePeer.doSelect(criteria); 1029 List results = new ArrayList (); 1030 1031 for (int i = 0; i < rows.size(); i++) 1032 { 1033 Record row = (Record) rows.get(i); 1034 1035 Class omClass = RModuleIssueTypePeer.getOMClass(); 1036 RModuleIssueType obj1 = (RModuleIssueType) RModuleIssueTypePeer 1037 .row2Object(row, 1, omClass); 1038 omClass = ScarabModulePeer.getOMClass(row, offset); 1039 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1040 .row2Object(row, offset, omClass); 1041 1042 boolean newObject = true; 1043 for (int j = 0; j < results.size(); j++) 1044 { 1045 RModuleIssueType temp_obj1 = (RModuleIssueType)results.get(j); 1046 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1047 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1048 { 1049 newObject = false; 1050 temp_obj2.addRModuleIssueType(obj1); 1051 break; 1052 } 1053 } 1054 if (newObject) 1055 { 1056 obj2.initRModuleIssueTypes(); 1057 obj2.addRModuleIssueType(obj1); 1058 } 1059 results.add(obj1); 1060 } 1061 return results; 1062 } 1063 1064 1065 1066 1067 1078 protected static List doSelectJoinIssueType(Criteria criteria) 1079 throws TorqueException 1080 { 1081 setDbName(criteria); 1082 1083 RModuleIssueTypePeer.addSelectColumns(criteria); 1084 int offset = numColumns + 1; 1085 IssueTypePeer.addSelectColumns(criteria); 1086 1087 1088 criteria.addJoin(RModuleIssueTypePeer.ISSUE_TYPE_ID, 1089 IssueTypePeer.ISSUE_TYPE_ID); 1090 1091 1092 if (criteria.containsKey(ACTIVE)) 1094 { 1095 Object possibleBoolean = criteria.get(ACTIVE); 1096 if (possibleBoolean instanceof Boolean ) 1097 { 1098 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1099 } 1100 } 1101 if (criteria.containsKey(DISPLAY)) 1103 { 1104 Object possibleBoolean = criteria.get(DISPLAY); 1105 if (possibleBoolean instanceof Boolean ) 1106 { 1107 criteria.add(DISPLAY, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1108 } 1109 } 1110 if (criteria.containsKey(DEDUPE)) 1112 { 1113 Object possibleBoolean = criteria.get(DEDUPE); 1114 if (possibleBoolean instanceof Boolean ) 1115 { 1116 criteria.add(DEDUPE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1117 } 1118 } 1119 1120 List rows = BasePeer.doSelect(criteria); 1121 List results = new ArrayList (); 1122 1123 for (int i = 0; i < rows.size(); i++) 1124 { 1125 Record row = (Record) rows.get(i); 1126 1127 Class omClass = RModuleIssueTypePeer.getOMClass(); 1128 RModuleIssueType obj1 = (RModuleIssueType) RModuleIssueTypePeer 1129 .row2Object(row, 1, omClass); 1130 omClass = IssueTypePeer.getOMClass(); 1131 IssueType obj2 = (IssueType)IssueTypePeer 1132 .row2Object(row, offset, omClass); 1133 1134 boolean newObject = true; 1135 for (int j = 0; j < results.size(); j++) 1136 { 1137 RModuleIssueType temp_obj1 = (RModuleIssueType)results.get(j); 1138 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1139 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1140 { 1141 newObject = false; 1142 temp_obj2.addRModuleIssueType(obj1); 1143 break; 1144 } 1145 } 1146 if (newObject) 1147 { 1148 obj2.initRModuleIssueTypes(); 1149 obj2.addRModuleIssueType(obj1); 1150 } 1151 results.add(obj1); 1152 } 1153 return results; 1154 } 1155 1156 1157 1158 1159 1166 protected static TableMap getTableMap() 1167 throws TorqueException 1168 { 1169 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1170 } 1171 1172 private static void setDbName(Criteria crit) 1173 { 1174 if (crit.getDbName() == Torque.getDefaultDB()) 1178 { 1179 crit.setDbName(DATABASE_NAME); 1180 } 1181 } 1182} 1183 | Popular Tags |