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 BaseRIssueTypeAttributePeer 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_ISSUETYPE_ATTRIBUTE"; 47 48 53 public static MapBuilder getMapBuilder() 54 throws TorqueException 55 { 56 return getMapBuilder(RIssueTypeAttributeMapBuilder.CLASS_NAME); 57 } 58 59 60 public static final String ATTRIBUTE_ID; 61 62 public static final String ISSUE_TYPE_ID; 63 64 public static final String ACTIVE; 65 66 public static final String REQUIRED; 67 68 public static final String PREFERRED_ORDER; 69 70 public static final String QUICK_SEARCH; 71 72 public static final String DEFAULT_TEXT_FLAG; 73 74 public static final String LOCKED; 75 76 static 77 { 78 ATTRIBUTE_ID = "SCARAB_R_ISSUETYPE_ATTRIBUTE.ATTRIBUTE_ID"; 79 ISSUE_TYPE_ID = "SCARAB_R_ISSUETYPE_ATTRIBUTE.ISSUE_TYPE_ID"; 80 ACTIVE = "SCARAB_R_ISSUETYPE_ATTRIBUTE.ACTIVE"; 81 REQUIRED = "SCARAB_R_ISSUETYPE_ATTRIBUTE.REQUIRED"; 82 PREFERRED_ORDER = "SCARAB_R_ISSUETYPE_ATTRIBUTE.PREFERRED_ORDER"; 83 QUICK_SEARCH = "SCARAB_R_ISSUETYPE_ATTRIBUTE.QUICK_SEARCH"; 84 DEFAULT_TEXT_FLAG = "SCARAB_R_ISSUETYPE_ATTRIBUTE.DEFAULT_TEXT_FLAG"; 85 LOCKED = "SCARAB_R_ISSUETYPE_ATTRIBUTE.LOCKED"; 86 if (Torque.isInit()) 87 { 88 try 89 { 90 getMapBuilder(RIssueTypeAttributeMapBuilder.CLASS_NAME); 91 } 92 catch (Exception e) 93 { 94 log.error("Could not initialize Peer", e); 95 } 96 } 97 else 98 { 99 Torque.registerMapBuilder(RIssueTypeAttributeMapBuilder.CLASS_NAME); 100 } 101 } 102 103 104 public static final int numColumns = 8; 105 106 107 protected static final String CLASSNAME_DEFAULT = 108 "org.tigris.scarab.om.RIssueTypeAttribute"; 109 110 111 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 112 113 119 private static Class initClass(String className) 120 { 121 Class c = null; 122 try 123 { 124 c = Class.forName(className); 125 } 126 catch (Throwable t) 127 { 128 log.error("A FATAL ERROR has occurred which should not " 129 + "have happened under any circumstance. Please notify " 130 + "the Torque developers <torque-dev@db.apache.org> " 131 + "and give as many details as possible (including the error " 132 + "stack trace).", t); 133 134 if (t instanceof Error ) 136 { 137 throw (Error ) t.fillInStackTrace(); 138 } 139 } 140 return c; 141 } 142 143 153 public static List resultSet2Objects(java.sql.ResultSet results) 154 throws TorqueException 155 { 156 try 157 { 158 QueryDataSet qds = null; 159 List rows = null; 160 try 161 { 162 qds = new QueryDataSet(results); 163 rows = getSelectResults(qds); 164 } 165 finally 166 { 167 if (qds != null) 168 { 169 qds.close(); 170 } 171 } 172 173 return populateObjects(rows); 174 } 175 catch (SQLException e) 176 { 177 throw new TorqueException(e); 178 } 179 catch (DataSetException e) 180 { 181 throw new TorqueException(e); 182 } 183 } 184 185 186 187 194 public static ObjectKey doInsert(Criteria criteria) 195 throws TorqueException 196 { 197 return BaseRIssueTypeAttributePeer 198 .doInsert(criteria, (Connection ) null); 199 } 200 201 211 public static ObjectKey doInsert(Criteria criteria, Connection con) 212 throws TorqueException 213 { 214 if (criteria.containsKey(ACTIVE)) 216 { 217 Object possibleBoolean = criteria.get(ACTIVE); 218 if (possibleBoolean instanceof Boolean ) 219 { 220 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 221 } 222 } 223 if (criteria.containsKey(REQUIRED)) 225 { 226 Object possibleBoolean = criteria.get(REQUIRED); 227 if (possibleBoolean instanceof Boolean ) 228 { 229 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 230 } 231 } 232 if (criteria.containsKey(QUICK_SEARCH)) 234 { 235 Object possibleBoolean = criteria.get(QUICK_SEARCH); 236 if (possibleBoolean instanceof Boolean ) 237 { 238 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 239 } 240 } 241 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 243 { 244 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 245 if (possibleBoolean instanceof Boolean ) 246 { 247 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 248 } 249 } 250 if (criteria.containsKey(LOCKED)) 252 { 253 Object possibleBoolean = criteria.get(LOCKED); 254 if (possibleBoolean instanceof Boolean ) 255 { 256 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 257 } 258 } 259 260 setDbName(criteria); 261 262 if (con == null) 263 { 264 return BasePeer.doInsert(criteria); 265 } 266 else 267 { 268 return BasePeer.doInsert(criteria, con); 269 } 270 } 271 272 279 public static void addSelectColumns(Criteria criteria) 280 throws TorqueException 281 { 282 criteria.addSelectColumn(ATTRIBUTE_ID); 283 criteria.addSelectColumn(ISSUE_TYPE_ID); 284 criteria.addSelectColumn(ACTIVE); 285 criteria.addSelectColumn(REQUIRED); 286 criteria.addSelectColumn(PREFERRED_ORDER); 287 criteria.addSelectColumn(QUICK_SEARCH); 288 criteria.addSelectColumn(DEFAULT_TEXT_FLAG); 289 criteria.addSelectColumn(LOCKED); 290 } 291 292 301 public static RIssueTypeAttribute row2Object(Record row, 302 int offset, 303 Class cls) 304 throws TorqueException 305 { 306 try 307 { 308 RIssueTypeAttribute obj = (RIssueTypeAttribute) cls.newInstance(); 309 RIssueTypeAttributePeer.populateObject(row, offset, obj); 310 obj.setModified(false); 311 obj.setNew(false); 312 313 return obj; 314 } 315 catch (InstantiationException e) 316 { 317 throw new TorqueException(e); 318 } 319 catch (IllegalAccessException e) 320 { 321 throw new TorqueException(e); 322 } 323 } 324 325 334 public static void populateObject(Record row, 335 int offset, 336 RIssueTypeAttribute obj) 337 throws TorqueException 338 { 339 try 340 { 341 obj.setAttributeId(row.getValue(offset + 0).asIntegerObj()); 342 obj.setIssueTypeId(row.getValue(offset + 1).asIntegerObj()); 343 obj.setActive(row.getValue(offset + 2).asBoolean()); 344 obj.setRequired(row.getValue(offset + 3).asBoolean()); 345 obj.setOrder(row.getValue(offset + 4).asInt()); 346 obj.setQuickSearch(row.getValue(offset + 5).asBoolean()); 347 obj.setDefaultTextFlag(row.getValue(offset + 6).asBoolean()); 348 obj.setLocked(row.getValue(offset + 7).asBoolean()); 349 } 350 catch (DataSetException e) 351 { 352 throw new TorqueException(e); 353 } 354 } 355 356 364 public static List doSelect(Criteria criteria) throws TorqueException 365 { 366 return populateObjects(doSelectVillageRecords(criteria)); 367 } 368 369 378 public static List doSelect(Criteria criteria, Connection con) 379 throws TorqueException 380 { 381 return populateObjects(doSelectVillageRecords(criteria, con)); 382 } 383 384 394 public static List doSelectVillageRecords(Criteria criteria) 395 throws TorqueException 396 { 397 return BaseRIssueTypeAttributePeer 398 .doSelectVillageRecords(criteria, (Connection ) null); 399 } 400 401 410 public static List doSelectVillageRecords(Criteria criteria, Connection con) 411 throws TorqueException 412 { 413 if (criteria.getSelectColumns().size() == 0) 414 { 415 addSelectColumns(criteria); 416 } 417 418 if (criteria.containsKey(ACTIVE)) 420 { 421 Object possibleBoolean = criteria.get(ACTIVE); 422 if (possibleBoolean instanceof Boolean ) 423 { 424 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 425 } 426 } 427 if (criteria.containsKey(REQUIRED)) 429 { 430 Object possibleBoolean = criteria.get(REQUIRED); 431 if (possibleBoolean instanceof Boolean ) 432 { 433 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 434 } 435 } 436 if (criteria.containsKey(QUICK_SEARCH)) 438 { 439 Object possibleBoolean = criteria.get(QUICK_SEARCH); 440 if (possibleBoolean instanceof Boolean ) 441 { 442 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 443 } 444 } 445 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 447 { 448 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 449 if (possibleBoolean instanceof Boolean ) 450 { 451 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 452 } 453 } 454 if (criteria.containsKey(LOCKED)) 456 { 457 Object possibleBoolean = criteria.get(LOCKED); 458 if (possibleBoolean instanceof Boolean ) 459 { 460 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 461 } 462 } 463 464 setDbName(criteria); 465 466 if (con == null) 469 { 470 return BasePeer.doSelect(criteria); 471 } 472 else 473 { 474 return BasePeer.doSelect(criteria, con); 475 } 476 } 477 478 485 public static List populateObjects(List records) 486 throws TorqueException 487 { 488 List results = new ArrayList (records.size()); 489 490 for (int i = 0; i < records.size(); i++) 492 { 493 Record row = (Record) records.get(i); 494 results.add(RIssueTypeAttributePeer.row2Object(row, 1, 495 RIssueTypeAttributePeer.getOMClass())); 496 } 497 return results; 498 } 499 500 501 509 public static Class getOMClass() 510 throws TorqueException 511 { 512 return CLASS_DEFAULT; 513 } 514 515 523 public static void doUpdate(Criteria criteria) throws TorqueException 524 { 525 BaseRIssueTypeAttributePeer 526 .doUpdate(criteria, (Connection ) null); 527 } 528 529 540 public static void doUpdate(Criteria criteria, Connection con) 541 throws TorqueException 542 { 543 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 544 selectCriteria.put(ATTRIBUTE_ID, criteria.remove(ATTRIBUTE_ID)); 545 selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID)); 546 if (criteria.containsKey(ACTIVE)) 548 { 549 Object possibleBoolean = criteria.get(ACTIVE); 550 if (possibleBoolean instanceof Boolean ) 551 { 552 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 553 } 554 } 555 if (criteria.containsKey(REQUIRED)) 557 { 558 Object possibleBoolean = criteria.get(REQUIRED); 559 if (possibleBoolean instanceof Boolean ) 560 { 561 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 562 } 563 } 564 if (criteria.containsKey(QUICK_SEARCH)) 566 { 567 Object possibleBoolean = criteria.get(QUICK_SEARCH); 568 if (possibleBoolean instanceof Boolean ) 569 { 570 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 571 } 572 } 573 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 575 { 576 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 577 if (possibleBoolean instanceof Boolean ) 578 { 579 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 580 } 581 } 582 if (criteria.containsKey(LOCKED)) 584 { 585 Object possibleBoolean = criteria.get(LOCKED); 586 if (possibleBoolean instanceof Boolean ) 587 { 588 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 589 } 590 } 591 592 setDbName(criteria); 593 594 if (con == null) 595 { 596 BasePeer.doUpdate(selectCriteria, criteria); 597 } 598 else 599 { 600 BasePeer.doUpdate(selectCriteria, criteria, con); 601 } 602 } 603 604 611 public static void doDelete(Criteria criteria) throws TorqueException 612 { 613 RIssueTypeAttributePeer 614 .doDelete(criteria, (Connection ) null); 615 } 616 617 627 public static void doDelete(Criteria criteria, Connection con) 628 throws TorqueException 629 { 630 if (criteria.containsKey(ACTIVE)) 632 { 633 Object possibleBoolean = criteria.get(ACTIVE); 634 if (possibleBoolean instanceof Boolean ) 635 { 636 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 637 } 638 } 639 if (criteria.containsKey(REQUIRED)) 641 { 642 Object possibleBoolean = criteria.get(REQUIRED); 643 if (possibleBoolean instanceof Boolean ) 644 { 645 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 646 } 647 } 648 if (criteria.containsKey(QUICK_SEARCH)) 650 { 651 Object possibleBoolean = criteria.get(QUICK_SEARCH); 652 if (possibleBoolean instanceof Boolean ) 653 { 654 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 655 } 656 } 657 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 659 { 660 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 661 if (possibleBoolean instanceof Boolean ) 662 { 663 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 664 } 665 } 666 if (criteria.containsKey(LOCKED)) 668 { 669 Object possibleBoolean = criteria.get(LOCKED); 670 if (possibleBoolean instanceof Boolean ) 671 { 672 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 673 } 674 } 675 676 setDbName(criteria); 677 678 if (con == null) 679 { 680 BasePeer.doDelete(criteria); 681 } 682 else 683 { 684 BasePeer.doDelete(criteria, con); 685 } 686 } 687 688 694 public static List doSelect(RIssueTypeAttribute obj) throws TorqueException 695 { 696 return doSelect(buildSelectCriteria(obj)); 697 } 698 699 705 public static void doInsert(RIssueTypeAttribute obj) throws TorqueException 706 { 707 doInsert(buildCriteria(obj)); 708 obj.setNew(false); 709 obj.setModified(false); 710 } 711 712 717 public static void doUpdate(RIssueTypeAttribute obj) throws TorqueException 718 { 719 doUpdate(buildCriteria(obj)); 720 obj.setModified(false); 721 } 722 723 728 public static void doDelete(RIssueTypeAttribute obj) throws TorqueException 729 { 730 doDelete(buildSelectCriteria(obj)); 731 } 732 733 743 public static void doInsert(RIssueTypeAttribute obj, Connection con) 744 throws TorqueException 745 { 746 doInsert(buildCriteria(obj), con); 747 obj.setNew(false); 748 obj.setModified(false); 749 } 750 751 761 public static void doUpdate(RIssueTypeAttribute obj, Connection con) 762 throws TorqueException 763 { 764 doUpdate(buildCriteria(obj), con); 765 obj.setModified(false); 766 } 767 768 778 public static void doDelete(RIssueTypeAttribute obj, Connection con) 779 throws TorqueException 780 { 781 doDelete(buildSelectCriteria(obj), con); 782 } 783 784 791 public static void doDelete(ObjectKey pk) throws TorqueException 792 { 793 BaseRIssueTypeAttributePeer 794 .doDelete(pk, (Connection ) null); 795 } 796 797 807 public static void doDelete(ObjectKey pk, Connection con) 808 throws TorqueException 809 { 810 doDelete(buildCriteria(pk), con); 811 } 812 813 814 public static Criteria buildCriteria( ObjectKey pk ) 815 { 816 Criteria criteria = new Criteria(); 817 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 818 criteria.add(ATTRIBUTE_ID, keys[0]); 819 criteria.add(ISSUE_TYPE_ID, keys[1]); 820 return criteria; 821 } 822 823 824 public static Criteria buildCriteria( RIssueTypeAttribute obj ) 825 { 826 Criteria criteria = new Criteria(DATABASE_NAME); 827 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 828 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 829 criteria.add(ACTIVE, obj.getActive()); 830 criteria.add(REQUIRED, obj.getRequired()); 831 criteria.add(PREFERRED_ORDER, obj.getOrder()); 832 criteria.add(QUICK_SEARCH, obj.getQuickSearch()); 833 criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag()); 834 criteria.add(LOCKED, obj.getLocked()); 835 return criteria; 836 } 837 838 839 public static Criteria buildSelectCriteria( RIssueTypeAttribute obj ) 840 { 841 Criteria criteria = new Criteria(DATABASE_NAME); 842 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 843 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 844 criteria.add(ACTIVE, obj.getActive()); 845 criteria.add(REQUIRED, obj.getRequired()); 846 criteria.add(PREFERRED_ORDER, obj.getOrder()); 847 criteria.add(QUICK_SEARCH, obj.getQuickSearch()); 848 criteria.add(DEFAULT_TEXT_FLAG, obj.getDefaultTextFlag()); 849 criteria.add(LOCKED, obj.getLocked()); 850 return criteria; 851 } 852 853 854 855 864 public static RIssueTypeAttribute retrieveByPK(ObjectKey pk) 865 throws TorqueException, NoRowsException, TooManyRowsException 866 { 867 Connection db = null; 868 RIssueTypeAttribute retVal = null; 869 try 870 { 871 db = Torque.getConnection(DATABASE_NAME); 872 retVal = retrieveByPK(pk, db); 873 } 874 finally 875 { 876 Torque.closeConnection(db); 877 } 878 return(retVal); 879 } 880 881 891 public static RIssueTypeAttribute retrieveByPK(ObjectKey pk, Connection con) 892 throws TorqueException, NoRowsException, TooManyRowsException 893 { 894 Criteria criteria = buildCriteria(pk); 895 List v = doSelect(criteria, con); 896 if (v.size() == 0) 897 { 898 throw new NoRowsException("Failed to select a row."); 899 } 900 else if (v.size() > 1) 901 { 902 throw new TooManyRowsException("Failed to select only one row."); 903 } 904 else 905 { 906 return (RIssueTypeAttribute)v.get(0); 907 } 908 } 909 910 917 public static List retrieveByPKs(List pks) 918 throws TorqueException 919 { 920 Connection db = null; 921 List retVal = null; 922 try 923 { 924 db = Torque.getConnection(DATABASE_NAME); 925 retVal = retrieveByPKs(pks, db); 926 } 927 finally 928 { 929 Torque.closeConnection(db); 930 } 931 return(retVal); 932 } 933 934 942 public static List retrieveByPKs( List pks, Connection dbcon ) 943 throws TorqueException 944 { 945 List objs = null; 946 if (pks == null || pks.size() == 0) 947 { 948 objs = new LinkedList (); 949 } 950 else 951 { 952 Criteria criteria = new Criteria(); 953 Iterator iter = pks.iterator(); 954 while (iter.hasNext()) 955 { 956 ObjectKey pk = (ObjectKey)iter.next(); 957 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 958 Criteria.Criterion c0 = criteria.getNewCriterion( 959 ATTRIBUTE_ID, keys[0], Criteria.EQUAL); 960 Criteria.Criterion c1 = criteria.getNewCriterion( 961 ISSUE_TYPE_ID, keys[1], Criteria.EQUAL); 962 c0.and(c1); 963 criteria.or(c0); 964 } 965 objs = doSelect(criteria, dbcon); 966 } 967 return objs; 968 } 969 970 971 977 public static RIssueTypeAttribute retrieveByPK( 978 Integer attribute_id 979 , Integer issue_type_id 980 ) throws TorqueException 981 { 982 Connection db = null; 983 RIssueTypeAttribute retVal = null; 984 try 985 { 986 db = Torque.getConnection(DATABASE_NAME); 987 retVal = retrieveByPK( 988 attribute_id 989 , issue_type_id 990 , db); 991 } 992 finally 993 { 994 Torque.closeConnection(db); 995 } 996 return(retVal); 997 } 998 999 1006 public static RIssueTypeAttribute retrieveByPK( 1007 Integer attribute_id 1008 , Integer issue_type_id 1009 ,Connection con) throws TorqueException 1010 { 1011 1012 Criteria criteria = new Criteria(5); 1013 criteria.add(ATTRIBUTE_ID, attribute_id); 1014 criteria.add(ISSUE_TYPE_ID, issue_type_id); 1015 List v = doSelect(criteria, con); 1016 if (v.size() != 1) 1017 { 1018 throw new TorqueException("Failed to select one and only one row."); 1019 } 1020 else 1021 { 1022 return (RIssueTypeAttribute) v.get(0); 1023 } 1024 } 1025 1026 1027 1028 1029 1030 1031 1032 1033 1044 protected static List doSelectJoinAttribute(Criteria criteria) 1045 throws TorqueException 1046 { 1047 setDbName(criteria); 1048 1049 RIssueTypeAttributePeer.addSelectColumns(criteria); 1050 int offset = numColumns + 1; 1051 AttributePeer.addSelectColumns(criteria); 1052 1053 1054 criteria.addJoin(RIssueTypeAttributePeer.ATTRIBUTE_ID, 1055 AttributePeer.ATTRIBUTE_ID); 1056 1057 1058 if (criteria.containsKey(ACTIVE)) 1060 { 1061 Object possibleBoolean = criteria.get(ACTIVE); 1062 if (possibleBoolean instanceof Boolean ) 1063 { 1064 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1065 } 1066 } 1067 if (criteria.containsKey(REQUIRED)) 1069 { 1070 Object possibleBoolean = criteria.get(REQUIRED); 1071 if (possibleBoolean instanceof Boolean ) 1072 { 1073 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1074 } 1075 } 1076 if (criteria.containsKey(QUICK_SEARCH)) 1078 { 1079 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1080 if (possibleBoolean instanceof Boolean ) 1081 { 1082 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1083 } 1084 } 1085 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1087 { 1088 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1089 if (possibleBoolean instanceof Boolean ) 1090 { 1091 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1092 } 1093 } 1094 if (criteria.containsKey(LOCKED)) 1096 { 1097 Object possibleBoolean = criteria.get(LOCKED); 1098 if (possibleBoolean instanceof Boolean ) 1099 { 1100 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1101 } 1102 } 1103 1104 List rows = BasePeer.doSelect(criteria); 1105 List results = new ArrayList (); 1106 1107 for (int i = 0; i < rows.size(); i++) 1108 { 1109 Record row = (Record) rows.get(i); 1110 1111 Class omClass = RIssueTypeAttributePeer.getOMClass(); 1112 RIssueTypeAttribute obj1 = (RIssueTypeAttribute) RIssueTypeAttributePeer 1113 .row2Object(row, 1, omClass); 1114 omClass = AttributePeer.getOMClass(); 1115 Attribute obj2 = (Attribute)AttributePeer 1116 .row2Object(row, offset, omClass); 1117 1118 boolean newObject = true; 1119 for (int j = 0; j < results.size(); j++) 1120 { 1121 RIssueTypeAttribute temp_obj1 = (RIssueTypeAttribute)results.get(j); 1122 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1123 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1124 { 1125 newObject = false; 1126 temp_obj2.addRIssueTypeAttribute(obj1); 1127 break; 1128 } 1129 } 1130 if (newObject) 1131 { 1132 obj2.initRIssueTypeAttributes(); 1133 obj2.addRIssueTypeAttribute(obj1); 1134 } 1135 results.add(obj1); 1136 } 1137 return results; 1138 } 1139 1140 1141 1142 1143 1154 protected static List doSelectJoinIssueType(Criteria criteria) 1155 throws TorqueException 1156 { 1157 setDbName(criteria); 1158 1159 RIssueTypeAttributePeer.addSelectColumns(criteria); 1160 int offset = numColumns + 1; 1161 IssueTypePeer.addSelectColumns(criteria); 1162 1163 1164 criteria.addJoin(RIssueTypeAttributePeer.ISSUE_TYPE_ID, 1165 IssueTypePeer.ISSUE_TYPE_ID); 1166 1167 1168 if (criteria.containsKey(ACTIVE)) 1170 { 1171 Object possibleBoolean = criteria.get(ACTIVE); 1172 if (possibleBoolean instanceof Boolean ) 1173 { 1174 criteria.add(ACTIVE, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1175 } 1176 } 1177 if (criteria.containsKey(REQUIRED)) 1179 { 1180 Object possibleBoolean = criteria.get(REQUIRED); 1181 if (possibleBoolean instanceof Boolean ) 1182 { 1183 criteria.add(REQUIRED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1184 } 1185 } 1186 if (criteria.containsKey(QUICK_SEARCH)) 1188 { 1189 Object possibleBoolean = criteria.get(QUICK_SEARCH); 1190 if (possibleBoolean instanceof Boolean ) 1191 { 1192 criteria.add(QUICK_SEARCH, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1193 } 1194 } 1195 if (criteria.containsKey(DEFAULT_TEXT_FLAG)) 1197 { 1198 Object possibleBoolean = criteria.get(DEFAULT_TEXT_FLAG); 1199 if (possibleBoolean instanceof Boolean ) 1200 { 1201 criteria.add(DEFAULT_TEXT_FLAG, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1202 } 1203 } 1204 if (criteria.containsKey(LOCKED)) 1206 { 1207 Object possibleBoolean = criteria.get(LOCKED); 1208 if (possibleBoolean instanceof Boolean ) 1209 { 1210 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1211 } 1212 } 1213 1214 List rows = BasePeer.doSelect(criteria); 1215 List results = new ArrayList (); 1216 1217 for (int i = 0; i < rows.size(); i++) 1218 { 1219 Record row = (Record) rows.get(i); 1220 1221 Class omClass = RIssueTypeAttributePeer.getOMClass(); 1222 RIssueTypeAttribute obj1 = (RIssueTypeAttribute) RIssueTypeAttributePeer 1223 .row2Object(row, 1, omClass); 1224 omClass = IssueTypePeer.getOMClass(); 1225 IssueType obj2 = (IssueType)IssueTypePeer 1226 .row2Object(row, offset, omClass); 1227 1228 boolean newObject = true; 1229 for (int j = 0; j < results.size(); j++) 1230 { 1231 RIssueTypeAttribute temp_obj1 = (RIssueTypeAttribute)results.get(j); 1232 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1233 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1234 { 1235 newObject = false; 1236 temp_obj2.addRIssueTypeAttribute(obj1); 1237 break; 1238 } 1239 } 1240 if (newObject) 1241 { 1242 obj2.initRIssueTypeAttributes(); 1243 obj2.addRIssueTypeAttribute(obj1); 1244 } 1245 results.add(obj1); 1246 } 1247 return results; 1248 } 1249 1250 1251 1252 1253 1260 protected static TableMap getTableMap() 1261 throws TorqueException 1262 { 1263 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1264 } 1265 1266 private static void setDbName(Criteria crit) 1267 { 1268 if (crit.getDbName() == Torque.getDefaultDB()) 1272 { 1273 crit.setDbName(DATABASE_NAME); 1274 } 1275 } 1276} 1277 | Popular Tags |