001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.Role;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.util.Html;
029:
030: import java.io.Serializable;
031:
032: import java.lang.reflect.Proxy;
033:
034: import java.sql.Types;
035:
036: /**
037: * <a href="RoleModelImpl.java.html"><b><i>View Source</i></b></a>
038: *
039: * <p>
040: * ServiceBuilder generated this class. Modifications in this class will be
041: * overwritten the next time is generated.
042: * </p>
043: *
044: * <p>
045: * This class is a model that represents the <code>Role</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portal.service.model.Role
052: * @see com.liferay.portal.service.model.RoleModel
053: * @see com.liferay.portal.service.model.impl.RoleImpl
054: *
055: */
056: public class RoleModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "Role_";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "roleId", new Integer(Types.BIGINT) },
060:
061: { "companyId", new Integer(Types.BIGINT) },
062:
063: { "classNameId", new Integer(Types.BIGINT) },
064:
065: { "classPK", new Integer(Types.BIGINT) },
066:
067: { "name", new Integer(Types.VARCHAR) },
068:
069: { "description", new Integer(Types.VARCHAR) },
070:
071: { "type_", new Integer(Types.INTEGER) } };
072: 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)";
073: public static final String TABLE_SQL_DROP = "drop table Role_";
074: public static final boolean CACHE_ENABLED = GetterUtil
075: .getBoolean(
076: PropsUtil
077: .get("value.object.finder.cache.enabled.com.liferay.portal.model.Role"),
078: true);
079: public static final boolean CACHE_ENABLED_GROUPS_ROLES = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ROLES;
080: public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = GetterUtil
081: .getBoolean(
082: PropsUtil
083: .get("value.object.finder.cache.enabled.Roles_Permissions"),
084: true);
085: public static final boolean CACHE_ENABLED_USERS_ROLES = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ROLES;
086: public static final long LOCK_EXPIRATION_TIME = GetterUtil
087: .getLong(PropsUtil
088: .get("lock.expiration.time.com.liferay.portal.model.Role"));
089:
090: public RoleModelImpl() {
091: }
092:
093: public long getPrimaryKey() {
094: return _roleId;
095: }
096:
097: public void setPrimaryKey(long pk) {
098: setRoleId(pk);
099: }
100:
101: public Serializable getPrimaryKeyObj() {
102: return new Long(_roleId);
103: }
104:
105: public long getRoleId() {
106: return _roleId;
107: }
108:
109: public void setRoleId(long roleId) {
110: if (roleId != _roleId) {
111: _roleId = roleId;
112: }
113: }
114:
115: public long getCompanyId() {
116: return _companyId;
117: }
118:
119: public void setCompanyId(long companyId) {
120: if (companyId != _companyId) {
121: _companyId = companyId;
122: }
123: }
124:
125: public long getClassNameId() {
126: return _classNameId;
127: }
128:
129: public void setClassNameId(long classNameId) {
130: if (classNameId != _classNameId) {
131: _classNameId = classNameId;
132: }
133: }
134:
135: public long getClassPK() {
136: return _classPK;
137: }
138:
139: public void setClassPK(long classPK) {
140: if (classPK != _classPK) {
141: _classPK = classPK;
142: }
143: }
144:
145: public String getName() {
146: return GetterUtil.getString(_name);
147: }
148:
149: public void setName(String name) {
150: if (((name == null) && (_name != null))
151: || ((name != null) && (_name == null))
152: || ((name != null) && (_name != null) && !name
153: .equals(_name))) {
154: _name = name;
155: }
156: }
157:
158: public String getDescription() {
159: return GetterUtil.getString(_description);
160: }
161:
162: public void setDescription(String description) {
163: if (((description == null) && (_description != null))
164: || ((description != null) && (_description == null))
165: || ((description != null) && (_description != null) && !description
166: .equals(_description))) {
167: _description = description;
168: }
169: }
170:
171: public int getType() {
172: return _type;
173: }
174:
175: public void setType(int type) {
176: if (type != _type) {
177: _type = type;
178: }
179: }
180:
181: public Role toEscapedModel() {
182: if (isEscapedModel()) {
183: return (Role) this ;
184: } else {
185: Role model = new RoleImpl();
186:
187: model.setEscapedModel(true);
188:
189: model.setRoleId(getRoleId());
190: model.setCompanyId(getCompanyId());
191: model.setClassNameId(getClassNameId());
192: model.setClassPK(getClassPK());
193: model.setName(Html.escape(getName()));
194: model.setDescription(Html.escape(getDescription()));
195: model.setType(getType());
196:
197: model = (Role) Proxy.newProxyInstance(Role.class
198: .getClassLoader(), new Class[] { Role.class },
199: new ReadOnlyBeanHandler(model));
200:
201: return model;
202: }
203: }
204:
205: public Object clone() {
206: RoleImpl clone = new RoleImpl();
207:
208: clone.setRoleId(getRoleId());
209: clone.setCompanyId(getCompanyId());
210: clone.setClassNameId(getClassNameId());
211: clone.setClassPK(getClassPK());
212: clone.setName(getName());
213: clone.setDescription(getDescription());
214: clone.setType(getType());
215:
216: return clone;
217: }
218:
219: public int compareTo(Object obj) {
220: if (obj == null) {
221: return -1;
222: }
223:
224: RoleImpl role = (RoleImpl) obj;
225:
226: int value = 0;
227:
228: value = getName().compareTo(role.getName());
229:
230: if (value != 0) {
231: return value;
232: }
233:
234: return 0;
235: }
236:
237: public boolean equals(Object obj) {
238: if (obj == null) {
239: return false;
240: }
241:
242: RoleImpl role = null;
243:
244: try {
245: role = (RoleImpl) obj;
246: } catch (ClassCastException cce) {
247: return false;
248: }
249:
250: long pk = role.getPrimaryKey();
251:
252: if (getPrimaryKey() == pk) {
253: return true;
254: } else {
255: return false;
256: }
257: }
258:
259: public int hashCode() {
260: return (int) getPrimaryKey();
261: }
262:
263: private long _roleId;
264: private long _companyId;
265: private long _classNameId;
266: private long _classPK;
267: private String _name;
268: private String _description;
269: private int _type;
270: }
|