1 package org.apache.fulcrum.security.impl.db.entity; 2 3 4 import java.math.BigDecimal ; 5 import java.sql.Connection ; 6 import java.util.ArrayList ; 7 import java.util.Date ; 8 import java.util.Collections ; 9 import java.util.List ; 10 11 import org.apache.commons.lang.ObjectUtils; 12 import org.apache.fulcrum.intake.Retrievable; 13 import org.apache.torque.TorqueException; 14 import org.apache.torque.om.BaseObject; 15 import org.apache.torque.om.ComboKey; 16 import org.apache.torque.om.DateKey; 17 import org.apache.torque.om.NumberKey; 18 import org.apache.torque.om.ObjectKey; 19 import org.apache.torque.om.SimpleKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.Persistent; 22 import org.apache.torque.util.Criteria; 23 import org.apache.torque.util.Transaction; 24 25 26 30 public abstract class BaseTurbineUser extends BaseObject 31 implements org.apache.fulcrum.intake.Retrievable 32 { 33 34 private static final TurbineUserPeer peer = 35 new TurbineUserPeer(); 36 37 38 39 private Integer userId; 40 41 42 private String userName; 43 44 45 private String password; 46 47 48 private String firstName; 49 50 51 private String lastName; 52 53 54 private String email; 55 56 57 private String confirmed; 58 59 60 private Date modified; 61 62 63 private Date createDate; 64 65 66 private Date lastLogin; 67 68 69 private byte[] objectdata; 70 71 72 77 public Integer getUserId() 78 { 79 return userId; 80 } 81 82 83 88 public void setUserId(Integer v) throws TorqueException 89 { 90 91 if (!ObjectUtils.equals(this.userId, v)) 92 { 93 this.userId = v; 94 setModified(true); 95 } 96 97 98 99 if (collTurbineUserGroupRoles != null) 101 { 102 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++) 103 { 104 ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)) 105 .setUserId(v); 106 } 107 } 108 } 109 110 115 public String getUserName() 116 { 117 return userName; 118 } 119 120 121 126 public void setUserName(String v) 127 { 128 129 if (!ObjectUtils.equals(this.userName, v)) 130 { 131 this.userName = v; 132 setModified(true); 133 } 134 135 136 } 137 138 143 public String getPassword() 144 { 145 return password; 146 } 147 148 149 154 public void setPassword(String v) 155 { 156 157 if (!ObjectUtils.equals(this.password, v)) 158 { 159 this.password = v; 160 setModified(true); 161 } 162 163 164 } 165 166 171 public String getFirstName() 172 { 173 return firstName; 174 } 175 176 177 182 public void setFirstName(String v) 183 { 184 185 if (!ObjectUtils.equals(this.firstName, v)) 186 { 187 this.firstName = v; 188 setModified(true); 189 } 190 191 192 } 193 194 199 public String getLastName() 200 { 201 return lastName; 202 } 203 204 205 210 public void setLastName(String v) 211 { 212 213 if (!ObjectUtils.equals(this.lastName, v)) 214 { 215 this.lastName = v; 216 setModified(true); 217 } 218 219 220 } 221 222 227 public String getEmail() 228 { 229 return email; 230 } 231 232 233 238 public void setEmail(String v) 239 { 240 241 if (!ObjectUtils.equals(this.email, v)) 242 { 243 this.email = v; 244 setModified(true); 245 } 246 247 248 } 249 250 255 public String getConfirmed() 256 { 257 return confirmed; 258 } 259 260 261 266 public void setConfirmed(String v) 267 { 268 269 if (!ObjectUtils.equals(this.confirmed, v)) 270 { 271 this.confirmed = v; 272 setModified(true); 273 } 274 275 276 } 277 278 283 public Date getModified() 284 { 285 return modified; 286 } 287 288 289 294 public void setModified(Date v) 295 { 296 297 if (!ObjectUtils.equals(this.modified, v)) 298 { 299 this.modified = v; 300 setModified(true); 301 } 302 303 304 } 305 306 311 public Date getCreateDate() 312 { 313 return createDate; 314 } 315 316 317 322 public void setCreateDate(Date v) 323 { 324 325 if (!ObjectUtils.equals(this.createDate, v)) 326 { 327 this.createDate = v; 328 setModified(true); 329 } 330 331 332 } 333 334 339 public Date getLastLogin() 340 { 341 return lastLogin; 342 } 343 344 345 350 public void setLastLogin(Date v) 351 { 352 353 if (!ObjectUtils.equals(this.lastLogin, v)) 354 { 355 this.lastLogin = v; 356 setModified(true); 357 } 358 359 360 } 361 362 367 public byte[] getObjectdata() 368 { 369 return objectdata; 370 } 371 372 373 378 public void setObjectdata(byte[] v) 379 { 380 381 if (!ObjectUtils.equals(this.objectdata, v)) 382 { 383 this.objectdata = v; 384 setModified(true); 385 } 386 387 388 } 389 390 391 392 393 396 protected List collTurbineUserGroupRoles; 397 398 403 protected void initTurbineUserGroupRoles() 404 { 405 if (collTurbineUserGroupRoles == null) 406 { 407 collTurbineUserGroupRoles = new ArrayList (); 408 } 409 } 410 411 418 public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException 419 { 420 getTurbineUserGroupRoles().add(l); 421 l.setTurbineUser((TurbineUser) this); 422 } 423 424 427 private Criteria lastTurbineUserGroupRolesCriteria = null; 428 429 436 public List getTurbineUserGroupRoles() throws TorqueException 437 { 438 if (collTurbineUserGroupRoles == null) 439 { 440 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10)); 441 } 442 return collTurbineUserGroupRoles; 443 } 444 445 456 public List getTurbineUserGroupRoles(Criteria criteria) throws TorqueException 457 { 458 if (collTurbineUserGroupRoles == null) 459 { 460 if (isNew()) 461 { 462 collTurbineUserGroupRoles = new ArrayList (); 463 } 464 else 465 { 466 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId() ); 467 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria); 468 } 469 } 470 else 471 { 472 if (!isNew()) 474 { 475 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 479 if (!lastTurbineUserGroupRolesCriteria.equals(criteria)) 480 { 481 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria); 482 } 483 } 484 } 485 lastTurbineUserGroupRolesCriteria = criteria; 486 487 return collTurbineUserGroupRoles; 488 } 489 490 498 public List getTurbineUserGroupRoles(Connection con) throws TorqueException 499 { 500 if (collTurbineUserGroupRoles == null) 501 { 502 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con); 503 } 504 return collTurbineUserGroupRoles; 505 } 506 507 519 public List getTurbineUserGroupRoles(Criteria criteria, Connection con) 520 throws TorqueException 521 { 522 if (collTurbineUserGroupRoles == null) 523 { 524 if (isNew()) 525 { 526 collTurbineUserGroupRoles = new ArrayList (); 527 } 528 else 529 { 530 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 531 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con); 532 } 533 } 534 else 535 { 536 if (!isNew()) 538 { 539 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 543 if (!lastTurbineUserGroupRolesCriteria.equals(criteria)) 544 { 545 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con); 546 } 547 } 548 } 549 lastTurbineUserGroupRolesCriteria = criteria; 550 551 return collTurbineUserGroupRoles; 552 } 553 554 555 556 557 558 559 560 561 562 563 564 575 protected List getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria) 576 throws TorqueException 577 { 578 if (collTurbineUserGroupRoles == null) 579 { 580 if (isNew()) 581 { 582 collTurbineUserGroupRoles = new ArrayList (); 583 } 584 else 585 { 586 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 587 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria); 588 } 589 } 590 else 591 { 592 boolean newCriteria = true; 596 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 597 if (!lastTurbineUserGroupRolesCriteria.equals(criteria)) 598 { 599 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria); 600 } 601 } 602 lastTurbineUserGroupRolesCriteria = criteria; 603 604 return collTurbineUserGroupRoles; 605 } 606 607 608 609 610 611 612 613 614 615 626 protected List getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria) 627 throws TorqueException 628 { 629 if (collTurbineUserGroupRoles == null) 630 { 631 if (isNew()) 632 { 633 collTurbineUserGroupRoles = new ArrayList (); 634 } 635 else 636 { 637 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 638 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria); 639 } 640 } 641 else 642 { 643 boolean newCriteria = true; 647 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 648 if (!lastTurbineUserGroupRolesCriteria.equals(criteria)) 649 { 650 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria); 651 } 652 } 653 lastTurbineUserGroupRolesCriteria = criteria; 654 655 return collTurbineUserGroupRoles; 656 } 657 658 659 660 661 662 663 664 665 666 677 protected List getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria) 678 throws TorqueException 679 { 680 if (collTurbineUserGroupRoles == null) 681 { 682 if (isNew()) 683 { 684 collTurbineUserGroupRoles = new ArrayList (); 685 } 686 else 687 { 688 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 689 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria); 690 } 691 } 692 else 693 { 694 boolean newCriteria = true; 698 criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId()); 699 if (!lastTurbineUserGroupRolesCriteria.equals(criteria)) 700 { 701 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria); 702 } 703 } 704 lastTurbineUserGroupRolesCriteria = criteria; 705 706 return collTurbineUserGroupRoles; 707 } 708 709 710 711 712 private static List fieldNames = null; 713 714 719 public static synchronized List getFieldNames() 720 { 721 if (fieldNames == null) 722 { 723 fieldNames = new ArrayList (); 724 fieldNames.add("UserId"); 725 fieldNames.add("UserName"); 726 fieldNames.add("Password"); 727 fieldNames.add("FirstName"); 728 fieldNames.add("LastName"); 729 fieldNames.add("Email"); 730 fieldNames.add("Confirmed"); 731 fieldNames.add("Modified"); 732 fieldNames.add("CreateDate"); 733 fieldNames.add("LastLogin"); 734 fieldNames.add("Objectdata"); 735 fieldNames = Collections.unmodifiableList(fieldNames); 736 } 737 return fieldNames; 738 } 739 740 746 public Object getByName(String name) 747 { 748 if (name.equals("UserId")) 749 { 750 return getUserId(); 751 } 752 if (name.equals("UserName")) 753 { 754 return getUserName(); 755 } 756 if (name.equals("Password")) 757 { 758 return getPassword(); 759 } 760 if (name.equals("FirstName")) 761 { 762 return getFirstName(); 763 } 764 if (name.equals("LastName")) 765 { 766 return getLastName(); 767 } 768 if (name.equals("Email")) 769 { 770 return getEmail(); 771 } 772 if (name.equals("Confirmed")) 773 { 774 return getConfirmed(); 775 } 776 if (name.equals("Modified")) 777 { 778 return getModified(); 779 } 780 if (name.equals("CreateDate")) 781 { 782 return getCreateDate(); 783 } 784 if (name.equals("LastLogin")) 785 { 786 return getLastLogin(); 787 } 788 if (name.equals("Objectdata")) 789 { 790 return getObjectdata(); 791 } 792 return null; 793 } 794 795 803 public Object getByPeerName(String name) 804 { 805 if (name.equals(TurbineUserPeer.USER_ID)) 806 { 807 return getUserId(); 808 } 809 if (name.equals(TurbineUserPeer.LOGIN_NAME)) 810 { 811 return getUserName(); 812 } 813 if (name.equals(TurbineUserPeer.PASSWORD_VALUE)) 814 { 815 return getPassword(); 816 } 817 if (name.equals(TurbineUserPeer.FIRST_NAME)) 818 { 819 return getFirstName(); 820 } 821 if (name.equals(TurbineUserPeer.LAST_NAME)) 822 { 823 return getLastName(); 824 } 825 if (name.equals(TurbineUserPeer.EMAIL)) 826 { 827 return getEmail(); 828 } 829 if (name.equals(TurbineUserPeer.CONFIRM_VALUE)) 830 { 831 return getConfirmed(); 832 } 833 if (name.equals(TurbineUserPeer.MODIFIED)) 834 { 835 return getModified(); 836 } 837 if (name.equals(TurbineUserPeer.CREATED)) 838 { 839 return getCreateDate(); 840 } 841 if (name.equals(TurbineUserPeer.LAST_LOGIN)) 842 { 843 return getLastLogin(); 844 } 845 if (name.equals(TurbineUserPeer.OBJECTDATA)) 846 { 847 return getObjectdata(); 848 } 849 return null; 850 } 851 852 859 public Object getByPosition(int pos) 860 { 861 if (pos == 0) 862 { 863 return getUserId(); 864 } 865 if (pos == 1) 866 { 867 return getUserName(); 868 } 869 if (pos == 2) 870 { 871 return getPassword(); 872 } 873 if (pos == 3) 874 { 875 return getFirstName(); 876 } 877 if (pos == 4) 878 { 879 return getLastName(); 880 } 881 if (pos == 5) 882 { 883 return getEmail(); 884 } 885 if (pos == 6) 886 { 887 return getConfirmed(); 888 } 889 if (pos == 7) 890 { 891 return getModified(); 892 } 893 if (pos == 8) 894 { 895 return getCreateDate(); 896 } 897 if (pos == 9) 898 { 899 return getLastLogin(); 900 } 901 if (pos == 10) 902 { 903 return getObjectdata(); 904 } 905 return null; 906 } 907 908 914 public void save() throws Exception 915 { 916 save(TurbineUserPeer.getMapBuilder() 917 .getDatabaseMap().getName()); 918 } 919 920 930 public void save(String dbName) throws TorqueException 931 { 932 Connection con = null; 933 try 934 { 935 con = Transaction.begin(dbName); 936 save(con); 937 Transaction.commit(con); 938 } 939 catch(TorqueException e) 940 { 941 Transaction.safeRollback(con); 942 throw e; 943 } 944 } 945 946 948 private boolean alreadyInSave = false; 949 959 public void save(Connection con) throws TorqueException 960 { 961 if (!alreadyInSave) 962 { 963 alreadyInSave = true; 964 965 966 967 if (isModified()) 969 { 970 if (isNew()) 971 { 972 TurbineUserPeer.doInsert((TurbineUser) this, con); 973 setNew(false); 974 } 975 else 976 { 977 TurbineUserPeer.doUpdate((TurbineUser) this, con); 978 } 979 } 980 981 982 983 if (collTurbineUserGroupRoles != null) 984 { 985 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++) 986 { 987 ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con); 988 } 989 } 990 alreadyInSave = false; 991 } 992 } 993 994 995 996 1001 public void setPrimaryKey(ObjectKey key) 1002 throws TorqueException 1003 { 1004 setUserId(new Integer (((NumberKey) key).intValue())); 1005 } 1006 1007 1012 public void setPrimaryKey(String key) throws TorqueException 1013 { 1014 setUserId(new Integer (key)); 1015 } 1016 1017 1018 1022 public ObjectKey getPrimaryKey() 1023 { 1024 return SimpleKey.keyFor(getUserId()); 1025 } 1026 1027 1028 1032 public String getQueryKey() 1033 { 1034 if (getPrimaryKey() == null) 1035 { 1036 return ""; 1037 } 1038 else 1039 { 1040 return getPrimaryKey().toString(); 1041 } 1042 } 1043 1044 1048 public void setQueryKey(String key) 1049 throws TorqueException 1050 { 1051 setPrimaryKey(key); 1052 } 1053 1054 1060 public TurbineUser copy() throws TorqueException 1061 { 1062 return copyInto(new TurbineUser()); 1063 } 1064 1065 protected TurbineUser copyInto(TurbineUser copyObj) throws TorqueException 1066 { 1067 copyObj.setUserId(userId); 1068 copyObj.setUserName(userName); 1069 copyObj.setPassword(password); 1070 copyObj.setFirstName(firstName); 1071 copyObj.setLastName(lastName); 1072 copyObj.setEmail(email); 1073 copyObj.setConfirmed(confirmed); 1074 copyObj.setModified(modified); 1075 copyObj.setCreateDate(createDate); 1076 copyObj.setLastLogin(lastLogin); 1077 copyObj.setObjectdata(objectdata); 1078 1079 copyObj.setUserId((Integer )null); 1080 1081 1082 1083 List v = getTurbineUserGroupRoles(); 1084 for (int i = 0; i < v.size(); i++) 1085 { 1086 TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i); 1087 copyObj.addTurbineUserGroupRole(obj.copy()); 1088 } 1089 1090 return copyObj; 1091 } 1092 1093 1099 public TurbineUserPeer getPeer() 1100 { 1101 return peer; 1102 } 1103 1104 public String toString() 1105 { 1106 StringBuffer str = new StringBuffer (); 1107 str.append("TurbineUser:\n"); 1108 str.append("UserId = ") 1109 .append(getUserId()) 1110 .append("\n"); 1111 str.append("UserName = ") 1112 .append(getUserName()) 1113 .append("\n"); 1114 str.append("Password = ") 1115 .append(getPassword()) 1116 .append("\n"); 1117 str.append("FirstName = ") 1118 .append(getFirstName()) 1119 .append("\n"); 1120 str.append("LastName = ") 1121 .append(getLastName()) 1122 .append("\n"); 1123 str.append("Email = ") 1124 .append(getEmail()) 1125 .append("\n"); 1126 str.append("Confirmed = ") 1127 .append(getConfirmed()) 1128 .append("\n"); 1129 str.append("Modified = ") 1130 .append(getModified()) 1131 .append("\n"); 1132 str.append("CreateDate = ") 1133 .append(getCreateDate()) 1134 .append("\n"); 1135 str.append("LastLogin = ") 1136 .append(getLastLogin()) 1137 .append("\n"); 1138 str.append("Objectdata = ") 1139 .append(getObjectdata()) 1140 .append("\n"); 1141 return(str.toString()); 1142 } 1143} 1144 | Popular Tags |