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 BaseRModuleAttributePeer 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_ATTRIBUTE"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(RModuleAttributeMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String MODULE_ID; 62 63 public static final String ATTRIBUTE_ID; 64 65 public static final String ISSUE_TYPE_ID; 66 67 public static final String DISPLAY_VALUE; 68 69 public static final String ACTIVE; 70 71 public static final String REQUIRED; 72 73 public static final String PREFERRED_ORDER; 74 75 public static final String QUICK_SEARCH; 76 77 public static final String DEFAULT_TEXT_FLAG; 78 79 static 80 { 81 MODULE_ID = "SCARAB_R_MODULE_ATTRIBUTE.MODULE_ID"; 82 ATTRIBUTE_ID = "SCARAB_R_MODULE_ATTRIBUTE.ATTRIBUTE_ID"; 83 ISSUE_TYPE_ID = "SCARAB_R_MODULE_ATTRIBUTE.ISSUE_TYPE_ID"; 84 DISPLAY_VALUE = "SCARAB_R_MODULE_ATTRIBUTE.DISPLAY_VALUE"; 85 ACTIVE = "SCARAB_R_MODULE_ATTRIBUTE.ACTIVE"; 86 REQUIRED = "SCARAB_R_MODULE_ATTRIBUTE.REQUIRED"; 87 PREFERRED_ORDER = "SCARAB_R_MODULE_ATTRIBUTE.PREFERRED_ORDER"; 88 QUICK_SEARCH = "SCARAB_R_MODULE_ATTRIBUTE.QUICK_SEARCH"; 89 DEFAULT_TEXT_FLAG = "SCARAB_R_MODULE_ATTRIBUTE.DEFAULT_TEXT_FLAG"; 90 if (Torque.isInit()) 91 { 92 try 93 { 94 getMapBuilder(RModuleAttributeMapBuilder.CLASS_NAME); 95 } 96 catch (Exception e) 97 { 98 log.error("Could not initialize Peer", e); 99 } 100 } 101 else 102 { 103 Torque.registerMapBuilder(RModuleAttributeMapBuilder.CLASS_NAME); 104 } 105 } 106 107 108 public static final int numColumns = 9; 109 110 111 protected static final String CLASSNAME_DEFAULT = 112 "org.tigris.scarab.om.RModuleAttribute"; 113 114 115 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 116 117 123 private static Class initClass(String className) 124 { 125 Class c = null; 126 try 127 { 128 c = Class.forName(className); 129 } 130 catch (Throwable t) 131 { 132 log.error("A FATAL ERROR has occurred which should not " 133 + "have happened under any circumstance. Please notify " 134 + "the Torque developers <torque-dev@db.apache.org> " 135 + "and give as many details as possible (including the error " 136 + "stack trace).", t); 137 138 if (t instanceof Error ) 140 { 141 throw (Error ) t.fillInStackTrace(); 142 } 143 } 144 return c; 145 } 146 147 157 public static List resultSet2Objects(java.sql.ResultSet results) 158 throws TorqueException 159 { 160 try 161 { 162 QueryDataSet qds = null; 163 List rows = null; 164 try 165 { 166 qds = new QueryDataSet(results); 167 rows = getSelectResults(qds); 168 } 169 finally 170 { 171 if (qds != null) 172 { 173 qds.close(); 174 } 175 } 176 177 return populateObjects(rows); 178 } 179 catch (SQLException e) 180 { 181 throw new TorqueException(e); 182 } 183 catch (DataSetException e) 184 { 185 throw new TorqueException(e); 186 } 187 } 188 189 190 191 198 public static ObjectKey doInsert(Criteria criteria) 199 throws TorqueException 200 { 201 return BaseRModuleAttributePeer 202 .doInsert(criteria, (Connection ) null); 203 } 204 205 215 public static ObjectKey doInsert(Criteria criteria, Connection con) 216 throws TorqueException 217 { 218 if (criteria.containsKey(ACTIVE)) 220 { 221 Object possibleBoolean = criteria.get(ACTIVE); 222 if (possibleBoolean instanceof Boolean ) 223 { 224 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 225 } 226 } 227 if (criteria.containsKey(REQUIRED)) 229 { 230 Object possibleBoolean = criteria.get(REQUIRED); 231 if (possibleBoolean instanceof Boolean ) 232 { 233 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 234 } 235 } 236 if (criteria.containsKey(QUICK_SEARCH)) 238 { 239 Object possibleBoolean = criteria.get(QUICK_SEARCH); 240 if (possibleBoolean instanceof Boolean ) 241 { 242 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 243 } 244 } 245 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 247 { 248 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 249 if (possibleBoolean instanceof Boolean ) 250 { 251 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 252 } 253 } 254 255 setDbName(criteria); 256 257 if (con == null) 258 { 259 return BasePeer.doInsert(criteria); 260 } 261 else 262 { 263 return BasePeer.doInsert(criteria, con); 264 } 265 } 266 267 274 public static void addSelectColumns(Criteria criteria) 275 throws TorqueException 276 { 277 criteria.addSelectColumn(MODULE_ID); 278 criteria.addSelectColumn(ATTRIBUTE_ID); 279 criteria.addSelectColumn(ISSUE_TYPE_ID); 280 criteria.addSelectColumn(DISPLAY_VALUE); 281 criteria.addSelectColumn(ACTIVE); 282 criteria.addSelectColumn(REQUIRED); 283 criteria.addSelectColumn(PREFERRED_ORDER); 284 criteria.addSelectColumn(QUICK_SEARCH); 285 criteria.addSelectColumn(DEFAULT_TEXT_FLAG); 286 } 287 288 297 public static RModuleAttribute row2Object(Record row, 298 int offset, 299 Class cls) 300 throws TorqueException 301 { 302 try 303 { 304 RModuleAttribute obj = (RModuleAttribute) cls.newInstance(); 305 RModuleAttributePeer.populateObject(row, offset, obj); 306 obj.setModified(false); 307 obj.setNew(false); 308 309 return obj; 310 } 311 catch (InstantiationException e) 312 { 313 throw new TorqueException(e); 314 } 315 catch (IllegalAccessException e) 316 { 317 throw new TorqueException(e); 318 } 319 } 320 321 330 public static void populateObject(Record row, 331 int offset, 332 RModuleAttribute obj) 333 throws TorqueException 334 { 335 try 336 { 337 obj.setModuleId(row.getValue(offset + 0).asIntegerObj()); 338 obj.setAttributeId(row.getValue(offset + 1).asIntegerObj()); 339 obj.setIssueTypeId(row.getValue(offset + 2).asIntegerObj()); 340 obj.setDisplayValue(row.getValue(offset + 3).asString()); 341 obj.setActive(row.getValue(offset + 4).asBoolean()); 342 obj.setRequired(row.getValue(offset + 5).asBoolean()); 343 obj.setOrder(row.getValue(offset + 6).asInt()); 344 obj.setQuickSearch(row.getValue(offset + 7).asBoolean()); 345 obj.setDefaultTextFlag(row.getValue(offset + 8).asBoolean()); 346 } 347 catch (DataSetException e) 348 { 349 throw new TorqueException(e); 350 } 351 } 352 353 361 public static List doSelect(Criteria criteria) throws TorqueException 362 { 363 return populateObjects(doSelectVillageRecords(criteria)); 364 } 365 366 375 public static List doSelect(Criteria criteria, Connection con) 376 throws TorqueException 377 { 378 return populateObjects(doSelectVillageRecords(criteria, con)); 379 } 380 381 391 public static List doSelectVillageRecords(Criteria criteria) 392 throws TorqueException 393 { 394 return BaseRModuleAttributePeer 395 .doSelectVillageRecords(criteria, (Connection ) null); 396 } 397 398 407 public static List doSelectVillageRecords(Criteria criteria, Connection con) 408 throws TorqueException 409 { 410 if (criteria.getSelectColumns().size() == 0) 411 { 412 addSelectColumns(criteria); 413 } 414 415 if (criteria.containsKey(ACTIVE)) 417 { 418 Object possibleBoolean = criteria.get(ACTIVE); 419 if (possibleBoolean instanceof Boolean ) 420 { 421 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 422 } 423 } 424 if (criteria.containsKey(REQUIRED)) 426 { 427 Object possibleBoolean = criteria.get(REQUIRED); 428 if (possibleBoolean instanceof Boolean ) 429 { 430 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 431 } 432 } 433 if (criteria.containsKey(QUICK_SEARCH)) 435 { 436 Object possibleBoolean = criteria.get(QUICK_SEARCH); 437 if (possibleBoolean instanceof Boolean ) 438 { 439 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 440 } 441 } 442 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 444 { 445 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 446 if (possibleBoolean instanceof Boolean ) 447 { 448 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 449 } 450 } 451 452 setDbName(criteria); 453 454 if (con == null) 457 { 458 return BasePeer.doSelect(criteria); 459 } 460 else 461 { 462 return BasePeer.doSelect(criteria, con); 463 } 464 } 465 466 473 public static List populateObjects(List records) 474 throws TorqueException 475 { 476 List results = new ArrayList (records.size()); 477 478 for (int i = 0; i < records.size(); i++) 480 { 481 Record row = (Record) records.get(i); 482 results.add(RModuleAttributePeer.row2Object(row, 1, 483 RModuleAttributePeer.getOMClass())); 484 } 485 return results; 486 } 487 488 489 497 public static Class getOMClass() 498 throws TorqueException 499 { 500 return CLASS_DEFAULT; 501 } 502 503 511 public static void doUpdate(Criteria criteria) throws TorqueException 512 { 513 BaseRModuleAttributePeer 514 .doUpdate(criteria, (Connection ) null); 515 } 516 517 528 public static void doUpdate(Criteria criteria, Connection con) 529 throws TorqueException 530 { 531 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 532 selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID)); 533 selectCriteria.put(ATTRIBUTE_ID, criteria.remove(ATTRIBUTE_ID)); 534 selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID)); 535 if (criteria.containsKey(ACTIVE)) 537 { 538 Object possibleBoolean = criteria.get(ACTIVE); 539 if (possibleBoolean instanceof Boolean ) 540 { 541 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 542 } 543 } 544 if (criteria.containsKey(REQUIRED)) 546 { 547 Object possibleBoolean = criteria.get(REQUIRED); 548 if (possibleBoolean instanceof Boolean ) 549 { 550 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 551 } 552 } 553 if (criteria.containsKey(QUICK_SEARCH)) 555 { 556 Object possibleBoolean = criteria.get(QUICK_SEARCH); 557 if (possibleBoolean instanceof Boolean ) 558 { 559 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 560 } 561 } 562 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 564 { 565 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 566 if (possibleBoolean instanceof Boolean ) 567 { 568 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 569 } 570 } 571 572 setDbName(criteria); 573 574 if (con == null) 575 { 576 BasePeer.doUpdate(selectCriteria, criteria); 577 } 578 else 579 { 580 BasePeer.doUpdate(selectCriteria, criteria, con); 581 } 582 } 583 584 591 public static void doDelete(Criteria criteria) throws TorqueException 592 { 593 RModuleAttributePeer 594 .doDelete(criteria, (Connection ) null); 595 } 596 597 607 public static void doDelete(Criteria criteria, Connection con) 608 throws TorqueException 609 { 610 if (criteria.containsKey(ACTIVE)) 612 { 613 Object possibleBoolean = criteria.get(ACTIVE); 614 if (possibleBoolean instanceof Boolean ) 615 { 616 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 617 } 618 } 619 if (criteria.containsKey(REQUIRED)) 621 { 622 Object possibleBoolean = criteria.get(REQUIRED); 623 if (possibleBoolean instanceof Boolean ) 624 { 625 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 626 } 627 } 628 if (criteria.containsKey(QUICK_SEARCH)) 630 { 631 Object possibleBoolean = criteria.get(QUICK_SEARCH); 632 if (possibleBoolean instanceof Boolean ) 633 { 634 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 635 } 636 } 637 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 639 { 640 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 641 if (possibleBoolean instanceof Boolean ) 642 { 643 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 644 } 645 } 646 647 setDbName(criteria); 648 649 if (con == null) 650 { 651 BasePeer.doDelete(criteria); 652 } 653 else 654 { 655 BasePeer.doDelete(criteria, con); 656 } 657 } 658 659 665 public static List doSelect(RModuleAttribute obj) throws TorqueException 666 { 667 return doSelect(buildSelectCriteria(obj)); 668 } 669 670 676 public static void doInsert(RModuleAttribute obj) throws TorqueException 677 { 678 doInsert(buildCriteria(obj)); 679 obj.setNew(false); 680 obj.setModified(false); 681 } 682 683 688 public static void doUpdate(RModuleAttribute obj) throws TorqueException 689 { 690 doUpdate(buildCriteria(obj)); 691 obj.setModified(false); 692 } 693 694 699 public static void doDelete(RModuleAttribute obj) throws TorqueException 700 { 701 doDelete(buildSelectCriteria(obj)); 702 } 703 704 714 public static void doInsert(RModuleAttribute obj, Connection con) 715 throws TorqueException 716 { 717 doInsert(buildCriteria(obj), con); 718 obj.setNew(false); 719 obj.setModified(false); 720 } 721 722 732 public static void doUpdate(RModuleAttribute obj, Connection con) 733 throws TorqueException 734 { 735 doUpdate(buildCriteria(obj), con); 736 obj.setModified(false); 737 } 738 739 749 public static void doDelete(RModuleAttribute obj, Connection con) 750 throws TorqueException 751 { 752 doDelete(buildSelectCriteria(obj), con); 753 } 754 755 762 public static void doDelete(ObjectKey pk) throws TorqueException 763 { 764 BaseRModuleAttributePeer 765 .doDelete(pk, (Connection ) null); 766 } 767 768 778 public static void doDelete(ObjectKey pk, Connection con) 779 throws TorqueException 780 { 781 doDelete(buildCriteria(pk), con); 782 } 783 784 785 public static Criteria buildCriteria( ObjectKey pk ) 786 { 787 Criteria criteria = new Criteria(); 788 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 789 criteria.add(MODULE_ID, keys[0]); 790 criteria.add(ATTRIBUTE_ID, keys[1]); 791 criteria.add(ISSUE_TYPE_ID, keys[2]); 792 return criteria; 793 } 794 795 796 public static Criteria buildCriteria( RModuleAttribute obj ) 797 { 798 Criteria criteria = new Criteria(DATABASE_NAME); 799 criteria.add(MODULE_ID, obj.getModuleId()); 800 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 801 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 802 criteria.add(DISPLAY_VALUE, obj.getDisplayValue()); 803 criteria.add(ACTIVE, obj.getActive()); 804 criteria.add(REQUIRED, obj.getRequired()); 805 criteria.add(PREFERRED_ORDER, obj.getOrder()); 806 criteria.add(QUICK_SEARCH, obj.getQuickSearch()); 807 criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag()); 808 return criteria; 809 } 810 811 812 public static Criteria buildSelectCriteria( RModuleAttribute obj ) 813 { 814 Criteria criteria = new Criteria(DATABASE_NAME); 815 criteria.add(MODULE_ID, obj.getModuleId()); 816 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 817 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 818 criteria.add(DISPLAY_VALUE, obj.getDisplayValue()); 819 criteria.add(ACTIVE, obj.getActive()); 820 criteria.add(REQUIRED, obj.getRequired()); 821 criteria.add(PREFERRED_ORDER, obj.getOrder()); 822 criteria.add(QUICK_SEARCH, obj.getQuickSearch()); 823 criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag()); 824 return criteria; 825 } 826 827 828 829 838 public static RModuleAttribute retrieveByPK(ObjectKey pk) 839 throws TorqueException, NoRowsException, TooManyRowsException 840 { 841 Connection db = null; 842 RModuleAttribute retVal = null; 843 try 844 { 845 db = Torque.getConnection(DATABASE_NAME); 846 retVal = retrieveByPK(pk, db); 847 } 848 finally 849 { 850 Torque.closeConnection(db); 851 } 852 return(retVal); 853 } 854 855 865 public static RModuleAttribute retrieveByPK(ObjectKey pk, Connection con) 866 throws TorqueException, NoRowsException, TooManyRowsException 867 { 868 Criteria criteria = buildCriteria(pk); 869 List v = doSelect(criteria, con); 870 if (v.size() == 0) 871 { 872 throw new NoRowsException("Failed to select a row."); 873 } 874 else if (v.size() > 1) 875 { 876 throw new TooManyRowsException("Failed to select only one row."); 877 } 878 else 879 { 880 return (RModuleAttribute)v.get(0); 881 } 882 } 883 884 891 public static List retrieveByPKs(List pks) 892 throws TorqueException 893 { 894 Connection db = null; 895 List retVal = null; 896 try 897 { 898 db = Torque.getConnection(DATABASE_NAME); 899 retVal = retrieveByPKs(pks, db); 900 } 901 finally 902 { 903 Torque.closeConnection(db); 904 } 905 return(retVal); 906 } 907 908 916 public static List retrieveByPKs( List pks, Connection dbcon ) 917 throws TorqueException 918 { 919 List objs = null; 920 if (pks == null || pks.size() == 0) 921 { 922 objs = new LinkedList (); 923 } 924 else 925 { 926 Criteria criteria = new Criteria(); 927 Iterator iter = pks.iterator(); 928 while (iter.hasNext()) 929 { 930 ObjectKey pk = (ObjectKey)iter.next(); 931 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 932 Criteria.Criterion c0 = criteria.getNewCriterion( 933 MODULE_ID, keys[0], Criteria.EQUAL); 934 Criteria.Criterion c1 = criteria.getNewCriterion( 935 ATTRIBUTE_ID, keys[1], Criteria.EQUAL); 936 c0.and(c1); 937 Criteria.Criterion c2 = criteria.getNewCriterion( 938 ISSUE_TYPE_ID, keys[2], Criteria.EQUAL); 939 c1.and(c2); 940 criteria.or(c0); 941 } 942 objs = doSelect(criteria, dbcon); 943 } 944 return objs; 945 } 946 947 948 955 public static RModuleAttribute retrieveByPK( 956 Integer module_id 957 , Integer attribute_id 958 , Integer issue_type_id 959 ) throws TorqueException 960 { 961 Connection db = null; 962 RModuleAttribute retVal = null; 963 try 964 { 965 db = Torque.getConnection(DATABASE_NAME); 966 retVal = retrieveByPK( 967 module_id 968 , attribute_id 969 , issue_type_id 970 , db); 971 } 972 finally 973 { 974 Torque.closeConnection(db); 975 } 976 return(retVal); 977 } 978 979 987 public static RModuleAttribute retrieveByPK( 988 Integer module_id 989 , Integer attribute_id 990 , Integer issue_type_id 991 ,Connection con) throws TorqueException 992 { 993 994 Criteria criteria = new Criteria(5); 995 criteria.add(MODULE_ID, module_id); 996 criteria.add(ATTRIBUTE_ID, attribute_id); 997 criteria.add(ISSUE_TYPE_ID, issue_type_id); 998 List v = doSelect(criteria, con); 999 if (v.size() != 1) 1000 { 1001 throw new TorqueException("Failed to select one and only one row."); 1002 } 1003 else 1004 { 1005 return (RModuleAttribute) v.get(0); 1006 } 1007 } 1008 1009 1010 1011 1012 1013 1014 1015 1016 1027 protected static List doSelectJoinAttribute(Criteria criteria) 1028 throws TorqueException 1029 { 1030 setDbName(criteria); 1031 1032 RModuleAttributePeer.addSelectColumns(criteria); 1033 int offset = numColumns + 1; 1034 AttributePeer.addSelectColumns(criteria); 1035 1036 1037 criteria.addJoin(RModuleAttributePeer.ATTRIBUTE_ID, 1038 AttributePeer.ATTRIBUTE_ID); 1039 1040 1041 if (criteria.containsKey(ACTIVE)) 1043 { 1044 Object possibleBoolean = criteria.get(ACTIVE); 1045 if (possibleBoolean instanceof Boolean ) 1046 { 1047 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1048 } 1049 } 1050 if (criteria.containsKey(REQUIRED)) 1052 { 1053 Object possibleBoolean = criteria.get(REQUIRED); 1054 if (possibleBoolean instanceof Boolean ) 1055 { 1056 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1057 } 1058 } 1059 if (criteria.containsKey(QUICK_SEARCH)) 1061 { 1062 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1063 if (possibleBoolean instanceof Boolean ) 1064 { 1065 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1066 } 1067 } 1068 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1070 { 1071 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1072 if (possibleBoolean instanceof Boolean ) 1073 { 1074 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1075 } 1076 } 1077 1078 List rows = BasePeer.doSelect(criteria); 1079 List results = new ArrayList (); 1080 1081 for (int i = 0; i < rows.size(); i++) 1082 { 1083 Record row = (Record) rows.get(i); 1084 1085 Class omClass = RModuleAttributePeer.getOMClass(); 1086 RModuleAttribute obj1 = (RModuleAttribute) RModuleAttributePeer 1087 .row2Object(row, 1, omClass); 1088 omClass = AttributePeer.getOMClass(); 1089 Attribute obj2 = (Attribute)AttributePeer 1090 .row2Object(row, offset, omClass); 1091 1092 boolean newObject = true; 1093 for (int j = 0; j < results.size(); j++) 1094 { 1095 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1096 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1097 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1098 { 1099 newObject = false; 1100 temp_obj2.addRModuleAttribute(obj1); 1101 break; 1102 } 1103 } 1104 if (newObject) 1105 { 1106 obj2.initRModuleAttributes(); 1107 obj2.addRModuleAttribute(obj1); 1108 } 1109 results.add(obj1); 1110 } 1111 return results; 1112 } 1113 1114 1115 1116 1117 1128 protected static List doSelectJoinScarabModule(Criteria criteria) 1129 throws TorqueException 1130 { 1131 setDbName(criteria); 1132 1133 RModuleAttributePeer.addSelectColumns(criteria); 1134 int offset = numColumns + 1; 1135 ScarabModulePeer.addSelectColumns(criteria); 1136 1137 1138 criteria.addJoin(RModuleAttributePeer.MODULE_ID, 1139 ScarabModulePeer.MODULE_ID); 1140 1141 1142 if (criteria.containsKey(ACTIVE)) 1144 { 1145 Object possibleBoolean = criteria.get(ACTIVE); 1146 if (possibleBoolean instanceof Boolean ) 1147 { 1148 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1149 } 1150 } 1151 if (criteria.containsKey(REQUIRED)) 1153 { 1154 Object possibleBoolean = criteria.get(REQUIRED); 1155 if (possibleBoolean instanceof Boolean ) 1156 { 1157 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1158 } 1159 } 1160 if (criteria.containsKey(QUICK_SEARCH)) 1162 { 1163 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1164 if (possibleBoolean instanceof Boolean ) 1165 { 1166 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1167 } 1168 } 1169 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1171 { 1172 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1173 if (possibleBoolean instanceof Boolean ) 1174 { 1175 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1176 } 1177 } 1178 1179 List rows = BasePeer.doSelect(criteria); 1180 List results = new ArrayList (); 1181 1182 for (int i = 0; i < rows.size(); i++) 1183 { 1184 Record row = (Record) rows.get(i); 1185 1186 Class omClass = RModuleAttributePeer.getOMClass(); 1187 RModuleAttribute obj1 = (RModuleAttribute) RModuleAttributePeer 1188 .row2Object(row, 1, omClass); 1189 omClass = ScarabModulePeer.getOMClass(row, offset); 1190 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1191 .row2Object(row, offset, omClass); 1192 1193 boolean newObject = true; 1194 for (int j = 0; j < results.size(); j++) 1195 { 1196 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1197 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1198 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1199 { 1200 newObject = false; 1201 temp_obj2.addRModuleAttribute(obj1); 1202 break; 1203 } 1204 } 1205 if (newObject) 1206 { 1207 obj2.initRModuleAttributes(); 1208 obj2.addRModuleAttribute(obj1); 1209 } 1210 results.add(obj1); 1211 } 1212 return results; 1213 } 1214 1215 1216 1217 1218 1229 protected static List doSelectJoinIssueType(Criteria criteria) 1230 throws TorqueException 1231 { 1232 setDbName(criteria); 1233 1234 RModuleAttributePeer.addSelectColumns(criteria); 1235 int offset = numColumns + 1; 1236 IssueTypePeer.addSelectColumns(criteria); 1237 1238 1239 criteria.addJoin(RModuleAttributePeer.ISSUE_TYPE_ID, 1240 IssueTypePeer.ISSUE_TYPE_ID); 1241 1242 1243 if (criteria.containsKey(ACTIVE)) 1245 { 1246 Object possibleBoolean = criteria.get(ACTIVE); 1247 if (possibleBoolean instanceof Boolean ) 1248 { 1249 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1250 } 1251 } 1252 if (criteria.containsKey(REQUIRED)) 1254 { 1255 Object possibleBoolean = criteria.get(REQUIRED); 1256 if (possibleBoolean instanceof Boolean ) 1257 { 1258 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1259 } 1260 } 1261 if (criteria.containsKey(QUICK_SEARCH)) 1263 { 1264 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1265 if (possibleBoolean instanceof Boolean ) 1266 { 1267 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1268 } 1269 } 1270 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1272 { 1273 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1274 if (possibleBoolean instanceof Boolean ) 1275 { 1276 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1277 } 1278 } 1279 1280 List rows = BasePeer.doSelect(criteria); 1281 List results = new ArrayList (); 1282 1283 for (int i = 0; i < rows.size(); i++) 1284 { 1285 Record row = (Record) rows.get(i); 1286 1287 Class omClass = RModuleAttributePeer.getOMClass(); 1288 RModuleAttribute obj1 = (RModuleAttribute) RModuleAttributePeer 1289 .row2Object(row, 1, omClass); 1290 omClass = IssueTypePeer.getOMClass(); 1291 IssueType obj2 = (IssueType)IssueTypePeer 1292 .row2Object(row, offset, omClass); 1293 1294 boolean newObject = true; 1295 for (int j = 0; j < results.size(); j++) 1296 { 1297 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1298 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1299 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1300 { 1301 newObject = false; 1302 temp_obj2.addRModuleAttribute(obj1); 1303 break; 1304 } 1305 } 1306 if (newObject) 1307 { 1308 obj2.initRModuleAttributes(); 1309 obj2.addRModuleAttribute(obj1); 1310 } 1311 results.add(obj1); 1312 } 1313 return results; 1314 } 1315 1316 1317 1318 1319 1320 1321 1322 1323 1334 protected static List doSelectJoinAllExceptAttribute(Criteria criteria) 1335 throws TorqueException 1336 { 1337 setDbName(criteria); 1338 1339 addSelectColumns(criteria); 1340 int offset2 = numColumns + 1; 1341 1342 1343 ScarabModulePeer.addSelectColumns(criteria); 1344 int offset3 = offset2 + ScarabModulePeer.numColumns; 1345 1346 IssueTypePeer.addSelectColumns(criteria); 1347 int offset4 = offset3 + IssueTypePeer.numColumns; 1348 if (criteria.containsKey(ACTIVE)) 1350 { 1351 Object possibleBoolean = criteria.get(ACTIVE); 1352 if (possibleBoolean instanceof Boolean ) 1353 { 1354 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1355 } 1356 } 1357 if (criteria.containsKey(REQUIRED)) 1359 { 1360 Object possibleBoolean = criteria.get(REQUIRED); 1361 if (possibleBoolean instanceof Boolean ) 1362 { 1363 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1364 } 1365 } 1366 if (criteria.containsKey(QUICK_SEARCH)) 1368 { 1369 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1370 if (possibleBoolean instanceof Boolean ) 1371 { 1372 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1373 } 1374 } 1375 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1377 { 1378 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1379 if (possibleBoolean instanceof Boolean ) 1380 { 1381 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1382 } 1383 } 1384 1385 List rows = BasePeer.doSelect(criteria); 1386 List results = new ArrayList (); 1387 1388 for (int i = 0; i < rows.size(); i++) 1389 { 1390 Record row = (Record)rows.get(i); 1391 1392 Class omClass = RModuleAttributePeer.getOMClass(); 1393 RModuleAttribute obj1 = (RModuleAttribute)RModuleAttributePeer 1394 .row2Object(row, 1, omClass); 1395 1396 1397 1398 1399 1400 omClass = ScarabModulePeer.getOMClass(row, offset2); 1401 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1402 .row2Object( row, offset2, omClass); 1403 1404 boolean newObject = true; 1405 for (int j = 0; j < results.size(); j++) 1406 { 1407 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1408 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1409 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1410 { 1411 newObject = false; 1412 temp_obj2.addRModuleAttribute(obj1); 1413 break; 1414 } 1415 } 1416 if (newObject) 1417 { 1418 obj2.initRModuleAttributes(); 1419 obj2.addRModuleAttribute(obj1); 1420 } 1421 1422 1423 1424 1425 omClass = IssueTypePeer.getOMClass(); 1426 IssueType obj3 = (IssueType)IssueTypePeer 1427 .row2Object( row, offset3, omClass); 1428 1429 newObject = true; 1430 for (int j = 0; j < results.size(); j++) 1431 { 1432 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1433 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1434 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1435 { 1436 newObject = false; 1437 temp_obj3.addRModuleAttribute(obj1); 1438 break; 1439 } 1440 } 1441 if (newObject) 1442 { 1443 obj3.initRModuleAttributes(); 1444 obj3.addRModuleAttribute(obj1); 1445 } 1446 results.add(obj1); 1447 } 1448 return results; 1449 } 1450 1451 1452 1453 1454 1455 1466 protected static List doSelectJoinAllExceptScarabModule(Criteria criteria) 1467 throws TorqueException 1468 { 1469 setDbName(criteria); 1470 1471 addSelectColumns(criteria); 1472 int offset2 = numColumns + 1; 1473 1474 AttributePeer.addSelectColumns(criteria); 1475 int offset3 = offset2 + AttributePeer.numColumns; 1476 1477 1478 IssueTypePeer.addSelectColumns(criteria); 1479 int offset4 = offset3 + IssueTypePeer.numColumns; 1480 if (criteria.containsKey(ACTIVE)) 1482 { 1483 Object possibleBoolean = criteria.get(ACTIVE); 1484 if (possibleBoolean instanceof Boolean ) 1485 { 1486 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1487 } 1488 } 1489 if (criteria.containsKey(REQUIRED)) 1491 { 1492 Object possibleBoolean = criteria.get(REQUIRED); 1493 if (possibleBoolean instanceof Boolean ) 1494 { 1495 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1496 } 1497 } 1498 if (criteria.containsKey(QUICK_SEARCH)) 1500 { 1501 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1502 if (possibleBoolean instanceof Boolean ) 1503 { 1504 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1505 } 1506 } 1507 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1509 { 1510 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1511 if (possibleBoolean instanceof Boolean ) 1512 { 1513 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1514 } 1515 } 1516 1517 List rows = BasePeer.doSelect(criteria); 1518 List results = new ArrayList (); 1519 1520 for (int i = 0; i < rows.size(); i++) 1521 { 1522 Record row = (Record)rows.get(i); 1523 1524 Class omClass = RModuleAttributePeer.getOMClass(); 1525 RModuleAttribute obj1 = (RModuleAttribute)RModuleAttributePeer 1526 .row2Object(row, 1, omClass); 1527 1528 1529 1530 1531 omClass = AttributePeer.getOMClass(); 1532 Attribute obj2 = (Attribute)AttributePeer 1533 .row2Object( row, offset2, omClass); 1534 1535 boolean newObject = true; 1536 for (int j = 0; j < results.size(); j++) 1537 { 1538 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1539 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1540 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1541 { 1542 newObject = false; 1543 temp_obj2.addRModuleAttribute(obj1); 1544 break; 1545 } 1546 } 1547 if (newObject) 1548 { 1549 obj2.initRModuleAttributes(); 1550 obj2.addRModuleAttribute(obj1); 1551 } 1552 1553 1554 1555 1556 1557 omClass = IssueTypePeer.getOMClass(); 1558 IssueType obj3 = (IssueType)IssueTypePeer 1559 .row2Object( row, offset3, omClass); 1560 1561 newObject = true; 1562 for (int j = 0; j < results.size(); j++) 1563 { 1564 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1565 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1566 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1567 { 1568 newObject = false; 1569 temp_obj3.addRModuleAttribute(obj1); 1570 break; 1571 } 1572 } 1573 if (newObject) 1574 { 1575 obj3.initRModuleAttributes(); 1576 obj3.addRModuleAttribute(obj1); 1577 } 1578 results.add(obj1); 1579 } 1580 return results; 1581 } 1582 1583 1584 1585 1586 1587 1598 protected static List doSelectJoinAllExceptIssueType(Criteria criteria) 1599 throws TorqueException 1600 { 1601 setDbName(criteria); 1602 1603 addSelectColumns(criteria); 1604 int offset2 = numColumns + 1; 1605 1606 AttributePeer.addSelectColumns(criteria); 1607 int offset3 = offset2 + AttributePeer.numColumns; 1608 1609 ScarabModulePeer.addSelectColumns(criteria); 1610 int offset4 = offset3 + ScarabModulePeer.numColumns; 1611 1612 if (criteria.containsKey(ACTIVE)) 1614 { 1615 Object possibleBoolean = criteria.get(ACTIVE); 1616 if (possibleBoolean instanceof Boolean ) 1617 { 1618 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1619 } 1620 } 1621 if (criteria.containsKey(REQUIRED)) 1623 { 1624 Object possibleBoolean = criteria.get(REQUIRED); 1625 if (possibleBoolean instanceof Boolean ) 1626 { 1627 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1628 } 1629 } 1630 if (criteria.containsKey(QUICK_SEARCH)) 1632 { 1633 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1634 if (possibleBoolean instanceof Boolean ) 1635 { 1636 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1637 } 1638 } 1639 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1641 { 1642 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1643 if (possibleBoolean instanceof Boolean ) 1644 { 1645 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1646 } 1647 } 1648 1649 List rows = BasePeer.doSelect(criteria); 1650 List results = new ArrayList (); 1651 1652 for (int i = 0; i < rows.size(); i++) 1653 { 1654 Record row = (Record)rows.get(i); 1655 1656 Class omClass = RModuleAttributePeer.getOMClass(); 1657 RModuleAttribute obj1 = (RModuleAttribute)RModuleAttributePeer 1658 .row2Object(row, 1, omClass); 1659 1660 1661 1662 1663 omClass = AttributePeer.getOMClass(); 1664 Attribute obj2 = (Attribute)AttributePeer 1665 .row2Object( row, offset2, omClass); 1666 1667 boolean newObject = true; 1668 for (int j = 0; j < results.size(); j++) 1669 { 1670 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1671 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1672 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1673 { 1674 newObject = false; 1675 temp_obj2.addRModuleAttribute(obj1); 1676 break; 1677 } 1678 } 1679 if (newObject) 1680 { 1681 obj2.initRModuleAttributes(); 1682 obj2.addRModuleAttribute(obj1); 1683 } 1684 1685 1686 1687 1688 omClass = ScarabModulePeer.getOMClass(row, offset3); 1689 ScarabModule obj3 = (ScarabModule)ScarabModulePeer 1690 .row2Object( row, offset3, omClass); 1691 1692 newObject = true; 1693 for (int j = 0; j < results.size(); j++) 1694 { 1695 RModuleAttribute temp_obj1 = (RModuleAttribute)results.get(j); 1696 ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule(); 1697 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1698 { 1699 newObject = false; 1700 temp_obj3.addRModuleAttribute(obj1); 1701 break; 1702 } 1703 } 1704 if (newObject) 1705 { 1706 obj3.initRModuleAttributes(); 1707 obj3.addRModuleAttribute(obj1); 1708 } 1709 1710 results.add(obj1); 1711 } 1712 return results; 1713 } 1714 1715 1716 1723 protected static TableMap getTableMap() 1724 throws TorqueException 1725 { 1726 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1727 } 1728 1729 private static void setDbName(Criteria crit) 1730 { 1731 if (crit.getDbName() == Torque.getDefaultDB()) 1735 { 1736 crit.setDbName(DATABASE_NAME); 1737 } 1738 } 1739} 1740 | Popular Tags |