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 BaseDependPeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_DEPEND"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(DependMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String DEPEND_ID; 62 63 public static final String OBSERVED_ID; 64 65 public static final String OBSERVER_ID; 66 67 public static final String DEPEND_TYPE_ID; 68 69 public static final String DELETED; 70 71 static 72 { 73 DEPEND_ID = "SCARAB_DEPEND.DEPEND_ID"; 74 OBSERVED_ID = "SCARAB_DEPEND.OBSERVED_ID"; 75 OBSERVER_ID = "SCARAB_DEPEND.OBSERVER_ID"; 76 DEPEND_TYPE_ID = "SCARAB_DEPEND.DEPEND_TYPE_ID"; 77 DELETED = "SCARAB_DEPEND.DELETED"; 78 if (Torque.isInit()) 79 { 80 try 81 { 82 getMapBuilder(DependMapBuilder.CLASS_NAME); 83 } 84 catch (Exception e) 85 { 86 log.error("Could not initialize Peer", e); 87 } 88 } 89 else 90 { 91 Torque.registerMapBuilder(DependMapBuilder.CLASS_NAME); 92 } 93 } 94 95 96 public static final int numColumns = 5; 97 98 99 protected static final String CLASSNAME_DEFAULT = 100 "org.tigris.scarab.om.Depend"; 101 102 103 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 104 105 111 private static Class initClass(String className) 112 { 113 Class c = null; 114 try 115 { 116 c = Class.forName(className); 117 } 118 catch (Throwable t) 119 { 120 log.error("A FATAL ERROR has occurred which should not " 121 + "have happened under any circumstance. Please notify " 122 + "the Torque developers <torque-dev@db.apache.org> " 123 + "and give as many details as possible (including the error " 124 + "stack trace).", t); 125 126 if (t instanceof Error ) 128 { 129 throw (Error ) t.fillInStackTrace(); 130 } 131 } 132 return c; 133 } 134 135 145 public static List resultSet2Objects(java.sql.ResultSet results) 146 throws TorqueException 147 { 148 try 149 { 150 QueryDataSet qds = null; 151 List rows = null; 152 try 153 { 154 qds = new QueryDataSet(results); 155 rows = getSelectResults(qds); 156 } 157 finally 158 { 159 if (qds != null) 160 { 161 qds.close(); 162 } 163 } 164 165 return populateObjects(rows); 166 } 167 catch (SQLException e) 168 { 169 throw new TorqueException(e); 170 } 171 catch (DataSetException e) 172 { 173 throw new TorqueException(e); 174 } 175 } 176 177 178 179 186 public static ObjectKey doInsert(Criteria criteria) 187 throws TorqueException 188 { 189 return BaseDependPeer 190 .doInsert(criteria, (Connection ) null); 191 } 192 193 203 public static ObjectKey doInsert(Criteria criteria, Connection con) 204 throws TorqueException 205 { 206 if (criteria.containsKey(DELETED)) 208 { 209 Object possibleBoolean = criteria.get(DELETED); 210 if (possibleBoolean instanceof Boolean ) 211 { 212 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 213 } 214 } 215 216 setDbName(criteria); 217 218 if (con == null) 219 { 220 return BasePeer.doInsert(criteria); 221 } 222 else 223 { 224 return BasePeer.doInsert(criteria, con); 225 } 226 } 227 228 235 public static void addSelectColumns(Criteria criteria) 236 throws TorqueException 237 { 238 criteria.addSelectColumn(DEPEND_ID); 239 criteria.addSelectColumn(OBSERVED_ID); 240 criteria.addSelectColumn(OBSERVER_ID); 241 criteria.addSelectColumn(DEPEND_TYPE_ID); 242 criteria.addSelectColumn(DELETED); 243 } 244 245 254 public static Depend row2Object(Record row, 255 int offset, 256 Class cls) 257 throws TorqueException 258 { 259 try 260 { 261 Depend obj = (Depend) cls.newInstance(); 262 DependPeer.populateObject(row, offset, obj); 263 obj.setModified(false); 264 obj.setNew(false); 265 266 return obj; 267 } 268 catch (InstantiationException e) 269 { 270 throw new TorqueException(e); 271 } 272 catch (IllegalAccessException e) 273 { 274 throw new TorqueException(e); 275 } 276 } 277 278 287 public static void populateObject(Record row, 288 int offset, 289 Depend obj) 290 throws TorqueException 291 { 292 try 293 { 294 obj.setDependId(row.getValue(offset + 0).asIntegerObj()); 295 obj.setObservedId(row.getValue(offset + 1).asLongObj()); 296 obj.setObserverId(row.getValue(offset + 2).asLongObj()); 297 obj.setTypeId(row.getValue(offset + 3).asIntegerObj()); 298 obj.setDeleted(row.getValue(offset + 4).asBoolean()); 299 } 300 catch (DataSetException e) 301 { 302 throw new TorqueException(e); 303 } 304 } 305 306 314 public static List doSelect(Criteria criteria) throws TorqueException 315 { 316 return populateObjects(doSelectVillageRecords(criteria)); 317 } 318 319 328 public static List doSelect(Criteria criteria, Connection con) 329 throws TorqueException 330 { 331 return populateObjects(doSelectVillageRecords(criteria, con)); 332 } 333 334 344 public static List doSelectVillageRecords(Criteria criteria) 345 throws TorqueException 346 { 347 return BaseDependPeer 348 .doSelectVillageRecords(criteria, (Connection ) null); 349 } 350 351 360 public static List doSelectVillageRecords(Criteria criteria, Connection con) 361 throws TorqueException 362 { 363 if (criteria.getSelectColumns().size() == 0) 364 { 365 addSelectColumns(criteria); 366 } 367 368 if (criteria.containsKey(DELETED)) 370 { 371 Object possibleBoolean = criteria.get(DELETED); 372 if (possibleBoolean instanceof Boolean ) 373 { 374 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 375 } 376 } 377 378 setDbName(criteria); 379 380 if (con == null) 383 { 384 return BasePeer.doSelect(criteria); 385 } 386 else 387 { 388 return BasePeer.doSelect(criteria, con); 389 } 390 } 391 392 399 public static List populateObjects(List records) 400 throws TorqueException 401 { 402 List results = new ArrayList (records.size()); 403 404 for (int i = 0; i < records.size(); i++) 406 { 407 Record row = (Record) records.get(i); 408 results.add(DependPeer.row2Object(row, 1, 409 DependPeer.getOMClass())); 410 } 411 return results; 412 } 413 414 415 423 public static Class getOMClass() 424 throws TorqueException 425 { 426 return CLASS_DEFAULT; 427 } 428 429 437 public static void doUpdate(Criteria criteria) throws TorqueException 438 { 439 BaseDependPeer 440 .doUpdate(criteria, (Connection ) null); 441 } 442 443 454 public static void doUpdate(Criteria criteria, Connection con) 455 throws TorqueException 456 { 457 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 458 selectCriteria.put(DEPEND_ID, criteria.remove(DEPEND_ID)); 459 if (criteria.containsKey(DELETED)) 461 { 462 Object possibleBoolean = criteria.get(DELETED); 463 if (possibleBoolean instanceof Boolean ) 464 { 465 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 466 } 467 } 468 469 setDbName(criteria); 470 471 if (con == null) 472 { 473 BasePeer.doUpdate(selectCriteria, criteria); 474 } 475 else 476 { 477 BasePeer.doUpdate(selectCriteria, criteria, con); 478 } 479 } 480 481 488 public static void doDelete(Criteria criteria) throws TorqueException 489 { 490 DependPeer 491 .doDelete(criteria, (Connection ) null); 492 } 493 494 504 public static void doDelete(Criteria criteria, Connection con) 505 throws TorqueException 506 { 507 if (criteria.containsKey(DELETED)) 509 { 510 Object possibleBoolean = criteria.get(DELETED); 511 if (possibleBoolean instanceof Boolean ) 512 { 513 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 514 } 515 } 516 517 setDbName(criteria); 518 519 if (con == null) 520 { 521 BasePeer.doDelete(criteria); 522 } 523 else 524 { 525 BasePeer.doDelete(criteria, con); 526 } 527 } 528 529 535 public static List doSelect(Depend obj) throws TorqueException 536 { 537 return doSelect(buildSelectCriteria(obj)); 538 } 539 540 546 public static void doInsert(Depend obj) throws TorqueException 547 { 548 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 549 obj.setNew(false); 550 obj.setModified(false); 551 } 552 553 558 public static void doUpdate(Depend obj) throws TorqueException 559 { 560 doUpdate(buildCriteria(obj)); 561 obj.setModified(false); 562 } 563 564 569 public static void doDelete(Depend obj) throws TorqueException 570 { 571 doDelete(buildSelectCriteria(obj)); 572 } 573 574 584 public static void doInsert(Depend obj, Connection con) 585 throws TorqueException 586 { 587 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 588 obj.setNew(false); 589 obj.setModified(false); 590 } 591 592 602 public static void doUpdate(Depend obj, Connection con) 603 throws TorqueException 604 { 605 doUpdate(buildCriteria(obj), con); 606 obj.setModified(false); 607 } 608 609 619 public static void doDelete(Depend obj, Connection con) 620 throws TorqueException 621 { 622 doDelete(buildSelectCriteria(obj), con); 623 } 624 625 632 public static void doDelete(ObjectKey pk) throws TorqueException 633 { 634 BaseDependPeer 635 .doDelete(pk, (Connection ) null); 636 } 637 638 648 public static void doDelete(ObjectKey pk, Connection con) 649 throws TorqueException 650 { 651 doDelete(buildCriteria(pk), con); 652 } 653 654 655 public static Criteria buildCriteria( ObjectKey pk ) 656 { 657 Criteria criteria = new Criteria(); 658 criteria.add(DEPEND_ID, pk); 659 return criteria; 660 } 661 662 663 public static Criteria buildCriteria( Depend obj ) 664 { 665 Criteria criteria = new Criteria(DATABASE_NAME); 666 if (!obj.isNew()) 667 criteria.add(DEPEND_ID, obj.getDependId()); 668 criteria.add(OBSERVED_ID, obj.getObservedId()); 669 criteria.add(OBSERVER_ID, obj.getObserverId()); 670 criteria.add(DEPEND_TYPE_ID, obj.getTypeId()); 671 criteria.add(DELETED, obj.getDeleted()); 672 return criteria; 673 } 674 675 676 public static Criteria buildSelectCriteria( Depend obj ) 677 { 678 Criteria criteria = new Criteria(DATABASE_NAME); 679 if (!obj.isNew()) 680 criteria.add(DEPEND_ID, obj.getDependId()); 681 criteria.add(OBSERVED_ID, obj.getObservedId()); 682 criteria.add(OBSERVER_ID, obj.getObserverId()); 683 criteria.add(DEPEND_TYPE_ID, obj.getTypeId()); 684 criteria.add(DELETED, obj.getDeleted()); 685 return criteria; 686 } 687 688 689 698 public static Depend retrieveByPK(Integer pk) 699 throws TorqueException, NoRowsException, TooManyRowsException 700 { 701 return retrieveByPK(SimpleKey.keyFor(pk)); 702 } 703 704 714 public static Depend retrieveByPK(Integer pk, Connection con) 715 throws TorqueException, NoRowsException, TooManyRowsException 716 { 717 return retrieveByPK(SimpleKey.keyFor(pk), con); 718 } 719 720 729 public static Depend retrieveByPK(ObjectKey pk) 730 throws TorqueException, NoRowsException, TooManyRowsException 731 { 732 Connection db = null; 733 Depend retVal = null; 734 try 735 { 736 db = Torque.getConnection(DATABASE_NAME); 737 retVal = retrieveByPK(pk, db); 738 } 739 finally 740 { 741 Torque.closeConnection(db); 742 } 743 return(retVal); 744 } 745 746 756 public static Depend retrieveByPK(ObjectKey pk, Connection con) 757 throws TorqueException, NoRowsException, TooManyRowsException 758 { 759 Criteria criteria = buildCriteria(pk); 760 List v = doSelect(criteria, con); 761 if (v.size() == 0) 762 { 763 throw new NoRowsException("Failed to select a row."); 764 } 765 else if (v.size() > 1) 766 { 767 throw new TooManyRowsException("Failed to select only one row."); 768 } 769 else 770 { 771 return (Depend)v.get(0); 772 } 773 } 774 775 782 public static List retrieveByPKs(List pks) 783 throws TorqueException 784 { 785 Connection db = null; 786 List retVal = null; 787 try 788 { 789 db = Torque.getConnection(DATABASE_NAME); 790 retVal = retrieveByPKs(pks, db); 791 } 792 finally 793 { 794 Torque.closeConnection(db); 795 } 796 return(retVal); 797 } 798 799 807 public static List retrieveByPKs( List pks, Connection dbcon ) 808 throws TorqueException 809 { 810 List objs = null; 811 if (pks == null || pks.size() == 0) 812 { 813 objs = new LinkedList (); 814 } 815 else 816 { 817 Criteria criteria = new Criteria(); 818 criteria.addIn( DEPEND_ID, pks ); 819 objs = doSelect(criteria, dbcon); 820 } 821 return objs; 822 } 823 824 825 826 827 828 829 830 831 832 833 844 protected static List doSelectJoinIssueRelatedByObservedId(Criteria criteria) 845 throws TorqueException 846 { 847 setDbName(criteria); 848 849 DependPeer.addSelectColumns(criteria); 850 int offset = numColumns + 1; 851 IssuePeer.addSelectColumns(criteria); 852 853 854 criteria.addJoin(DependPeer.OBSERVED_ID, 855 IssuePeer.ISSUE_ID); 856 857 858 if (criteria.containsKey(DELETED)) 860 { 861 Object possibleBoolean = criteria.get(DELETED); 862 if (possibleBoolean instanceof Boolean ) 863 { 864 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 865 } 866 } 867 868 List rows = BasePeer.doSelect(criteria); 869 List results = new ArrayList (); 870 871 for (int i = 0; i < rows.size(); i++) 872 { 873 Record row = (Record) rows.get(i); 874 875 Class omClass = DependPeer.getOMClass(); 876 Depend obj1 = (Depend) DependPeer 877 .row2Object(row, 1, omClass); 878 omClass = IssuePeer.getOMClass(); 879 Issue obj2 = (Issue)IssuePeer 880 .row2Object(row, offset, omClass); 881 882 boolean newObject = true; 883 for (int j = 0; j < results.size(); j++) 884 { 885 Depend temp_obj1 = (Depend)results.get(j); 886 Issue temp_obj2 = (Issue)temp_obj1.getIssueRelatedByObservedId(); 887 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 888 { 889 newObject = false; 890 temp_obj2.addDependRelatedByObservedId(obj1); 891 break; 892 } 893 } 894 if (newObject) 895 { 896 obj2.initDependsRelatedByObservedId(); 897 obj2.addDependRelatedByObservedId(obj1); 898 } 899 results.add(obj1); 900 } 901 return results; 902 } 903 904 905 906 907 918 protected static List doSelectJoinIssueRelatedByObserverId(Criteria criteria) 919 throws TorqueException 920 { 921 setDbName(criteria); 922 923 DependPeer.addSelectColumns(criteria); 924 int offset = numColumns + 1; 925 IssuePeer.addSelectColumns(criteria); 926 927 928 criteria.addJoin(DependPeer.OBSERVER_ID, 929 IssuePeer.ISSUE_ID); 930 931 932 if (criteria.containsKey(DELETED)) 934 { 935 Object possibleBoolean = criteria.get(DELETED); 936 if (possibleBoolean instanceof Boolean ) 937 { 938 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 939 } 940 } 941 942 List rows = BasePeer.doSelect(criteria); 943 List results = new ArrayList (); 944 945 for (int i = 0; i < rows.size(); i++) 946 { 947 Record row = (Record) rows.get(i); 948 949 Class omClass = DependPeer.getOMClass(); 950 Depend obj1 = (Depend) DependPeer 951 .row2Object(row, 1, omClass); 952 omClass = IssuePeer.getOMClass(); 953 Issue obj2 = (Issue)IssuePeer 954 .row2Object(row, offset, omClass); 955 956 boolean newObject = true; 957 for (int j = 0; j < results.size(); j++) 958 { 959 Depend temp_obj1 = (Depend)results.get(j); 960 Issue temp_obj2 = (Issue)temp_obj1.getIssueRelatedByObserverId(); 961 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 962 { 963 newObject = false; 964 temp_obj2.addDependRelatedByObserverId(obj1); 965 break; 966 } 967 } 968 if (newObject) 969 { 970 obj2.initDependsRelatedByObserverId(); 971 obj2.addDependRelatedByObserverId(obj1); 972 } 973 results.add(obj1); 974 } 975 return results; 976 } 977 978 979 980 981 992 protected static List doSelectJoinDependType(Criteria criteria) 993 throws TorqueException 994 { 995 setDbName(criteria); 996 997 DependPeer.addSelectColumns(criteria); 998 int offset = numColumns + 1; 999 DependTypePeer.addSelectColumns(criteria); 1000 1001 1002 criteria.addJoin(DependPeer.DEPEND_TYPE_ID, 1003 DependTypePeer.DEPEND_TYPE_ID); 1004 1005 1006 if (criteria.containsKey(DELETED)) 1008 { 1009 Object possibleBoolean = criteria.get(DELETED); 1010 if (possibleBoolean instanceof Boolean ) 1011 { 1012 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1013 } 1014 } 1015 1016 List rows = BasePeer.doSelect(criteria); 1017 List results = new ArrayList (); 1018 1019 for (int i = 0; i < rows.size(); i++) 1020 { 1021 Record row = (Record) rows.get(i); 1022 1023 Class omClass = DependPeer.getOMClass(); 1024 Depend obj1 = (Depend) DependPeer 1025 .row2Object(row, 1, omClass); 1026 omClass = DependTypePeer.getOMClass(); 1027 DependType obj2 = (DependType)DependTypePeer 1028 .row2Object(row, offset, omClass); 1029 1030 boolean newObject = true; 1031 for (int j = 0; j < results.size(); j++) 1032 { 1033 Depend temp_obj1 = (Depend)results.get(j); 1034 DependType temp_obj2 = (DependType)temp_obj1.getDependType(); 1035 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1036 { 1037 newObject = false; 1038 temp_obj2.addDepend(obj1); 1039 break; 1040 } 1041 } 1042 if (newObject) 1043 { 1044 obj2.initDepends(); 1045 obj2.addDepend(obj1); 1046 } 1047 results.add(obj1); 1048 } 1049 return results; 1050 } 1051 1052 1053 1054 1055 1056 1057 1058 1059 1070 protected static List doSelectJoinAllExceptIssueRelatedByObservedId(Criteria criteria) 1071 throws TorqueException 1072 { 1073 setDbName(criteria); 1074 1075 addSelectColumns(criteria); 1076 int offset2 = numColumns + 1; 1077 1078 1079 1080 DependTypePeer.addSelectColumns(criteria); 1081 int offset3 = offset2 + DependTypePeer.numColumns; 1082 if (criteria.containsKey(DELETED)) 1084 { 1085 Object possibleBoolean = criteria.get(DELETED); 1086 if (possibleBoolean instanceof Boolean ) 1087 { 1088 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1089 } 1090 } 1091 1092 List rows = BasePeer.doSelect(criteria); 1093 List results = new ArrayList (); 1094 1095 for (int i = 0; i < rows.size(); i++) 1096 { 1097 Record row = (Record)rows.get(i); 1098 1099 Class omClass = DependPeer.getOMClass(); 1100 Depend obj1 = (Depend)DependPeer 1101 .row2Object(row, 1, omClass); 1102 1103 1104 1105 1106 1107 1108 omClass = DependTypePeer.getOMClass(); 1109 DependType obj2 = (DependType)DependTypePeer 1110 .row2Object( row, offset2, omClass); 1111 1112 boolean newObject = true; 1113 for (int j = 0; j < results.size(); j++) 1114 { 1115 Depend temp_obj1 = (Depend)results.get(j); 1116 DependType temp_obj2 = (DependType)temp_obj1.getDependType(); 1117 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1118 { 1119 newObject = false; 1120 temp_obj2.addDepend(obj1); 1121 break; 1122 } 1123 } 1124 if (newObject) 1125 { 1126 obj2.initDepends(); 1127 obj2.addDepend(obj1); 1128 } 1129 results.add(obj1); 1130 } 1131 return results; 1132 } 1133 1134 1135 1136 1137 1138 1149 protected static List doSelectJoinAllExceptIssueRelatedByObserverId(Criteria criteria) 1150 throws TorqueException 1151 { 1152 setDbName(criteria); 1153 1154 addSelectColumns(criteria); 1155 int offset2 = numColumns + 1; 1156 1157 1158 1159 DependTypePeer.addSelectColumns(criteria); 1160 int offset3 = offset2 + DependTypePeer.numColumns; 1161 if (criteria.containsKey(DELETED)) 1163 { 1164 Object possibleBoolean = criteria.get(DELETED); 1165 if (possibleBoolean instanceof Boolean ) 1166 { 1167 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1168 } 1169 } 1170 1171 List rows = BasePeer.doSelect(criteria); 1172 List results = new ArrayList (); 1173 1174 for (int i = 0; i < rows.size(); i++) 1175 { 1176 Record row = (Record)rows.get(i); 1177 1178 Class omClass = DependPeer.getOMClass(); 1179 Depend obj1 = (Depend)DependPeer 1180 .row2Object(row, 1, omClass); 1181 1182 1183 1184 1185 1186 1187 omClass = DependTypePeer.getOMClass(); 1188 DependType obj2 = (DependType)DependTypePeer 1189 .row2Object( row, offset2, omClass); 1190 1191 boolean newObject = true; 1192 for (int j = 0; j < results.size(); j++) 1193 { 1194 Depend temp_obj1 = (Depend)results.get(j); 1195 DependType temp_obj2 = (DependType)temp_obj1.getDependType(); 1196 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1197 { 1198 newObject = false; 1199 temp_obj2.addDepend(obj1); 1200 break; 1201 } 1202 } 1203 if (newObject) 1204 { 1205 obj2.initDepends(); 1206 obj2.addDepend(obj1); 1207 } 1208 results.add(obj1); 1209 } 1210 return results; 1211 } 1212 1213 1214 1215 1216 1217 1228 protected static List doSelectJoinAllExceptDependType(Criteria criteria) 1229 throws TorqueException 1230 { 1231 setDbName(criteria); 1232 1233 addSelectColumns(criteria); 1234 int offset2 = numColumns + 1; 1235 1236 IssuePeer.addSelectColumns(criteria); 1237 int offset3 = offset2 + IssuePeer.numColumns; 1238 1239 IssuePeer.addSelectColumns(criteria); 1240 int offset4 = offset3 + IssuePeer.numColumns; 1241 1242 if (criteria.containsKey(DELETED)) 1244 { 1245 Object possibleBoolean = criteria.get(DELETED); 1246 if (possibleBoolean instanceof Boolean ) 1247 { 1248 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1249 } 1250 } 1251 1252 List rows = BasePeer.doSelect(criteria); 1253 List results = new ArrayList (); 1254 1255 for (int i = 0; i < rows.size(); i++) 1256 { 1257 Record row = (Record)rows.get(i); 1258 1259 Class omClass = DependPeer.getOMClass(); 1260 Depend obj1 = (Depend)DependPeer 1261 .row2Object(row, 1, omClass); 1262 1263 1264 1265 1266 omClass = IssuePeer.getOMClass(); 1267 Issue obj2 = (Issue)IssuePeer 1268 .row2Object( row, offset2, omClass); 1269 1270 boolean newObject = true; 1271 for (int j = 0; j < results.size(); j++) 1272 { 1273 Depend temp_obj1 = (Depend)results.get(j); 1274 Issue temp_obj2 = (Issue)temp_obj1.getIssueRelatedByObservedId(); 1275 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1276 { 1277 newObject = false; 1278 temp_obj2.addDependRelatedByObservedId(obj1); 1279 break; 1280 } 1281 } 1282 if (newObject) 1283 { 1284 obj2.initDependsRelatedByObservedId(); 1285 obj2.addDependRelatedByObservedId(obj1); 1286 } 1287 1288 1289 1290 1291 omClass = IssuePeer.getOMClass(); 1292 Issue obj3 = (Issue)IssuePeer 1293 .row2Object( row, offset3, omClass); 1294 1295 newObject = true; 1296 for (int j = 0; j < results.size(); j++) 1297 { 1298 Depend temp_obj1 = (Depend)results.get(j); 1299 Issue temp_obj3 = (Issue)temp_obj1.getIssueRelatedByObserverId(); 1300 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1301 { 1302 newObject = false; 1303 temp_obj3.addDependRelatedByObserverId(obj1); 1304 break; 1305 } 1306 } 1307 if (newObject) 1308 { 1309 obj3.initDependsRelatedByObserverId(); 1310 obj3.addDependRelatedByObserverId(obj1); 1311 } 1312 1313 results.add(obj1); 1314 } 1315 return results; 1316 } 1317 1318 1319 1326 protected static TableMap getTableMap() 1327 throws TorqueException 1328 { 1329 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1330 } 1331 1332 private static void setDbName(Criteria crit) 1333 { 1334 if (crit.getDbName() == Torque.getDefaultDB()) 1338 { 1339 crit.setDbName(DATABASE_NAME); 1340 } 1341 } 1342} 1343 | Popular Tags |