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.kernel.util.StringPool;
29 import com.liferay.portal.model.Role;
30 import com.liferay.portal.model.RoleSoap;
31 import com.liferay.portal.util.PortalUtil;
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 String DATA_SOURCE = "liferayDataSource";
88 public static final String SESSION_FACTORY = "liferaySessionFactory";
89 public static final String TX_MANAGER = "liferayTransactionManager";
90 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
91 "value.object.finder.cache.enabled.com.liferay.portal.model.Role"),
92 true);
93
94 public static Role toModel(RoleSoap soapModel) {
95 Role model = new RoleImpl();
96
97 model.setRoleId(soapModel.getRoleId());
98 model.setCompanyId(soapModel.getCompanyId());
99 model.setClassNameId(soapModel.getClassNameId());
100 model.setClassPK(soapModel.getClassPK());
101 model.setName(soapModel.getName());
102 model.setDescription(soapModel.getDescription());
103 model.setType(soapModel.getType());
104
105 return model;
106 }
107
108 public static List<Role> toModels(RoleSoap[] soapModels) {
109 List<Role> models = new ArrayList<Role>(soapModels.length);
110
111 for (RoleSoap soapModel : soapModels) {
112 models.add(toModel(soapModel));
113 }
114
115 return models;
116 }
117
118 public static final boolean CACHE_ENABLED_GROUPS_ROLES = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ROLES;
119 public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
120 "value.object.finder.cache.enabled.Roles_Permissions"), true);
121 public static final boolean CACHE_ENABLED_USERS_ROLES = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ROLES;
122 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123 "lock.expiration.time.com.liferay.portal.model.Role"));
124
125 public RoleModelImpl() {
126 }
127
128 public long getPrimaryKey() {
129 return _roleId;
130 }
131
132 public void setPrimaryKey(long pk) {
133 setRoleId(pk);
134 }
135
136 public Serializable getPrimaryKeyObj() {
137 return new Long(_roleId);
138 }
139
140 public long getRoleId() {
141 return _roleId;
142 }
143
144 public void setRoleId(long roleId) {
145 if (roleId != _roleId) {
146 _roleId = roleId;
147 }
148 }
149
150 public long getCompanyId() {
151 return _companyId;
152 }
153
154 public void setCompanyId(long companyId) {
155 if (companyId != _companyId) {
156 _companyId = companyId;
157 }
158 }
159
160 public String getClassName() {
161 if (getClassNameId() <= 0) {
162 return StringPool.BLANK;
163 }
164
165 return PortalUtil.getClassName(getClassNameId());
166 }
167
168 public long getClassNameId() {
169 return _classNameId;
170 }
171
172 public void setClassNameId(long classNameId) {
173 if (classNameId != _classNameId) {
174 _classNameId = classNameId;
175 }
176 }
177
178 public long getClassPK() {
179 return _classPK;
180 }
181
182 public void setClassPK(long classPK) {
183 if (classPK != _classPK) {
184 _classPK = classPK;
185 }
186 }
187
188 public String getName() {
189 return GetterUtil.getString(_name);
190 }
191
192 public void setName(String name) {
193 if (((name == null) && (_name != null)) ||
194 ((name != null) && (_name == null)) ||
195 ((name != null) && (_name != null) && !name.equals(_name))) {
196 _name = name;
197 }
198 }
199
200 public String getDescription() {
201 return GetterUtil.getString(_description);
202 }
203
204 public void setDescription(String description) {
205 if (((description == null) && (_description != null)) ||
206 ((description != null) && (_description == null)) ||
207 ((description != null) && (_description != null) &&
208 !description.equals(_description))) {
209 _description = description;
210 }
211 }
212
213 public int getType() {
214 return _type;
215 }
216
217 public void setType(int type) {
218 if (type != _type) {
219 _type = type;
220 }
221 }
222
223 public Role toEscapedModel() {
224 if (isEscapedModel()) {
225 return (Role)this;
226 }
227 else {
228 Role model = new RoleImpl();
229
230 model.setNew(isNew());
231 model.setEscapedModel(true);
232
233 model.setRoleId(getRoleId());
234 model.setCompanyId(getCompanyId());
235 model.setClassNameId(getClassNameId());
236 model.setClassPK(getClassPK());
237 model.setName(HtmlUtil.escape(getName()));
238 model.setDescription(HtmlUtil.escape(getDescription()));
239 model.setType(getType());
240
241 model = (Role)Proxy.newProxyInstance(Role.class.getClassLoader(),
242 new Class[] { Role.class }, new ReadOnlyBeanHandler(model));
243
244 return model;
245 }
246 }
247
248 public Object clone() {
249 RoleImpl clone = new RoleImpl();
250
251 clone.setRoleId(getRoleId());
252 clone.setCompanyId(getCompanyId());
253 clone.setClassNameId(getClassNameId());
254 clone.setClassPK(getClassPK());
255 clone.setName(getName());
256 clone.setDescription(getDescription());
257 clone.setType(getType());
258
259 return clone;
260 }
261
262 public int compareTo(Object obj) {
263 if (obj == null) {
264 return -1;
265 }
266
267 RoleImpl role = (RoleImpl)obj;
268
269 int value = 0;
270
271 value = getName().compareTo(role.getName());
272
273 if (value != 0) {
274 return value;
275 }
276
277 return 0;
278 }
279
280 public boolean equals(Object obj) {
281 if (obj == null) {
282 return false;
283 }
284
285 RoleImpl role = null;
286
287 try {
288 role = (RoleImpl)obj;
289 }
290 catch (ClassCastException cce) {
291 return false;
292 }
293
294 long pk = role.getPrimaryKey();
295
296 if (getPrimaryKey() == pk) {
297 return true;
298 }
299 else {
300 return false;
301 }
302 }
303
304 public int hashCode() {
305 return (int)getPrimaryKey();
306 }
307
308 private long _roleId;
309 private long _companyId;
310 private long _classNameId;
311 private long _classPK;
312 private String _name;
313 private String _description;
314 private int _type;
315 }