1 package org.apache.fulcrum.security.impl.db.entity; 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.fulcrum.security.impl.db.entity.map.*; 32 33 34 35 36 37 39 public abstract class BaseTurbineUserGroupRolePeer 40 extends BasePeer 41 { 42 43 44 public static final String DATABASE_NAME = "scarab"; 45 46 47 public static final String TABLE_NAME = "TURBINE_USER_GROUP_ROLE"; 48 49 54 public static MapBuilder getMapBuilder() 55 throws TorqueException 56 { 57 return getMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME); 58 } 59 60 61 public static final String USER_ID; 62 63 public static final String GROUP_ID; 64 65 public static final String ROLE_ID; 66 67 static 68 { 69 USER_ID = "TURBINE_USER_GROUP_ROLE.USER_ID"; 70 GROUP_ID = "TURBINE_USER_GROUP_ROLE.GROUP_ID"; 71 ROLE_ID = "TURBINE_USER_GROUP_ROLE.ROLE_ID"; 72 if (Torque.isInit()) 73 { 74 try 75 { 76 getMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME); 77 } 78 catch (Exception e) 79 { 80 log.error("Could not initialize Peer", e); 81 } 82 } 83 else 84 { 85 Torque.registerMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME); 86 } 87 } 88 89 90 public static final int numColumns = 3; 91 92 93 protected static final String CLASSNAME_DEFAULT = 94 "org.apache.fulcrum.security.impl.db.entity.TurbineUserGroupRole"; 95 96 97 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); 98 99 105 private static Class initClass(String className) 106 { 107 Class c = null; 108 try 109 { 110 c = Class.forName(className); 111 } 112 catch (Throwable t) 113 { 114 log.error("A FATAL ERROR has occurred which should not " 115 + "have happened under any circumstance. Please notify " 116 + "the Torque developers <torque-dev@db.apache.org> " 117 + "and give as many details as possible (including the error " 118 + "stack trace).", t); 119 120 if (t instanceof Error ) 122 { 123 throw (Error ) t.fillInStackTrace(); 124 } 125 } 126 return c; 127 } 128 129 139 public static List resultSet2Objects(java.sql.ResultSet results) 140 throws TorqueException 141 { 142 try 143 { 144 QueryDataSet qds = null; 145 List rows = null; 146 try 147 { 148 qds = new QueryDataSet(results); 149 rows = getSelectResults(qds); 150 } 151 finally 152 { 153 if (qds != null) 154 { 155 qds.close(); 156 } 157 } 158 159 return populateObjects(rows); 160 } 161 catch (SQLException e) 162 { 163 throw new TorqueException(e); 164 } 165 catch (DataSetException e) 166 { 167 throw new TorqueException(e); 168 } 169 } 170 171 172 173 180 public static ObjectKey doInsert(Criteria criteria) 181 throws TorqueException 182 { 183 return BaseTurbineUserGroupRolePeer 184 .doInsert(criteria, (Connection ) null); 185 } 186 187 197 public static ObjectKey doInsert(Criteria criteria, Connection con) 198 throws TorqueException 199 { 200 201 if (criteria.getDbName() == Torque.getDefaultDB()) 205 { 206 criteria.setDbName(DATABASE_NAME); 207 } 208 if (con == null) 209 { 210 return BasePeer.doInsert(criteria); 211 } 212 else 213 { 214 return BasePeer.doInsert(criteria, con); 215 } 216 } 217 218 225 public static void addSelectColumns(Criteria criteria) 226 throws TorqueException 227 { 228 criteria.addSelectColumn(USER_ID); 229 criteria.addSelectColumn(GROUP_ID); 230 criteria.addSelectColumn(ROLE_ID); 231 } 232 233 242 public static TurbineUserGroupRole row2Object(Record row, 243 int offset, 244 Class cls) 245 throws TorqueException 246 { 247 try 248 { 249 TurbineUserGroupRole obj = (TurbineUserGroupRole) cls.newInstance(); 250 TurbineUserGroupRolePeer.populateObject(row, offset, obj); 251 obj.setModified(false); 252 obj.setNew(false); 253 254 return obj; 255 } 256 catch (InstantiationException e) 257 { 258 throw new TorqueException(e); 259 } 260 catch (IllegalAccessException e) 261 { 262 throw new TorqueException(e); 263 } 264 } 265 266 275 public static void populateObject(Record row, 276 int offset, 277 TurbineUserGroupRole obj) 278 throws TorqueException 279 { 280 try 281 { 282 obj.setUserId(row.getValue(offset + 0).asIntegerObj()); 283 obj.setGroupId(row.getValue(offset + 1).asIntegerObj()); 284 obj.setRoleId(row.getValue(offset + 2).asIntegerObj()); 285 } 286 catch (DataSetException e) 287 { 288 throw new TorqueException(e); 289 } 290 } 291 292 300 public static List doSelect(Criteria criteria) throws TorqueException 301 { 302 return populateObjects(doSelectVillageRecords(criteria)); 303 } 304 305 314 public static List doSelect(Criteria criteria, Connection con) 315 throws TorqueException 316 { 317 return populateObjects(doSelectVillageRecords(criteria, con)); 318 } 319 320 330 public static List doSelectVillageRecords(Criteria criteria) 331 throws TorqueException 332 { 333 return BaseTurbineUserGroupRolePeer 334 .doSelectVillageRecords(criteria, (Connection ) null); 335 } 336 337 345 public static List doSelectVillageRecords(Criteria criteria, Connection con) 346 throws TorqueException 347 { 348 if (criteria.getSelectColumns().size() == 0) 349 { 350 addSelectColumns(criteria); 351 } 352 353 354 if (criteria.getDbName() == Torque.getDefaultDB()) 358 { 359 criteria.setDbName(DATABASE_NAME); 360 } 361 if (con == null) 364 { 365 return BasePeer.doSelect(criteria); 366 } 367 else 368 { 369 return BasePeer.doSelect(criteria, con); 370 } 371 } 372 373 380 public static List populateObjects(List records) 381 throws TorqueException 382 { 383 List results = new ArrayList (records.size()); 384 385 for (int i = 0; i < records.size(); i++) 387 { 388 Record row = (Record) records.get(i); 389 results.add(TurbineUserGroupRolePeer.row2Object(row, 1, 390 TurbineUserGroupRolePeer.getOMClass())); 391 } 392 return results; 393 } 394 395 396 404 public static Class getOMClass() 405 throws TorqueException 406 { 407 return CLASS_DEFAULT; 408 } 409 410 418 public static void doUpdate(Criteria criteria) throws TorqueException 419 { 420 BaseTurbineUserGroupRolePeer 421 .doUpdate(criteria, (Connection ) null); 422 } 423 424 435 public static void doUpdate(Criteria criteria, Connection con) 436 throws TorqueException 437 { 438 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); 439 selectCriteria.put(USER_ID, criteria.remove(USER_ID)); 440 selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID)); 441 selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID)); 442 443 if (criteria.getDbName() == Torque.getDefaultDB()) 447 { 448 criteria.setDbName(DATABASE_NAME); 449 } 450 if (con == null) 451 { 452 BasePeer.doUpdate(selectCriteria, criteria); 453 } 454 else 455 { 456 BasePeer.doUpdate(selectCriteria, criteria, con); 457 } 458 } 459 460 467 public static void doDelete(Criteria criteria) throws TorqueException 468 { 469 BaseTurbineUserGroupRolePeer 470 .doDelete(criteria, (Connection ) null); 471 } 472 473 483 public static void doDelete(Criteria criteria, Connection con) 484 throws TorqueException 485 { 486 487 if (criteria.getDbName() == Torque.getDefaultDB()) 491 { 492 criteria.setDbName(DATABASE_NAME); 493 } 494 if (con == null) 495 { 496 BasePeer.doDelete(criteria); 497 } 498 else 499 { 500 BasePeer.doDelete(criteria, con); 501 } 502 } 503 504 510 public static List doSelect(TurbineUserGroupRole obj) throws TorqueException 511 { 512 return doSelect(buildCriteria(obj)); 513 } 514 515 521 public static void doInsert(TurbineUserGroupRole obj) throws TorqueException 522 { 523 doInsert(buildCriteria(obj)); 524 obj.setNew(false); 525 obj.setModified(false); 526 } 527 528 533 public static void doUpdate(TurbineUserGroupRole obj) throws TorqueException 534 { 535 doUpdate(buildCriteria(obj)); 536 obj.setModified(false); 537 } 538 539 544 public static void doDelete(TurbineUserGroupRole obj) throws TorqueException 545 { 546 doDelete(buildCriteria(obj)); 547 } 548 549 559 public static void doInsert(TurbineUserGroupRole obj, Connection con) 560 throws TorqueException 561 { 562 doInsert(buildCriteria(obj), con); 563 obj.setNew(false); 564 obj.setModified(false); 565 } 566 567 577 public static void doUpdate(TurbineUserGroupRole obj, Connection con) 578 throws TorqueException 579 { 580 doUpdate(buildCriteria(obj), con); 581 obj.setModified(false); 582 } 583 584 594 public static void doDelete(TurbineUserGroupRole obj, Connection con) 595 throws TorqueException 596 { 597 doDelete(buildCriteria(obj), con); 598 } 599 600 607 public static void doDelete(ObjectKey pk) throws TorqueException 608 { 609 BaseTurbineUserGroupRolePeer 610 .doDelete(pk, (Connection ) null); 611 } 612 613 623 public static void doDelete(ObjectKey pk, Connection con) 624 throws TorqueException 625 { 626 doDelete(buildCriteria(pk), con); 627 } 628 629 630 public static Criteria buildCriteria( ObjectKey pk ) 631 { 632 Criteria criteria = new Criteria(); 633 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 634 criteria.add(USER_ID, keys[0]); 635 criteria.add(GROUP_ID, keys[1]); 636 criteria.add(ROLE_ID, keys[2]); 637 return criteria; 638 } 639 640 641 public static Criteria buildCriteria( TurbineUserGroupRole obj ) 642 { 643 Criteria criteria = new Criteria(DATABASE_NAME); 644 criteria.add(USER_ID, obj.getUserId()); 645 criteria.add(GROUP_ID, obj.getGroupId()); 646 criteria.add(ROLE_ID, obj.getRoleId()); 647 return criteria; 648 } 649 650 651 652 661 public static TurbineUserGroupRole retrieveByPK(ObjectKey pk) 662 throws TorqueException, NoRowsException, TooManyRowsException 663 { 664 Connection db = null; 665 TurbineUserGroupRole retVal = null; 666 try 667 { 668 db = Torque.getConnection(DATABASE_NAME); 669 retVal = retrieveByPK(pk, db); 670 } 671 finally 672 { 673 Torque.closeConnection(db); 674 } 675 return(retVal); 676 } 677 678 688 public static TurbineUserGroupRole retrieveByPK(ObjectKey pk, Connection con) 689 throws TorqueException, NoRowsException, TooManyRowsException 690 { 691 Criteria criteria = buildCriteria(pk); 692 List v = doSelect(criteria, con); 693 if (v.size() == 0) 694 { 695 throw new NoRowsException("Failed to select a row."); 696 } 697 else if (v.size() > 1) 698 { 699 throw new TooManyRowsException("Failed to select only one row."); 700 } 701 else 702 { 703 return (TurbineUserGroupRole)v.get(0); 704 } 705 } 706 707 714 public static List retrieveByPKs(List pks) 715 throws TorqueException 716 { 717 Connection db = null; 718 List retVal = null; 719 try 720 { 721 db = Torque.getConnection(DATABASE_NAME); 722 retVal = retrieveByPKs(pks, db); 723 } 724 finally 725 { 726 Torque.closeConnection(db); 727 } 728 return(retVal); 729 } 730 731 739 public static List retrieveByPKs( List pks, Connection dbcon ) 740 throws TorqueException 741 { 742 List objs = null; 743 if (pks == null || pks.size() == 0) 744 { 745 objs = new LinkedList (); 746 } 747 else 748 { 749 Criteria criteria = new Criteria(); 750 Iterator iter = pks.iterator(); 751 while (iter.hasNext()) 752 { 753 ObjectKey pk = (ObjectKey)iter.next(); 754 SimpleKey[] keys = (SimpleKey[])pk.getValue(); 755 Criteria.Criterion c0 = criteria.getNewCriterion( 756 USER_ID, keys[0], Criteria.EQUAL); 757 Criteria.Criterion c1 = criteria.getNewCriterion( 758 GROUP_ID, keys[1], Criteria.EQUAL); 759 c0.and(c1); 760 Criteria.Criterion c2 = criteria.getNewCriterion( 761 ROLE_ID, keys[2], Criteria.EQUAL); 762 c1.and(c2); 763 criteria.or(c0); 764 } 765 objs = doSelect(criteria, dbcon); 766 } 767 return objs; 768 } 769 770 771 778 public static TurbineUserGroupRole retrieveByPK( 779 Integer user_id 780 , Integer group_id 781 , Integer role_id 782 ) throws TorqueException 783 { 784 Connection db = null; 785 TurbineUserGroupRole retVal = null; 786 try 787 { 788 db = Torque.getConnection(DATABASE_NAME); 789 retVal = retrieveByPK( 790 user_id 791 , group_id 792 , role_id 793 , db); 794 } 795 finally 796 { 797 Torque.closeConnection(db); 798 } 799 return(retVal); 800 } 801 802 810 public static TurbineUserGroupRole retrieveByPK( 811 Integer user_id 812 , Integer group_id 813 , Integer role_id 814 ,Connection con) throws TorqueException 815 { 816 817 Criteria criteria = new Criteria(5); 818 criteria.add(USER_ID, user_id); 819 criteria.add(GROUP_ID, group_id); 820 criteria.add(ROLE_ID, role_id); 821 List v = doSelect(criteria, con); 822 if (v.size() != 1) 823 { 824 throw new TorqueException("Failed to select one and only one row."); 825 } 826 else 827 { 828 return (TurbineUserGroupRole) v.get(0); 829 } 830 } 831 832 833 834 835 836 837 838 839 850 protected static List doSelectJoinTurbineUser(Criteria c) 851 throws TorqueException 852 { 853 if (c.getDbName() == Torque.getDefaultDB()) 857 { 858 c.setDbName(DATABASE_NAME); 859 } 860 861 TurbineUserGroupRolePeer.addSelectColumns(c); 862 int offset = numColumns + 1; 863 TurbineUserPeer.addSelectColumns(c); 864 865 866 c.addJoin(TurbineUserGroupRolePeer.USER_ID, 867 TurbineUserPeer.USER_ID); 868 869 870 871 List rows = BasePeer.doSelect(c); 872 List results = new ArrayList (); 873 874 for (int i = 0; i < rows.size(); i++) 875 { 876 Record row = (Record) rows.get(i); 877 878 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 879 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer 880 .row2Object(row, 1, omClass); 881 omClass = TurbineUserPeer.getOMClass(); 882 TurbineUser obj2 = (TurbineUser)TurbineUserPeer 883 .row2Object(row, offset, omClass); 884 885 boolean newObject = true; 886 for (int j = 0; j < results.size(); j++) 887 { 888 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 889 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser(); 890 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 891 { 892 newObject = false; 893 temp_obj2.addTurbineUserGroupRole(obj1); 894 break; 895 } 896 } 897 if (newObject) 898 { 899 obj2.initTurbineUserGroupRoles(); 900 obj2.addTurbineUserGroupRole(obj1); 901 } 902 results.add(obj1); 903 } 904 return results; 905 } 906 907 908 909 910 921 protected static List doSelectJoinTurbineGroup(Criteria c) 922 throws TorqueException 923 { 924 if (c.getDbName() == Torque.getDefaultDB()) 928 { 929 c.setDbName(DATABASE_NAME); 930 } 931 932 TurbineUserGroupRolePeer.addSelectColumns(c); 933 int offset = numColumns + 1; 934 TurbineGroupPeer.addSelectColumns(c); 935 936 937 c.addJoin(TurbineUserGroupRolePeer.GROUP_ID, 938 TurbineGroupPeer.GROUP_ID); 939 940 941 942 List rows = BasePeer.doSelect(c); 943 List results = new ArrayList (); 944 945 for (int i = 0; i < rows.size(); i++) 946 { 947 Record row = (Record) rows.get(i); 948 949 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 950 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer 951 .row2Object(row, 1, omClass); 952 omClass = TurbineGroupPeer.getOMClass(); 953 TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer 954 .row2Object(row, offset, omClass); 955 956 boolean newObject = true; 957 for (int j = 0; j < results.size(); j++) 958 { 959 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 960 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup(); 961 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 962 { 963 newObject = false; 964 temp_obj2.addTurbineUserGroupRole(obj1); 965 break; 966 } 967 } 968 if (newObject) 969 { 970 obj2.initTurbineUserGroupRoles(); 971 obj2.addTurbineUserGroupRole(obj1); 972 } 973 results.add(obj1); 974 } 975 return results; 976 } 977 978 979 980 981 992 protected static List doSelectJoinTurbineRole(Criteria c) 993 throws TorqueException 994 { 995 if (c.getDbName() == Torque.getDefaultDB()) 999 { 1000 c.setDbName(DATABASE_NAME); 1001 } 1002 1003 TurbineUserGroupRolePeer.addSelectColumns(c); 1004 int offset = numColumns + 1; 1005 TurbineRolePeer.addSelectColumns(c); 1006 1007 1008 c.addJoin(TurbineUserGroupRolePeer.ROLE_ID, 1009 TurbineRolePeer.ROLE_ID); 1010 1011 1012 1013 List rows = BasePeer.doSelect(c); 1014 List results = new ArrayList (); 1015 1016 for (int i = 0; i < rows.size(); i++) 1017 { 1018 Record row = (Record) rows.get(i); 1019 1020 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1021 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer 1022 .row2Object(row, 1, omClass); 1023 omClass = TurbineRolePeer.getOMClass(); 1024 TurbineRole obj2 = (TurbineRole)TurbineRolePeer 1025 .row2Object(row, offset, omClass); 1026 1027 boolean newObject = true; 1028 for (int j = 0; j < results.size(); j++) 1029 { 1030 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1031 TurbineRole temp_obj2 = (TurbineRole)temp_obj1.getTurbineRole(); 1032 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1033 { 1034 newObject = false; 1035 temp_obj2.addTurbineUserGroupRole(obj1); 1036 break; 1037 } 1038 } 1039 if (newObject) 1040 { 1041 obj2.initTurbineUserGroupRoles(); 1042 obj2.addTurbineUserGroupRole(obj1); 1043 } 1044 results.add(obj1); 1045 } 1046 return results; 1047 } 1048 1049 1050 1051 1052 1053 1054 1055 1056 1067 protected static List doSelectJoinAllExceptTurbineUser(Criteria c) 1068 throws TorqueException 1069 { 1070 if (c.getDbName() == Torque.getDefaultDB()) 1074 { 1075 c.setDbName(DATABASE_NAME); 1076 } 1077 1078 addSelectColumns(c); 1079 int offset2 = numColumns + 1; 1080 1081 1082 TurbineGroupPeer.addSelectColumns(c); 1083 int offset3 = offset2 + TurbineGroupPeer.numColumns; 1084 1085 TurbineRolePeer.addSelectColumns(c); 1086 int offset4 = offset3 + TurbineRolePeer.numColumns; 1087 1088 List rows = BasePeer.doSelect(c); 1089 List results = new ArrayList (); 1090 1091 for (int i = 0; i < rows.size(); i++) 1092 { 1093 Record row = (Record)rows.get(i); 1094 1095 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1096 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer 1097 .row2Object(row, 1, omClass); 1098 1099 1100 1101 1102 1103 omClass = TurbineGroupPeer.getOMClass(); 1104 TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer 1105 .row2Object( row, offset2, omClass); 1106 1107 boolean newObject = true; 1108 for (int j = 0; j < results.size(); j++) 1109 { 1110 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1111 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup(); 1112 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1113 { 1114 newObject = false; 1115 temp_obj2.addTurbineUserGroupRole(obj1); 1116 break; 1117 } 1118 } 1119 if (newObject) 1120 { 1121 obj2.initTurbineUserGroupRoles(); 1122 obj2.addTurbineUserGroupRole(obj1); 1123 } 1124 1125 1126 1127 1128 omClass = TurbineRolePeer.getOMClass(); 1129 TurbineRole obj3 = (TurbineRole)TurbineRolePeer 1130 .row2Object( row, offset3, omClass); 1131 1132 newObject = true; 1133 for (int j = 0; j < results.size(); j++) 1134 { 1135 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1136 TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole(); 1137 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1138 { 1139 newObject = false; 1140 temp_obj3.addTurbineUserGroupRole(obj1); 1141 break; 1142 } 1143 } 1144 if (newObject) 1145 { 1146 obj3.initTurbineUserGroupRoles(); 1147 obj3.addTurbineUserGroupRole(obj1); 1148 } 1149 results.add(obj1); 1150 } 1151 return results; 1152 } 1153 1154 1155 1156 1157 1158 1169 protected static List doSelectJoinAllExceptTurbineGroup(Criteria c) 1170 throws TorqueException 1171 { 1172 if (c.getDbName() == Torque.getDefaultDB()) 1176 { 1177 c.setDbName(DATABASE_NAME); 1178 } 1179 1180 addSelectColumns(c); 1181 int offset2 = numColumns + 1; 1182 1183 TurbineUserPeer.addSelectColumns(c); 1184 int offset3 = offset2 + TurbineUserPeer.numColumns; 1185 1186 1187 TurbineRolePeer.addSelectColumns(c); 1188 int offset4 = offset3 + TurbineRolePeer.numColumns; 1189 1190 List rows = BasePeer.doSelect(c); 1191 List results = new ArrayList (); 1192 1193 for (int i = 0; i < rows.size(); i++) 1194 { 1195 Record row = (Record)rows.get(i); 1196 1197 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1198 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer 1199 .row2Object(row, 1, omClass); 1200 1201 1202 1203 1204 omClass = TurbineUserPeer.getOMClass(); 1205 TurbineUser obj2 = (TurbineUser)TurbineUserPeer 1206 .row2Object( row, offset2, omClass); 1207 1208 boolean newObject = true; 1209 for (int j = 0; j < results.size(); j++) 1210 { 1211 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1212 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser(); 1213 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1214 { 1215 newObject = false; 1216 temp_obj2.addTurbineUserGroupRole(obj1); 1217 break; 1218 } 1219 } 1220 if (newObject) 1221 { 1222 obj2.initTurbineUserGroupRoles(); 1223 obj2.addTurbineUserGroupRole(obj1); 1224 } 1225 1226 1227 1228 1229 1230 omClass = TurbineRolePeer.getOMClass(); 1231 TurbineRole obj3 = (TurbineRole)TurbineRolePeer 1232 .row2Object( row, offset3, omClass); 1233 1234 newObject = true; 1235 for (int j = 0; j < results.size(); j++) 1236 { 1237 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1238 TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole(); 1239 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1240 { 1241 newObject = false; 1242 temp_obj3.addTurbineUserGroupRole(obj1); 1243 break; 1244 } 1245 } 1246 if (newObject) 1247 { 1248 obj3.initTurbineUserGroupRoles(); 1249 obj3.addTurbineUserGroupRole(obj1); 1250 } 1251 results.add(obj1); 1252 } 1253 return results; 1254 } 1255 1256 1257 1258 1259 1260 1271 protected static List doSelectJoinAllExceptTurbineRole(Criteria c) 1272 throws TorqueException 1273 { 1274 if (c.getDbName() == Torque.getDefaultDB()) 1278 { 1279 c.setDbName(DATABASE_NAME); 1280 } 1281 1282 addSelectColumns(c); 1283 int offset2 = numColumns + 1; 1284 1285 TurbineUserPeer.addSelectColumns(c); 1286 int offset3 = offset2 + TurbineUserPeer.numColumns; 1287 1288 TurbineGroupPeer.addSelectColumns(c); 1289 int offset4 = offset3 + TurbineGroupPeer.numColumns; 1290 1291 1292 List rows = BasePeer.doSelect(c); 1293 List results = new ArrayList (); 1294 1295 for (int i = 0; i < rows.size(); i++) 1296 { 1297 Record row = (Record)rows.get(i); 1298 1299 Class omClass = TurbineUserGroupRolePeer.getOMClass(); 1300 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer 1301 .row2Object(row, 1, omClass); 1302 1303 1304 1305 1306 omClass = TurbineUserPeer.getOMClass(); 1307 TurbineUser obj2 = (TurbineUser)TurbineUserPeer 1308 .row2Object( row, offset2, omClass); 1309 1310 boolean newObject = true; 1311 for (int j = 0; j < results.size(); j++) 1312 { 1313 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1314 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser(); 1315 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) 1316 { 1317 newObject = false; 1318 temp_obj2.addTurbineUserGroupRole(obj1); 1319 break; 1320 } 1321 } 1322 if (newObject) 1323 { 1324 obj2.initTurbineUserGroupRoles(); 1325 obj2.addTurbineUserGroupRole(obj1); 1326 } 1327 1328 1329 1330 1331 omClass = TurbineGroupPeer.getOMClass(); 1332 TurbineGroup obj3 = (TurbineGroup)TurbineGroupPeer 1333 .row2Object( row, offset3, omClass); 1334 1335 newObject = true; 1336 for (int j = 0; j < results.size(); j++) 1337 { 1338 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j); 1339 TurbineGroup temp_obj3 = (TurbineGroup)temp_obj1.getTurbineGroup(); 1340 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) 1341 { 1342 newObject = false; 1343 temp_obj3.addTurbineUserGroupRole(obj1); 1344 break; 1345 } 1346 } 1347 if (newObject) 1348 { 1349 obj3.initTurbineUserGroupRoles(); 1350 obj3.addTurbineUserGroupRole(obj1); 1351 } 1352 1353 results.add(obj1); 1354 } 1355 return results; 1356 } 1357 1358 1359 1366 protected static TableMap getTableMap() 1367 throws TorqueException 1368 { 1369 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); 1370 } 1371 } 1372 | Popular Tags |