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 BaseAttributePeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_ATTRIBUTE"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(AttributeMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String ATTRIBUTE_ID; 62 63 public static final String ATTRIBUTE_NAME; 64 65 public static final String ATTRIBUTE_TYPE_ID; 66 67 public static final String PERMISSION; 68 69 public static final String REQUIRED_OPTION_ID; 70 71 public static final String DESCRIPTION; 72 73 public static final String ACTION; 74 75 public static final String CREATED_BY; 76 77 public static final String CREATED_DATE; 78 79 public static final String DELETED; 80 81 static 82 { 83 ATTRIBUTE_ID = "SCARAB_ATTRIBUTE.ATTRIBUTE_ID"; 84 ATTRIBUTE_NAME = "SCARAB_ATTRIBUTE.ATTRIBUTE_NAME"; 85 ATTRIBUTE_TYPE_ID = "SCARAB_ATTRIBUTE.ATTRIBUTE_TYPE_ID"; 86 PERMISSION = "SCARAB_ATTRIBUTE.PERMISSION"; 87 REQUIRED_OPTION_ID = "SCARAB_ATTRIBUTE.REQUIRED_OPTION_ID"; 88 DESCRIPTION = "SCARAB_ATTRIBUTE.DESCRIPTION"; 89 ACTION = "SCARAB_ATTRIBUTE.ACTION"; 90 CREATED_BY = "SCARAB_ATTRIBUTE.CREATED_BY"; 91 CREATED_DATE = "SCARAB_ATTRIBUTE.CREATED_DATE"; 92 DELETED = "SCARAB_ATTRIBUTE.DELETED"; 93 if (Torque.isInit()) 94 { 95 try 96 { 97 getMapBuilder(AttributeMapBuilder.CLASS_NAME); 98 } 99 catch (Exception e) 100 { 101 log.error("Could not initialize Peer", e); 102 } 103 } 104 else 105 { 106 Torque.registerMapBuilder(AttributeMapBuilder.CLASS_NAME); 107 } 108 } 109 110 111 public static final int numColumns = 10; 112 113 114 protected static final String CLASSNAME_DEFAULT = 115 "org.tigris.scarab.om.Attribute"; 116 117 118 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 119 120 126 private static Class initClass(String className) 127 { 128 Class c = null; 129 try 130 { 131 c = Class.forName(className); 132 } 133 catch (Throwable t) 134 { 135 log.error("A FATAL ERROR has occurred which should not " 136 + "have happened under any circumstance. Please notify " 137 + "the Torque developers <torque-dev@db.apache.org> " 138 + "and give as many details as possible (including the error " 139 + "stack trace).", t); 140 141 if (t instanceof Error ) 143 { 144 throw (Error ) t.fillInStackTrace(); 145 } 146 } 147 return c; 148 } 149 150 160 public static List resultSet2Objects(java.sql.ResultSet results) 161 throws TorqueException 162 { 163 try 164 { 165 QueryDataSet qds = null; 166 List rows = null; 167 try 168 { 169 qds = new QueryDataSet(results); 170 rows = getSelectResults(qds); 171 } 172 finally 173 { 174 if (qds != null) 175 { 176 qds.close(); 177 } 178 } 179 180 return populateObjects(rows); 181 } 182 catch (SQLException e) 183 { 184 throw new TorqueException(e); 185 } 186 catch (DataSetException e) 187 { 188 throw new TorqueException(e); 189 } 190 } 191 192 193 194 201 public static ObjectKey doInsert(Criteria criteria) 202 throws TorqueException 203 { 204 return BaseAttributePeer 205 .doInsert(criteria, (Connection ) null); 206 } 207 208 218 public static ObjectKey doInsert(Criteria criteria, Connection con) 219 throws TorqueException 220 { 221 if (criteria.containsKey(DELETED)) 223 { 224 Object possibleBoolean = criteria.get(DELETED); 225 if (possibleBoolean instanceof Boolean ) 226 { 227 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 228 } 229 } 230 231 setDbName(criteria); 232 233 if (con == null) 234 { 235 return BasePeer.doInsert(criteria); 236 } 237 else 238 { 239 return BasePeer.doInsert(criteria, con); 240 } 241 } 242 243 250 public static void addSelectColumns(Criteria criteria) 251 throws TorqueException 252 { 253 criteria.addSelectColumn(ATTRIBUTE_ID); 254 criteria.addSelectColumn(ATTRIBUTE_NAME); 255 criteria.addSelectColumn(ATTRIBUTE_TYPE_ID); 256 criteria.addSelectColumn(PERMISSION); 257 criteria.addSelectColumn(REQUIRED_OPTION_ID); 258 criteria.addSelectColumn(DESCRIPTION); 259 criteria.addSelectColumn(ACTION); 260 criteria.addSelectColumn(CREATED_BY); 261 criteria.addSelectColumn(CREATED_DATE); 262 criteria.addSelectColumn(DELETED); 263 } 264 265 274 public static Attribute row2Object(Record row, 275 int offset, 276 Class cls) 277 throws TorqueException 278 { 279 try 280 { 281 Attribute obj = (Attribute) cls.newInstance(); 282 AttributePeer.populateObject(row, offset, obj); 283 obj.setModified(false); 284 obj.setNew(false); 285 286 return obj; 287 } 288 catch (InstantiationException e) 289 { 290 throw new TorqueException(e); 291 } 292 catch (IllegalAccessException e) 293 { 294 throw new TorqueException(e); 295 } 296 } 297 298 307 public static void populateObject(Record row, 308 int offset, 309 Attribute obj) 310 throws TorqueException 311 { 312 try 313 { 314 obj.setAttributeId(row.getValue(offset + 0).asIntegerObj()); 315 obj.setName(row.getValue(offset + 1).asString()); 316 obj.setTypeId(row.getValue(offset + 2).asIntegerObj()); 317 obj.setPermission(row.getValue(offset + 3).asString()); 318 obj.setRequiredOptionId(row.getValue(offset + 4).asIntegerObj()); 319 obj.setDescription(row.getValue(offset + 5).asString()); 320 obj.setAction(row.getValue(offset + 6).asString()); 321 obj.setCreatedBy(row.getValue(offset + 7).asIntegerObj()); 322 obj.setCreatedDate(row.getValue(offset + 8).asUtilDate()); 323 obj.setDeleted(row.getValue(offset + 9).asBoolean()); 324 } 325 catch (DataSetException e) 326 { 327 throw new TorqueException(e); 328 } 329 } 330 331 339 public static List doSelect(Criteria criteria) throws TorqueException 340 { 341 return populateObjects(doSelectVillageRecords(criteria)); 342 } 343 344 353 public static List doSelect(Criteria criteria, Connection con) 354 throws TorqueException 355 { 356 return populateObjects(doSelectVillageRecords(criteria, con)); 357 } 358 359 369 public static List doSelectVillageRecords(Criteria criteria) 370 throws TorqueException 371 { 372 return BaseAttributePeer 373 .doSelectVillageRecords(criteria, (Connection ) null); 374 } 375 376 385 public static List doSelectVillageRecords(Criteria criteria, Connection con) 386 throws TorqueException 387 { 388 if (criteria.getSelectColumns().size() == 0) 389 { 390 addSelectColumns(criteria); 391 } 392 393 if (criteria.containsKey(DELETED)) 395 { 396 Object possibleBoolean = criteria.get(DELETED); 397 if (possibleBoolean instanceof Boolean ) 398 { 399 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 400 } 401 } 402 403 setDbName(criteria); 404 405 if (con == null) 408 { 409 return BasePeer.doSelect(criteria); 410 } 411 else 412 { 413 return BasePeer.doSelect(criteria, con); 414 } 415 } 416 417 424 public static List populateObjects(List records) 425 throws TorqueException 426 { 427 List results = new ArrayList (records.size()); 428 429 for (int i = 0; i < records.size(); i++) 431 { 432 Record row = (Record) records.get(i); 433 results.add(AttributePeer.row2Object(row, 1, 434 AttributePeer.getOMClass())); 435 } 436 return results; 437 } 438 439 440 448 public static Class getOMClass() 449 throws TorqueException 450 { 451 return CLASS_DEFAULT; 452 } 453 454 462 public static void doUpdate(Criteria criteria) throws TorqueException 463 { 464 BaseAttributePeer 465 .doUpdate(criteria, (Connection ) null); 466 } 467 468 479 public static void doUpdate(Criteria criteria, Connection con) 480 throws TorqueException 481 { 482 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 483 selectCriteria.put(ATTRIBUTE_ID, criteria.remove(ATTRIBUTE_ID)); 484 if (criteria.containsKey(DELETED)) 486 { 487 Object possibleBoolean = criteria.get(DELETED); 488 if (possibleBoolean instanceof Boolean ) 489 { 490 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 491 } 492 } 493 494 setDbName(criteria); 495 496 if (con == null) 497 { 498 BasePeer.doUpdate(selectCriteria, criteria); 499 } 500 else 501 { 502 BasePeer.doUpdate(selectCriteria, criteria, con); 503 } 504 } 505 506 513 public static void doDelete(Criteria criteria) throws TorqueException 514 { 515 AttributePeer 516 .doDelete(criteria, (Connection ) null); 517 } 518 519 529 public static void doDelete(Criteria criteria, Connection con) 530 throws TorqueException 531 { 532 if (criteria.containsKey(DELETED)) 534 { 535 Object possibleBoolean = criteria.get(DELETED); 536 if (possibleBoolean instanceof Boolean ) 537 { 538 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 539 } 540 } 541 542 setDbName(criteria); 543 544 if (con == null) 545 { 546 BasePeer.doDelete(criteria); 547 } 548 else 549 { 550 BasePeer.doDelete(criteria, con); 551 } 552 } 553 554 560 public static List doSelect(Attribute obj) throws TorqueException 561 { 562 return doSelect(buildSelectCriteria(obj)); 563 } 564 565 571 public static void doInsert(Attribute obj) throws TorqueException 572 { 573 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 574 obj.setNew(false); 575 obj.setModified(false); 576 } 577 578 583 public static void doUpdate(Attribute obj) throws TorqueException 584 { 585 doUpdate(buildCriteria(obj)); 586 obj.setModified(false); 587 } 588 589 594 public static void doDelete(Attribute obj) throws TorqueException 595 { 596 doDelete(buildSelectCriteria(obj)); 597 } 598 599 609 public static void doInsert(Attribute obj, Connection con) 610 throws TorqueException 611 { 612 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 613 obj.setNew(false); 614 obj.setModified(false); 615 } 616 617 627 public static void doUpdate(Attribute obj, Connection con) 628 throws TorqueException 629 { 630 doUpdate(buildCriteria(obj), con); 631 obj.setModified(false); 632 } 633 634 644 public static void doDelete(Attribute obj, Connection con) 645 throws TorqueException 646 { 647 doDelete(buildSelectCriteria(obj), con); 648 } 649 650 657 public static void doDelete(ObjectKey pk) throws TorqueException 658 { 659 BaseAttributePeer 660 .doDelete(pk, (Connection ) null); 661 } 662 663 673 public static void doDelete(ObjectKey pk, Connection con) 674 throws TorqueException 675 { 676 doDelete(buildCriteria(pk), con); 677 } 678 679 680 public static Criteria buildCriteria( ObjectKey pk ) 681 { 682 Criteria criteria = new Criteria(); 683 criteria.add(ATTRIBUTE_ID, pk); 684 return criteria; 685 } 686 687 688 public static Criteria buildCriteria( Attribute obj ) 689 { 690 Criteria criteria = new Criteria(DATABASE_NAME); 691 if (!obj.isNew()) 692 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 693 criteria.add(ATTRIBUTE_NAME, obj.getName()); 694 criteria.add(ATTRIBUTE_TYPE_ID, obj.getTypeId()); 695 criteria.add(PERMISSION, obj.getPermission()); 696 criteria.add(REQUIRED_OPTION_ID, obj.getRequiredOptionId()); 697 criteria.add(DESCRIPTION, obj.getDescription()); 698 criteria.add(ACTION, obj.getAction()); 699 criteria.add(CREATED_BY, obj.getCreatedBy()); 700 criteria.add(CREATED_DATE, obj.getCreatedDate()); 701 criteria.add(DELETED, obj.getDeleted()); 702 return criteria; 703 } 704 705 706 public static Criteria buildSelectCriteria( Attribute obj ) 707 { 708 Criteria criteria = new Criteria(DATABASE_NAME); 709 if (!obj.isNew()) 710 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 711 criteria.add(ATTRIBUTE_NAME, obj.getName()); 712 criteria.add(ATTRIBUTE_TYPE_ID, obj.getTypeId()); 713 criteria.add(PERMISSION, obj.getPermission()); 714 criteria.add(REQUIRED_OPTION_ID, obj.getRequiredOptionId()); 715 criteria.add(DESCRIPTION, obj.getDescription()); 716 criteria.add(ACTION, obj.getAction()); 717 criteria.add(CREATED_BY, obj.getCreatedBy()); 718 criteria.add(CREATED_DATE, obj.getCreatedDate()); 719 criteria.add(DELETED, obj.getDeleted()); 720 return criteria; 721 } 722 723 724 733 public static Attribute retrieveByPK(Integer pk) 734 throws TorqueException, NoRowsException, TooManyRowsException 735 { 736 return retrieveByPK(SimpleKey.keyFor(pk)); 737 } 738 739 749 public static Attribute retrieveByPK(Integer pk, Connection con) 750 throws TorqueException, NoRowsException, TooManyRowsException 751 { 752 return retrieveByPK(SimpleKey.keyFor(pk), con); 753 } 754 755 764 public static Attribute retrieveByPK(ObjectKey pk) 765 throws TorqueException, NoRowsException, TooManyRowsException 766 { 767 Connection db = null; 768 Attribute retVal = null; 769 try 770 { 771 db = Torque.getConnection(DATABASE_NAME); 772 retVal = retrieveByPK(pk, db); 773 } 774 finally 775 { 776 Torque.closeConnection(db); 777 } 778 return(retVal); 779 } 780 781 791 public static Attribute retrieveByPK(ObjectKey pk, Connection con) 792 throws TorqueException, NoRowsException, TooManyRowsException 793 { 794 Criteria criteria = buildCriteria(pk); 795 List v = doSelect(criteria, con); 796 if (v.size() == 0) 797 { 798 throw new NoRowsException("Failed to select a row."); 799 } 800 else if (v.size() > 1) 801 { 802 throw new TooManyRowsException("Failed to select only one row."); 803 } 804 else 805 { 806 return (Attribute)v.get(0); 807 } 808 } 809 810 817 public static List retrieveByPKs(List pks) 818 throws TorqueException 819 { 820 Connection db = null; 821 List retVal = null; 822 try 823 { 824 db = Torque.getConnection(DATABASE_NAME); 825 retVal = retrieveByPKs(pks, db); 826 } 827 finally 828 { 829 Torque.closeConnection(db); 830 } 831 return(retVal); 832 } 833 834 842 public static List retrieveByPKs( List pks, Connection dbcon ) 843 throws TorqueException 844 { 845 List objs = null; 846 if (pks == null || pks.size() == 0) 847 { 848 objs = new LinkedList (); 849 } 850 else 851 { 852 Criteria criteria = new Criteria(); 853 criteria.addIn( ATTRIBUTE_ID, pks ); 854 objs = doSelect(criteria, dbcon); 855 } 856 return objs; 857 } 858 859 860 861 862 863 864 865 866 867 868 879 protected static List doSelectJoinAttributeType(Criteria criteria) 880 throws TorqueException 881 { 882 setDbName(criteria); 883 884 AttributePeer.addSelectColumns(criteria); 885 int offset = numColumns + 1; 886 AttributeTypePeer.addSelectColumns(criteria); 887 888 889 criteria.addJoin(AttributePeer.ATTRIBUTE_TYPE_ID, 890 AttributeTypePeer.ATTRIBUTE_TYPE_ID); 891 892 893 if (criteria.containsKey(DELETED)) 895 { 896 Object possibleBoolean = criteria.get(DELETED); 897 if (possibleBoolean instanceof Boolean ) 898 { 899 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 900 } 901 } 902 903 List rows = BasePeer.doSelect(criteria); 904 List results = new ArrayList (); 905 906 for (int i = 0; i < rows.size(); i++) 907 { 908 Record row = (Record) rows.get(i); 909 910 Class omClass = AttributePeer.getOMClass(); 911 Attribute obj1 = (Attribute) AttributePeer 912 .row2Object(row, 1, omClass); 913 omClass = AttributeTypePeer.getOMClass(); 914 AttributeType obj2 = (AttributeType)AttributeTypePeer 915 .row2Object(row, offset, omClass); 916 917 boolean newObject = true; 918 for (int j = 0; j < results.size(); j++) 919 { 920 Attribute temp_obj1 = (Attribute)results.get(j); 921 AttributeType temp_obj2 = (AttributeType)temp_obj1.getAttributeType(); 922 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 923 { 924 newObject = false; 925 temp_obj2.addAttribute(obj1); 926 break; 927 } 928 } 929 if (newObject) 930 { 931 obj2.initAttributes(); 932 obj2.addAttribute(obj1); 933 } 934 results.add(obj1); 935 } 936 return results; 937 } 938 939 940 941 942 953 protected static List doSelectJoinAttributeOption(Criteria criteria) 954 throws TorqueException 955 { 956 setDbName(criteria); 957 958 AttributePeer.addSelectColumns(criteria); 959 int offset = numColumns + 1; 960 AttributeOptionPeer.addSelectColumns(criteria); 961 962 963 criteria.addJoin(AttributePeer.REQUIRED_OPTION_ID, 964 AttributeOptionPeer.OPTION_ID); 965 966 967 if (criteria.containsKey(DELETED)) 969 { 970 Object possibleBoolean = criteria.get(DELETED); 971 if (possibleBoolean instanceof Boolean ) 972 { 973 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 974 } 975 } 976 977 List rows = BasePeer.doSelect(criteria); 978 List results = new ArrayList (); 979 980 for (int i = 0; i < rows.size(); i++) 981 { 982 Record row = (Record) rows.get(i); 983 984 Class omClass = AttributePeer.getOMClass(); 985 Attribute obj1 = (Attribute) AttributePeer 986 .row2Object(row, 1, omClass); 987 omClass = AttributeOptionPeer.getOMClass(); 988 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 989 .row2Object(row, offset, omClass); 990 991 boolean newObject = true; 992 for (int j = 0; j < results.size(); j++) 993 { 994 Attribute temp_obj1 = (Attribute)results.get(j); 995 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 996 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 997 { 998 newObject = false; 999 temp_obj2.addAttribute(obj1); 1000 break; 1001 } 1002 } 1003 if (newObject) 1004 { 1005 obj2.initAttributes(); 1006 obj2.addAttribute(obj1); 1007 } 1008 results.add(obj1); 1009 } 1010 return results; 1011 } 1012 1013 1014 1015 1016 1027 protected static List doSelectJoinScarabUserImpl(Criteria criteria) 1028 throws TorqueException 1029 { 1030 setDbName(criteria); 1031 1032 AttributePeer.addSelectColumns(criteria); 1033 int offset = numColumns + 1; 1034 ScarabUserImplPeer.addSelectColumns(criteria); 1035 1036 1037 criteria.addJoin(AttributePeer.CREATED_BY, 1038 ScarabUserImplPeer.USER_ID); 1039 1040 1041 if (criteria.containsKey(DELETED)) 1043 { 1044 Object possibleBoolean = criteria.get(DELETED); 1045 if (possibleBoolean instanceof Boolean ) 1046 { 1047 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1048 } 1049 } 1050 1051 List rows = BasePeer.doSelect(criteria); 1052 List results = new ArrayList (); 1053 1054 for (int i = 0; i < rows.size(); i++) 1055 { 1056 Record row = (Record) rows.get(i); 1057 1058 Class omClass = AttributePeer.getOMClass(); 1059 Attribute obj1 = (Attribute) AttributePeer 1060 .row2Object(row, 1, omClass); 1061 omClass = ScarabUserImplPeer.getOMClass(); 1062 ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer 1063 .row2Object(row, offset, omClass); 1064 1065 boolean newObject = true; 1066 for (int j = 0; j < results.size(); j++) 1067 { 1068 Attribute temp_obj1 = (Attribute)results.get(j); 1069 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1070 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1071 { 1072 newObject = false; 1073 temp_obj2.addAttribute(obj1); 1074 break; 1075 } 1076 } 1077 if (newObject) 1078 { 1079 obj2.initAttributes(); 1080 obj2.addAttribute(obj1); 1081 } 1082 results.add(obj1); 1083 } 1084 return results; 1085 } 1086 1087 1088 1089 1090 1091 1092 1093 1094 1105 protected static List doSelectJoinAllExceptAttributeType(Criteria criteria) 1106 throws TorqueException 1107 { 1108 setDbName(criteria); 1109 1110 addSelectColumns(criteria); 1111 int offset2 = numColumns + 1; 1112 1113 1114 AttributeOptionPeer.addSelectColumns(criteria); 1115 int offset3 = offset2 + AttributeOptionPeer.numColumns; 1116 1117 ScarabUserImplPeer.addSelectColumns(criteria); 1118 int offset4 = offset3 + ScarabUserImplPeer.numColumns; 1119 if (criteria.containsKey(DELETED)) 1121 { 1122 Object possibleBoolean = criteria.get(DELETED); 1123 if (possibleBoolean instanceof Boolean ) 1124 { 1125 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1126 } 1127 } 1128 1129 List rows = BasePeer.doSelect(criteria); 1130 List results = new ArrayList (); 1131 1132 for (int i = 0; i < rows.size(); i++) 1133 { 1134 Record row = (Record)rows.get(i); 1135 1136 Class omClass = AttributePeer.getOMClass(); 1137 Attribute obj1 = (Attribute)AttributePeer 1138 .row2Object(row, 1, omClass); 1139 1140 1141 1142 1143 1144 omClass = AttributeOptionPeer.getOMClass(); 1145 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1146 .row2Object( row, offset2, omClass); 1147 1148 boolean newObject = true; 1149 for (int j = 0; j < results.size(); j++) 1150 { 1151 Attribute temp_obj1 = (Attribute)results.get(j); 1152 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOption(); 1153 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1154 { 1155 newObject = false; 1156 temp_obj2.addAttribute(obj1); 1157 break; 1158 } 1159 } 1160 if (newObject) 1161 { 1162 obj2.initAttributes(); 1163 obj2.addAttribute(obj1); 1164 } 1165 1166 1167 1168 1169 omClass = ScarabUserImplPeer.getOMClass(); 1170 ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer 1171 .row2Object( row, offset3, omClass); 1172 1173 newObject = true; 1174 for (int j = 0; j < results.size(); j++) 1175 { 1176 Attribute temp_obj1 = (Attribute)results.get(j); 1177 ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1178 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1179 { 1180 newObject = false; 1181 temp_obj3.addAttribute(obj1); 1182 break; 1183 } 1184 } 1185 if (newObject) 1186 { 1187 obj3.initAttributes(); 1188 obj3.addAttribute(obj1); 1189 } 1190 results.add(obj1); 1191 } 1192 return results; 1193 } 1194 1195 1196 1197 1198 1199 1210 protected static List doSelectJoinAllExceptAttributeOption(Criteria criteria) 1211 throws TorqueException 1212 { 1213 setDbName(criteria); 1214 1215 addSelectColumns(criteria); 1216 int offset2 = numColumns + 1; 1217 1218 AttributeTypePeer.addSelectColumns(criteria); 1219 int offset3 = offset2 + AttributeTypePeer.numColumns; 1220 1221 1222 ScarabUserImplPeer.addSelectColumns(criteria); 1223 int offset4 = offset3 + ScarabUserImplPeer.numColumns; 1224 if (criteria.containsKey(DELETED)) 1226 { 1227 Object possibleBoolean = criteria.get(DELETED); 1228 if (possibleBoolean instanceof Boolean ) 1229 { 1230 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1231 } 1232 } 1233 1234 List rows = BasePeer.doSelect(criteria); 1235 List results = new ArrayList (); 1236 1237 for (int i = 0; i < rows.size(); i++) 1238 { 1239 Record row = (Record)rows.get(i); 1240 1241 Class omClass = AttributePeer.getOMClass(); 1242 Attribute obj1 = (Attribute)AttributePeer 1243 .row2Object(row, 1, omClass); 1244 1245 1246 1247 1248 omClass = AttributeTypePeer.getOMClass(); 1249 AttributeType obj2 = (AttributeType)AttributeTypePeer 1250 .row2Object( row, offset2, omClass); 1251 1252 boolean newObject = true; 1253 for (int j = 0; j < results.size(); j++) 1254 { 1255 Attribute temp_obj1 = (Attribute)results.get(j); 1256 AttributeType temp_obj2 = (AttributeType)temp_obj1.getAttributeType(); 1257 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1258 { 1259 newObject = false; 1260 temp_obj2.addAttribute(obj1); 1261 break; 1262 } 1263 } 1264 if (newObject) 1265 { 1266 obj2.initAttributes(); 1267 obj2.addAttribute(obj1); 1268 } 1269 1270 1271 1272 1273 1274 omClass = ScarabUserImplPeer.getOMClass(); 1275 ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer 1276 .row2Object( row, offset3, omClass); 1277 1278 newObject = true; 1279 for (int j = 0; j < results.size(); j++) 1280 { 1281 Attribute temp_obj1 = (Attribute)results.get(j); 1282 ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser(); 1283 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1284 { 1285 newObject = false; 1286 temp_obj3.addAttribute(obj1); 1287 break; 1288 } 1289 } 1290 if (newObject) 1291 { 1292 obj3.initAttributes(); 1293 obj3.addAttribute(obj1); 1294 } 1295 results.add(obj1); 1296 } 1297 return results; 1298 } 1299 1300 1301 1302 1303 1304 1315 protected static List doSelectJoinAllExceptScarabUserImpl(Criteria criteria) 1316 throws TorqueException 1317 { 1318 setDbName(criteria); 1319 1320 addSelectColumns(criteria); 1321 int offset2 = numColumns + 1; 1322 1323 AttributeTypePeer.addSelectColumns(criteria); 1324 int offset3 = offset2 + AttributeTypePeer.numColumns; 1325 1326 AttributeOptionPeer.addSelectColumns(criteria); 1327 int offset4 = offset3 + AttributeOptionPeer.numColumns; 1328 1329 if (criteria.containsKey(DELETED)) 1331 { 1332 Object possibleBoolean = criteria.get(DELETED); 1333 if (possibleBoolean instanceof Boolean ) 1334 { 1335 criteria.add(DELETED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1336 } 1337 } 1338 1339 List rows = BasePeer.doSelect(criteria); 1340 List results = new ArrayList (); 1341 1342 for (int i = 0; i < rows.size(); i++) 1343 { 1344 Record row = (Record)rows.get(i); 1345 1346 Class omClass = AttributePeer.getOMClass(); 1347 Attribute obj1 = (Attribute)AttributePeer 1348 .row2Object(row, 1, omClass); 1349 1350 1351 1352 1353 omClass = AttributeTypePeer.getOMClass(); 1354 AttributeType obj2 = (AttributeType)AttributeTypePeer 1355 .row2Object( row, offset2, omClass); 1356 1357 boolean newObject = true; 1358 for (int j = 0; j < results.size(); j++) 1359 { 1360 Attribute temp_obj1 = (Attribute)results.get(j); 1361 AttributeType temp_obj2 = (AttributeType)temp_obj1.getAttributeType(); 1362 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1363 { 1364 newObject = false; 1365 temp_obj2.addAttribute(obj1); 1366 break; 1367 } 1368 } 1369 if (newObject) 1370 { 1371 obj2.initAttributes(); 1372 obj2.addAttribute(obj1); 1373 } 1374 1375 1376 1377 1378 omClass = AttributeOptionPeer.getOMClass(); 1379 AttributeOption obj3 = (AttributeOption)AttributeOptionPeer 1380 .row2Object( row, offset3, omClass); 1381 1382 newObject = true; 1383 for (int j = 0; j < results.size(); j++) 1384 { 1385 Attribute temp_obj1 = (Attribute)results.get(j); 1386 AttributeOption temp_obj3 = (AttributeOption)temp_obj1.getAttributeOption(); 1387 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1388 { 1389 newObject = false; 1390 temp_obj3.addAttribute(obj1); 1391 break; 1392 } 1393 } 1394 if (newObject) 1395 { 1396 obj3.initAttributes(); 1397 obj3.addAttribute(obj1); 1398 } 1399 1400 results.add(obj1); 1401 } 1402 return results; 1403 } 1404 1405 1406 1413 protected static TableMap getTableMap() 1414 throws TorqueException 1415 { 1416 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1417 } 1418 1419 private static void setDbName(Criteria crit) 1420 { 1421 if (crit.getDbName() == Torque.getDefaultDB()) 1425 { 1426 crit.setDbName(DATABASE_NAME); 1427 } 1428 } 1429} 1430 | Popular Tags |