1 package org.apache.jetspeed.om.security.turbine; 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.apache.jetspeed.om.security.turbine.map.*; 32 33 34 35 36 37 43 public abstract class BaseTurbineUserGroupRolePeer 44 extends BasePeer 45 { 46 47 48 public static final String DATABASE_NAME = "default"; 49 50 51 public static final String TABLE_NAME = "TURBINE_USER_GROUP_ROLE"; 52 53 58 public static MapBuilder getMapBuilder() 59 throws TorqueException 60 { 61 return getMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME); 62 } 63 64 65 public static final String USER_ID; 66 67 public static final String GROUP_ID; 68 69 public static final String ROLE_ID; 70 71 static 72 { 73 USER_ID = "TURBINE_USER_GROUP_ROLE.USER_ID"; 74 GROUP_ID = "TURBINE_USER_GROUP_ROLE.GROUP_ID"; 75 ROLE_ID = "TURBINE_USER_GROUP_ROLE.ROLE_ID"; 76 if (Torque.isInit()) 77 { 78 try 79 { 80 getMapBuilder(); 81 } 82 catch (Exception e) 83 { 84 log.error("Could not initialize Peer", e); 85 } 86 } 87 else 88 { 89 Torque.registerMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME); 90 } 91 } 92 93 94 public static final int numColumns = 3; 95 96 97 protected static final String CLASSNAME_DEFAULT = 98 "org.apache.jetspeed.om.security.turbine.TurbineUserGroupRole"; 99 100 101 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 102 103 109 private static Class initClass(String className) 110 { 111 Class c = null; 112 try 113 { 114 c = Class.forName(className); 115 } 116 catch (Throwable t) 117 { 118 log.error("A FATAL ERROR has occurred which should not " 119 + "have happened under any circumstance. Please notify " 120 + "the Torque developers <turbine-torque-dev@jakarta.apache.org> " 121 + "and give as many details as possible (including the error " 122 + "stack trace).", t); 123 124 if (t instanceof Error ) 126 { 127 throw (Error ) t.fillInStackTrace(); 128 } 129 } 130 return c; 131 } 132 133 143 public static List resultSet2Objects(java.sql.ResultSet results) 144 throws TorqueException 145 { 146 try 147 { 148 QueryDataSet qds = null; 149 List rows = null; 150 try 151 { 152 qds = new QueryDataSet(results); 153 rows = getSelectResults(qds); 154 } 155 finally 156 { 157 if (qds != null) 158 { 159 qds.close(); 160 } 161 } 162 163 return populateObjects(rows); 164 } 165 catch (SQLException e) 166 { 167 throw new TorqueException(e); 168 } 169 catch (DataSetException e) 170 { 171 throw new TorqueException(e); 172 } 173 } 174 175 176 177 184 public static ObjectKey doInsert(Criteria criteria) 185 throws TorqueException 186 { 187 return BaseTurbineUserGroupRolePeer 188 .doInsert(criteria, (Connection ) null); 189 } 190 191 201 public static ObjectKey doInsert(Criteria criteria, Connection con) 202 throws TorqueException 203 { 204 205 if (criteria.getDbName() == Torque.getDefaultDB()) 209 { 210 criteria.setDbName(DATABASE_NAME); 211 } 212 if (con == null) 213 { 214 return BasePeer.doInsert(criteria); 215 } 216 else 217 { 218 return BasePeer.doInsert(criteria, con); 219 } 220 } 221 222 229 public static void addSelectColumns(Criteria criteria) 230 throws TorqueException 231 { 232 criteria.addSelectColumn(USER_ID); 233 criteria.addSelectColumn(GROUP_ID); 234 criteria.addSelectColumn(ROLE_ID); 235 } 236 237 246 public static TurbineUserGroupRole row2Object(Record row, 247 int offset, 248 Class cls) 249 throws TorqueException 250 { 251 try 252 { 253 TurbineUserGroupRole obj = (TurbineUserGroupRole) cls.newInstance(); 254 TurbineUserGroupRolePeer.populateObject(row, offset, obj); 255 obj.setModified(false); 256 obj.setNew(false); 257 258 return obj; 259 } 260 catch (InstantiationException e) 261 { 262 throw new TorqueException(e); 263 } 264 catch (IllegalAccessException e) 265 { 266 throw new TorqueException(e); 267 } 268 } 269 270 279 public static void populateObject(Record row, 280 int offset, 281 TurbineUserGroupRole obj) 282 throws TorqueException 283 { 284 try 285 { 286 obj.setUserId(row.getValue(offset + 0).asInt()); 287 obj.setGroupId(row.getValue(offset + 1).asInt()); 288 obj.setRoleId(row.getValue(offset + 2).asInt()); 289 } 290 catch (DataSetException e) 291 { 292 throw new TorqueException(e); 293 } 294 } 295 296 304 public static List doSelect(Criteria criteria) throws TorqueException 305 { 306 return populateObjects(doSelectVillageRecords(criteria)); 307 } 308 309 318 public static List doSelect(Criteria criteria, Connection con) 319 throws TorqueException 320 { 321 return populateObjects(doSelectVillageRecords(criteria, con)); 322 } 323 324 334 public static List doSelectVillageRecords(Criteria criteria) 335 throws TorqueException 336 { 337 return BaseTurbineUserGroupRolePeer 338 .doSelectVillageRecords(criteria, (Connection ) null); 339 } 340 341 349 public static List doSelectVillageRecords(Criteria criteria, Connection con) 350 throws TorqueException 351 { 352 if (criteria.getSelectColumns().size() == 0) 353 { 354 addSelectColumns(criteria); 355 } 356 357 358 if (criteria.getDbName() == Torque.getDefaultDB()) 362 { 363 criteria.setDbName(DATABASE_NAME); 364 } 365 if (con == null) 368 { 369 return BasePeer.doSelect(criteria); 370 } 371 else 372 { 373 return BasePeer.doSelect(criteria, con); 374 } 375 } 376 377 384 public static List populateObjects(List records) 385 throws TorqueException 386 { 387 List results = new ArrayList (records.size()); 388 389 for (int i = 0; i < records.size(); i++) 391 { 392 Record row = (Record) records.get(i); 393 results.add(TurbineUserGroupRolePeer.row2Object(row, 1, 394 TurbineUserGroupRolePeer.getOMClass())); 395 } 396 return results; 397 } 398 399 400 408 public static Class getOMClass() 409 throws TorqueException 410 { 411 return CLASS_DEFAULT; 412 } 413 414 422 public static void doUpdate(Criteria criteria) throws TorqueException 423 { 424 BaseTurbineUserGroupRolePeer 425 .doUpdate(criteria, (Connection ) null); 426 } 427 428 439 public static void doUpdate(Criteria criteria, Connection con) 440 throws TorqueException 441 { 442 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 443 selectCriteria.put(USER_ID, criteria.remove(USER_ID)); 444 selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID)); 445 selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID)); 446 447 if (criteria.getDbName() == Torque.getDefaultDB()) 451 { 452 criteria.setDbName(DATABASE_NAME); 453 } 454 if (con == null) 455 { 456 BasePeer.doUpdate(selectCriteria, criteria); 457 } 458 else 459 { 460 BasePeer.doUpdate(selectCriteria, criteria, con); 461 } 462 } 463 464 471 public static void doDelete(Criteria criteria) throws TorqueException 472 { 473 BaseTurbineUserGroupRolePeer 474 .doDelete(criteria, (Connection ) null); 475 } 476 477 487 public static void doDelete(Criteria criteria, Connection con) 488 throws TorqueException 489 { 490 491 if (criteria.getDbName() == Torque.getDefaultDB()) 495 { 496 criteria.setDbName(DATABASE_NAME); 497 } 498 if (con == null) 499 { 500 BasePeer.doDelete(criteria); 501 } 502 else 503 { 504 BasePeer.doDelete(criteria, con); 505 } 506 } 507 508 514 public static List doSelect(TurbineUserGroupRole obj) throws TorqueException 515 { 516 return doSelect(buildCriteria(obj)); 517 } 518 519 525 public static void doInsert(TurbineUserGroupRole obj) throws TorqueException 526 { 527 doInsert(buildCriteria(obj)); 528 obj.setNew(false); 529 obj.setModified(false); 530 } 531 532 537 public static void doUpdate(TurbineUserGroupRole obj) throws TorqueException 538 { 539 doUpdate(buildCriteria(obj)); 540 obj.setModified(false); 541 } 542 543 548 public static void doDelete(TurbineUserGroupRole obj) throws TorqueException 549 { 550 doDelete(buildCriteria(obj)); 551 } 552 553 563 public static void doInsert(TurbineUserGroupRole obj, Connection con) 564 throws TorqueException 565 { 566 doInsert(buildCriteria(obj), con); 567 obj.setNew(false); 568 obj.setModified(false); 569 } 570 571 581 public static void doUpdate(TurbineUserGroupRole obj, Connection con) 582 throws TorqueException 583 { 584 doUpdate(buildCriteria(obj), con); 585 obj.setModified(false); 586 } 587 588 598 public static void doDelete(TurbineUserGroupRole obj, Connection con) 599 throws TorqueException 600 { 601 doDelete(buildCriteria(obj), con); 602 } 603 604 611 public static void doDelete(ObjectKey pk) throws TorqueException 612 { 613 BaseTurbineUserGroupRolePeer 614 .doDelete(pk, (Connection ) null); 615 } 616 617 627 public static void doDelete(ObjectKey pk, Connection con) 628 throws TorqueException 629 { 630 doDelete(buildCriteria(pk), con); 631 } 632 633 634 public static Criteria buildCriteria( ObjectKey pk ) 635 { 636 Criteria criteria = new Criteria(); 637 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 638 criteria.add(USER_ID, keys[0]); 639 criteria.add(GROUP_ID, keys[1]); 640 criteria.add(ROLE_ID, keys[2]); 641 return criteria; 642 } 643 644 645 public static Criteria buildCriteria( TurbineUserGroupRole obj ) 646 { 647 Criteria criteria = new Criteria(DATABASE_NAME); 648 criteria.add(USER_ID, obj.getUserId()); 649 criteria.add(GROUP_ID, obj.getGroupId()); 650 criteria.add(ROLE_ID, obj.getRoleId()); 651 return criteria; 652 } 653 654 655 656 665 public static TurbineUserGroupRole retrieveByPK(ObjectKey pk) 666 throws TorqueException, NoRowsException, TooManyRowsException 667 { 668 Connection db = null; 669 TurbineUserGroupRole retVal = null; 670 try 671 { 672 db = Torque.getConnection(DATABASE_NAME); 673 retVal = retrieveByPK(pk, db); 674 } 675 finally 676 { 677 Torque.closeConnection(db); 678 } 679 return(retVal); 680 } 681 682 692 public static TurbineUserGroupRole retrieveByPK(ObjectKey pk, Connection con) 693 throws TorqueException, NoRowsException, TooManyRowsException 694 { 695 Criteria criteria = buildCriteria(pk); 696 List v = doSelect(criteria, con); 697 if (v.size() == 0) 698 { 699 throw new NoRowsException("Failed to select a row."); 700 } 701 else if (v.size() > 1) 702 { 703 throw new TooManyRowsException("Failed to select only one row."); 704 } 705 else 706 { 707 return (TurbineUserGroupRole)v.get(0); 708 } 709 } 710 711 718 public static List retrieveByPKs(List pks) 719 throws TorqueException 720 { 721 Connection db = null; 722 List retVal = null; 723 try 724 { 725 db = Torque.getConnection(DATABASE_NAME); 726 retVal = retrieveByPKs(pks, db); 727 } 728 finally 729 { 730 Torque.closeConnection(db); 731 } 732 return(retVal); 733 } 734 735 743 public static List retrieveByPKs( List pks, Connection dbcon ) 744 throws TorqueException 745 { 746 List objs = null; 747 if (pks == null || pks.size() == 0) 748 { 749 objs = new LinkedList (); 750 } 751 else 752 { 753 Criteria criteria = new Criteria(); 754 Iterator iter = pks.iterator(); 755 while (iter.hasNext()) 756 { 757 ObjectKey pk = (ObjectKey)iter.next(); 758 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 759 Criteria.Criterion c0 = criteria.getNewCriterion( 760 USER_ID, keys[0], Criteria.EQUAL); 761 Criteria.Criterion c1 = criteria.getNewCriterion( 762 GROUP_ID, keys[1], Criteria.EQUAL); 763 c0.and(c1); 764 Criteria.Criterion c2 = criteria.getNewCriterion( 765 ROLE_ID, keys[2], Criteria.EQUAL); 766 c1.and(c2); 767 criteria.or(c0); 768 } 769 objs = doSelect(criteria, dbcon); 770 } 771 return objs; 772 } 773 774 775 782 public static TurbineUserGroupRole retrieveByPK( 783 int user_id 784 , int group_id 785 , int role_id 786 ) throws TorqueException 787 { 788 Connection db = null; 789 TurbineUserGroupRole retVal = null; 790 try 791 { 792 db = Torque.getConnection(DATABASE_NAME); 793 retVal = retrieveByPK( 794 user_id 795 , group_id 796 , role_id 797 , db); 798 } 799 finally 800 { 801 Torque.closeConnection(db); 802 } 803 return(retVal); 804 } 805 806 814 public static TurbineUserGroupRole retrieveByPK( 815 int user_id 816 , int group_id 817 , int role_id 818 ,Connection con) throws TorqueException 819 { 820 821 Criteria criteria = new Criteria(5); 822 criteria.add(USER_ID, user_id); 823 criteria.add(GROUP_ID, group_id); 824 criteria.add(ROLE_ID, role_id); 825 List v = doSelect(criteria, con); 826 if (v.size() != 1) 827 { 828 throw new TorqueException("Failed to select one and only one row."); 829 } 830 else 831 { 832 return (TurbineUserGroupRole) v.get(0); 833 } 834 } 835 836 837 838 839 840 841 842 843 854 protected static List doSelectJoinTurbineUser(Criteria c) 855 throws TorqueException 856 { 857 if (c.getDbName() == Torque.getDefaultDB()) 861 { 862 c.setDbName(DATABASE_NAME); 863 } 864 865 TurbineUserGroupRolePeer.addSelectColumns(c); 866 int offset = numColumns + 1; 867 TurbineUserPeer.addSelectColumns(c); 868 869 870 c.addJoin(TurbineUserGroupRolePeer.USER_ID, 871 TurbineUserPeer.USER_ID); 872 873 874 875 List rows = BasePeer.doSelect(c); 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 = TurbineUserGroupRolePeer.getOMClass(); 883 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer 884 .row2Object(row, 1, omClass); 885 omClass = TurbineUserPeer.getOMClass(); 886 TurbineUser obj2 = (TurbineUser)TurbineUserPeer 887 .row2Object(row, offset, omClass); 888 889 boolean newObject = true; 890 for (int j = 0; j < results.size(); j++) 891 { 892 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 893 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser(); 894 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 895 { 896 newObject = false; 897 temp_obj2.addTurbineUserGroupRole(obj1); 898 break; 899 } 900 } 901 if (newObject) 902 { 903 obj2.initTurbineUserGroupRoles(); 904 obj2.addTurbineUserGroupRole(obj1); 905 } 906 results.add(obj1); 907 } 908 return results; 909 } 910 911 912 913 914 925 protected static List doSelectJoinTurbineGroup(Criteria c) 926 throws TorqueException 927 { 928 if (c.getDbName() == Torque.getDefaultDB()) 932 { 933 c.setDbName(DATABASE_NAME); 934 } 935 936 TurbineUserGroupRolePeer.addSelectColumns(c); 937 int offset = numColumns + 1; 938 TurbineGroupPeer.addSelectColumns(c); 939 940 941 c.addJoin(TurbineUserGroupRolePeer.GROUP_ID, 942 TurbineGroupPeer.GROUP_ID); 943 944 945 946 List rows = BasePeer.doSelect(c); 947 List results = new ArrayList (); 948 949 for (int i = 0; i < rows.size(); i++) 950 { 951 Record row = (Record) rows.get(i); 952 953 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 954 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer 955 .row2Object(row, 1, omClass); 956 omClass = TurbineGroupPeer.getOMClass(); 957 TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer 958 .row2Object(row, offset, omClass); 959 960 boolean newObject = true; 961 for (int j = 0; j < results.size(); j++) 962 { 963 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 964 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup(); 965 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 966 { 967 newObject = false; 968 temp_obj2.addTurbineUserGroupRole(obj1); 969 break; 970 } 971 } 972 if (newObject) 973 { 974 obj2.initTurbineUserGroupRoles(); 975 obj2.addTurbineUserGroupRole(obj1); 976 } 977 results.add(obj1); 978 } 979 return results; 980 } 981 982 983 984 985 996 protected static List doSelectJoinTurbineRole(Criteria c) 997 throws TorqueException 998 { 999 if (c.getDbName() == Torque.getDefaultDB()) 1003 { 1004 c.setDbName(DATABASE_NAME); 1005 } 1006 1007 TurbineUserGroupRolePeer.addSelectColumns(c); 1008 int offset = numColumns + 1; 1009 TurbineRolePeer.addSelectColumns(c); 1010 1011 1012 c.addJoin(TurbineUserGroupRolePeer.ROLE_ID, 1013 TurbineRolePeer.ROLE_ID); 1014 1015 1016 1017 List rows = BasePeer.doSelect(c); 1018 List results = new ArrayList (); 1019 1020 for (int i = 0; i < rows.size(); i++) 1021 { 1022 Record row = (Record) rows.get(i); 1023 1024 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1025 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer 1026 .row2Object(row, 1, omClass); 1027 omClass = TurbineRolePeer.getOMClass(); 1028 TurbineRole obj2 = (TurbineRole)TurbineRolePeer 1029 .row2Object(row, offset, omClass); 1030 1031 boolean newObject = true; 1032 for (int j = 0; j < results.size(); j++) 1033 { 1034 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1035 TurbineRole temp_obj2 = (TurbineRole)temp_obj1.getTurbineRole(); 1036 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1037 { 1038 newObject = false; 1039 temp_obj2.addTurbineUserGroupRole(obj1); 1040 break; 1041 } 1042 } 1043 if (newObject) 1044 { 1045 obj2.initTurbineUserGroupRoles(); 1046 obj2.addTurbineUserGroupRole(obj1); 1047 } 1048 results.add(obj1); 1049 } 1050 return results; 1051 } 1052 1053 1054 1055 1056 1057 1058 1059 1060 1071 protected static List doSelectJoinAllExceptTurbineUser(Criteria c) 1072 throws TorqueException 1073 { 1074 if (c.getDbName() == Torque.getDefaultDB()) 1078 { 1079 c.setDbName(DATABASE_NAME); 1080 } 1081 1082 addSelectColumns(c); 1083 int offset2 = numColumns + 1; 1084 1085 1086 TurbineGroupPeer.addSelectColumns(c); 1087 int offset3 = offset2 + TurbineGroupPeer.numColumns; 1088 1089 TurbineRolePeer.addSelectColumns(c); 1090 int offset4 = offset3 + TurbineRolePeer.numColumns; 1091 1092 List rows = BasePeer.doSelect(c); 1093 List results = new ArrayList (); 1094 1095 for (int i = 0; i < rows.size(); i++) 1096 { 1097 Record row = (Record)rows.get(i); 1098 1099 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1100 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer 1101 .row2Object(row, 1, omClass); 1102 1103 1104 1105 1106 1107 omClass = TurbineGroupPeer.getOMClass(); 1108 TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer 1109 .row2Object( row, offset2, omClass); 1110 1111 boolean newObject = true; 1112 for (int j = 0; j < results.size(); j++) 1113 { 1114 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1115 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup(); 1116 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1117 { 1118 newObject = false; 1119 temp_obj2.addTurbineUserGroupRole(obj1); 1120 break; 1121 } 1122 } 1123 if (newObject) 1124 { 1125 obj2.initTurbineUserGroupRoles(); 1126 obj2.addTurbineUserGroupRole(obj1); 1127 } 1128 1129 1130 1131 1132 omClass = TurbineRolePeer.getOMClass(); 1133 TurbineRole obj3 = (TurbineRole)TurbineRolePeer 1134 .row2Object( row, offset3, omClass); 1135 1136 newObject = true; 1137 for (int j = 0; j < results.size(); j++) 1138 { 1139 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1140 TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole(); 1141 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1142 { 1143 newObject = false; 1144 temp_obj3.addTurbineUserGroupRole(obj1); 1145 break; 1146 } 1147 } 1148 if (newObject) 1149 { 1150 obj3.initTurbineUserGroupRoles(); 1151 obj3.addTurbineUserGroupRole(obj1); 1152 } 1153 results.add(obj1); 1154 } 1155 return results; 1156 } 1157 1158 1159 1160 1161 1162 1173 protected static List doSelectJoinAllExceptTurbineGroup(Criteria c) 1174 throws TorqueException 1175 { 1176 if (c.getDbName() == Torque.getDefaultDB()) 1180 { 1181 c.setDbName(DATABASE_NAME); 1182 } 1183 1184 addSelectColumns(c); 1185 int offset2 = numColumns + 1; 1186 1187 TurbineUserPeer.addSelectColumns(c); 1188 int offset3 = offset2 + TurbineUserPeer.numColumns; 1189 1190 1191 TurbineRolePeer.addSelectColumns(c); 1192 int offset4 = offset3 + TurbineRolePeer.numColumns; 1193 1194 List rows = BasePeer.doSelect(c); 1195 List results = new ArrayList (); 1196 1197 for (int i = 0; i < rows.size(); i++) 1198 { 1199 Record row = (Record)rows.get(i); 1200 1201 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1202 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer 1203 .row2Object(row, 1, omClass); 1204 1205 1206 1207 1208 omClass = TurbineUserPeer.getOMClass(); 1209 TurbineUser obj2 = (TurbineUser)TurbineUserPeer 1210 .row2Object( row, offset2, omClass); 1211 1212 boolean newObject = true; 1213 for (int j = 0; j < results.size(); j++) 1214 { 1215 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1216 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser(); 1217 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1218 { 1219 newObject = false; 1220 temp_obj2.addTurbineUserGroupRole(obj1); 1221 break; 1222 } 1223 } 1224 if (newObject) 1225 { 1226 obj2.initTurbineUserGroupRoles(); 1227 obj2.addTurbineUserGroupRole(obj1); 1228 } 1229 1230 1231 1232 1233 1234 omClass = TurbineRolePeer.getOMClass(); 1235 TurbineRole obj3 = (TurbineRole)TurbineRolePeer 1236 .row2Object( row, offset3, omClass); 1237 1238 newObject = true; 1239 for (int j = 0; j < results.size(); j++) 1240 { 1241 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1242 TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole(); 1243 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1244 { 1245 newObject = false; 1246 temp_obj3.addTurbineUserGroupRole(obj1); 1247 break; 1248 } 1249 } 1250 if (newObject) 1251 { 1252 obj3.initTurbineUserGroupRoles(); 1253 obj3.addTurbineUserGroupRole(obj1); 1254 } 1255 results.add(obj1); 1256 } 1257 return results; 1258 } 1259 1260 1261 1262 1263 1264 1275 protected static List doSelectJoinAllExceptTurbineRole(Criteria c) 1276 throws TorqueException 1277 { 1278 if (c.getDbName() == Torque.getDefaultDB()) 1282 { 1283 c.setDbName(DATABASE_NAME); 1284 } 1285 1286 addSelectColumns(c); 1287 int offset2 = numColumns + 1; 1288 1289 TurbineUserPeer.addSelectColumns(c); 1290 int offset3 = offset2 + TurbineUserPeer.numColumns; 1291 1292 TurbineGroupPeer.addSelectColumns(c); 1293 int offset4 = offset3 + TurbineGroupPeer.numColumns; 1294 1295 1296 List rows = BasePeer.doSelect(c); 1297 List results = new ArrayList (); 1298 1299 for (int i = 0; i < rows.size(); i++) 1300 { 1301 Record row = (Record)rows.get(i); 1302 1303 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1304 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer 1305 .row2Object(row, 1, omClass); 1306 1307 1308 1309 1310 omClass = TurbineUserPeer.getOMClass(); 1311 TurbineUser obj2 = (TurbineUser)TurbineUserPeer 1312 .row2Object( row, offset2, omClass); 1313 1314 boolean newObject = true; 1315 for (int j = 0; j < results.size(); j++) 1316 { 1317 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1318 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser(); 1319 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1320 { 1321 newObject = false; 1322 temp_obj2.addTurbineUserGroupRole(obj1); 1323 break; 1324 } 1325 } 1326 if (newObject) 1327 { 1328 obj2.initTurbineUserGroupRoles(); 1329 obj2.addTurbineUserGroupRole(obj1); 1330 } 1331 1332 1333 1334 1335 omClass = TurbineGroupPeer.getOMClass(); 1336 TurbineGroup obj3 = (TurbineGroup)TurbineGroupPeer 1337 .row2Object( row, offset3, omClass); 1338 1339 newObject = true; 1340 for (int j = 0; j < results.size(); j++) 1341 { 1342 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1343 TurbineGroup temp_obj3 = (TurbineGroup)temp_obj1.getTurbineGroup(); 1344 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1345 { 1346 newObject = false; 1347 temp_obj3.addTurbineUserGroupRole(obj1); 1348 break; 1349 } 1350 } 1351 if (newObject) 1352 { 1353 obj3.initTurbineUserGroupRoles(); 1354 obj3.addTurbineUserGroupRole(obj1); 1355 } 1356 1357 results.add(obj1); 1358 } 1359 return results; 1360 } 1361 1362 1363 1370 protected static TableMap getTableMap() 1371 throws TorqueException 1372 { 1373 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1374 } 1375 } 1376 | Popular Tags |