1
22
23 package com.liferay.portal.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.Role;
29 import com.liferay.portal.model.RoleSoap;
30 import com.liferay.portal.util.PortalUtil;
31 import com.liferay.portal.util.PropsUtil;
32
33 import java.io.Serializable;
34
35 import java.lang.reflect.Proxy;
36
37 import java.sql.Types;
38
39 import java.util.ArrayList;
40 import java.util.List;
41
42
62 public class RoleModelImpl extends BaseModelImpl {
63 public static final String TABLE_NAME = "Role_";
64 public static final Object[][] TABLE_COLUMNS = {
65 { "roleId", new Integer(Types.BIGINT) },
66
67
68 { "companyId", new Integer(Types.BIGINT) },
69
70
71 { "classNameId", new Integer(Types.BIGINT) },
72
73
74 { "classPK", new Integer(Types.BIGINT) },
75
76
77 { "name", new Integer(Types.VARCHAR) },
78
79
80 { "description", new Integer(Types.VARCHAR) },
81
82
83 { "type_", new Integer(Types.INTEGER) }
84 };
85 public static final String TABLE_SQL_CREATE = "create table Role_ (roleId LONG not null primary key,companyId LONG,classNameId LONG,classPK LONG,name VARCHAR(75) null,description STRING null,type_ INTEGER)";
86 public static final String TABLE_SQL_DROP = "drop table Role_";
87 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
88 "value.object.finder.cache.enabled.com.liferay.portal.model.Role"),
89 true);
90
91 public static Role toModel(RoleSoap soapModel) {
92 Role model = new RoleImpl();
93
94 model.setRoleId(soapModel.getRoleId());
95 model.setCompanyId(soapModel.getCompanyId());
96 model.setClassNameId(soapModel.getClassNameId());
97 model.setClassPK(soapModel.getClassPK());
98 model.setName(soapModel.getName());
99 model.setDescription(soapModel.getDescription());
100 model.setType(soapModel.getType());
101
102 return model;
103 }
104
105 public static List<Role> toModels(RoleSoap[] soapModels) {
106 List<Role> models = new ArrayList<Role>(soapModels.length);
107
108 for (RoleSoap soapModel : soapModels) {
109 models.add(toModel(soapModel));
110 }
111
112 return models;
113 }
114
115 public static final boolean CACHE_ENABLED_GROUPS_ROLES = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ROLES;
116 public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = GetterUtil.getBoolean(PropsUtil.get(
117 "value.object.finder.cache.enabled.Roles_Permissions"), true);
118 public static final boolean CACHE_ENABLED_USERS_ROLES = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ROLES;
119 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
120 "lock.expiration.time.com.liferay.portal.model.Role"));
121
122 public RoleModelImpl() {
123 }
124
125 public long getPrimaryKey() {
126 return _roleId;
127 }
128
129 public void setPrimaryKey(long pk) {
130 setRoleId(pk);
131 }
132
133 public Serializable getPrimaryKeyObj() {
134 return new Long(_roleId);
135 }
136
137 public long getRoleId() {
138 return _roleId;
139 }
140
141 public void setRoleId(long roleId) {
142 if (roleId != _roleId) {
143 _roleId = roleId;
144 }
145 }
146
147 public long getCompanyId() {
148 return _companyId;
149 }
150
151 public void setCompanyId(long companyId) {
152 if (companyId != _companyId) {
153 _companyId = companyId;
154 }
155 }
156
157 public String getClassName() {
158 return PortalUtil.getClassName(getClassNameId());
159 }
160
161 public long getClassNameId() {
162 return _classNameId;
163 }
164
165 public void setClassNameId(long classNameId) {
166 if (classNameId != _classNameId) {
167 _classNameId = classNameId;
168 }
169 }
170
171 public long getClassPK() {
172 return _classPK;
173 }
174
175 public void setClassPK(long classPK) {
176 if (classPK != _classPK) {
177 _classPK = classPK;
178 }
179 }
180
181 public String getName() {
182 return GetterUtil.getString(_name);
183 }
184
185 public void setName(String name) {
186 if (((name == null) && (_name != null)) ||
187 ((name != null) && (_name == null)) ||
188 ((name != null) && (_name != null) && !name.equals(_name))) {
189 _name = name;
190 }
191 }
192
193 public String getDescription() {
194 return GetterUtil.getString(_description);
195 }
196
197 public void setDescription(String description) {
198 if (((description == null) && (_description != null)) ||
199 ((description != null) && (_description == null)) ||
200 ((description != null) && (_description != null) &&
201 !description.equals(_description))) {
202 _description = description;
203 }
204 }
205
206 public int getType() {
207 return _type;
208 }
209
210 public void setType(int type) {
211 if (type != _type) {
212 _type = type;
213 }
214 }
215
216 public Role toEscapedModel() {
217 if (isEscapedModel()) {
218 return (Role)this;
219 }
220 else {
221 Role model = new RoleImpl();
222
223 model.setEscapedModel(true);
224
225 model.setRoleId(getRoleId());
226 model.setCompanyId(getCompanyId());
227 model.setClassNameId(getClassNameId());
228 model.setClassPK(getClassPK());
229 model.setName(HtmlUtil.escape(getName()));
230 model.setDescription(HtmlUtil.escape(getDescription()));
231 model.setType(getType());
232
233 model = (Role)Proxy.newProxyInstance(Role.class.getClassLoader(),
234 new Class[] { Role.class }, new ReadOnlyBeanHandler(model));
235
236 return model;
237 }
238 }
239
240 public Object clone() {
241 RoleImpl clone = new RoleImpl();
242
243 clone.setRoleId(getRoleId());
244 clone.setCompanyId(getCompanyId());
245 clone.setClassNameId(getClassNameId());
246 clone.setClassPK(getClassPK());
247 clone.setName(getName());
248 clone.setDescription(getDescription());
249 clone.setType(getType());
250
251 return clone;
252 }
253
254 public int compareTo(Object obj) {
255 if (obj == null) {
256 return -1;
257 }
258
259 RoleImpl role = (RoleImpl)obj;
260
261 int value = 0;
262
263 value = getName().compareTo(role.getName());
264
265 if (value != 0) {
266 return value;
267 }
268
269 return 0;
270 }
271
272 public boolean equals(Object obj) {
273 if (obj == null) {
274 return false;
275 }
276
277 RoleImpl role = null;
278
279 try {
280 role = (RoleImpl)obj;
281 }
282 catch (ClassCastException cce) {
283 return false;
284 }
285
286 long pk = role.getPrimaryKey();
287
288 if (getPrimaryKey() == pk) {
289 return true;
290 }
291 else {
292 return false;
293 }
294 }
295
296 public int hashCode() {
297 return (int)getPrimaryKey();
298 }
299
300 private long _roleId;
301 private long _companyId;
302 private long _classNameId;
303 private long _classPK;
304 private String _name;
305 private String _description;
306 private int _type;
307 }