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 BaseIssuePeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_ISSUE"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(IssueMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String ISSUE_ID; 62 63 public static final String ID_PREFIX; 64 65 public static final String ID_COUNT; 66 67 public static final String ID_DOMAIN; 68 69 public static final String TYPE_ID; 70 71 public static final String MODULE_ID; 72 73 public static final String CREATED_TRANS_ID; 74 75 public static final String DELETED; 76 77 static 78 { 79 ISSUE_ID = "SCARAB_ISSUE.ISSUE_ID"; 80 ID_PREFIX = "SCARAB_ISSUE.ID_PREFIX"; 81 ID_COUNT = "SCARAB_ISSUE.ID_COUNT"; 82 ID_DOMAIN = "SCARAB_ISSUE.ID_DOMAIN"; 83 TYPE_ID = "SCARAB_ISSUE.TYPE_ID"; 84 MODULE_ID = "SCARAB_ISSUE.MODULE_ID"; 85 CREATED_TRANS_ID = "SCARAB_ISSUE.CREATED_TRANS_ID"; 86 DELETED = "SCARAB_ISSUE.DELETED"; 87 if (Torque.isInit()) 88 { 89 try 90 { 91 getMapBuilder(IssueMapBuilder.CLASS_NAME); 92 } 93 catch (Exception e) 94 { 95 log.error("Could not initialize Peer", e); 96 } 97 } 98 else 99 { 100 Torque.registerMapBuilder(IssueMapBuilder.CLASS_NAME); 101 } 102 } 103 104 105 public static final int numColumns = 8; 106 107 108 protected static final String CLASSNAME_DEFAULT = 109 "org.tigris.scarab.om.Issue"; 110 111 112 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 113 114 120 private static Class initClass(String className) 121 { 122 Class c = null; 123 try 124 { 125 c = Class.forName(className); 126 } 127 catch (Throwable t) 128 { 129 log.error("A FATAL ERROR has occurred which should not " 130 + "have happened under any circumstance. Please notify " 131 + "the Torque developers <torque-dev@db.apache.org> " 132 + "and give as many details as possible (including the error " 133 + "stack trace).", t); 134 135 if (t instanceof Error ) 137 { 138 throw (Error ) t.fillInStackTrace(); 139 } 140 } 141 return c; 142 } 143 144 154 public static List resultSet2Objects(java.sql.ResultSet results) 155 throws TorqueException 156 { 157 try 158 { 159 QueryDataSet qds = null; 160 List rows = null; 161 try 162 { 163 qds = new QueryDataSet(results); 164 rows = getSelectResults(qds); 165 } 166 finally 167 { 168 if (qds != null) 169 { 170 qds.close(); 171 } 172 } 173 174 return populateObjects(rows); 175 } 176 catch (SQLException e) 177 { 178 throw new TorqueException(e); 179 } 180 catch (DataSetException e) 181 { 182 throw new TorqueException(e); 183 } 184 } 185 186 187 188 195 public static ObjectKey doInsert(Criteria criteria) 196 throws TorqueException 197 { 198 return BaseIssuePeer 199 .doInsert(criteria, (Connection ) null); 200 } 201 202 212 public static ObjectKey doInsert(Criteria criteria, Connection con) 213 throws TorqueException 214 { 215 if (criteria.containsKey(DELETED)) 217 { 218 Object possibleBoolean = criteria.get(DELETED); 219 if (possibleBoolean instanceof Boolean ) 220 { 221 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 222 } 223 } 224 225 setDbName(criteria); 226 227 if (con == null) 228 { 229 return BasePeer.doInsert(criteria); 230 } 231 else 232 { 233 return BasePeer.doInsert(criteria, con); 234 } 235 } 236 237 244 public static void addSelectColumns(Criteria criteria) 245 throws TorqueException 246 { 247 criteria.addSelectColumn(ISSUE_ID); 248 criteria.addSelectColumn(ID_PREFIX); 249 criteria.addSelectColumn(ID_COUNT); 250 criteria.addSelectColumn(ID_DOMAIN); 251 criteria.addSelectColumn(TYPE_ID); 252 criteria.addSelectColumn(MODULE_ID); 253 criteria.addSelectColumn(CREATED_TRANS_ID); 254 criteria.addSelectColumn(DELETED); 255 } 256 257 266 public static Issue row2Object(Record row, 267 int offset, 268 Class cls) 269 throws TorqueException 270 { 271 try 272 { 273 Issue obj = (Issue) cls.newInstance(); 274 IssuePeer.populateObject(row, offset, obj); 275 obj.setModified(false); 276 obj.setNew(false); 277 278 return obj; 279 } 280 catch (InstantiationException e) 281 { 282 throw new TorqueException(e); 283 } 284 catch (IllegalAccessException e) 285 { 286 throw new TorqueException(e); 287 } 288 } 289 290 299 public static void populateObject(Record row, 300 int offset, 301 Issue obj) 302 throws TorqueException 303 { 304 try 305 { 306 obj.setIssueId(row.getValue(offset + 0).asLongObj()); 307 obj.setIdPrefix(row.getValue(offset + 1).asString()); 308 obj.setIdCount(row.getValue(offset + 2).asInt()); 309 obj.setIdDomain(row.getValue(offset + 3).asString()); 310 obj.setTypeId(row.getValue(offset + 4).asIntegerObj()); 311 obj.setModuleId(row.getValue(offset + 5).asIntegerObj()); 312 obj.setCreatedTransId(row.getValue(offset + 6).asLongObj()); 313 obj.setDeleted(row.getValue(offset + 7).asBoolean()); 314 } 315 catch (DataSetException e) 316 { 317 throw new TorqueException(e); 318 } 319 } 320 321 329 public static List doSelect(Criteria criteria) throws TorqueException 330 { 331 return populateObjects(doSelectVillageRecords(criteria)); 332 } 333 334 343 public static List doSelect(Criteria criteria, Connection con) 344 throws TorqueException 345 { 346 return populateObjects(doSelectVillageRecords(criteria, con)); 347 } 348 349 359 public static List doSelectVillageRecords(Criteria criteria) 360 throws TorqueException 361 { 362 return BaseIssuePeer 363 .doSelectVillageRecords(criteria, (Connection ) null); 364 } 365 366 375 public static List doSelectVillageRecords(Criteria criteria, Connection con) 376 throws TorqueException 377 { 378 if (criteria.getSelectColumns().size() == 0) 379 { 380 addSelectColumns(criteria); 381 } 382 383 if (criteria.containsKey(DELETED)) 385 { 386 Object possibleBoolean = criteria.get(DELETED); 387 if (possibleBoolean instanceof Boolean ) 388 { 389 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 390 } 391 } 392 393 setDbName(criteria); 394 395 if (con == null) 398 { 399 return BasePeer.doSelect(criteria); 400 } 401 else 402 { 403 return BasePeer.doSelect(criteria, con); 404 } 405 } 406 407 414 public static List populateObjects(List records) 415 throws TorqueException 416 { 417 List results = new ArrayList (records.size()); 418 419 for (int i = 0; i < records.size(); i++) 421 { 422 Record row = (Record) records.get(i); 423 results.add(IssuePeer.row2Object(row, 1, 424 IssuePeer.getOMClass())); 425 } 426 return results; 427 } 428 429 430 438 public static Class getOMClass() 439 throws TorqueException 440 { 441 return CLASS_DEFAULT; 442 } 443 444 452 public static void doUpdate(Criteria criteria) throws TorqueException 453 { 454 BaseIssuePeer 455 .doUpdate(criteria, (Connection ) null); 456 } 457 458 469 public static void doUpdate(Criteria criteria, Connection con) 470 throws TorqueException 471 { 472 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 473 selectCriteria.put(ISSUE_ID, criteria.remove(ISSUE_ID)); 474 if (criteria.containsKey(DELETED)) 476 { 477 Object possibleBoolean = criteria.get(DELETED); 478 if (possibleBoolean instanceof Boolean ) 479 { 480 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 481 } 482 } 483 484 setDbName(criteria); 485 486 if (con == null) 487 { 488 BasePeer.doUpdate(selectCriteria, criteria); 489 } 490 else 491 { 492 BasePeer.doUpdate(selectCriteria, criteria, con); 493 } 494 } 495 496 503 public static void doDelete(Criteria criteria) throws TorqueException 504 { 505 IssuePeer 506 .doDelete(criteria, (Connection ) null); 507 } 508 509 519 public static void doDelete(Criteria criteria, Connection con) 520 throws TorqueException 521 { 522 if (criteria.containsKey(DELETED)) 524 { 525 Object possibleBoolean = criteria.get(DELETED); 526 if (possibleBoolean instanceof Boolean ) 527 { 528 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 529 } 530 } 531 532 setDbName(criteria); 533 534 if (con == null) 535 { 536 BasePeer.doDelete(criteria); 537 } 538 else 539 { 540 BasePeer.doDelete(criteria, con); 541 } 542 } 543 544 550 public static List doSelect(Issue obj) throws TorqueException 551 { 552 return doSelect(buildSelectCriteria(obj)); 553 } 554 555 561 public static void doInsert(Issue obj) throws TorqueException 562 { 563 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 564 obj.setNew(false); 565 obj.setModified(false); 566 } 567 568 573 public static void doUpdate(Issue obj) throws TorqueException 574 { 575 doUpdate(buildCriteria(obj)); 576 obj.setModified(false); 577 } 578 579 584 public static void doDelete(Issue obj) throws TorqueException 585 { 586 doDelete(buildSelectCriteria(obj)); 587 } 588 589 599 public static void doInsert(Issue obj, Connection con) 600 throws TorqueException 601 { 602 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 603 obj.setNew(false); 604 obj.setModified(false); 605 } 606 607 617 public static void doUpdate(Issue obj, Connection con) 618 throws TorqueException 619 { 620 doUpdate(buildCriteria(obj), con); 621 obj.setModified(false); 622 } 623 624 634 public static void doDelete(Issue obj, Connection con) 635 throws TorqueException 636 { 637 doDelete(buildSelectCriteria(obj), con); 638 } 639 640 647 public static void doDelete(ObjectKey pk) throws TorqueException 648 { 649 BaseIssuePeer 650 .doDelete(pk, (Connection ) null); 651 } 652 653 663 public static void doDelete(ObjectKey pk, Connection con) 664 throws TorqueException 665 { 666 doDelete(buildCriteria(pk), con); 667 } 668 669 670 public static Criteria buildCriteria( ObjectKey pk ) 671 { 672 Criteria criteria = new Criteria(); 673 criteria.add(ISSUE_ID, pk); 674 return criteria; 675 } 676 677 678 public static Criteria buildCriteria( Issue obj ) 679 { 680 Criteria criteria = new Criteria(DATABASE_NAME); 681 if (!obj.isNew()) 682 criteria.add(ISSUE_ID, obj.getIssueId()); 683 criteria.add(ID_PREFIX, obj.getIdPrefix()); 684 criteria.add(ID_COUNT, obj.getIdCount()); 685 criteria.add(ID_DOMAIN, obj.getIdDomain()); 686 criteria.add(TYPE_ID, obj.getTypeId()); 687 criteria.add(MODULE_ID, obj.getModuleId()); 688 criteria.add(CREATED_TRANS_ID, obj.getCreatedTransId()); 689 criteria.add(DELETED, obj.getDeleted()); 690 return criteria; 691 } 692 693 694 public static Criteria buildSelectCriteria( Issue obj ) 695 { 696 Criteria criteria = new Criteria(DATABASE_NAME); 697 if (!obj.isNew()) 698 criteria.add(ISSUE_ID, obj.getIssueId()); 699 criteria.add(ID_PREFIX, obj.getIdPrefix()); 700 criteria.add(ID_COUNT, obj.getIdCount()); 701 criteria.add(ID_DOMAIN, obj.getIdDomain()); 702 criteria.add(TYPE_ID, obj.getTypeId()); 703 criteria.add(MODULE_ID, obj.getModuleId()); 704 criteria.add(CREATED_TRANS_ID, obj.getCreatedTransId()); 705 criteria.add(DELETED, obj.getDeleted()); 706 return criteria; 707 } 708 709 710 719 public static Issue retrieveByPK(Long pk) 720 throws TorqueException, NoRowsException, TooManyRowsException 721 { 722 return retrieveByPK(SimpleKey.keyFor(pk)); 723 } 724 725 735 public static Issue retrieveByPK(Long pk, Connection con) 736 throws TorqueException, NoRowsException, TooManyRowsException 737 { 738 return retrieveByPK(SimpleKey.keyFor(pk), con); 739 } 740 741 750 public static Issue retrieveByPK(ObjectKey pk) 751 throws TorqueException, NoRowsException, TooManyRowsException 752 { 753 Connection db = null; 754 Issue retVal = null; 755 try 756 { 757 db = Torque.getConnection(DATABASE_NAME); 758 retVal = retrieveByPK(pk, db); 759 } 760 finally 761 { 762 Torque.closeConnection(db); 763 } 764 return(retVal); 765 } 766 767 777 public static Issue retrieveByPK(ObjectKey pk, Connection con) 778 throws TorqueException, NoRowsException, TooManyRowsException 779 { 780 Criteria criteria = buildCriteria(pk); 781 List v = doSelect(criteria, con); 782 if (v.size() == 0) 783 { 784 throw new NoRowsException("Failed to select a row."); 785 } 786 else if (v.size() > 1) 787 { 788 throw new TooManyRowsException("Failed to select only one row."); 789 } 790 else 791 { 792 return (Issue)v.get(0); 793 } 794 } 795 796 803 public static List retrieveByPKs(List pks) 804 throws TorqueException 805 { 806 Connection db = null; 807 List retVal = null; 808 try 809 { 810 db = Torque.getConnection(DATABASE_NAME); 811 retVal = retrieveByPKs(pks, db); 812 } 813 finally 814 { 815 Torque.closeConnection(db); 816 } 817 return(retVal); 818 } 819 820 828 public static List retrieveByPKs( List pks, Connection dbcon ) 829 throws TorqueException 830 { 831 List objs = null; 832 if (pks == null || pks.size() == 0) 833 { 834 objs = new LinkedList (); 835 } 836 else 837 { 838 Criteria criteria = new Criteria(); 839 criteria.addIn( ISSUE_ID, pks ); 840 objs = doSelect(criteria, dbcon); 841 } 842 return objs; 843 } 844 845 846 847 848 849 850 851 852 853 854 865 protected static List doSelectJoinScarabModule(Criteria criteria) 866 throws TorqueException 867 { 868 setDbName(criteria); 869 870 IssuePeer.addSelectColumns(criteria); 871 int offset = numColumns + 1; 872 ScarabModulePeer.addSelectColumns(criteria); 873 874 875 criteria.addJoin(IssuePeer.MODULE_ID, 876 ScarabModulePeer.MODULE_ID); 877 878 879 if (criteria.containsKey(DELETED)) 881 { 882 Object possibleBoolean = criteria.get(DELETED); 883 if (possibleBoolean instanceof Boolean ) 884 { 885 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 886 } 887 } 888 889 List rows = BasePeer.doSelect(criteria); 890 List results = new ArrayList (); 891 892 for (int i = 0; i < rows.size(); i++) 893 { 894 Record row = (Record) rows.get(i); 895 896 Class omClass = IssuePeer.getOMClass(); 897 Issue obj1 = (Issue) IssuePeer 898 .row2Object(row, 1, omClass); 899 omClass = ScarabModulePeer.getOMClass(row, offset); 900 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 901 .row2Object(row, offset, omClass); 902 903 boolean newObject = true; 904 for (int j = 0; j < results.size(); j++) 905 { 906 Issue temp_obj1 = (Issue)results.get(j); 907 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 908 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 909 { 910 newObject = false; 911 temp_obj2.addIssue(obj1); 912 break; 913 } 914 } 915 if (newObject) 916 { 917 obj2.initIssues(); 918 obj2.addIssue(obj1); 919 } 920 results.add(obj1); 921 } 922 return results; 923 } 924 925 926 927 928 939 protected static List doSelectJoinIssueType(Criteria criteria) 940 throws TorqueException 941 { 942 setDbName(criteria); 943 944 IssuePeer.addSelectColumns(criteria); 945 int offset = numColumns + 1; 946 IssueTypePeer.addSelectColumns(criteria); 947 948 949 criteria.addJoin(IssuePeer.TYPE_ID, 950 IssueTypePeer.ISSUE_TYPE_ID); 951 952 953 if (criteria.containsKey(DELETED)) 955 { 956 Object possibleBoolean = criteria.get(DELETED); 957 if (possibleBoolean instanceof Boolean ) 958 { 959 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 960 } 961 } 962 963 List rows = BasePeer.doSelect(criteria); 964 List results = new ArrayList (); 965 966 for (int i = 0; i < rows.size(); i++) 967 { 968 Record row = (Record) rows.get(i); 969 970 Class omClass = IssuePeer.getOMClass(); 971 Issue obj1 = (Issue) IssuePeer 972 .row2Object(row, 1, omClass); 973 omClass = IssueTypePeer.getOMClass(); 974 IssueType obj2 = (IssueType)IssueTypePeer 975 .row2Object(row, offset, omClass); 976 977 boolean newObject = true; 978 for (int j = 0; j < results.size(); j++) 979 { 980 Issue temp_obj1 = (Issue)results.get(j); 981 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 982 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 983 { 984 newObject = false; 985 temp_obj2.addIssue(obj1); 986 break; 987 } 988 } 989 if (newObject) 990 { 991 obj2.initIssues(); 992 obj2.addIssue(obj1); 993 } 994 results.add(obj1); 995 } 996 return results; 997 } 998 999 1000 1001 1002 1013 protected static List doSelectJoinActivitySet(Criteria criteria) 1014 throws TorqueException 1015 { 1016 setDbName(criteria); 1017 1018 IssuePeer.addSelectColumns(criteria); 1019 int offset = numColumns + 1; 1020 ActivitySetPeer.addSelectColumns(criteria); 1021 1022 1023 criteria.addJoin(IssuePeer.CREATED_TRANS_ID, 1024 ActivitySetPeer.TRANSACTION_ID); 1025 1026 1027 if (criteria.containsKey(DELETED)) 1029 { 1030 Object possibleBoolean = criteria.get(DELETED); 1031 if (possibleBoolean instanceof Boolean ) 1032 { 1033 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1034 } 1035 } 1036 1037 List rows = BasePeer.doSelect(criteria); 1038 List results = new ArrayList (); 1039 1040 for (int i = 0; i < rows.size(); i++) 1041 { 1042 Record row = (Record) rows.get(i); 1043 1044 Class omClass = IssuePeer.getOMClass(); 1045 Issue obj1 = (Issue) IssuePeer 1046 .row2Object(row, 1, omClass); 1047 omClass = ActivitySetPeer.getOMClass(); 1048 ActivitySet obj2 = (ActivitySet)ActivitySetPeer 1049 .row2Object(row, offset, omClass); 1050 1051 boolean newObject = true; 1052 for (int j = 0; j < results.size(); j++) 1053 { 1054 Issue temp_obj1 = (Issue)results.get(j); 1055 ActivitySet temp_obj2 = (ActivitySet)temp_obj1.getActivitySet(); 1056 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1057 { 1058 newObject = false; 1059 temp_obj2.addIssue(obj1); 1060 break; 1061 } 1062 } 1063 if (newObject) 1064 { 1065 obj2.initIssues(); 1066 obj2.addIssue(obj1); 1067 } 1068 results.add(obj1); 1069 } 1070 return results; 1071 } 1072 1073 1074 1075 1076 1077 1078 1079 1080 1091 protected static List doSelectJoinAllExceptScarabModule(Criteria criteria) 1092 throws TorqueException 1093 { 1094 setDbName(criteria); 1095 1096 addSelectColumns(criteria); 1097 int offset2 = numColumns + 1; 1098 1099 1100 IssueTypePeer.addSelectColumns(criteria); 1101 int offset3 = offset2 + IssueTypePeer.numColumns; 1102 1103 ActivitySetPeer.addSelectColumns(criteria); 1104 int offset4 = offset3 + ActivitySetPeer.numColumns; 1105 if (criteria.containsKey(DELETED)) 1107 { 1108 Object possibleBoolean = criteria.get(DELETED); 1109 if (possibleBoolean instanceof Boolean ) 1110 { 1111 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1112 } 1113 } 1114 1115 List rows = BasePeer.doSelect(criteria); 1116 List results = new ArrayList (); 1117 1118 for (int i = 0; i < rows.size(); i++) 1119 { 1120 Record row = (Record)rows.get(i); 1121 1122 Class omClass = IssuePeer.getOMClass(); 1123 Issue obj1 = (Issue)IssuePeer 1124 .row2Object(row, 1, omClass); 1125 1126 1127 1128 1129 1130 omClass = IssueTypePeer.getOMClass(); 1131 IssueType obj2 = (IssueType)IssueTypePeer 1132 .row2Object( row, offset2, omClass); 1133 1134 boolean newObject = true; 1135 for (int j = 0; j < results.size(); j++) 1136 { 1137 Issue temp_obj1 = (Issue)results.get(j); 1138 IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType(); 1139 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1140 { 1141 newObject = false; 1142 temp_obj2.addIssue(obj1); 1143 break; 1144 } 1145 } 1146 if (newObject) 1147 { 1148 obj2.initIssues(); 1149 obj2.addIssue(obj1); 1150 } 1151 1152 1153 1154 1155 omClass = ActivitySetPeer.getOMClass(); 1156 ActivitySet obj3 = (ActivitySet)ActivitySetPeer 1157 .row2Object( row, offset3, omClass); 1158 1159 newObject = true; 1160 for (int j = 0; j < results.size(); j++) 1161 { 1162 Issue temp_obj1 = (Issue)results.get(j); 1163 ActivitySet temp_obj3 = (ActivitySet)temp_obj1.getActivitySet(); 1164 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1165 { 1166 newObject = false; 1167 temp_obj3.addIssue(obj1); 1168 break; 1169 } 1170 } 1171 if (newObject) 1172 { 1173 obj3.initIssues(); 1174 obj3.addIssue(obj1); 1175 } 1176 results.add(obj1); 1177 } 1178 return results; 1179 } 1180 1181 1182 1183 1184 1185 1196 protected static List doSelectJoinAllExceptIssueType(Criteria criteria) 1197 throws TorqueException 1198 { 1199 setDbName(criteria); 1200 1201 addSelectColumns(criteria); 1202 int offset2 = numColumns + 1; 1203 1204 ScarabModulePeer.addSelectColumns(criteria); 1205 int offset3 = offset2 + ScarabModulePeer.numColumns; 1206 1207 1208 ActivitySetPeer.addSelectColumns(criteria); 1209 int offset4 = offset3 + ActivitySetPeer.numColumns; 1210 if (criteria.containsKey(DELETED)) 1212 { 1213 Object possibleBoolean = criteria.get(DELETED); 1214 if (possibleBoolean instanceof Boolean ) 1215 { 1216 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1217 } 1218 } 1219 1220 List rows = BasePeer.doSelect(criteria); 1221 List results = new ArrayList (); 1222 1223 for (int i = 0; i < rows.size(); i++) 1224 { 1225 Record row = (Record)rows.get(i); 1226 1227 Class omClass = IssuePeer.getOMClass(); 1228 Issue obj1 = (Issue)IssuePeer 1229 .row2Object(row, 1, omClass); 1230 1231 1232 1233 1234 omClass = ScarabModulePeer.getOMClass(row, offset2); 1235 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1236 .row2Object( row, offset2, omClass); 1237 1238 boolean newObject = true; 1239 for (int j = 0; j < results.size(); j++) 1240 { 1241 Issue temp_obj1 = (Issue)results.get(j); 1242 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1243 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1244 { 1245 newObject = false; 1246 temp_obj2.addIssue(obj1); 1247 break; 1248 } 1249 } 1250 if (newObject) 1251 { 1252 obj2.initIssues(); 1253 obj2.addIssue(obj1); 1254 } 1255 1256 1257 1258 1259 1260 omClass = ActivitySetPeer.getOMClass(); 1261 ActivitySet obj3 = (ActivitySet)ActivitySetPeer 1262 .row2Object( row, offset3, omClass); 1263 1264 newObject = true; 1265 for (int j = 0; j < results.size(); j++) 1266 { 1267 Issue temp_obj1 = (Issue)results.get(j); 1268 ActivitySet temp_obj3 = (ActivitySet)temp_obj1.getActivitySet(); 1269 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1270 { 1271 newObject = false; 1272 temp_obj3.addIssue(obj1); 1273 break; 1274 } 1275 } 1276 if (newObject) 1277 { 1278 obj3.initIssues(); 1279 obj3.addIssue(obj1); 1280 } 1281 results.add(obj1); 1282 } 1283 return results; 1284 } 1285 1286 1287 1288 1289 1290 1301 protected static List doSelectJoinAllExceptActivitySet(Criteria criteria) 1302 throws TorqueException 1303 { 1304 setDbName(criteria); 1305 1306 addSelectColumns(criteria); 1307 int offset2 = numColumns + 1; 1308 1309 ScarabModulePeer.addSelectColumns(criteria); 1310 int offset3 = offset2 + ScarabModulePeer.numColumns; 1311 1312 IssueTypePeer.addSelectColumns(criteria); 1313 int offset4 = offset3 + IssueTypePeer.numColumns; 1314 1315 if (criteria.containsKey(DELETED)) 1317 { 1318 Object possibleBoolean = criteria.get(DELETED); 1319 if (possibleBoolean instanceof Boolean ) 1320 { 1321 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1322 } 1323 } 1324 1325 List rows = BasePeer.doSelect(criteria); 1326 List results = new ArrayList (); 1327 1328 for (int i = 0; i < rows.size(); i++) 1329 { 1330 Record row = (Record)rows.get(i); 1331 1332 Class omClass = IssuePeer.getOMClass(); 1333 Issue obj1 = (Issue)IssuePeer 1334 .row2Object(row, 1, omClass); 1335 1336 1337 1338 1339 omClass = ScarabModulePeer.getOMClass(row, offset2); 1340 ScarabModule obj2 = (ScarabModule)ScarabModulePeer 1341 .row2Object( row, offset2, omClass); 1342 1343 boolean newObject = true; 1344 for (int j = 0; j < results.size(); j++) 1345 { 1346 Issue temp_obj1 = (Issue)results.get(j); 1347 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule(); 1348 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1349 { 1350 newObject = false; 1351 temp_obj2.addIssue(obj1); 1352 break; 1353 } 1354 } 1355 if (newObject) 1356 { 1357 obj2.initIssues(); 1358 obj2.addIssue(obj1); 1359 } 1360 1361 1362 1363 1364 omClass = IssueTypePeer.getOMClass(); 1365 IssueType obj3 = (IssueType)IssueTypePeer 1366 .row2Object( row, offset3, omClass); 1367 1368 newObject = true; 1369 for (int j = 0; j < results.size(); j++) 1370 { 1371 Issue temp_obj1 = (Issue)results.get(j); 1372 IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType(); 1373 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1374 { 1375 newObject = false; 1376 temp_obj3.addIssue(obj1); 1377 break; 1378 } 1379 } 1380 if (newObject) 1381 { 1382 obj3.initIssues(); 1383 obj3.addIssue(obj1); 1384 } 1385 1386 results.add(obj1); 1387 } 1388 return results; 1389 } 1390 1391 1392 1399 protected static TableMap getTableMap() 1400 throws TorqueException 1401 { 1402 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1403 } 1404 1405 private static void setDbName(Criteria crit) 1406 { 1407 if (crit.getDbName() == Torque.getDefaultDB()) 1411 { 1412 crit.setDbName(DATABASE_NAME); 1413 } 1414 } 1415} 1416 | Popular Tags |