001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.pojos;
020:
021: /**
022: * Role bean.
023: * @author David M Johnson
024: *
025: * @ejb:bean name="RoleData"
026: * @struts.form include-all="true"
027: * @hibernate.class lazy="false" table="userrole"
028: * @hibernate.cache usage="read-write"
029: */
030: public class RoleData extends org.apache.roller.pojos.PersistentObject
031: implements java.io.Serializable {
032: static final long serialVersionUID = -4254083071697970972L;
033:
034: private java.lang.String id;
035: private java.lang.String userName;
036: private UserData user;
037: private java.lang.String role;
038:
039: public RoleData() {
040: }
041:
042: public RoleData(String id, UserData user, String role) {
043: this .id = id;
044: this .userName = user.getUserName();
045: this .user = user;
046: this .role = role;
047: }
048:
049: public RoleData(RoleData otherData) {
050: setData(otherData);
051: }
052:
053: /**
054: * @ejb:pk-field
055: * @ejb:persistent-field
056: * @hibernate.id column="id"
057: * generator-class="uuid.hex" unsaved-value="null"
058: */
059: public java.lang.String getId() {
060: return this .id;
061: }
062:
063: /** @ejb:persistent-field */
064: public void setId(java.lang.String id) {
065: this .id = id;
066: }
067:
068: /**
069: * @ejb:persistent-field
070: * @hibernate.property column="username" non-null="true" unique="false"
071: */
072: public java.lang.String getUserName() {
073: return this .userName;
074: }
075:
076: /** @ejb:persistent-field */
077: public void setUserName(java.lang.String userName) {
078: this .userName = userName;
079: }
080:
081: /**
082: * @hibernate.many-to-one column="userid" cascade="none" not-null="true"
083: * @ejb:persistent-field
084: */
085: public UserData getUser() {
086: return this .user;
087: }
088:
089: /** @ejb:persistent-field */
090: public void setUser(UserData user) {
091: this .user = user;
092: }
093:
094: /**
095: * @ejb:persistent-field
096: * @hibernate.property column="rolename" non-null="true" unique="false"
097: */
098: public java.lang.String getRole() {
099: return this .role;
100: }
101:
102: /** @ejb:persistent-field */
103: public void setRole(java.lang.String role) {
104: this .role = role;
105: }
106:
107: public String toString() {
108: StringBuffer str = new StringBuffer("{");
109:
110: str.append("id=" + id + " " + "userName=" + userName + " "
111: + "user=" + user + " " + "role=" + role);
112: str.append('}');
113:
114: return (str.toString());
115: }
116:
117: public boolean equals(Object pOther) {
118: if (pOther instanceof RoleData) {
119: RoleData lTest = (RoleData) pOther;
120: boolean lEquals = true;
121:
122: if (this .userName == null) {
123: lEquals = lEquals && (lTest.getUserName() == null);
124: } else {
125: lEquals = lEquals
126: && this .userName.equals(lTest.getUserName());
127: }
128: if (this .user == null) {
129: lEquals = lEquals && (lTest.getUser() == null);
130: } else {
131: lEquals = lEquals && this .user.equals(lTest.getUser());
132: }
133: if (this .role == null) {
134: lEquals = lEquals && (lTest.getRole() == null);
135: } else {
136: lEquals = lEquals && this .role.equals(lTest.getRole());
137: }
138:
139: return lEquals;
140: } else {
141: return false;
142: }
143: }
144:
145: public int hashCode() {
146: int result = 17;
147: result = 37 * result
148: + ((this .id != null) ? this .id.hashCode() : 0);
149: result = 37
150: * result
151: + ((this .userName != null) ? this .userName.hashCode()
152: : 0);
153: result = 37 * result
154: + ((this .user != null) ? this .user.hashCode() : 0);
155: result = 37 * result
156: + ((this .role != null) ? this .role.hashCode() : 0);
157: return result;
158: }
159:
160: /**
161: * Setter is needed in RollerImpl.storePersistentObject()
162: */
163: public void setData(
164: org.apache.roller.pojos.PersistentObject otherData) {
165:
166: this .id = ((RoleData) otherData).getId();
167: this .userName = ((RoleData) otherData).getUserName();
168: this .user = ((RoleData) otherData).getUser();
169: this .role = ((RoleData) otherData).getRole();
170: }
171:
172: }
|