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 BaseAttributeValuePeer 41 extends BasePeer 42 { 43 44 45 public static final String DATABASE_NAME = "scarab"; 46 47 48 public static final String TABLE_NAME = "SCARAB_ISSUE_ATTRIBUTE_VALUE"; 49 50 55 public static MapBuilder getMapBuilder() 56 throws TorqueException 57 { 58 return getMapBuilder(AttributeValueMapBuilder.CLASS_NAME); 59 } 60 61 62 public static final String VALUE_ID; 63 64 public static final String ISSUE_ID; 65 66 public static final String ATTRIBUTE_ID; 67 68 public static final String NUMERIC_VALUE; 69 70 public static final String OPTION_ID; 71 72 public static final String USER_ID; 73 74 public static final String VALUE; 75 76 public static final String DELETED; 77 78 static 79 { 80 VALUE_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.VALUE_ID"; 81 ISSUE_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.ISSUE_ID"; 82 ATTRIBUTE_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.ATTRIBUTE_ID"; 83 NUMERIC_VALUE = "SCARAB_ISSUE_ATTRIBUTE_VALUE.NUMERIC_VALUE"; 84 OPTION_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.OPTION_ID"; 85 USER_ID = "SCARAB_ISSUE_ATTRIBUTE_VALUE.USER_ID"; 86 VALUE = "SCARAB_ISSUE_ATTRIBUTE_VALUE.VALUE"; 87 DELETED = "SCARAB_ISSUE_ATTRIBUTE_VALUE.DELETED"; 88 if (Torque.isInit()) 89 { 90 try 91 { 92 getMapBuilder(AttributeValueMapBuilder.CLASS_NAME); 93 } 94 catch (Exception e) 95 { 96 log.error("Could not initialize Peer", e); 97 } 98 } 99 else 100 { 101 Torque.registerMapBuilder(AttributeValueMapBuilder.CLASS_NAME); 102 } 103 } 104 105 106 public static final int numColumns = 8; 107 108 109 protected static final String CLASSNAME_DEFAULT = 110 "org.tigris.scarab.om.AttributeValue"; 111 112 113 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 114 115 121 private static Class initClass(String className) 122 { 123 Class c = null; 124 try 125 { 126 c = Class.forName(className); 127 } 128 catch (Throwable t) 129 { 130 log.error("A FATAL ERROR has occurred which should not " 131 + "have happened under any circumstance. Please notify " 132 + "the Torque developers <torque-dev@db.apache.org> " 133 + "and give as many details as possible (including the error " 134 + "stack trace).", t); 135 136 if (t instanceof Error ) 138 { 139 throw (Error ) t.fillInStackTrace(); 140 } 141 } 142 return c; 143 } 144 145 155 public static List resultSet2Objects(java.sql.ResultSet results) 156 throws TorqueException 157 { 158 try 159 { 160 QueryDataSet qds = null; 161 List rows = null; 162 try 163 { 164 qds = new QueryDataSet(results); 165 rows = getSelectResults(qds); 166 } 167 finally 168 { 169 if (qds != null) 170 { 171 qds.close(); 172 } 173 } 174 175 return populateObjects(rows); 176 } 177 catch (SQLException e) 178 { 179 throw new TorqueException(e); 180 } 181 catch (DataSetException e) 182 { 183 throw new TorqueException(e); 184 } 185 } 186 187 188 189 190 191 198 public static ObjectKey doInsert(Criteria criteria) 199 throws TorqueException 200 { 201 return BaseAttributeValuePeer 202 .doInsert(criteria, (Connection ) null); 203 } 204 205 215 public static ObjectKey doInsert(Criteria criteria, Connection con) 216 throws TorqueException 217 { 218 if (criteria.containsKey(DELETED)) 220 { 221 Object possibleBoolean = criteria.get(DELETED); 222 if (possibleBoolean instanceof Boolean ) 223 { 224 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 225 } 226 } 227 228 setDbName(criteria); 229 230 if (con == null) 231 { 232 return BasePeer.doInsert(criteria); 233 } 234 else 235 { 236 return BasePeer.doInsert(criteria, con); 237 } 238 } 239 240 247 public static void addSelectColumns(Criteria criteria) 248 throws TorqueException 249 { 250 criteria.addSelectColumn(VALUE_ID); 251 criteria.addSelectColumn(ISSUE_ID); 252 criteria.addSelectColumn(ATTRIBUTE_ID); 253 criteria.addSelectColumn(NUMERIC_VALUE); 254 criteria.addSelectColumn(OPTION_ID); 255 criteria.addSelectColumn(USER_ID); 256 criteria.addSelectColumn(VALUE); 257 criteria.addSelectColumn(DELETED); 258 } 259 260 269 public static AttributeValue row2Object(Record row, 270 int offset, 271 Class cls) 272 throws TorqueException 273 { 274 try 275 { 276 AttributeValue obj = (AttributeValue) cls.newInstance(); 277 AttributeValuePeer.populateObject(row, offset, obj); 278 obj.setModified(false); 279 obj.setNew(false); 280 281 return obj; 282 } 283 catch (InstantiationException e) 284 { 285 throw new TorqueException(e); 286 } 287 catch (IllegalAccessException e) 288 { 289 throw new TorqueException(e); 290 } 291 } 292 293 302 public static void populateObject(Record row, 303 int offset, 304 AttributeValue obj) 305 throws TorqueException 306 { 307 try 308 { 309 obj.setValueId(row.getValue(offset + 0).asLongObj()); 310 obj.setIssueId(row.getValue(offset + 1).asLongObj()); 311 obj.setAttributeId(row.getValue(offset + 2).asIntegerObj()); 312 obj.setNumericValue(row.getValue(offset + 3).asIntegerObj()); 313 obj.setOptionId(row.getValue(offset + 4).asIntegerObj()); 314 obj.setUserId(row.getValue(offset + 5).asIntegerObj()); 315 obj.setValue(row.getValue(offset + 6).asString()); 316 obj.setDeleted(row.getValue(offset + 7).asBoolean()); 317 } 318 catch (DataSetException e) 319 { 320 throw new TorqueException(e); 321 } 322 } 323 324 332 public static List doSelect(Criteria criteria) throws TorqueException 333 { 334 return populateObjects(doSelectVillageRecords(criteria)); 335 } 336 337 346 public static List doSelect(Criteria criteria, Connection con) 347 throws TorqueException 348 { 349 return populateObjects(doSelectVillageRecords(criteria, con)); 350 } 351 352 362 public static List doSelectVillageRecords(Criteria criteria) 363 throws TorqueException 364 { 365 return BaseAttributeValuePeer 366 .doSelectVillageRecords(criteria, (Connection ) null); 367 } 368 369 378 public static List doSelectVillageRecords(Criteria criteria, Connection con) 379 throws TorqueException 380 { 381 if (criteria.getSelectColumns().size() == 0) 382 { 383 addSelectColumns(criteria); 384 } 385 386 if (criteria.containsKey(DELETED)) 388 { 389 Object possibleBoolean = criteria.get(DELETED); 390 if (possibleBoolean instanceof Boolean ) 391 { 392 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 393 } 394 } 395 396 setDbName(criteria); 397 398 if (con == null) 401 { 402 return BasePeer.doSelect(criteria); 403 } 404 else 405 { 406 return BasePeer.doSelect(criteria, con); 407 } 408 } 409 410 417 public static List populateObjects(List records) 418 throws TorqueException 419 { 420 List results = new ArrayList (records.size()); 421 422 for (int i = 0; i < records.size(); i++) 424 { 425 Record row = (Record) records.get(i); 426 results.add(AttributeValuePeer.row2Object(row, 1, 427 AttributeValuePeer.getOMClass(row, 1))); 428 } 429 return results; 430 } 431 432 439 public static Class getOMClass(Record record, int offset) 440 throws TorqueException 441 { 442 Class c = null; 443 try 444 { 445 c = Class.forName( 446 record.getValue(offset - 1 + 3).asString()); 447 } 448 catch (Exception e) 449 { 450 throw new TorqueException(e); 451 } 452 return c; 453 } 454 455 463 public static Class getOMClass() 464 throws TorqueException 465 { 466 return CLASS_DEFAULT; 467 } 468 469 477 public static void doUpdate(Criteria criteria) throws TorqueException 478 { 479 BaseAttributeValuePeer 480 .doUpdate(criteria, (Connection ) null); 481 } 482 483 494 public static void doUpdate(Criteria criteria, Connection con) 495 throws TorqueException 496 { 497 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 498 selectCriteria.put(VALUE_ID, criteria.remove(VALUE_ID)); 499 if (criteria.containsKey(DELETED)) 501 { 502 Object possibleBoolean = criteria.get(DELETED); 503 if (possibleBoolean instanceof Boolean ) 504 { 505 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 506 } 507 } 508 509 setDbName(criteria); 510 511 if (con == null) 512 { 513 BasePeer.doUpdate(selectCriteria, criteria); 514 } 515 else 516 { 517 BasePeer.doUpdate(selectCriteria, criteria, con); 518 } 519 } 520 521 528 public static void doDelete(Criteria criteria) throws TorqueException 529 { 530 AttributeValuePeer 531 .doDelete(criteria, (Connection ) null); 532 } 533 534 544 public static void doDelete(Criteria criteria, Connection con) 545 throws TorqueException 546 { 547 if (criteria.containsKey(DELETED)) 549 { 550 Object possibleBoolean = criteria.get(DELETED); 551 if (possibleBoolean instanceof Boolean ) 552 { 553 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 554 } 555 } 556 557 setDbName(criteria); 558 559 if (con == null) 560 { 561 BasePeer.doDelete(criteria); 562 } 563 else 564 { 565 BasePeer.doDelete(criteria, con); 566 } 567 } 568 569 575 public static List doSelect(AttributeValue obj) throws TorqueException 576 { 577 return doSelect(buildSelectCriteria(obj)); 578 } 579 580 586 public static void doInsert(AttributeValue obj) throws TorqueException 587 { 588 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 589 obj.setNew(false); 590 obj.setModified(false); 591 } 592 593 598 public static void doUpdate(AttributeValue obj) throws TorqueException 599 { 600 doUpdate(buildCriteria(obj)); 601 obj.setModified(false); 602 } 603 604 609 public static void doDelete(AttributeValue obj) throws TorqueException 610 { 611 doDelete(buildSelectCriteria(obj)); 612 } 613 614 624 public static void doInsert(AttributeValue obj, Connection con) 625 throws TorqueException 626 { 627 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 628 obj.setNew(false); 629 obj.setModified(false); 630 } 631 632 642 public static void doUpdate(AttributeValue obj, Connection con) 643 throws TorqueException 644 { 645 doUpdate(buildCriteria(obj), con); 646 obj.setModified(false); 647 } 648 649 659 public static void doDelete(AttributeValue obj, Connection con) 660 throws TorqueException 661 { 662 doDelete(buildSelectCriteria(obj), con); 663 } 664 665 672 public static void doDelete(ObjectKey pk) throws TorqueException 673 { 674 BaseAttributeValuePeer 675 .doDelete(pk, (Connection ) null); 676 } 677 678 688 public static void doDelete(ObjectKey pk, Connection con) 689 throws TorqueException 690 { 691 doDelete(buildCriteria(pk), con); 692 } 693 694 695 public static Criteria buildCriteria( ObjectKey pk ) 696 { 697 Criteria criteria = new Criteria(); 698 criteria.add(VALUE_ID, pk); 699 return criteria; 700 } 701 702 703 public static Criteria buildCriteria( AttributeValue obj ) 704 { 705 Criteria criteria = new Criteria(DATABASE_NAME); 706 if (!obj.isNew()) 707 criteria.add(VALUE_ID, obj.getValueId()); 708 criteria.add(ISSUE_ID, obj.getIssueId()); 709 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 710 criteria.add(NUMERIC_VALUE, obj.getNumericValue()); 711 criteria.add(OPTION_ID, obj.getOptionId()); 712 criteria.add(USER_ID, obj.getUserId()); 713 criteria.add(VALUE, obj.getValue()); 714 criteria.add(DELETED, obj.getDeleted()); 715 return criteria; 716 } 717 718 719 public static Criteria buildSelectCriteria( AttributeValue obj ) 720 { 721 Criteria criteria = new Criteria(DATABASE_NAME); 722 if (!obj.isNew()) 723 criteria.add(VALUE_ID, obj.getValueId()); 724 criteria.add(ISSUE_ID, obj.getIssueId()); 725 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 726 criteria.add(NUMERIC_VALUE, obj.getNumericValue()); 727 criteria.add(OPTION_ID, obj.getOptionId()); 728 criteria.add(USER_ID, obj.getUserId()); 729 criteria.add(VALUE, obj.getValue()); 730 criteria.add(DELETED, obj.getDeleted()); 731 return criteria; 732 } 733 734 735 744 public static AttributeValue retrieveByPK(Long pk) 745 throws TorqueException, NoRowsException, TooManyRowsException 746 { 747 return retrieveByPK(SimpleKey.keyFor(pk)); 748 } 749 750 760 public static AttributeValue retrieveByPK(Long pk, Connection con) 761 throws TorqueException, NoRowsException, TooManyRowsException 762 { 763 return retrieveByPK(SimpleKey.keyFor(pk), con); 764 } 765 766 775 public static AttributeValue retrieveByPK(ObjectKey pk) 776 throws TorqueException, NoRowsException, TooManyRowsException 777 { 778 Connection db = null; 779 AttributeValue retVal = null; 780 try 781 { 782 db = Torque.getConnection(DATABASE_NAME); 783 retVal = retrieveByPK(pk, db); 784 } 785 finally 786 { 787 Torque.closeConnection(db); 788 } 789 return(retVal); 790 } 791 792 802 public static AttributeValue retrieveByPK(ObjectKey pk, Connection con) 803 throws TorqueException, NoRowsException, TooManyRowsException 804 { 805 Criteria criteria = buildCriteria(pk); 806 List v = doSelect(criteria, con); 807 if (v.size() == 0) 808 { 809 throw new NoRowsException("Failed to select a row."); 810 } 811 else if (v.size() > 1) 812 { 813 throw new TooManyRowsException("Failed to select only one row."); 814 } 815 else 816 { 817 return (AttributeValue)v.get(0); 818 } 819 } 820 821 828 public static List retrieveByPKs(List pks) 829 throws TorqueException 830 { 831 Connection db = null; 832 List retVal = null; 833 try 834 { 835 db = Torque.getConnection(DATABASE_NAME); 836 retVal = retrieveByPKs(pks, db); 837 } 838 finally 839 { 840 Torque.closeConnection(db); 841 } 842 return(retVal); 843 } 844 845 853 public static List retrieveByPKs( List pks, Connection dbcon ) 854 throws TorqueException 855 { 856 List objs = null; 857 if (pks == null || pks.size() == 0) 858 { 859 objs = new LinkedList (); 860 } 861 else 862 { 863 Criteria criteria = new Criteria(); 864 criteria.addIn( VALUE_ID, pks ); 865 objs = doSelect(criteria, dbcon); 866 } 867 return objs; 868 } 869 870 871 872 873 874 875 876 877 878 879 890 protected static List doSelectJoinIssue(Criteria criteria) 891 throws TorqueException 892 { 893 setDbName(criteria); 894 895 AttributeValuePeer.addSelectColumns(criteria); 896 int offset = numColumns + 1; 897 IssuePeer.addSelectColumns(criteria); 898 899 900 criteria.addJoin(AttributeValuePeer.ISSUE_ID, 901 IssuePeer.ISSUE_ID); 902 903 904 if (criteria.containsKey(DELETED)) 906 { 907 Object possibleBoolean = criteria.get(DELETED); 908 if (possibleBoolean instanceof Boolean ) 909 { 910 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 911 } 912 } 913 914 List rows = BasePeer.doSelect(criteria); 915 List results = new ArrayList (); 916 917 for (int i = 0; i < rows.size(); i++) 918 { 919 Record row = (Record) rows.get(i); 920 921 Class omClass = AttributeValuePeer.getOMClass(row, 1); 922 AttributeValue obj1 = (AttributeValue) AttributeValuePeer 923 .row2Object(row, 1, omClass); 924 omClass = IssuePeer.getOMClass(); 925 Issue obj2 = (Issue)IssuePeer 926 .row2Object(row, offset, omClass); 927 928 boolean newObject = true; 929 for (int j = 0; j < results.size(); j++) 930 { 931 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 932 Issue temp_obj2 = (Issue)temp_obj1.getIssue(); 933 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 934 { 935 newObject = false; 936 temp_obj2.addAttributeValue(obj1); 937 break; 938 } 939 } 940 if (newObject) 941 { 942 obj2.initAttributeValues(); 943 obj2.addAttributeValue(obj1); 944 } 945 results.add(obj1); 946 } 947 return results; 948 } 949 950 951 952 953 964 protected static List doSelectJoinAttribute(Criteria criteria) 965 throws TorqueException 966 { 967 setDbName(criteria); 968 969 AttributeValuePeer.addSelectColumns(criteria); 970 int offset = numColumns + 1; 971 AttributePeer.addSelectColumns(criteria); 972 973 974 criteria.addJoin(AttributeValuePeer.ATTRIBUTE_ID, 975 AttributePeer.ATTRIBUTE_ID); 976 977 978 if (criteria.containsKey(DELETED)) 980 { 981 Object possibleBoolean = criteria.get(DELETED); 982 if (possibleBoolean instanceof Boolean ) 983 { 984 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 985 } 986 } 987 988 List rows = BasePeer.doSelect(criteria); 989 List results = new ArrayList (); 990 991 for (int i = 0; i < rows.size(); i++) 992 { 993 Record row = (Record) rows.get(i); 994 995 Class omClass = AttributeValuePeer.getOMClass(row, 1); 996 AttributeValue obj1 = (AttributeValue) AttributeValuePeer 997 .row2Object(row, 1, omClass); 998 omClass = AttributePeer.getOMClass(); 999 Attribute obj2 = (Attribute)AttributePeer 1000 .row2Object(row, offset, omClass); 1001 1002 boolean newObject = true; 1003 for (int j = 0; j < results.size(); j++) 1004 { 1005 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1006 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1007 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1008 { 1009 newObject = false; 1010 temp_obj2.addAttributeValue(obj1); 1011 break; 1012 } 1013 } 1014 if (newObject) 1015 { 1016 obj2.initAttributeValues(); 1017 obj2.addAttributeValue(obj1); 1018 } 1019 results.add(obj1); 1020 } 1021 return results; 1022 } 1023 1024 1025 1026 1027 1038 protected static List doSelectJoinAttributeOption(Criteria criteria) 1039 throws TorqueException 1040 { 1041 setDbName(criteria); 1042 1043 AttributeValuePeer.addSelectColumns(criteria); 1044 int offset = numColumns + 1; 1045 AttributeOptionPeer.addSelectColumns(criteria); 1046 1047 1048 criteria.addJoin(AttributeValuePeer.OPTION_ID, 1049 AttributeOptionPeer.OPTION_ID); 1050 1051 1052 if (criteria.containsKey(DELETED)) 1054 { 1055 Object possibleBoolean = criteria.get(DELETED); 1056 if (possibleBoolean instanceof Boolean ) 1057 { 1058 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1059 } 1060 } 1061 1062 List rows = BasePeer.doSelect(criteria); 1063 List results = new ArrayList (); 1064 1065 for (int i = 0; i < rows.size(); i++) 1066 { 1067 Record row = (Record) rows.get(i); 1068 1069 Class omClass = AttributeValuePeer.getOMClass(row, 1); 1070 AttributeValue obj1 = (AttributeValue) AttributeValuePeer 1071 .row2Object(row, 1, omClass); 1072 omClass = AttributeOptionPeer.getOMClass(); 1073 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1074 .row2Object(row, offset, omClass); 1075 1076 boolean newObject = true; 1077 for (int j = 0; j < results.size(); j++) 1078 { 1079 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1080 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 1081 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1082 { 1083 newObject = false; 1084 temp_obj2.addAttributeValue(obj1); 1085 break; 1086 } 1087 } 1088 if (newObject) 1089 { 1090 obj2.initAttributeValues(); 1091 obj2.addAttributeValue(obj1); 1092 } 1093 results.add(obj1); 1094 } 1095 return results; 1096 } 1097 1098 1099 1100 1101 1112 protected static List doSelectJoinScarabUserImpl(Criteria criteria) 1113 throws TorqueException 1114 { 1115 setDbName(criteria); 1116 1117 AttributeValuePeer.addSelectColumns(criteria); 1118 int offset = numColumns + 1; 1119 ScarabUserImplPeer.addSelectColumns(criteria); 1120 1121 1122 criteria.addJoin(AttributeValuePeer.USER_ID, 1123 ScarabUserImplPeer.USER_ID); 1124 1125 1126 if (criteria.containsKey(DELETED)) 1128 { 1129 Object possibleBoolean = criteria.get(DELETED); 1130 if (possibleBoolean instanceof Boolean ) 1131 { 1132 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1133 } 1134 } 1135 1136 List rows = BasePeer.doSelect(criteria); 1137 List results = new ArrayList (); 1138 1139 for (int i = 0; i < rows.size(); i++) 1140 { 1141 Record row = (Record) rows.get(i); 1142 1143 Class omClass = AttributeValuePeer.getOMClass(row, 1); 1144 AttributeValue obj1 = (AttributeValue) AttributeValuePeer 1145 .row2Object(row, 1, omClass); 1146 omClass = ScarabUserImplPeer.getOMClass(); 1147 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1148 .row2Object(row, offset, omClass); 1149 1150 boolean newObject = true; 1151 for (int j = 0; j < results.size(); j++) 1152 { 1153 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1154 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1155 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1156 { 1157 newObject = false; 1158 temp_obj2.addAttributeValue(obj1); 1159 break; 1160 } 1161 } 1162 if (newObject) 1163 { 1164 obj2.initAttributeValues(); 1165 obj2.addAttributeValue(obj1); 1166 } 1167 results.add(obj1); 1168 } 1169 return results; 1170 } 1171 1172 1173 1174 1175 1176 1177 1178 1179 1190 protected static List doSelectJoinAllExceptIssue(Criteria criteria) 1191 throws TorqueException 1192 { 1193 setDbName(criteria); 1194 1195 addSelectColumns(criteria); 1196 int offset2 = numColumns + 1; 1197 1198 1199 AttributePeer.addSelectColumns(criteria); 1200 int offset3 = offset2 + AttributePeer.numColumns; 1201 1202 AttributeOptionPeer.addSelectColumns(criteria); 1203 int offset4 = offset3 + AttributeOptionPeer.numColumns; 1204 1205 ScarabUserImplPeer.addSelectColumns(criteria); 1206 int offset5 = offset4 + ScarabUserImplPeer.numColumns; 1207 if (criteria.containsKey(DELETED)) 1209 { 1210 Object possibleBoolean = criteria.get(DELETED); 1211 if (possibleBoolean instanceof Boolean ) 1212 { 1213 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1214 } 1215 } 1216 1217 List rows = BasePeer.doSelect(criteria); 1218 List results = new ArrayList (); 1219 1220 for (int i = 0; i < rows.size(); i++) 1221 { 1222 Record row = (Record)rows.get(i); 1223 1224 Class omClass = AttributeValuePeer.getOMClass(row, 1); 1225 AttributeValue obj1 = (AttributeValue)AttributeValuePeer 1226 .row2Object(row, 1, omClass); 1227 1228 1229 1230 1231 1232 omClass = AttributePeer.getOMClass(); 1233 Attribute obj2 = (Attribute)AttributePeer 1234 .row2Object( row, offset2, omClass); 1235 1236 boolean newObject = true; 1237 for (int j = 0; j < results.size(); j++) 1238 { 1239 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1240 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1241 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1242 { 1243 newObject = false; 1244 temp_obj2.addAttributeValue(obj1); 1245 break; 1246 } 1247 } 1248 if (newObject) 1249 { 1250 obj2.initAttributeValues(); 1251 obj2.addAttributeValue(obj1); 1252 } 1253 1254 1255 1256 1257 omClass = AttributeOptionPeer.getOMClass(); 1258 AttributeOption obj3 = (AttributeOption)AttributeOptionPeer 1259 .row2Object( row, offset3, omClass); 1260 1261 newObject = true; 1262 for (int j = 0; j < results.size(); j++) 1263 { 1264 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1265 AttributeOption temp_obj3 = (AttributeOption)temp_obj1.getAttributeOption(); 1266 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1267 { 1268 newObject = false; 1269 temp_obj3.addAttributeValue(obj1); 1270 break; 1271 } 1272 } 1273 if (newObject) 1274 { 1275 obj3.initAttributeValues(); 1276 obj3.addAttributeValue(obj1); 1277 } 1278 1279 1280 1281 1282 omClass = ScarabUserImplPeer.getOMClass(); 1283 ScarabUserImpl obj4 = (ScarabUserImpl)ScarabUserImplPeer 1284 .row2Object( row, offset4, omClass); 1285 1286 newObject = true; 1287 for (int j = 0; j < results.size(); j++) 1288 { 1289 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1290 ScarabUserImpl temp_obj4 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1291 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1292 { 1293 newObject = false; 1294 temp_obj4.addAttributeValue(obj1); 1295 break; 1296 } 1297 } 1298 if (newObject) 1299 { 1300 obj4.initAttributeValues(); 1301 obj4.addAttributeValue(obj1); 1302 } 1303 results.add(obj1); 1304 } 1305 return results; 1306 } 1307 1308 1309 1310 1311 1312 1323 protected static List doSelectJoinAllExceptAttribute(Criteria criteria) 1324 throws TorqueException 1325 { 1326 setDbName(criteria); 1327 1328 addSelectColumns(criteria); 1329 int offset2 = numColumns + 1; 1330 1331 IssuePeer.addSelectColumns(criteria); 1332 int offset3 = offset2 + IssuePeer.numColumns; 1333 1334 1335 AttributeOptionPeer.addSelectColumns(criteria); 1336 int offset4 = offset3 + AttributeOptionPeer.numColumns; 1337 1338 ScarabUserImplPeer.addSelectColumns(criteria); 1339 int offset5 = offset4 + ScarabUserImplPeer.numColumns; 1340 if (criteria.containsKey(DELETED)) 1342 { 1343 Object possibleBoolean = criteria.get(DELETED); 1344 if (possibleBoolean instanceof Boolean ) 1345 { 1346 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1347 } 1348 } 1349 1350 List rows = BasePeer.doSelect(criteria); 1351 List results = new ArrayList (); 1352 1353 for (int i = 0; i < rows.size(); i++) 1354 { 1355 Record row = (Record)rows.get(i); 1356 1357 Class omClass = AttributeValuePeer.getOMClass(row, 1); 1358 AttributeValue obj1 = (AttributeValue)AttributeValuePeer 1359 .row2Object(row, 1, omClass); 1360 1361 1362 1363 1364 omClass = IssuePeer.getOMClass(); 1365 Issue obj2 = (Issue)IssuePeer 1366 .row2Object( row, offset2, omClass); 1367 1368 boolean newObject = true; 1369 for (int j = 0; j < results.size(); j++) 1370 { 1371 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1372 Issue temp_obj2 = (Issue)temp_obj1.getIssue(); 1373 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1374 { 1375 newObject = false; 1376 temp_obj2.addAttributeValue(obj1); 1377 break; 1378 } 1379 } 1380 if (newObject) 1381 { 1382 obj2.initAttributeValues(); 1383 obj2.addAttributeValue(obj1); 1384 } 1385 1386 1387 1388 1389 1390 omClass = AttributeOptionPeer.getOMClass(); 1391 AttributeOption obj3 = (AttributeOption)AttributeOptionPeer 1392 .row2Object( row, offset3, omClass); 1393 1394 newObject = true; 1395 for (int j = 0; j < results.size(); j++) 1396 { 1397 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1398 AttributeOption temp_obj3 = (AttributeOption)temp_obj1.getAttributeOption(); 1399 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1400 { 1401 newObject = false; 1402 temp_obj3.addAttributeValue(obj1); 1403 break; 1404 } 1405 } 1406 if (newObject) 1407 { 1408 obj3.initAttributeValues(); 1409 obj3.addAttributeValue(obj1); 1410 } 1411 1412 1413 1414 1415 omClass = ScarabUserImplPeer.getOMClass(); 1416 ScarabUserImpl obj4 = (ScarabUserImpl)ScarabUserImplPeer 1417 .row2Object( row, offset4, omClass); 1418 1419 newObject = true; 1420 for (int j = 0; j < results.size(); j++) 1421 { 1422 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1423 ScarabUserImpl temp_obj4 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1424 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1425 { 1426 newObject = false; 1427 temp_obj4.addAttributeValue(obj1); 1428 break; 1429 } 1430 } 1431 if (newObject) 1432 { 1433 obj4.initAttributeValues(); 1434 obj4.addAttributeValue(obj1); 1435 } 1436 results.add(obj1); 1437 } 1438 return results; 1439 } 1440 1441 1442 1443 1444 1445 1456 protected static List doSelectJoinAllExceptAttributeOption(Criteria criteria) 1457 throws TorqueException 1458 { 1459 setDbName(criteria); 1460 1461 addSelectColumns(criteria); 1462 int offset2 = numColumns + 1; 1463 1464 IssuePeer.addSelectColumns(criteria); 1465 int offset3 = offset2 + IssuePeer.numColumns; 1466 1467 AttributePeer.addSelectColumns(criteria); 1468 int offset4 = offset3 + AttributePeer.numColumns; 1469 1470 1471 ScarabUserImplPeer.addSelectColumns(criteria); 1472 int offset5 = offset4 + ScarabUserImplPeer.numColumns; 1473 if (criteria.containsKey(DELETED)) 1475 { 1476 Object possibleBoolean = criteria.get(DELETED); 1477 if (possibleBoolean instanceof Boolean ) 1478 { 1479 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1480 } 1481 } 1482 1483 List rows = BasePeer.doSelect(criteria); 1484 List results = new ArrayList (); 1485 1486 for (int i = 0; i < rows.size(); i++) 1487 { 1488 Record row = (Record)rows.get(i); 1489 1490 Class omClass = AttributeValuePeer.getOMClass(row, 1); 1491 AttributeValue obj1 = (AttributeValue)AttributeValuePeer 1492 .row2Object(row, 1, omClass); 1493 1494 1495 1496 1497 omClass = IssuePeer.getOMClass(); 1498 Issue obj2 = (Issue)IssuePeer 1499 .row2Object( row, offset2, omClass); 1500 1501 boolean newObject = true; 1502 for (int j = 0; j < results.size(); j++) 1503 { 1504 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1505 Issue temp_obj2 = (Issue)temp_obj1.getIssue(); 1506 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1507 { 1508 newObject = false; 1509 temp_obj2.addAttributeValue(obj1); 1510 break; 1511 } 1512 } 1513 if (newObject) 1514 { 1515 obj2.initAttributeValues(); 1516 obj2.addAttributeValue(obj1); 1517 } 1518 1519 1520 1521 1522 omClass = AttributePeer.getOMClass(); 1523 Attribute obj3 = (Attribute)AttributePeer 1524 .row2Object( row, offset3, omClass); 1525 1526 newObject = true; 1527 for (int j = 0; j < results.size(); j++) 1528 { 1529 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1530 Attribute temp_obj3 = (Attribute)temp_obj1.getAttribute(); 1531 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1532 { 1533 newObject = false; 1534 temp_obj3.addAttributeValue(obj1); 1535 break; 1536 } 1537 } 1538 if (newObject) 1539 { 1540 obj3.initAttributeValues(); 1541 obj3.addAttributeValue(obj1); 1542 } 1543 1544 1545 1546 1547 1548 omClass = ScarabUserImplPeer.getOMClass(); 1549 ScarabUserImpl obj4 = (ScarabUserImpl)ScarabUserImplPeer 1550 .row2Object( row, offset4, omClass); 1551 1552 newObject = true; 1553 for (int j = 0; j < results.size(); j++) 1554 { 1555 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1556 ScarabUserImpl temp_obj4 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1557 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1558 { 1559 newObject = false; 1560 temp_obj4.addAttributeValue(obj1); 1561 break; 1562 } 1563 } 1564 if (newObject) 1565 { 1566 obj4.initAttributeValues(); 1567 obj4.addAttributeValue(obj1); 1568 } 1569 results.add(obj1); 1570 } 1571 return results; 1572 } 1573 1574 1575 1576 1577 1578 1589 protected static List doSelectJoinAllExceptScarabUserImpl(Criteria criteria) 1590 throws TorqueException 1591 { 1592 setDbName(criteria); 1593 1594 addSelectColumns(criteria); 1595 int offset2 = numColumns + 1; 1596 1597 IssuePeer.addSelectColumns(criteria); 1598 int offset3 = offset2 + IssuePeer.numColumns; 1599 1600 AttributePeer.addSelectColumns(criteria); 1601 int offset4 = offset3 + AttributePeer.numColumns; 1602 1603 AttributeOptionPeer.addSelectColumns(criteria); 1604 int offset5 = offset4 + AttributeOptionPeer.numColumns; 1605 1606 if (criteria.containsKey(DELETED)) 1608 { 1609 Object possibleBoolean = criteria.get(DELETED); 1610 if (possibleBoolean instanceof Boolean ) 1611 { 1612 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1613 } 1614 } 1615 1616 List rows = BasePeer.doSelect(criteria); 1617 List results = new ArrayList (); 1618 1619 for (int i = 0; i < rows.size(); i++) 1620 { 1621 Record row = (Record)rows.get(i); 1622 1623 Class omClass = AttributeValuePeer.getOMClass(row, 1); 1624 AttributeValue obj1 = (AttributeValue)AttributeValuePeer 1625 .row2Object(row, 1, omClass); 1626 1627 1628 1629 1630 omClass = IssuePeer.getOMClass(); 1631 Issue obj2 = (Issue)IssuePeer 1632 .row2Object( row, offset2, omClass); 1633 1634 boolean newObject = true; 1635 for (int j = 0; j < results.size(); j++) 1636 { 1637 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1638 Issue temp_obj2 = (Issue)temp_obj1.getIssue(); 1639 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1640 { 1641 newObject = false; 1642 temp_obj2.addAttributeValue(obj1); 1643 break; 1644 } 1645 } 1646 if (newObject) 1647 { 1648 obj2.initAttributeValues(); 1649 obj2.addAttributeValue(obj1); 1650 } 1651 1652 1653 1654 1655 omClass = AttributePeer.getOMClass(); 1656 Attribute obj3 = (Attribute)AttributePeer 1657 .row2Object( row, offset3, omClass); 1658 1659 newObject = true; 1660 for (int j = 0; j < results.size(); j++) 1661 { 1662 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1663 Attribute temp_obj3 = (Attribute)temp_obj1.getAttribute(); 1664 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1665 { 1666 newObject = false; 1667 temp_obj3.addAttributeValue(obj1); 1668 break; 1669 } 1670 } 1671 if (newObject) 1672 { 1673 obj3.initAttributeValues(); 1674 obj3.addAttributeValue(obj1); 1675 } 1676 1677 1678 1679 1680 omClass = AttributeOptionPeer.getOMClass(); 1681 AttributeOption obj4 = (AttributeOption)AttributeOptionPeer 1682 .row2Object( row, offset4, omClass); 1683 1684 newObject = true; 1685 for (int j = 0; j < results.size(); j++) 1686 { 1687 AttributeValue temp_obj1 = (AttributeValue)results.get(j); 1688 AttributeOption temp_obj4 = (AttributeOption)temp_obj1.getAttributeOption(); 1689 if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) 1690 { 1691 newObject = false; 1692 temp_obj4.addAttributeValue(obj1); 1693 break; 1694 } 1695 } 1696 if (newObject) 1697 { 1698 obj4.initAttributeValues(); 1699 obj4.addAttributeValue(obj1); 1700 } 1701 1702 results.add(obj1); 1703 } 1704 return results; 1705 } 1706 1707 1708 1715 protected static TableMap getTableMap() 1716 throws TorqueException 1717 { 1718 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1719 } 1720 1721 private static void setDbName(Criteria crit) 1722 { 1723 if (crit.getDbName() == Torque.getDefaultDB()) 1727 { 1728 crit.setDbName(DATABASE_NAME); 1729 } 1730 } 1731} 1732 | Popular Tags |