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 BaseScarabModulePeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_MODULE"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(ScarabModuleMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String MODULE_ID; 62 63 public static final String MODULE_NAME; 64 65 public static final String DOMAIN; 66 67 public static final String MODULE_CODE; 68 69 public static final String MODULE_DESCRIPTION; 70 71 public static final String MODULE_URL; 72 73 public static final String ARCHIVE_EMAIL; 74 75 public static final String PARENT_ID; 76 77 public static final String OWNER_ID; 78 79 public static final String QA_CONTACT_ID; 80 81 public static final String DELETED; 82 83 public static final String LOCKED; 84 85 public static final String CLASS_KEY; 86 87 static 88 { 89 MODULE_ID = "SCARAB_MODULE.MODULE_ID"; 90 MODULE_NAME = "SCARAB_MODULE.MODULE_NAME"; 91 DOMAIN = "SCARAB_MODULE.DOMAIN"; 92 MODULE_CODE = "SCARAB_MODULE.MODULE_CODE"; 93 MODULE_DESCRIPTION = "SCARAB_MODULE.MODULE_DESCRIPTION"; 94 MODULE_URL = "SCARAB_MODULE.MODULE_URL"; 95 ARCHIVE_EMAIL = "SCARAB_MODULE.ARCHIVE_EMAIL"; 96 PARENT_ID = "SCARAB_MODULE.PARENT_ID"; 97 OWNER_ID = "SCARAB_MODULE.OWNER_ID"; 98 QA_CONTACT_ID = "SCARAB_MODULE.QA_CONTACT_ID"; 99 DELETED = "SCARAB_MODULE.DELETED"; 100 LOCKED = "SCARAB_MODULE.LOCKED"; 101 CLASS_KEY = "SCARAB_MODULE.CLASS_KEY"; 102 if (Torque.isInit()) 103 { 104 try 105 { 106 getMapBuilder(ScarabModuleMapBuilder.CLASS_NAME); 107 } 108 catch (Exception e) 109 { 110 log.error("Could not initialize Peer", e); 111 } 112 } 113 else 114 { 115 Torque.registerMapBuilder(ScarabModuleMapBuilder.CLASS_NAME); 116 } 117 } 118 119 120 public static final int numColumns = 13; 121 122 123 protected static final String CLASSNAME_DEFAULT = 124 "org.tigris.scarab.om.ScarabModule"; 125 126 127 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 128 129 135 private static Class initClass(String className) 136 { 137 Class c = null; 138 try 139 { 140 c = Class.forName(className); 141 } 142 catch (Throwable t) 143 { 144 log.error("A FATAL ERROR has occurred which should not " 145 + "have happened under any circumstance. Please notify " 146 + "the Torque developers <torque-dev@db.apache.org> " 147 + "and give as many details as possible (including the error " 148 + "stack trace).", t); 149 150 if (t instanceof Error ) 152 { 153 throw (Error ) t.fillInStackTrace(); 154 } 155 } 156 return c; 157 } 158 159 169 public static List resultSet2Objects(java.sql.ResultSet results) 170 throws TorqueException 171 { 172 try 173 { 174 QueryDataSet qds = null; 175 List rows = null; 176 try 177 { 178 qds = new QueryDataSet(results); 179 rows = getSelectResults(qds); 180 } 181 finally 182 { 183 if (qds != null) 184 { 185 qds.close(); 186 } 187 } 188 189 return populateObjects(rows); 190 } 191 catch (SQLException e) 192 { 193 throw new TorqueException(e); 194 } 195 catch (DataSetException e) 196 { 197 throw new TorqueException(e); 198 } 199 } 200 201 202 203 204 205 206 public static final int CLASSKEY_1 = 207 1; 208 209 210 public static final String CLASSNAME_1 = 211 "org.tigris.scarab.om.ScarabModuleContainer"; 212 213 214 public static final Class CLASS_1 = 215 initClass(CLASSNAME_1); 216 217 224 public static ObjectKey doInsert(Criteria criteria) 225 throws TorqueException 226 { 227 return BaseScarabModulePeer 228 .doInsert(criteria, (Connection ) null); 229 } 230 231 241 public static ObjectKey doInsert(Criteria criteria, Connection con) 242 throws TorqueException 243 { 244 if (criteria.containsKey(DELETED)) 246 { 247 Object possibleBoolean = criteria.get(DELETED); 248 if (possibleBoolean instanceof Boolean ) 249 { 250 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 251 } 252 } 253 if (criteria.containsKey(LOCKED)) 255 { 256 Object possibleBoolean = criteria.get(LOCKED); 257 if (possibleBoolean instanceof Boolean ) 258 { 259 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 260 } 261 } 262 263 setDbName(criteria); 264 265 if (con == null) 266 { 267 return BasePeer.doInsert(criteria); 268 } 269 else 270 { 271 return BasePeer.doInsert(criteria, con); 272 } 273 } 274 275 282 public static void addSelectColumns(Criteria criteria) 283 throws TorqueException 284 { 285 criteria.addSelectColumn(MODULE_ID); 286 criteria.addSelectColumn(MODULE_NAME); 287 criteria.addSelectColumn(DOMAIN); 288 criteria.addSelectColumn(MODULE_CODE); 289 criteria.addSelectColumn(MODULE_DESCRIPTION); 290 criteria.addSelectColumn(MODULE_URL); 291 criteria.addSelectColumn(ARCHIVE_EMAIL); 292 criteria.addSelectColumn(PARENT_ID); 293 criteria.addSelectColumn(OWNER_ID); 294 criteria.addSelectColumn(QA_CONTACT_ID); 295 criteria.addSelectColumn(DELETED); 296 criteria.addSelectColumn(LOCKED); 297 criteria.addSelectColumn(CLASS_KEY); 298 } 299 300 309 public static ScarabModule row2Object(Record row, 310 int offset, 311 Class cls) 312 throws TorqueException 313 { 314 try 315 { 316 ScarabModule obj = (ScarabModule) cls.newInstance(); 317 ScarabModulePeer.populateObject(row, offset, obj); 318 obj.setModified(false); 319 obj.setNew(false); 320 321 return obj; 322 } 323 catch (InstantiationException e) 324 { 325 throw new TorqueException(e); 326 } 327 catch (IllegalAccessException e) 328 { 329 throw new TorqueException(e); 330 } 331 } 332 333 342 public static void populateObject(Record row, 343 int offset, 344 ScarabModule obj) 345 throws TorqueException 346 { 347 try 348 { 349 obj.setModuleId(row.getValue(offset + 0).asIntegerObj()); 350 obj.setRealName(row.getValue(offset + 1).asString()); 351 obj.setDomain(row.getValue(offset + 2).asString()); 352 obj.setCode(row.getValue(offset + 3).asString()); 353 obj.setDescription(row.getValue(offset + 4).asString()); 354 obj.setUrl(row.getValue(offset + 5).asString()); 355 obj.setArchiveEmail(row.getValue(offset + 6).asString()); 356 obj.setParentId(row.getValue(offset + 7).asIntegerObj()); 357 obj.setOwnerId(row.getValue(offset + 8).asIntegerObj()); 358 obj.setQaContactId(row.getValue(offset + 9).asIntegerObj()); 359 obj.setDeleted(row.getValue(offset + 10).asBoolean()); 360 obj.setLocked(row.getValue(offset + 11).asBoolean()); 361 obj.setClassKey(row.getValue(offset + 12).asInt()); 362 } 363 catch (DataSetException e) 364 { 365 throw new TorqueException(e); 366 } 367 } 368 369 377 public static List doSelect(Criteria criteria) throws TorqueException 378 { 379 return populateObjects(doSelectVillageRecords(criteria)); 380 } 381 382 391 public static List doSelect(Criteria criteria, Connection con) 392 throws TorqueException 393 { 394 return populateObjects(doSelectVillageRecords(criteria, con)); 395 } 396 397 407 public static List doSelectVillageRecords(Criteria criteria) 408 throws TorqueException 409 { 410 return BaseScarabModulePeer 411 .doSelectVillageRecords(criteria, (Connection ) null); 412 } 413 414 423 public static List doSelectVillageRecords(Criteria criteria, Connection con) 424 throws TorqueException 425 { 426 if (criteria.getSelectColumns().size() == 0) 427 { 428 addSelectColumns(criteria); 429 } 430 431 if (criteria.containsKey(DELETED)) 433 { 434 Object possibleBoolean = criteria.get(DELETED); 435 if (possibleBoolean instanceof Boolean ) 436 { 437 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 438 } 439 } 440 if (criteria.containsKey(LOCKED)) 442 { 443 Object possibleBoolean = criteria.get(LOCKED); 444 if (possibleBoolean instanceof Boolean ) 445 { 446 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 447 } 448 } 449 450 setDbName(criteria); 451 452 if (con == null) 455 { 456 return BasePeer.doSelect(criteria); 457 } 458 else 459 { 460 return BasePeer.doSelect(criteria, con); 461 } 462 } 463 464 471 public static List populateObjects(List records) 472 throws TorqueException 473 { 474 List results = new ArrayList (records.size()); 475 476 for (int i = 0; i < records.size(); i++) 478 { 479 Record row = (Record) records.get(i); 480 results.add(ScarabModulePeer.row2Object(row, 1, 481 ScarabModulePeer.getOMClass(row, 1))); 482 } 483 return results; 484 } 485 486 493 public static Class getOMClass(Record record, int offset) 494 throws TorqueException 495 { 496 Class c = null; 497 try 498 { 499 Class omClass = null; 500 int classKey = 501 record.getValue(offset - 1 + 13) 502 .asInt(); 503 if (classKey == CLASSKEY_1) 504 { 505 omClass = CLASS_1; 506 } 507 else 508 { 509 omClass = getOMClass(); 510 } 511 c = omClass; 512 } 513 catch (Exception e) 514 { 515 throw new TorqueException(e); 516 } 517 return c; 518 } 519 520 528 public static Class getOMClass() 529 throws TorqueException 530 { 531 return CLASS_DEFAULT; 532 } 533 534 542 public static void doUpdate(Criteria criteria) throws TorqueException 543 { 544 BaseScarabModulePeer 545 .doUpdate(criteria, (Connection ) null); 546 } 547 548 559 public static void doUpdate(Criteria criteria, Connection con) 560 throws TorqueException 561 { 562 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 563 selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID)); 564 if (criteria.containsKey(DELETED)) 566 { 567 Object possibleBoolean = criteria.get(DELETED); 568 if (possibleBoolean instanceof Boolean ) 569 { 570 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 571 } 572 } 573 if (criteria.containsKey(LOCKED)) 575 { 576 Object possibleBoolean = criteria.get(LOCKED); 577 if (possibleBoolean instanceof Boolean ) 578 { 579 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 580 } 581 } 582 583 setDbName(criteria); 584 585 if (con == null) 586 { 587 BasePeer.doUpdate(selectCriteria, criteria); 588 } 589 else 590 { 591 BasePeer.doUpdate(selectCriteria, criteria, con); 592 } 593 } 594 595 602 public static void doDelete(Criteria criteria) throws TorqueException 603 { 604 ScarabModulePeer 605 .doDelete(criteria, (Connection ) null); 606 } 607 608 618 public static void doDelete(Criteria criteria, Connection con) 619 throws TorqueException 620 { 621 if (criteria.containsKey(DELETED)) 623 { 624 Object possibleBoolean = criteria.get(DELETED); 625 if (possibleBoolean instanceof Boolean ) 626 { 627 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 628 } 629 } 630 if (criteria.containsKey(LOCKED)) 632 { 633 Object possibleBoolean = criteria.get(LOCKED); 634 if (possibleBoolean instanceof Boolean ) 635 { 636 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 637 } 638 } 639 640 setDbName(criteria); 641 642 if (con == null) 643 { 644 BasePeer.doDelete(criteria); 645 } 646 else 647 { 648 BasePeer.doDelete(criteria, con); 649 } 650 } 651 652 658 public static List doSelect(ScarabModule obj) throws TorqueException 659 { 660 return doSelect(buildSelectCriteria(obj)); 661 } 662 663 669 public static void doInsert(ScarabModule obj) throws TorqueException 670 { 671 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 672 obj.setNew(false); 673 obj.setModified(false); 674 } 675 676 681 public static void doUpdate(ScarabModule obj) throws TorqueException 682 { 683 doUpdate(buildCriteria(obj)); 684 obj.setModified(false); 685 } 686 687 692 public static void doDelete(ScarabModule obj) throws TorqueException 693 { 694 doDelete(buildSelectCriteria(obj)); 695 } 696 697 707 public static void doInsert(ScarabModule obj, Connection con) 708 throws TorqueException 709 { 710 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 711 obj.setNew(false); 712 obj.setModified(false); 713 } 714 715 725 public static void doUpdate(ScarabModule obj, Connection con) 726 throws TorqueException 727 { 728 doUpdate(buildCriteria(obj), con); 729 obj.setModified(false); 730 } 731 732 742 public static void doDelete(ScarabModule obj, Connection con) 743 throws TorqueException 744 { 745 doDelete(buildSelectCriteria(obj), con); 746 } 747 748 755 public static void doDelete(ObjectKey pk) throws TorqueException 756 { 757 BaseScarabModulePeer 758 .doDelete(pk, (Connection ) null); 759 } 760 761 771 public static void doDelete(ObjectKey pk, Connection con) 772 throws TorqueException 773 { 774 doDelete(buildCriteria(pk), con); 775 } 776 777 778 public static Criteria buildCriteria( ObjectKey pk ) 779 { 780 Criteria criteria = new Criteria(); 781 criteria.add(MODULE_ID, pk); 782 return criteria; 783 } 784 785 786 public static Criteria buildCriteria( ScarabModule obj ) 787 { 788 Criteria criteria = new Criteria(DATABASE_NAME); 789 if (!obj.isNew()) 790 criteria.add(MODULE_ID, obj.getModuleId()); 791 criteria.add(MODULE_NAME, obj.getRealName()); 792 criteria.add(DOMAIN, obj.getDomain()); 793 criteria.add(MODULE_CODE, obj.getCode()); 794 criteria.add(MODULE_DESCRIPTION, obj.getDescription()); 795 criteria.add(MODULE_URL, obj.getUrl()); 796 criteria.add(ARCHIVE_EMAIL, obj.getArchiveEmail()); 797 criteria.add(PARENT_ID, obj.getParentId()); 798 criteria.add(OWNER_ID, obj.getOwnerId()); 799 criteria.add(QA_CONTACT_ID, obj.getQaContactId()); 800 criteria.add(DELETED, obj.getDeleted()); 801 criteria.add(LOCKED, obj.getLocked()); 802 criteria.add(CLASS_KEY, obj.getClassKey()); 803 return criteria; 804 } 805 806 807 public static Criteria buildSelectCriteria( ScarabModule obj ) 808 { 809 Criteria criteria = new Criteria(DATABASE_NAME); 810 if (!obj.isNew()) 811 criteria.add(MODULE_ID, obj.getModuleId()); 812 criteria.add(MODULE_NAME, obj.getRealName()); 813 criteria.add(DOMAIN, obj.getDomain()); 814 criteria.add(MODULE_CODE, obj.getCode()); 815 criteria.add(MODULE_DESCRIPTION, obj.getDescription()); 816 criteria.add(MODULE_URL, obj.getUrl()); 817 criteria.add(ARCHIVE_EMAIL, obj.getArchiveEmail()); 818 criteria.add(PARENT_ID, obj.getParentId()); 819 criteria.add(OWNER_ID, obj.getOwnerId()); 820 criteria.add(QA_CONTACT_ID, obj.getQaContactId()); 821 criteria.add(DELETED, obj.getDeleted()); 822 criteria.add(LOCKED, obj.getLocked()); 823 criteria.add(CLASS_KEY, obj.getClassKey()); 824 return criteria; 825 } 826 827 828 837 public static ScarabModule retrieveByPK(Integer pk) 838 throws TorqueException, NoRowsException, TooManyRowsException 839 { 840 return retrieveByPK(SimpleKey.keyFor(pk)); 841 } 842 843 853 public static ScarabModule retrieveByPK(Integer pk, Connection con) 854 throws TorqueException, NoRowsException, TooManyRowsException 855 { 856 return retrieveByPK(SimpleKey.keyFor(pk), con); 857 } 858 859 868 public static ScarabModule retrieveByPK(ObjectKey pk) 869 throws TorqueException, NoRowsException, TooManyRowsException 870 { 871 Connection db = null; 872 ScarabModule retVal = null; 873 try 874 { 875 db = Torque.getConnection(DATABASE_NAME); 876 retVal = retrieveByPK(pk, db); 877 } 878 finally 879 { 880 Torque.closeConnection(db); 881 } 882 return(retVal); 883 } 884 885 895 public static ScarabModule retrieveByPK(ObjectKey pk, Connection con) 896 throws TorqueException, NoRowsException, TooManyRowsException 897 { 898 Criteria criteria = buildCriteria(pk); 899 List v = doSelect(criteria, con); 900 if (v.size() == 0) 901 { 902 throw new NoRowsException("Failed to select a row."); 903 } 904 else if (v.size() > 1) 905 { 906 throw new TooManyRowsException("Failed to select only one row."); 907 } 908 else 909 { 910 return (ScarabModule)v.get(0); 911 } 912 } 913 914 921 public static List retrieveByPKs(List pks) 922 throws TorqueException 923 { 924 Connection db = null; 925 List retVal = null; 926 try 927 { 928 db = Torque.getConnection(DATABASE_NAME); 929 retVal = retrieveByPKs(pks, db); 930 } 931 finally 932 { 933 Torque.closeConnection(db); 934 } 935 return(retVal); 936 } 937 938 946 public static List retrieveByPKs( List pks, Connection dbcon ) 947 throws TorqueException 948 { 949 List objs = null; 950 if (pks == null || pks.size() == 0) 951 { 952 objs = new LinkedList (); 953 } 954 else 955 { 956 Criteria criteria = new Criteria(); 957 criteria.addIn( MODULE_ID, pks ); 958 objs = doSelect(criteria, dbcon); 959 } 960 return objs; 961 } 962 963 964 965 966 967 968 969 970 971 972 983 protected static List doSelectJoinScarabUserImplRelatedByOwnerId(Criteria criteria) 984 throws TorqueException 985 { 986 setDbName(criteria); 987 988 ScarabModulePeer.addSelectColumns(criteria); 989 int offset = numColumns + 1; 990 ScarabUserImplPeer.addSelectColumns(criteria); 991 992 993 criteria.addJoin(ScarabModulePeer.OWNER_ID, 994 ScarabUserImplPeer.USER_ID); 995 996 997 if (criteria.containsKey(DELETED)) 999 { 1000 Object possibleBoolean = criteria.get(DELETED); 1001 if (possibleBoolean instanceof Boolean ) 1002 { 1003 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1004 } 1005 } 1006 if (criteria.containsKey(LOCKED)) 1008 { 1009 Object possibleBoolean = criteria.get(LOCKED); 1010 if (possibleBoolean instanceof Boolean ) 1011 { 1012 criteria.add(LOCKED, ((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 = ScarabModulePeer.getOMClass(row, 1); 1024 ScarabModule obj1 = (ScarabModule) ScarabModulePeer 1025 .row2Object(row, 1, omClass); 1026 omClass = ScarabUserImplPeer.getOMClass(); 1027 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1028 .row2Object(row, offset, omClass); 1029 1030 boolean newObject = true; 1031 for (int j = 0; j < results.size(); j++) 1032 { 1033 ScarabModule temp_obj1 = (ScarabModule)results.get(j); 1034 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByOwnerId(); 1035 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1036 { 1037 newObject = false; 1038 temp_obj2.addScarabModuleRelatedByOwnerId(obj1); 1039 break; 1040 } 1041 } 1042 if (newObject) 1043 { 1044 obj2.initScarabModulesRelatedByOwnerId(); 1045 obj2.addScarabModuleRelatedByOwnerId(obj1); 1046 } 1047 results.add(obj1); 1048 } 1049 return results; 1050 } 1051 1052 1053 1054 1055 1066 protected static List doSelectJoinScarabUserImplRelatedByQaContactId(Criteria criteria) 1067 throws TorqueException 1068 { 1069 setDbName(criteria); 1070 1071 ScarabModulePeer.addSelectColumns(criteria); 1072 int offset = numColumns + 1; 1073 ScarabUserImplPeer.addSelectColumns(criteria); 1074 1075 1076 criteria.addJoin(ScarabModulePeer.QA_CONTACT_ID, 1077 ScarabUserImplPeer.USER_ID); 1078 1079 1080 if (criteria.containsKey(DELETED)) 1082 { 1083 Object possibleBoolean = criteria.get(DELETED); 1084 if (possibleBoolean instanceof Boolean ) 1085 { 1086 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1087 } 1088 } 1089 if (criteria.containsKey(LOCKED)) 1091 { 1092 Object possibleBoolean = criteria.get(LOCKED); 1093 if (possibleBoolean instanceof Boolean ) 1094 { 1095 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1096 } 1097 } 1098 1099 List rows = BasePeer.doSelect(criteria); 1100 List results = new ArrayList (); 1101 1102 for (int i = 0; i < rows.size(); i++) 1103 { 1104 Record row = (Record) rows.get(i); 1105 1106 Class omClass = ScarabModulePeer.getOMClass(row, 1); 1107 ScarabModule obj1 = (ScarabModule) ScarabModulePeer 1108 .row2Object(row, 1, omClass); 1109 omClass = ScarabUserImplPeer.getOMClass(); 1110 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1111 .row2Object(row, offset, omClass); 1112 1113 boolean newObject = true; 1114 for (int j = 0; j < results.size(); j++) 1115 { 1116 ScarabModule temp_obj1 = (ScarabModule)results.get(j); 1117 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByQaContactId(); 1118 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1119 { 1120 newObject = false; 1121 temp_obj2.addScarabModuleRelatedByQaContactId(obj1); 1122 break; 1123 } 1124 } 1125 if (newObject) 1126 { 1127 obj2.initScarabModulesRelatedByQaContactId(); 1128 obj2.addScarabModuleRelatedByQaContactId(obj1); 1129 } 1130 results.add(obj1); 1131 } 1132 return results; 1133 } 1134 1135 1136 1137 1138 1139 1140 1141 1142 1153 protected static List doSelectJoinAllExceptScarabModule(Criteria criteria) 1154 throws TorqueException 1155 { 1156 setDbName(criteria); 1157 1158 addSelectColumns(criteria); 1159 int offset2 = numColumns + 1; 1160 1161 ScarabUserImplPeer.addSelectColumns(criteria); 1162 int offset3 = offset2 + ScarabUserImplPeer.numColumns; 1163 1164 ScarabUserImplPeer.addSelectColumns(criteria); 1165 int offset4 = offset3 + ScarabUserImplPeer.numColumns; 1166 if (criteria.containsKey(DELETED)) 1168 { 1169 Object possibleBoolean = criteria.get(DELETED); 1170 if (possibleBoolean instanceof Boolean ) 1171 { 1172 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1173 } 1174 } 1175 if (criteria.containsKey(LOCKED)) 1177 { 1178 Object possibleBoolean = criteria.get(LOCKED); 1179 if (possibleBoolean instanceof Boolean ) 1180 { 1181 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1182 } 1183 } 1184 1185 List rows = BasePeer.doSelect(criteria); 1186 List results = new ArrayList (); 1187 1188 for (int i = 0; i < rows.size(); i++) 1189 { 1190 Record row = (Record)rows.get(i); 1191 1192 Class omClass = ScarabModulePeer.getOMClass(row, 1); 1193 ScarabModule obj1 = (ScarabModule)ScarabModulePeer 1194 .row2Object(row, 1, omClass); 1195 1196 1197 1198 1199 omClass = ScarabUserImplPeer.getOMClass(); 1200 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1201 .row2Object( row, offset2, omClass); 1202 1203 boolean newObject = true; 1204 for (int j = 0; j < results.size(); j++) 1205 { 1206 ScarabModule temp_obj1 = (ScarabModule)results.get(j); 1207 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByOwnerId(); 1208 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1209 { 1210 newObject = false; 1211 temp_obj2.addScarabModuleRelatedByOwnerId(obj1); 1212 break; 1213 } 1214 } 1215 if (newObject) 1216 { 1217 obj2.initScarabModulesRelatedByOwnerId(); 1218 obj2.addScarabModuleRelatedByOwnerId(obj1); 1219 } 1220 1221 1222 1223 1224 omClass = ScarabUserImplPeer.getOMClass(); 1225 ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer 1226 .row2Object( row, offset3, omClass); 1227 1228 newObject = true; 1229 for (int j = 0; j < results.size(); j++) 1230 { 1231 ScarabModule temp_obj1 = (ScarabModule)results.get(j); 1232 ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByQaContactId(); 1233 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1234 { 1235 newObject = false; 1236 temp_obj3.addScarabModuleRelatedByQaContactId(obj1); 1237 break; 1238 } 1239 } 1240 if (newObject) 1241 { 1242 obj3.initScarabModulesRelatedByQaContactId(); 1243 obj3.addScarabModuleRelatedByQaContactId(obj1); 1244 } 1245 results.add(obj1); 1246 } 1247 return results; 1248 } 1249 1250 1251 1252 1253 1254 1265 protected static List doSelectJoinAllExceptScarabUserImplRelatedByOwnerId(Criteria criteria) 1266 throws TorqueException 1267 { 1268 setDbName(criteria); 1269 1270 addSelectColumns(criteria); 1271 int offset2 = numColumns + 1; 1272 1273 1274 if (criteria.containsKey(DELETED)) 1276 { 1277 Object possibleBoolean = criteria.get(DELETED); 1278 if (possibleBoolean instanceof Boolean ) 1279 { 1280 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1281 } 1282 } 1283 if (criteria.containsKey(LOCKED)) 1285 { 1286 Object possibleBoolean = criteria.get(LOCKED); 1287 if (possibleBoolean instanceof Boolean ) 1288 { 1289 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1290 } 1291 } 1292 1293 List rows = BasePeer.doSelect(criteria); 1294 List results = new ArrayList (); 1295 1296 for (int i = 0; i < rows.size(); i++) 1297 { 1298 Record row = (Record)rows.get(i); 1299 1300 Class omClass = ScarabModulePeer.getOMClass(row, 1); 1301 ScarabModule obj1 = (ScarabModule)ScarabModulePeer 1302 .row2Object(row, 1, omClass); 1303 1304 1305 results.add(obj1); 1306 } 1307 return results; 1308 } 1309 1310 1311 1312 1313 1314 1325 protected static List doSelectJoinAllExceptScarabUserImplRelatedByQaContactId(Criteria criteria) 1326 throws TorqueException 1327 { 1328 setDbName(criteria); 1329 1330 addSelectColumns(criteria); 1331 int offset2 = numColumns + 1; 1332 1333 1334 if (criteria.containsKey(DELETED)) 1336 { 1337 Object possibleBoolean = criteria.get(DELETED); 1338 if (possibleBoolean instanceof Boolean ) 1339 { 1340 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1341 } 1342 } 1343 if (criteria.containsKey(LOCKED)) 1345 { 1346 Object possibleBoolean = criteria.get(LOCKED); 1347 if (possibleBoolean instanceof Boolean ) 1348 { 1349 criteria.add(LOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1350 } 1351 } 1352 1353 List rows = BasePeer.doSelect(criteria); 1354 List results = new ArrayList (); 1355 1356 for (int i = 0; i < rows.size(); i++) 1357 { 1358 Record row = (Record)rows.get(i); 1359 1360 Class omClass = ScarabModulePeer.getOMClass(row, 1); 1361 ScarabModule obj1 = (ScarabModule)ScarabModulePeer 1362 .row2Object(row, 1, omClass); 1363 1364 1365 results.add(obj1); 1366 } 1367 return results; 1368 } 1369 1370 1371 1378 protected static TableMap getTableMap() 1379 throws TorqueException 1380 { 1381 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1382 } 1383 1384 private static void setDbName(Criteria crit) 1385 { 1386 if (crit.getDbName() == Torque.getDefaultDB()) 1390 { 1391 crit.setDbName(DATABASE_NAME); 1392 } 1393 } 1394} 1395 | Popular Tags |