1 package org.tigris.scarab.om; 2 3 import java.math.BigDecimal ; 4 import java.sql.Connection ; 5 import java.sql.SQLException ; 6 import java.util.ArrayList ; 7 import java.util.Date ; 8 import java.util.Iterator ; 9 import java.util.LinkedList ; 10 import java.util.List ; 11 12 import org.apache.torque.NoRowsException; 13 import org.apache.torque.TooManyRowsException; 14 import org.apache.torque.Torque; 15 import org.apache.torque.TorqueException; 16 import org.apache.torque.map.MapBuilder; 17 import org.apache.torque.map.TableMap; 18 import org.apache.torque.om.DateKey; 19 import org.apache.torque.om.NumberKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.ObjectKey; 22 import org.apache.torque.om.SimpleKey; 23 import org.apache.torque.util.BasePeer; 24 import org.apache.torque.util.Criteria; 25 26 import com.workingdogs.village.DataSetException; 27 import com.workingdogs.village.QueryDataSet; 28 import com.workingdogs.village.Record; 29 30 import org.tigris.scarab.om.map.*; 32 33 34 35 36 37 38 40 public abstract class BaseReportPeer 41 extends BasePeer 42 { 43 44 45 public static final String DATABASE_NAME = "scarab"; 46 47 48 public static final String TABLE_NAME = "SCARAB_REPORT"; 49 50 55 public static MapBuilder getMapBuilder() 56 throws TorqueException 57 { 58 return getMapBuilder(ReportMapBuilder.CLASS_NAME); 59 } 60 61 62 public static final String REPORT_ID; 63 64 public static final String USER_ID; 65 66 public static final String MODULE_ID; 67 68 public static final String ISSUE_TYPE_ID; 69 70 public static final String NAME; 71 72 public static final String DESCRIPTION; 73 74 public static final String QUERY_STRING; 75 76 public static final String SCOPE_ID; 77 78 public static final String DELETED; 79 80 public static final String CREATED_DATE; 81 82 static 83 { 84 REPORT_ID = "SCARAB_REPORT.REPORT_ID"; 85 USER_ID = "SCARAB_REPORT.USER_ID"; 86 MODULE_ID = "SCARAB_REPORT.MODULE_ID"; 87 ISSUE_TYPE_ID = "SCARAB_REPORT.ISSUE_TYPE_ID"; 88 NAME = "SCARAB_REPORT.NAME"; 89 DESCRIPTION = "SCARAB_REPORT.DESCRIPTION"; 90 QUERY_STRING = "SCARAB_REPORT.QUERY_STRING"; 91 SCOPE_ID = "SCARAB_REPORT.SCOPE_ID"; 92 DELETED = "SCARAB_REPORT.DELETED"; 93 CREATED_DATE = "SCARAB_REPORT.CREATED_DATE"; 94 if (Torque.isInit()) 95 { 96 try 97 { 98 getMapBuilder(ReportMapBuilder.CLASS_NAME); 99 } 100 catch (Exception e) 101 { 102 log.error("Could not initialize Peer", e); 103 } 104 } 105 else 106 { 107 Torque.registerMapBuilder(ReportMapBuilder.CLASS_NAME); 108 } 109 } 110 111 112 public static final int numColumns = 10; 113 114 115 protected static final String CLASSNAME_DEFAULT = 116 "org.tigris.scarab.om.Report"; 117 118 119 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 120 121 127 private static Class initClass(String className) 128 { 129 Class c = null; 130 try 131 { 132 c = Class.forName(className); 133 } 134 catch (Throwable t) 135 { 136 log.error("A FATAL ERROR has occurred which should not " 137 + "have happened under any circumstance. Please notify " 138 + "the Torque developers <torque-dev@db.apache.org> " 139 + "and give as many details as possible (including the error " 140 + "stack trace).", t); 141 142 if (t instanceof Error ) 144 { 145 throw (Error ) t.fillInStackTrace(); 146 } 147 } 148 return c; 149 } 150 151 161 public static List resultSet2Objects(java.sql.ResultSet results) 162 throws TorqueException 163 { 164 try 165 { 166 QueryDataSet qds = null; 167 List rows = null; 168 try 169 { 170 qds = new QueryDataSet(results); 171 rows = getSelectResults(qds); 172 } 173 finally 174 { 175 if (qds != null) 176 { 177 qds.close(); 178 } 179 } 180 181 return populateObjects(rows); 182 } 183 catch (SQLException e) 184 { 185 throw new TorqueException(e); 186 } 187 catch (DataSetException e) 188 { 189 throw new TorqueException(e); 190 } 191 } 192 193 194 195 202 public static ObjectKey doInsert(Criteria criteria) 203 throws TorqueException 204 { 205 return BaseReportPeer 206 .doInsert(criteria, (Connection ) null); 207 } 208 209 219 public static ObjectKey doInsert(Criteria criteria, Connection con) 220 throws TorqueException 221 { 222 if (criteria.containsKey(DELETED)) 224 { 225 Object possibleBoolean = criteria.get(DELETED); 226 if (possibleBoolean instanceof Boolean ) 227 { 228 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 229 } 230 } 231 232 setDbName(criteria); 233 234 if (con == null) 235 { 236 return BasePeer.doInsert(criteria); 237 } 238 else 239 { 240 return BasePeer.doInsert(criteria, con); 241 } 242 } 243 244 251 public static void addSelectColumns(Criteria criteria) 252 throws TorqueException 253 { 254 criteria.addSelectColumn(REPORT_ID); 255 criteria.addSelectColumn(USER_ID); 256 criteria.addSelectColumn(MODULE_ID); 257 criteria.addSelectColumn(ISSUE_TYPE_ID); 258 criteria.addSelectColumn(NAME); 259 criteria.addSelectColumn(DESCRIPTION); 260 criteria.addSelectColumn(QUERY_STRING); 261 criteria.addSelectColumn(SCOPE_ID); 262 criteria.addSelectColumn(DELETED); 263 criteria.addSelectColumn(CREATED_DATE); 264 } 265 266 275 public static Report row2Object(Record row, 276 int offset, 277 Class cls) 278 throws TorqueException 279 { 280 try 281 { 282 Report obj = (Report) cls.newInstance(); 283 ReportPeer.populateObject(row, offset, obj); 284 obj.setModified(false); 285 obj.setNew(false); 286 287 return obj; 288 } 289 catch (InstantiationException e) 290 { 291 throw new TorqueException(e); 292 } 293 catch (IllegalAccessException e) 294 { 295 throw new TorqueException(e); 296 } 297 } 298 299 308 public static void populateObject(Record row, 309 int offset, 310 Report obj) 311 throws TorqueException 312 { 313 try 314 { 315 obj.setReportId(row.getValue(offset + 0).asIntegerObj()); 316 obj.setUserId(row.getValue(offset + 1).asIntegerObj()); 317 obj.setModuleId(row.getValue(offset + 2).asIntegerObj()); 318 obj.setIssueTypeId(row.getValue(offset + 3).asIntegerObj()); 319 obj.setName(row.getValue(offset + 4).asString()); 320 obj.setDescription(row.getValue(offset + 5).asString()); 321 obj.setQueryString(row.getValue(offset + 6).asString()); 322 obj.setScopeId(row.getValue(offset + 7).asIntegerObj()); 323 obj.setDeleted(row.getValue(offset + 8).asBoolean()); 324 obj.setCreatedDate(row.getValue(offset + 9).asUtilDate()); 325 } 326 catch (DataSetException e) 327 { 328 throw new TorqueException(e); 329 } 330 } 331 332 340 public static List doSelect(Criteria criteria) throws TorqueException 341 { 342 return populateObjects(doSelectVillageRecords(criteria)); 343 } 344 345 354 public static List doSelect(Criteria criteria, Connection con) 355 throws TorqueException 356 { 357 return populateObjects(doSelectVillageRecords(criteria, con)); 358 } 359 360 370 public static List doSelectVillageRecords(Criteria criteria) 371 throws TorqueException 372 { 373 return BaseReportPeer 374 .doSelectVillageRecords(criteria, (Connection ) null); 375 } 376 377 386 public static List doSelectVillageRecords(Criteria criteria, Connection con) 387 throws TorqueException 388 { 389 if (criteria.getSelectColumns().size() == 0) 390 { 391 addSelectColumns(criteria); 392 } 393 394 if (criteria.containsKey(DELETED)) 396 { 397 Object possibleBoolean = criteria.get(DELETED); 398 if (possibleBoolean instanceof Boolean ) 399 { 400 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 401 } 402 } 403 404 setDbName(criteria); 405 406 if (con == null) 409 { 410 return BasePeer.doSelect(criteria); 411 } 412 else 413 { 414 return BasePeer.doSelect(criteria, con); 415 } 416 } 417 418 425 public static List populateObjects(List records) 426 throws TorqueException 427 { 428 List results = new ArrayList (records.size()); 429 430 for (int i = 0; i < records.size(); i++) 432 { 433 Record row = (Record) records.get(i); 434 results.add(ReportPeer.row2Object(row, 1, 435 ReportPeer.getOMClass())); 436 } 437 return results; 438 } 439 440 441 449 public static Class getOMClass() 450 throws TorqueException 451 { 452 return CLASS_DEFAULT; 453 } 454 455 463 public static void doUpdate(Criteria criteria) throws TorqueException 464 { 465 BaseReportPeer 466 .doUpdate(criteria, (Connection ) null); 467 } 468 469 480 public static void doUpdate(Criteria criteria, Connection con) 481 throws TorqueException 482 { 483 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 484 selectCriteria.put(REPORT_ID, criteria.remove(REPORT_ID)); 485 if (criteria.containsKey(DELETED)) 487 { 488 Object possibleBoolean = criteria.get(DELETED); 489 if (possibleBoolean instanceof Boolean ) 490 { 491 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 492 } 493 } 494 495 setDbName(criteria); 496 497 if (con == null) 498 { 499 BasePeer.doUpdate(selectCriteria, criteria); 500 } 501 else 502 { 503 BasePeer.doUpdate(selectCriteria, criteria, con); 504 } 505 } 506 507 514 public static void doDelete(Criteria criteria) throws TorqueException 515 { 516 ReportPeer 517 .doDelete(criteria, (Connection ) null); 518 } 519 520 530 public static void doDelete(Criteria criteria, Connection con) 531 throws TorqueException 532 { 533 if (criteria.containsKey(DELETED)) 535 { 536 Object possibleBoolean = criteria.get(DELETED); 537 if (possibleBoolean instanceof Boolean ) 538 { 539 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 540 } 541 } 542 543 setDbName(criteria); 544 545 if (con == null) 546 { 547 BasePeer.doDelete(criteria); 548 } 549 else 550 { 551 BasePeer.doDelete(criteria, con); 552 } 553 } 554 555 561 public static List doSelect(Report obj) throws TorqueException 562 { 563 return doSelect(buildSelectCriteria(obj)); 564 } 565 566 572 public static void doInsert(Report obj) throws TorqueException 573 { 574 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 575 obj.setNew(false); 576 obj.setModified(false); 577 } 578 579 584 public static void doUpdate(Report obj) throws TorqueException 585 { 586 doUpdate(buildCriteria(obj)); 587 obj.setModified(false); 588 } 589 590 595 public static void doDelete(Report obj) throws TorqueException 596 { 597 doDelete(buildSelectCriteria(obj)); 598 } 599 600 610 public static void doInsert(Report obj, Connection con) 611 throws TorqueException 612 { 613 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 614 obj.setNew(false); 615 obj.setModified(false); 616 } 617 618 628 public static void doUpdate(Report obj, Connection con) 629 throws TorqueException 630 { 631 doUpdate(buildCriteria(obj), con); 632 obj.setModified(false); 633 } 634 635 645 public static void doDelete(Report obj, Connection con) 646 throws TorqueException 647 { 648 doDelete(buildSelectCriteria(obj), con); 649 } 650 651 658 public static void doDelete(ObjectKey pk) throws TorqueException 659 { 660 BaseReportPeer 661 .doDelete(pk, (Connection ) null); 662 } 663 664 674 public static void doDelete(ObjectKey pk, Connection con) 675 throws TorqueException 676 { 677 doDelete(buildCriteria(pk), con); 678 } 679 680 681 public static Criteria buildCriteria( ObjectKey pk ) 682 { 683 Criteria criteria = new Criteria(); 684 criteria.add(REPORT_ID, pk); 685 return criteria; 686 } 687 688 689 public static Criteria buildCriteria( Report obj ) 690 { 691 Criteria criteria = new Criteria(DATABASE_NAME); 692 if (!obj.isNew()) 693 criteria.add(REPORT_ID, obj.getReportId()); 694 criteria.add(USER_ID, obj.getUserId()); 695 criteria.add(MODULE_ID, obj.getModuleId()); 696 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 697 criteria.add(NAME, obj.getName()); 698 criteria.add(DESCRIPTION, obj.getDescription()); 699 criteria.add(QUERY_STRING, obj.getQueryString()); 700 criteria.add(SCOPE_ID, obj.getScopeId()); 701 criteria.add(DELETED, obj.getDeleted()); 702 criteria.add(CREATED_DATE, obj.getCreatedDate()); 703 return criteria; 704 } 705 706 707 public static Criteria buildSelectCriteria( Report obj ) 708 { 709 Criteria criteria = new Criteria(DATABASE_NAME); 710 if (!obj.isNew()) 711 criteria.add(REPORT_ID, obj.getReportId()); 712 criteria.add(USER_ID, obj.getUserId()); 713 criteria.add(MODULE_ID, obj.getModuleId()); 714 criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId()); 715 criteria.add(NAME, obj.getName()); 716 criteria.add(DESCRIPTION, obj.getDescription()); 717 criteria.add(QUERY_STRING, obj.getQueryString()); 718 criteria.add(SCOPE_ID, obj.getScopeId()); 719 criteria.add(DELETED, obj.getDeleted()); 720 criteria.add(CREATED_DATE, obj.getCreatedDate()); 721 return criteria; 722 } 723 724 725 734 public static Report retrieveByPK(Integer pk) 735 throws TorqueException, NoRowsException, TooManyRowsException 736 { 737 return retrieveByPK(SimpleKey.keyFor(pk)); 738 } 739 740 750 public static Report retrieveByPK(Integer pk, Connection con) 751 throws TorqueException, NoRowsException, TooManyRowsException 752 { 753 return retrieveByPK(SimpleKey.keyFor(pk), con); 754 } 755 756 765 public static Report retrieveByPK(ObjectKey pk) 766 throws TorqueException, NoRowsException, TooManyRowsException 767 { 768 Connection db = null; 769 Report retVal = null; 770 try 771 { 772 db = Torque.getConnection(DATABASE_NAME); 773 retVal = retrieveByPK(pk, db); 774 } 775 finally 776 { 777 Torque.closeConnection(db); 778 } 779 return(retVal); 780 } 781 782 792 public static Report retrieveByPK(ObjectKey pk, Connection con) 793 throws TorqueException, NoRowsException, TooManyRowsException 794 { 795 Criteria criteria = buildCriteria(pk); 796 List v = doSelect(criteria, con); 797 if (v.size() == 0) 798 { 799 throw new NoRowsException("Failed to select a row."); 800 } 801 else if (v.size() > 1) 802 { 803 throw new TooManyRowsException("Failed to select only one row."); 804 } 805 else 806 { 807 return (Report)v.get(0); 808 } 809 } 810 811 818 public static List retrieveByPKs(List pks) 819 throws TorqueException 820 { 821 Connection db = null; 822 List retVal = null; 823 try 824 { 825 db = Torque.getConnection(DATABASE_NAME); 826 retVal = retrieveByPKs(pks, db); 827 } 828 finally 829 { 830 Torque.closeConnection(db); 831 } 832 return(retVal); 833 } 834 835 843 public static List retrieveByPKs( List pks, Connection dbcon ) 844 throws TorqueException 845 { 846 List objs = null; 847 if (pks == null || pks.size() == 0) 848 { 849 objs = new LinkedList (); 850 } 851 else 852 { 853 Criteria criteria = new Criteria(); 854 criteria.addIn( REPORT_ID, pks ); 855 objs = doSelect(criteria, dbcon); 856 } 857 return objs; 858 } 859 860 861 862 863 864 865 866 867 868 869 880 protected static List doSelectJoinIssueType(Criteria criteria) 881 throws TorqueException 882 { 883 setDbName(criteria); 884 885 ReportPeer.addSelectColumns(criteria); 886 int offset = numColumns + 1; 887 IssueTypePeer.addSelectColumns(criteria); 888 889 890 criteria.addJoin(ReportPeer.ISSUE_TYPE_ID, 891 IssueTypePeer.ISSUE_TYPE_ID); 892 893 894 if (criteria.containsKey(DELETED)) 896 { 897 Object possibleBoolean = criteria.get(DELETED); 898 if (possibleBoolean instanceof Boolean ) 899 { 900 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 901 } 902 } 903 904 List rows = BasePeer.doSelect(criteria); 905 List results = new ArrayList (); 906 907 for (int i = 0; i < rows.size(); i++) 908 { 909 Record row = (Record) rows.get(i); 910 911 Class omClass = ReportPeer.getOMClass(); 912 Report obj1 = (Report) ReportPeer 913 .row2Object(row, 1, omClass); 914 omClass = IssueTypePeer.getOMClass(); 915 IssueType obj2 = (IssueType)IssueTypePeer 916 .row2Object(row, offset, omClass); 917 918 boolean newObject = true; 919 for (int j = 0; j < results.size(); j++) 920 { 921 Report temp_obj1 = (Report)results.get(j); 922 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 923 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 924 { 925 newObject = false; 926 temp_obj2.addReport(obj1); 927 break; 928 } 929 } 930 if (newObject) 931 { 932 obj2.initReports(); 933 obj2.addReport(obj1); 934 } 935 results.add(obj1); 936 } 937 return results; 938 } 939 940 941 942 943 954 protected static List doSelectJoinScarabUserImpl(Criteria criteria) 955 throws TorqueException 956 { 957 setDbName(criteria); 958 959 ReportPeer.addSelectColumns(criteria); 960 int offset = numColumns + 1; 961 ScarabUserImplPeer.addSelectColumns(criteria); 962 963 964 criteria.addJoin(ReportPeer.USER_ID, 965 ScarabUserImplPeer.USER_ID); 966 967 968 if (criteria.containsKey(DELETED)) 970 { 971 Object possibleBoolean = criteria.get(DELETED); 972 if (possibleBoolean instanceof Boolean ) 973 { 974 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 975 } 976 } 977 978 List rows = BasePeer.doSelect(criteria); 979 List results = new ArrayList (); 980 981 for (int i = 0; i < rows.size(); i++) 982 { 983 Record row = (Record) rows.get(i); 984 985 Class omClass = ReportPeer.getOMClass(); 986 Report obj1 = (Report) ReportPeer 987 .row2Object(row, 1, omClass); 988 omClass = ScarabUserImplPeer.getOMClass(); 989 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 990 .row2Object(row, offset, omClass); 991 992 boolean newObject = true; 993 for (int j = 0; j < results.size(); j++) 994 { 995 Report temp_obj1 = (Report)results.get(j); 996 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 997 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 998 { 999 newObject = false; 1000 temp_obj2.addReport(obj1); 1001 break; 1002 } 1003 } 1004 if (newObject) 1005 { 1006 obj2.initReports(); 1007 obj2.addReport(obj1); 1008 } 1009 results.add(obj1); 1010 } 1011 return results; 1012 } 1013 1014 1015 1016 1017 1028 protected static List doSelectJoinScarabModule(Criteria criteria) 1029 throws TorqueException 1030 { 1031 setDbName(criteria); 1032 1033 ReportPeer.addSelectColumns(criteria); 1034 int offset = numColumns + 1; 1035 ScarabModulePeer.addSelectColumns(criteria); 1036 1037 1038 criteria.addJoin(ReportPeer.MODULE_ID, 1039 ScarabModulePeer.MODULE_ID); 1040 1041 1042 if (criteria.containsKey(DELETED)) 1044 { 1045 Object possibleBoolean = criteria.get(DELETED); 1046 if (possibleBoolean instanceof Boolean ) 1047 { 1048 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1049 } 1050 } 1051 1052 List rows = BasePeer.doSelect(criteria); 1053 List results = new ArrayList (); 1054 1055 for (int i = 0; i < rows.size(); i++) 1056 { 1057 Record row = (Record) rows.get(i); 1058 1059 Class omClass = ReportPeer.getOMClass(); 1060 Report obj1 = (Report) ReportPeer 1061 .row2Object(row, 1, omClass); 1062 omClass = ScarabModulePeer.getOMClass(row, offset); 1063 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1064 .row2Object(row, offset, omClass); 1065 1066 boolean newObject = true; 1067 for (int j = 0; j < results.size(); j++) 1068 { 1069 Report temp_obj1 = (Report)results.get(j); 1070 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1071 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1072 { 1073 newObject = false; 1074 temp_obj2.addReport(obj1); 1075 break; 1076 } 1077 } 1078 if (newObject) 1079 { 1080 obj2.initReports(); 1081 obj2.addReport(obj1); 1082 } 1083 results.add(obj1); 1084 } 1085 return results; 1086 } 1087 1088 1089 1090 1091 1102 protected static List doSelectJoinScope(Criteria criteria) 1103 throws TorqueException 1104 { 1105 setDbName(criteria); 1106 1107 ReportPeer.addSelectColumns(criteria); 1108 int offset = numColumns + 1; 1109 ScopePeer.addSelectColumns(criteria); 1110 1111 1112 criteria.addJoin(ReportPeer.SCOPE_ID, 1113 ScopePeer.SCOPE_ID); 1114 1115 1116 if (criteria.containsKey(DELETED)) 1118 { 1119 Object possibleBoolean = criteria.get(DELETED); 1120 if (possibleBoolean instanceof Boolean ) 1121 { 1122 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1123 } 1124 } 1125 1126 List rows = BasePeer.doSelect(criteria); 1127 List results = new ArrayList (); 1128 1129 for (int i = 0; i < rows.size(); i++) 1130 { 1131 Record row = (Record) rows.get(i); 1132 1133 Class omClass = ReportPeer.getOMClass(); 1134 Report obj1 = (Report) ReportPeer 1135 .row2Object(row, 1, omClass); 1136 omClass = ScopePeer.getOMClass(); 1137 Scope obj2 = (Scope)ScopePeer 1138 .row2Object(row, offset, omClass); 1139 1140 boolean newObject = true; 1141 for (int j = 0; j < results.size(); j++) 1142 { 1143 Report temp_obj1 = (Report)results.get(j); 1144 Scope temp_obj2 = (Scope)temp_obj1.getScope(); 1145 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1146 { 1147 newObject = false; 1148 temp_obj2.addReport(obj1); 1149 break; 1150 } 1151 } 1152 if (newObject) 1153 { 1154 obj2.initReports(); 1155 obj2.addReport(obj1); 1156 } 1157 results.add(obj1); 1158 } 1159 return results; 1160 } 1161 1162 1163 1164 1165 1166 1167 1168 1169 1180 protected static List doSelectJoinAllExceptIssueType(Criteria criteria) 1181 throws TorqueException 1182 { 1183 setDbName(criteria); 1184 1185 addSelectColumns(criteria); 1186 int offset2 = numColumns + 1; 1187 1188 1189 ScarabUserImplPeer.addSelectColumns(criteria); 1190 int offset3 = offset2 + ScarabUserImplPeer.numColumns; 1191 1192 ScarabModulePeer.addSelectColumns(criteria); 1193 int offset4 = offset3 + ScarabModulePeer.numColumns; 1194 1195 ScopePeer.addSelectColumns(criteria); 1196 int offset5 = offset4 + ScopePeer.numColumns; 1197 if (criteria.containsKey(DELETED)) 1199 { 1200 Object possibleBoolean = criteria.get(DELETED); 1201 if (possibleBoolean instanceof Boolean ) 1202 { 1203 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1204 } 1205 } 1206 1207 List rows = BasePeer.doSelect(criteria); 1208 List results = new ArrayList (); 1209 1210 for (int i = 0; i < rows.size(); i++) 1211 { 1212 Record row = (Record)rows.get(i); 1213 1214 Class omClass = ReportPeer.getOMClass(); 1215 Report obj1 = (Report)ReportPeer 1216 .row2Object(row, 1, omClass); 1217 1218 1219 1220 1221 1222 omClass = ScarabUserImplPeer.getOMClass(); 1223 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1224 .row2Object( row, offset2, omClass); 1225 1226 boolean newObject = true; 1227 for (int j = 0; j < results.size(); j++) 1228 { 1229 Report temp_obj1 = (Report)results.get(j); 1230 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1231 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1232 { 1233 newObject = false; 1234 temp_obj2.addReport(obj1); 1235 break; 1236 } 1237 } 1238 if (newObject) 1239 { 1240 obj2.initReports(); 1241 obj2.addReport(obj1); 1242 } 1243 1244 1245 1246 1247 omClass = ScarabModulePeer.getOMClass(row, offset3); 1248 ScarabModule obj3 = (ScarabModule)ScarabModulePeer 1249 .row2Object( row, offset3, omClass); 1250 1251 newObject = true; 1252 for (int j = 0; j < results.size(); j++) 1253 { 1254 Report temp_obj1 = (Report)results.get(j); 1255 ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule(); 1256 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1257 { 1258 newObject = false; 1259 temp_obj3.addReport(obj1); 1260 break; 1261 } 1262 } 1263 if (newObject) 1264 { 1265 obj3.initReports(); 1266 obj3.addReport(obj1); 1267 } 1268 1269 1270 1271 1272 omClass = ScopePeer.getOMClass(); 1273 Scope obj4 = (Scope)ScopePeer 1274 .row2Object( row, offset4, omClass); 1275 1276 newObject = true; 1277 for (int j = 0; j < results.size(); j++) 1278 { 1279 Report temp_obj1 = (Report)results.get(j); 1280 Scope temp_obj4 = (Scope)temp_obj1.getScope(); 1281 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1282 { 1283 newObject = false; 1284 temp_obj4.addReport(obj1); 1285 break; 1286 } 1287 } 1288 if (newObject) 1289 { 1290 obj4.initReports(); 1291 obj4.addReport(obj1); 1292 } 1293 results.add(obj1); 1294 } 1295 return results; 1296 } 1297 1298 1299 1300 1301 1302 1313 protected static List doSelectJoinAllExceptScarabUserImpl(Criteria criteria) 1314 throws TorqueException 1315 { 1316 setDbName(criteria); 1317 1318 addSelectColumns(criteria); 1319 int offset2 = numColumns + 1; 1320 1321 IssueTypePeer.addSelectColumns(criteria); 1322 int offset3 = offset2 + IssueTypePeer.numColumns; 1323 1324 1325 ScarabModulePeer.addSelectColumns(criteria); 1326 int offset4 = offset3 + ScarabModulePeer.numColumns; 1327 1328 ScopePeer.addSelectColumns(criteria); 1329 int offset5 = offset4 + ScopePeer.numColumns; 1330 if (criteria.containsKey(DELETED)) 1332 { 1333 Object possibleBoolean = criteria.get(DELETED); 1334 if (possibleBoolean instanceof Boolean ) 1335 { 1336 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1337 } 1338 } 1339 1340 List rows = BasePeer.doSelect(criteria); 1341 List results = new ArrayList (); 1342 1343 for (int i = 0; i < rows.size(); i++) 1344 { 1345 Record row = (Record)rows.get(i); 1346 1347 Class omClass = ReportPeer.getOMClass(); 1348 Report obj1 = (Report)ReportPeer 1349 .row2Object(row, 1, omClass); 1350 1351 1352 1353 1354 omClass = IssueTypePeer.getOMClass(); 1355 IssueType obj2 = (IssueType)IssueTypePeer 1356 .row2Object( row, offset2, omClass); 1357 1358 boolean newObject = true; 1359 for (int j = 0; j < results.size(); j++) 1360 { 1361 Report temp_obj1 = (Report)results.get(j); 1362 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1363 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1364 { 1365 newObject = false; 1366 temp_obj2.addReport(obj1); 1367 break; 1368 } 1369 } 1370 if (newObject) 1371 { 1372 obj2.initReports(); 1373 obj2.addReport(obj1); 1374 } 1375 1376 1377 1378 1379 1380 omClass = ScarabModulePeer.getOMClass(row, offset3); 1381 ScarabModule obj3 = (ScarabModule)ScarabModulePeer 1382 .row2Object( row, offset3, omClass); 1383 1384 newObject = true; 1385 for (int j = 0; j < results.size(); j++) 1386 { 1387 Report temp_obj1 = (Report)results.get(j); 1388 ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule(); 1389 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1390 { 1391 newObject = false; 1392 temp_obj3.addReport(obj1); 1393 break; 1394 } 1395 } 1396 if (newObject) 1397 { 1398 obj3.initReports(); 1399 obj3.addReport(obj1); 1400 } 1401 1402 1403 1404 1405 omClass = ScopePeer.getOMClass(); 1406 Scope obj4 = (Scope)ScopePeer 1407 .row2Object( row, offset4, omClass); 1408 1409 newObject = true; 1410 for (int j = 0; j < results.size(); j++) 1411 { 1412 Report temp_obj1 = (Report)results.get(j); 1413 Scope temp_obj4 = (Scope)temp_obj1.getScope(); 1414 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1415 { 1416 newObject = false; 1417 temp_obj4.addReport(obj1); 1418 break; 1419 } 1420 } 1421 if (newObject) 1422 { 1423 obj4.initReports(); 1424 obj4.addReport(obj1); 1425 } 1426 results.add(obj1); 1427 } 1428 return results; 1429 } 1430 1431 1432 1433 1434 1435 1446 protected static List doSelectJoinAllExceptScarabModule(Criteria criteria) 1447 throws TorqueException 1448 { 1449 setDbName(criteria); 1450 1451 addSelectColumns(criteria); 1452 int offset2 = numColumns + 1; 1453 1454 IssueTypePeer.addSelectColumns(criteria); 1455 int offset3 = offset2 + IssueTypePeer.numColumns; 1456 1457 ScarabUserImplPeer.addSelectColumns(criteria); 1458 int offset4 = offset3 + ScarabUserImplPeer.numColumns; 1459 1460 1461 ScopePeer.addSelectColumns(criteria); 1462 int offset5 = offset4 + ScopePeer.numColumns; 1463 if (criteria.containsKey(DELETED)) 1465 { 1466 Object possibleBoolean = criteria.get(DELETED); 1467 if (possibleBoolean instanceof Boolean ) 1468 { 1469 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1470 } 1471 } 1472 1473 List rows = BasePeer.doSelect(criteria); 1474 List results = new ArrayList (); 1475 1476 for (int i = 0; i < rows.size(); i++) 1477 { 1478 Record row = (Record)rows.get(i); 1479 1480 Class omClass = ReportPeer.getOMClass(); 1481 Report obj1 = (Report)ReportPeer 1482 .row2Object(row, 1, omClass); 1483 1484 1485 1486 1487 omClass = IssueTypePeer.getOMClass(); 1488 IssueType obj2 = (IssueType)IssueTypePeer 1489 .row2Object( row, offset2, omClass); 1490 1491 boolean newObject = true; 1492 for (int j = 0; j < results.size(); j++) 1493 { 1494 Report temp_obj1 = (Report)results.get(j); 1495 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1496 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1497 { 1498 newObject = false; 1499 temp_obj2.addReport(obj1); 1500 break; 1501 } 1502 } 1503 if (newObject) 1504 { 1505 obj2.initReports(); 1506 obj2.addReport(obj1); 1507 } 1508 1509 1510 1511 1512 omClass = ScarabUserImplPeer.getOMClass(); 1513 ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer 1514 .row2Object( row, offset3, omClass); 1515 1516 newObject = true; 1517 for (int j = 0; j < results.size(); j++) 1518 { 1519 Report temp_obj1 = (Report)results.get(j); 1520 ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1521 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1522 { 1523 newObject = false; 1524 temp_obj3.addReport(obj1); 1525 break; 1526 } 1527 } 1528 if (newObject) 1529 { 1530 obj3.initReports(); 1531 obj3.addReport(obj1); 1532 } 1533 1534 1535 1536 1537 1538 omClass = ScopePeer.getOMClass(); 1539 Scope obj4 = (Scope)ScopePeer 1540 .row2Object( row, offset4, omClass); 1541 1542 newObject = true; 1543 for (int j = 0; j < results.size(); j++) 1544 { 1545 Report temp_obj1 = (Report)results.get(j); 1546 Scope temp_obj4 = (Scope)temp_obj1.getScope(); 1547 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1548 { 1549 newObject = false; 1550 temp_obj4.addReport(obj1); 1551 break; 1552 } 1553 } 1554 if (newObject) 1555 { 1556 obj4.initReports(); 1557 obj4.addReport(obj1); 1558 } 1559 results.add(obj1); 1560 } 1561 return results; 1562 } 1563 1564 1565 1566 1567 1568 1579 protected static List doSelectJoinAllExceptScope(Criteria criteria) 1580 throws TorqueException 1581 { 1582 setDbName(criteria); 1583 1584 addSelectColumns(criteria); 1585 int offset2 = numColumns + 1; 1586 1587 IssueTypePeer.addSelectColumns(criteria); 1588 int offset3 = offset2 + IssueTypePeer.numColumns; 1589 1590 ScarabUserImplPeer.addSelectColumns(criteria); 1591 int offset4 = offset3 + ScarabUserImplPeer.numColumns; 1592 1593 ScarabModulePeer.addSelectColumns(criteria); 1594 int offset5 = offset4 + ScarabModulePeer.numColumns; 1595 1596 if (criteria.containsKey(DELETED)) 1598 { 1599 Object possibleBoolean = criteria.get(DELETED); 1600 if (possibleBoolean instanceof Boolean ) 1601 { 1602 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1603 } 1604 } 1605 1606 List rows = BasePeer.doSelect(criteria); 1607 List results = new ArrayList (); 1608 1609 for (int i = 0; i < rows.size(); i++) 1610 { 1611 Record row = (Record)rows.get(i); 1612 1613 Class omClass = ReportPeer.getOMClass(); 1614 Report obj1 = (Report)ReportPeer 1615 .row2Object(row, 1, omClass); 1616 1617 1618 1619 1620 omClass = IssueTypePeer.getOMClass(); 1621 IssueType obj2 = (IssueType)IssueTypePeer 1622 .row2Object( row, offset2, omClass); 1623 1624 boolean newObject = true; 1625 for (int j = 0; j < results.size(); j++) 1626 { 1627 Report temp_obj1 = (Report)results.get(j); 1628 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1629 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1630 { 1631 newObject = false; 1632 temp_obj2.addReport(obj1); 1633 break; 1634 } 1635 } 1636 if (newObject) 1637 { 1638 obj2.initReports(); 1639 obj2.addReport(obj1); 1640 } 1641 1642 1643 1644 1645 omClass = ScarabUserImplPeer.getOMClass(); 1646 ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer 1647 .row2Object( row, offset3, omClass); 1648 1649 newObject = true; 1650 for (int j = 0; j < results.size(); j++) 1651 { 1652 Report temp_obj1 = (Report)results.get(j); 1653 ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1654 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1655 { 1656 newObject = false; 1657 temp_obj3.addReport(obj1); 1658 break; 1659 } 1660 } 1661 if (newObject) 1662 { 1663 obj3.initReports(); 1664 obj3.addReport(obj1); 1665 } 1666 1667 1668 1669 1670 omClass = ScarabModulePeer.getOMClass(row, offset4); 1671 ScarabModule obj4 = (ScarabModule)ScarabModulePeer 1672 .row2Object( row, offset4, omClass); 1673 1674 newObject = true; 1675 for (int j = 0; j < results.size(); j++) 1676 { 1677 Report temp_obj1 = (Report)results.get(j); 1678 ScarabModule temp_obj4 = (ScarabModule)temp_obj1.getModule(); 1679 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1680 { 1681 newObject = false; 1682 temp_obj4.addReport(obj1); 1683 break; 1684 } 1685 } 1686 if (newObject) 1687 { 1688 obj4.initReports(); 1689 obj4.addReport(obj1); 1690 } 1691 1692 results.add(obj1); 1693 } 1694 return results; 1695 } 1696 1697 1698 1705 protected static TableMap getTableMap() 1706 throws TorqueException 1707 { 1708 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1709 } 1710 1711 private static void setDbName(Criteria crit) 1712 { 1713 if (crit.getDbName() == Torque.getDefaultDB()) 1717 { 1718 crit.setDbName(DATABASE_NAME); 1719 } 1720 } 1721} 1722 | Popular Tags |