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 BaseTransitionPeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "SCARAB_TRANSITION"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(TransitionMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String TRANSITION_ID; 62 63 public static final String ROLE_ID; 64 65 public static final String ATTRIBUTE_ID; 66 67 public static final String FROM_OPTION_ID; 68 69 public static final String TO_OPTION_ID; 70 71 public static final String DISABLED_IF_BLOCKED; 72 73 static 74 { 75 TRANSITION_ID = "SCARAB_TRANSITION.TRANSITION_ID"; 76 ROLE_ID = "SCARAB_TRANSITION.ROLE_ID"; 77 ATTRIBUTE_ID = "SCARAB_TRANSITION.ATTRIBUTE_ID"; 78 FROM_OPTION_ID = "SCARAB_TRANSITION.FROM_OPTION_ID"; 79 TO_OPTION_ID = "SCARAB_TRANSITION.TO_OPTION_ID"; 80 DISABLED_IF_BLOCKED = "SCARAB_TRANSITION.DISABLED_IF_BLOCKED"; 81 if (Torque.isInit()) 82 { 83 try 84 { 85 getMapBuilder(TransitionMapBuilder.CLASS_NAME); 86 } 87 catch (Exception e) 88 { 89 log.error("Could not initialize Peer", e); 90 } 91 } 92 else 93 { 94 Torque.registerMapBuilder(TransitionMapBuilder.CLASS_NAME); 95 } 96 } 97 98 99 public static final int numColumns = 6; 100 101 102 protected static final String CLASSNAME_DEFAULT = 103 "org.tigris.scarab.om.Transition"; 104 105 106 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 107 108 114 private static Class initClass(String className) 115 { 116 Class c = null; 117 try 118 { 119 c = Class.forName(className); 120 } 121 catch (Throwable t) 122 { 123 log.error("A FATAL ERROR has occurred which should not " 124 + "have happened under any circumstance. Please notify " 125 + "the Torque developers <torque-dev@db.apache.org> " 126 + "and give as many details as possible (including the error " 127 + "stack trace).", t); 128 129 if (t instanceof Error ) 131 { 132 throw (Error ) t.fillInStackTrace(); 133 } 134 } 135 return c; 136 } 137 138 148 public static List resultSet2Objects(java.sql.ResultSet results) 149 throws TorqueException 150 { 151 try 152 { 153 QueryDataSet qds = null; 154 List rows = null; 155 try 156 { 157 qds = new QueryDataSet(results); 158 rows = getSelectResults(qds); 159 } 160 finally 161 { 162 if (qds != null) 163 { 164 qds.close(); 165 } 166 } 167 168 return populateObjects(rows); 169 } 170 catch (SQLException e) 171 { 172 throw new TorqueException(e); 173 } 174 catch (DataSetException e) 175 { 176 throw new TorqueException(e); 177 } 178 } 179 180 181 182 189 public static ObjectKey doInsert(Criteria criteria) 190 throws TorqueException 191 { 192 return BaseTransitionPeer 193 .doInsert(criteria, (Connection ) null); 194 } 195 196 206 public static ObjectKey doInsert(Criteria criteria, Connection con) 207 throws TorqueException 208 { 209 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 211 { 212 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 213 if (possibleBoolean instanceof Boolean ) 214 { 215 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 216 } 217 } 218 219 setDbName(criteria); 220 221 if (con == null) 222 { 223 return BasePeer.doInsert(criteria); 224 } 225 else 226 { 227 return BasePeer.doInsert(criteria, con); 228 } 229 } 230 231 238 public static void addSelectColumns(Criteria criteria) 239 throws TorqueException 240 { 241 criteria.addSelectColumn(TRANSITION_ID); 242 criteria.addSelectColumn(ROLE_ID); 243 criteria.addSelectColumn(ATTRIBUTE_ID); 244 criteria.addSelectColumn(FROM_OPTION_ID); 245 criteria.addSelectColumn(TO_OPTION_ID); 246 criteria.addSelectColumn(DISABLED_IF_BLOCKED); 247 } 248 249 258 public static Transition row2Object(Record row, 259 int offset, 260 Class cls) 261 throws TorqueException 262 { 263 try 264 { 265 Transition obj = (Transition) cls.newInstance(); 266 TransitionPeer.populateObject(row, offset, obj); 267 obj.setModified(false); 268 obj.setNew(false); 269 270 return obj; 271 } 272 catch (InstantiationException e) 273 { 274 throw new TorqueException(e); 275 } 276 catch (IllegalAccessException e) 277 { 278 throw new TorqueException(e); 279 } 280 } 281 282 291 public static void populateObject(Record row, 292 int offset, 293 Transition obj) 294 throws TorqueException 295 { 296 try 297 { 298 obj.setTransitionId(row.getValue(offset + 0).asIntegerObj()); 299 obj.setRoleId(row.getValue(offset + 1).asIntegerObj()); 300 obj.setAttributeId(row.getValue(offset + 2).asIntegerObj()); 301 obj.setFromOptionId(row.getValue(offset + 3).asIntegerObj()); 302 obj.setToOptionId(row.getValue(offset + 4).asIntegerObj()); 303 obj.setDisabledIfBlocked(row.getValue(offset + 5).asBoolean()); 304 } 305 catch (DataSetException e) 306 { 307 throw new TorqueException(e); 308 } 309 } 310 311 319 public static List doSelect(Criteria criteria) throws TorqueException 320 { 321 return populateObjects(doSelectVillageRecords(criteria)); 322 } 323 324 333 public static List doSelect(Criteria criteria, Connection con) 334 throws TorqueException 335 { 336 return populateObjects(doSelectVillageRecords(criteria, con)); 337 } 338 339 349 public static List doSelectVillageRecords(Criteria criteria) 350 throws TorqueException 351 { 352 return BaseTransitionPeer 353 .doSelectVillageRecords(criteria, (Connection ) null); 354 } 355 356 365 public static List doSelectVillageRecords(Criteria criteria, Connection con) 366 throws TorqueException 367 { 368 if (criteria.getSelectColumns().size() == 0) 369 { 370 addSelectColumns(criteria); 371 } 372 373 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 375 { 376 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 377 if (possibleBoolean instanceof Boolean ) 378 { 379 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 380 } 381 } 382 383 setDbName(criteria); 384 385 if (con == null) 388 { 389 return BasePeer.doSelect(criteria); 390 } 391 else 392 { 393 return BasePeer.doSelect(criteria, con); 394 } 395 } 396 397 404 public static List populateObjects(List records) 405 throws TorqueException 406 { 407 List results = new ArrayList (records.size()); 408 409 for (int i = 0; i < records.size(); i++) 411 { 412 Record row = (Record) records.get(i); 413 results.add(TransitionPeer.row2Object(row, 1, 414 TransitionPeer.getOMClass())); 415 } 416 return results; 417 } 418 419 420 428 public static Class getOMClass() 429 throws TorqueException 430 { 431 return CLASS_DEFAULT; 432 } 433 434 442 public static void doUpdate(Criteria criteria) throws TorqueException 443 { 444 BaseTransitionPeer 445 .doUpdate(criteria, (Connection ) null); 446 } 447 448 459 public static void doUpdate(Criteria criteria, Connection con) 460 throws TorqueException 461 { 462 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 463 selectCriteria.put(TRANSITION_ID, criteria.remove(TRANSITION_ID)); 464 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 466 { 467 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 468 if (possibleBoolean instanceof Boolean ) 469 { 470 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 471 } 472 } 473 474 setDbName(criteria); 475 476 if (con == null) 477 { 478 BasePeer.doUpdate(selectCriteria, criteria); 479 } 480 else 481 { 482 BasePeer.doUpdate(selectCriteria, criteria, con); 483 } 484 } 485 486 493 public static void doDelete(Criteria criteria) throws TorqueException 494 { 495 TransitionPeer 496 .doDelete(criteria, (Connection ) null); 497 } 498 499 509 public static void doDelete(Criteria criteria, Connection con) 510 throws TorqueException 511 { 512 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 514 { 515 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 516 if (possibleBoolean instanceof Boolean ) 517 { 518 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 519 } 520 } 521 522 setDbName(criteria); 523 524 if (con == null) 525 { 526 BasePeer.doDelete(criteria); 527 } 528 else 529 { 530 BasePeer.doDelete(criteria, con); 531 } 532 } 533 534 540 public static List doSelect(Transition obj) throws TorqueException 541 { 542 return doSelect(buildSelectCriteria(obj)); 543 } 544 545 551 public static void doInsert(Transition obj) throws TorqueException 552 { 553 obj.setPrimaryKey(doInsert(buildCriteria(obj))); 554 obj.setNew(false); 555 obj.setModified(false); 556 } 557 558 563 public static void doUpdate(Transition obj) throws TorqueException 564 { 565 doUpdate(buildCriteria(obj)); 566 obj.setModified(false); 567 } 568 569 574 public static void doDelete(Transition obj) throws TorqueException 575 { 576 doDelete(buildSelectCriteria(obj)); 577 } 578 579 589 public static void doInsert(Transition obj, Connection con) 590 throws TorqueException 591 { 592 obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); 593 obj.setNew(false); 594 obj.setModified(false); 595 } 596 597 607 public static void doUpdate(Transition obj, Connection con) 608 throws TorqueException 609 { 610 doUpdate(buildCriteria(obj), con); 611 obj.setModified(false); 612 } 613 614 624 public static void doDelete(Transition obj, Connection con) 625 throws TorqueException 626 { 627 doDelete(buildSelectCriteria(obj), con); 628 } 629 630 637 public static void doDelete(ObjectKey pk) throws TorqueException 638 { 639 BaseTransitionPeer 640 .doDelete(pk, (Connection ) null); 641 } 642 643 653 public static void doDelete(ObjectKey pk, Connection con) 654 throws TorqueException 655 { 656 doDelete(buildCriteria(pk), con); 657 } 658 659 660 public static Criteria buildCriteria( ObjectKey pk ) 661 { 662 Criteria criteria = new Criteria(); 663 criteria.add(TRANSITION_ID, pk); 664 return criteria; 665 } 666 667 668 public static Criteria buildCriteria( Transition obj ) 669 { 670 Criteria criteria = new Criteria(DATABASE_NAME); 671 if (!obj.isNew()) 672 criteria.add(TRANSITION_ID, obj.getTransitionId()); 673 criteria.add(ROLE_ID, obj.getRoleId()); 674 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 675 criteria.add(FROM_OPTION_ID, obj.getFromOptionId()); 676 criteria.add(TO_OPTION_ID, obj.getToOptionId()); 677 criteria.add(DISABLED_IF_BLOCKED, obj.getDisabledIfBlocked()); 678 return criteria; 679 } 680 681 682 public static Criteria buildSelectCriteria( Transition obj ) 683 { 684 Criteria criteria = new Criteria(DATABASE_NAME); 685 if (!obj.isNew()) 686 criteria.add(TRANSITION_ID, obj.getTransitionId()); 687 criteria.add(ROLE_ID, obj.getRoleId()); 688 criteria.add(ATTRIBUTE_ID, obj.getAttributeId()); 689 criteria.add(FROM_OPTION_ID, obj.getFromOptionId()); 690 criteria.add(TO_OPTION_ID, obj.getToOptionId()); 691 criteria.add(DISABLED_IF_BLOCKED, obj.getDisabledIfBlocked()); 692 return criteria; 693 } 694 695 696 705 public static Transition retrieveByPK(Integer pk) 706 throws TorqueException, NoRowsException, TooManyRowsException 707 { 708 return retrieveByPK(SimpleKey.keyFor(pk)); 709 } 710 711 721 public static Transition retrieveByPK(Integer pk, Connection con) 722 throws TorqueException, NoRowsException, TooManyRowsException 723 { 724 return retrieveByPK(SimpleKey.keyFor(pk), con); 725 } 726 727 736 public static Transition retrieveByPK(ObjectKey pk) 737 throws TorqueException, NoRowsException, TooManyRowsException 738 { 739 Connection db = null; 740 Transition retVal = null; 741 try 742 { 743 db = Torque.getConnection(DATABASE_NAME); 744 retVal = retrieveByPK(pk, db); 745 } 746 finally 747 { 748 Torque.closeConnection(db); 749 } 750 return(retVal); 751 } 752 753 763 public static Transition retrieveByPK(ObjectKey pk, Connection con) 764 throws TorqueException, NoRowsException, TooManyRowsException 765 { 766 Criteria criteria = buildCriteria(pk); 767 List v = doSelect(criteria, con); 768 if (v.size() == 0) 769 { 770 throw new NoRowsException("Failed to select a row."); 771 } 772 else if (v.size() > 1) 773 { 774 throw new TooManyRowsException("Failed to select only one row."); 775 } 776 else 777 { 778 return (Transition)v.get(0); 779 } 780 } 781 782 789 public static List retrieveByPKs(List pks) 790 throws TorqueException 791 { 792 Connection db = null; 793 List retVal = null; 794 try 795 { 796 db = Torque.getConnection(DATABASE_NAME); 797 retVal = retrieveByPKs(pks, db); 798 } 799 finally 800 { 801 Torque.closeConnection(db); 802 } 803 return(retVal); 804 } 805 806 814 public static List retrieveByPKs( List pks, Connection dbcon ) 815 throws TorqueException 816 { 817 List objs = null; 818 if (pks == null || pks.size() == 0) 819 { 820 objs = new LinkedList (); 821 } 822 else 823 { 824 Criteria criteria = new Criteria(); 825 criteria.addIn( TRANSITION_ID, pks ); 826 objs = doSelect(criteria, dbcon); 827 } 828 return objs; 829 } 830 831 832 833 834 835 836 837 838 839 840 851 protected static List doSelectJoinAttribute(Criteria criteria) 852 throws TorqueException 853 { 854 setDbName(criteria); 855 856 TransitionPeer.addSelectColumns(criteria); 857 int offset = numColumns + 1; 858 AttributePeer.addSelectColumns(criteria); 859 860 861 criteria.addJoin(TransitionPeer.ATTRIBUTE_ID, 862 AttributePeer.ATTRIBUTE_ID); 863 864 865 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 867 { 868 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 869 if (possibleBoolean instanceof Boolean ) 870 { 871 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 872 } 873 } 874 875 List rows = BasePeer.doSelect(criteria); 876 List results = new ArrayList (); 877 878 for (int i = 0; i < rows.size(); i++) 879 { 880 Record row = (Record) rows.get(i); 881 882 Class omClass = TransitionPeer.getOMClass(); 883 Transition obj1 = (Transition) TransitionPeer 884 .row2Object(row, 1, omClass); 885 omClass = AttributePeer.getOMClass(); 886 Attribute obj2 = (Attribute)AttributePeer 887 .row2Object(row, offset, omClass); 888 889 boolean newObject = true; 890 for (int j = 0; j < results.size(); j++) 891 { 892 Transition temp_obj1 = (Transition)results.get(j); 893 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 894 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 895 { 896 newObject = false; 897 temp_obj2.addTransition(obj1); 898 break; 899 } 900 } 901 if (newObject) 902 { 903 obj2.initTransitions(); 904 obj2.addTransition(obj1); 905 } 906 results.add(obj1); 907 } 908 return results; 909 } 910 911 912 913 914 925 protected static List doSelectJoinAttributeOptionRelatedByFromOptionId(Criteria criteria) 926 throws TorqueException 927 { 928 setDbName(criteria); 929 930 TransitionPeer.addSelectColumns(criteria); 931 int offset = numColumns + 1; 932 AttributeOptionPeer.addSelectColumns(criteria); 933 934 935 criteria.addJoin(TransitionPeer.FROM_OPTION_ID, 936 AttributeOptionPeer.OPTION_ID); 937 938 939 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 941 { 942 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 943 if (possibleBoolean instanceof Boolean ) 944 { 945 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 946 } 947 } 948 949 List rows = BasePeer.doSelect(criteria); 950 List results = new ArrayList (); 951 952 for (int i = 0; i < rows.size(); i++) 953 { 954 Record row = (Record) rows.get(i); 955 956 Class omClass = TransitionPeer.getOMClass(); 957 Transition obj1 = (Transition) TransitionPeer 958 .row2Object(row, 1, omClass); 959 omClass = AttributeOptionPeer.getOMClass(); 960 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 961 .row2Object(row, offset, omClass); 962 963 boolean newObject = true; 964 for (int j = 0; j < results.size(); j++) 965 { 966 Transition temp_obj1 = (Transition)results.get(j); 967 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByFromOptionId(); 968 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 969 { 970 newObject = false; 971 temp_obj2.addTransitionRelatedByFromOptionId(obj1); 972 break; 973 } 974 } 975 if (newObject) 976 { 977 obj2.initTransitionsRelatedByFromOptionId(); 978 obj2.addTransitionRelatedByFromOptionId(obj1); 979 } 980 results.add(obj1); 981 } 982 return results; 983 } 984 985 986 987 988 999 protected static List doSelectJoinAttributeOptionRelatedByToOptionId(Criteria criteria) 1000 throws TorqueException 1001 { 1002 setDbName(criteria); 1003 1004 TransitionPeer.addSelectColumns(criteria); 1005 int offset = numColumns + 1; 1006 AttributeOptionPeer.addSelectColumns(criteria); 1007 1008 1009 criteria.addJoin(TransitionPeer.TO_OPTION_ID, 1010 AttributeOptionPeer.OPTION_ID); 1011 1012 1013 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 1015 { 1016 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 1017 if (possibleBoolean instanceof Boolean ) 1018 { 1019 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1020 } 1021 } 1022 1023 List rows = BasePeer.doSelect(criteria); 1024 List results = new ArrayList (); 1025 1026 for (int i = 0; i < rows.size(); i++) 1027 { 1028 Record row = (Record) rows.get(i); 1029 1030 Class omClass = TransitionPeer.getOMClass(); 1031 Transition obj1 = (Transition) TransitionPeer 1032 .row2Object(row, 1, omClass); 1033 omClass = AttributeOptionPeer.getOMClass(); 1034 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1035 .row2Object(row, offset, omClass); 1036 1037 boolean newObject = true; 1038 for (int j = 0; j < results.size(); j++) 1039 { 1040 Transition temp_obj1 = (Transition)results.get(j); 1041 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByToOptionId(); 1042 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1043 { 1044 newObject = false; 1045 temp_obj2.addTransitionRelatedByToOptionId(obj1); 1046 break; 1047 } 1048 } 1049 if (newObject) 1050 { 1051 obj2.initTransitionsRelatedByToOptionId(); 1052 obj2.addTransitionRelatedByToOptionId(obj1); 1053 } 1054 results.add(obj1); 1055 } 1056 return results; 1057 } 1058 1059 1060 1061 1062 1063 1064 1065 1066 1077 protected static List doSelectJoinAllExceptAttribute(Criteria criteria) 1078 throws TorqueException 1079 { 1080 setDbName(criteria); 1081 1082 addSelectColumns(criteria); 1083 int offset2 = numColumns + 1; 1084 1085 1086 AttributeOptionPeer.addSelectColumns(criteria); 1087 int offset3 = offset2 + AttributeOptionPeer.numColumns; 1088 1089 AttributeOptionPeer.addSelectColumns(criteria); 1090 int offset4 = offset3 + AttributeOptionPeer.numColumns; 1091 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 1093 { 1094 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 1095 if (possibleBoolean instanceof Boolean ) 1096 { 1097 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1098 } 1099 } 1100 1101 List rows = BasePeer.doSelect(criteria); 1102 List results = new ArrayList (); 1103 1104 for (int i = 0; i < rows.size(); i++) 1105 { 1106 Record row = (Record)rows.get(i); 1107 1108 Class omClass = TransitionPeer.getOMClass(); 1109 Transition obj1 = (Transition)TransitionPeer 1110 .row2Object(row, 1, omClass); 1111 1112 1113 1114 1115 1116 omClass = AttributeOptionPeer.getOMClass(); 1117 AttributeOption obj2 = (AttributeOption)AttributeOptionPeer 1118 .row2Object( row, offset2, omClass); 1119 1120 boolean newObject = true; 1121 for (int j = 0; j < results.size(); j++) 1122 { 1123 Transition temp_obj1 = (Transition)results.get(j); 1124 AttributeOption temp_obj2 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByFromOptionId(); 1125 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1126 { 1127 newObject = false; 1128 temp_obj2.addTransitionRelatedByFromOptionId(obj1); 1129 break; 1130 } 1131 } 1132 if (newObject) 1133 { 1134 obj2.initTransitionsRelatedByFromOptionId(); 1135 obj2.addTransitionRelatedByFromOptionId(obj1); 1136 } 1137 1138 1139 1140 1141 omClass = AttributeOptionPeer.getOMClass(); 1142 AttributeOption obj3 = (AttributeOption)AttributeOptionPeer 1143 .row2Object( row, offset3, omClass); 1144 1145 newObject = true; 1146 for (int j = 0; j < results.size(); j++) 1147 { 1148 Transition temp_obj1 = (Transition)results.get(j); 1149 AttributeOption temp_obj3 = (AttributeOption)temp_obj1.getAttributeOptionRelatedByToOptionId(); 1150 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1151 { 1152 newObject = false; 1153 temp_obj3.addTransitionRelatedByToOptionId(obj1); 1154 break; 1155 } 1156 } 1157 if (newObject) 1158 { 1159 obj3.initTransitionsRelatedByToOptionId(); 1160 obj3.addTransitionRelatedByToOptionId(obj1); 1161 } 1162 results.add(obj1); 1163 } 1164 return results; 1165 } 1166 1167 1168 1169 1170 1171 1182 protected static List doSelectJoinAllExceptAttributeOptionRelatedByFromOptionId(Criteria criteria) 1183 throws TorqueException 1184 { 1185 setDbName(criteria); 1186 1187 addSelectColumns(criteria); 1188 int offset2 = numColumns + 1; 1189 1190 AttributePeer.addSelectColumns(criteria); 1191 int offset3 = offset2 + AttributePeer.numColumns; 1192 1193 1194 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 1196 { 1197 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 1198 if (possibleBoolean instanceof Boolean ) 1199 { 1200 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1201 } 1202 } 1203 1204 List rows = BasePeer.doSelect(criteria); 1205 List results = new ArrayList (); 1206 1207 for (int i = 0; i < rows.size(); i++) 1208 { 1209 Record row = (Record)rows.get(i); 1210 1211 Class omClass = TransitionPeer.getOMClass(); 1212 Transition obj1 = (Transition)TransitionPeer 1213 .row2Object(row, 1, omClass); 1214 1215 1216 1217 1218 omClass = AttributePeer.getOMClass(); 1219 Attribute obj2 = (Attribute)AttributePeer 1220 .row2Object( row, offset2, omClass); 1221 1222 boolean newObject = true; 1223 for (int j = 0; j < results.size(); j++) 1224 { 1225 Transition temp_obj1 = (Transition)results.get(j); 1226 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1227 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1228 { 1229 newObject = false; 1230 temp_obj2.addTransition(obj1); 1231 break; 1232 } 1233 } 1234 if (newObject) 1235 { 1236 obj2.initTransitions(); 1237 obj2.addTransition(obj1); 1238 } 1239 1240 1241 results.add(obj1); 1242 } 1243 return results; 1244 } 1245 1246 1247 1248 1249 1250 1261 protected static List doSelectJoinAllExceptAttributeOptionRelatedByToOptionId(Criteria criteria) 1262 throws TorqueException 1263 { 1264 setDbName(criteria); 1265 1266 addSelectColumns(criteria); 1267 int offset2 = numColumns + 1; 1268 1269 AttributePeer.addSelectColumns(criteria); 1270 int offset3 = offset2 + AttributePeer.numColumns; 1271 1272 1273 if (criteria.containsKey(DISABLED_IF_BLOCKED)) 1275 { 1276 Object possibleBoolean = criteria.get(DISABLED_IF_BLOCKED); 1277 if (possibleBoolean instanceof Boolean ) 1278 { 1279 criteria.add(DISABLED_IF_BLOCKED, ((Boolean ) possibleBoolean).booleanValue() ? 1 : 0); 1280 } 1281 } 1282 1283 List rows = BasePeer.doSelect(criteria); 1284 List results = new ArrayList (); 1285 1286 for (int i = 0; i < rows.size(); i++) 1287 { 1288 Record row = (Record)rows.get(i); 1289 1290 Class omClass = TransitionPeer.getOMClass(); 1291 Transition obj1 = (Transition)TransitionPeer 1292 .row2Object(row, 1, omClass); 1293 1294 1295 1296 1297 omClass = AttributePeer.getOMClass(); 1298 Attribute obj2 = (Attribute)AttributePeer 1299 .row2Object( row, offset2, omClass); 1300 1301 boolean newObject = true; 1302 for (int j = 0; j < results.size(); j++) 1303 { 1304 Transition temp_obj1 = (Transition)results.get(j); 1305 Attribute temp_obj2 = (Attribute)temp_obj1.getAttribute(); 1306 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1307 { 1308 newObject = false; 1309 temp_obj2.addTransition(obj1); 1310 break; 1311 } 1312 } 1313 if (newObject) 1314 { 1315 obj2.initTransitions(); 1316 obj2.addTransition(obj1); 1317 } 1318 1319 1320 results.add(obj1); 1321 } 1322 return results; 1323 } 1324 1325 1326 1333 protected static TableMap getTableMap() 1334 throws TorqueException 1335 { 1336 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1337 } 1338 1339 private static void setDbName(Criteria crit) 1340 { 1341 if (crit.getDbName() == Torque.getDefaultDB()) 1345 { 1346 crit.setDbName(DATABASE_NAME); 1347 } 1348 } 1349} 1350 | Popular Tags |