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.Permission;
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="PermissionModelImpl.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>Permission</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portal.service.model.Permission
052: * @see com.liferay.portal.service.model.PermissionModel
053: * @see com.liferay.portal.service.model.impl.PermissionImpl
054: *
055: */
056: public class PermissionModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "Permission_";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "permissionId", new Integer(Types.BIGINT) },
060:
061: { "companyId", new Integer(Types.BIGINT) },
062:
063: { "actionId", new Integer(Types.VARCHAR) },
064:
065: { "resourceId", new Integer(Types.BIGINT) } };
066: public static final String TABLE_SQL_CREATE = "create table Permission_ (permissionId LONG not null primary key,companyId LONG,actionId VARCHAR(75) null,resourceId LONG)";
067: public static final String TABLE_SQL_DROP = "drop table Permission_";
068: public static final boolean CACHE_ENABLED = GetterUtil
069: .getBoolean(
070: PropsUtil
071: .get("value.object.finder.cache.enabled.com.liferay.portal.model.Permission"),
072: true);
073: public static final boolean CACHE_ENABLED_GROUPS_PERMISSIONS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_PERMISSIONS;
074: public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = com.liferay.portal.model.impl.RoleModelImpl.CACHE_ENABLED_ROLES_PERMISSIONS;
075: public static final boolean CACHE_ENABLED_USERS_PERMISSIONS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
076: public static final long LOCK_EXPIRATION_TIME = GetterUtil
077: .getLong(PropsUtil
078: .get("lock.expiration.time.com.liferay.portal.model.Permission"));
079:
080: public PermissionModelImpl() {
081: }
082:
083: public long getPrimaryKey() {
084: return _permissionId;
085: }
086:
087: public void setPrimaryKey(long pk) {
088: setPermissionId(pk);
089: }
090:
091: public Serializable getPrimaryKeyObj() {
092: return new Long(_permissionId);
093: }
094:
095: public long getPermissionId() {
096: return _permissionId;
097: }
098:
099: public void setPermissionId(long permissionId) {
100: if (permissionId != _permissionId) {
101: _permissionId = permissionId;
102: }
103: }
104:
105: public long getCompanyId() {
106: return _companyId;
107: }
108:
109: public void setCompanyId(long companyId) {
110: if (companyId != _companyId) {
111: _companyId = companyId;
112: }
113: }
114:
115: public String getActionId() {
116: return GetterUtil.getString(_actionId);
117: }
118:
119: public void setActionId(String actionId) {
120: if (((actionId == null) && (_actionId != null))
121: || ((actionId != null) && (_actionId == null))
122: || ((actionId != null) && (_actionId != null) && !actionId
123: .equals(_actionId))) {
124: _actionId = actionId;
125: }
126: }
127:
128: public long getResourceId() {
129: return _resourceId;
130: }
131:
132: public void setResourceId(long resourceId) {
133: if (resourceId != _resourceId) {
134: _resourceId = resourceId;
135: }
136: }
137:
138: public Permission toEscapedModel() {
139: if (isEscapedModel()) {
140: return (Permission) this ;
141: } else {
142: Permission model = new PermissionImpl();
143:
144: model.setEscapedModel(true);
145:
146: model.setPermissionId(getPermissionId());
147: model.setCompanyId(getCompanyId());
148: model.setActionId(Html.escape(getActionId()));
149: model.setResourceId(getResourceId());
150:
151: model = (Permission) Proxy.newProxyInstance(
152: Permission.class.getClassLoader(),
153: new Class[] { Permission.class },
154: new ReadOnlyBeanHandler(model));
155:
156: return model;
157: }
158: }
159:
160: public Object clone() {
161: PermissionImpl clone = new PermissionImpl();
162:
163: clone.setPermissionId(getPermissionId());
164: clone.setCompanyId(getCompanyId());
165: clone.setActionId(getActionId());
166: clone.setResourceId(getResourceId());
167:
168: return clone;
169: }
170:
171: public int compareTo(Object obj) {
172: if (obj == null) {
173: return -1;
174: }
175:
176: PermissionImpl permission = (PermissionImpl) obj;
177:
178: long pk = permission.getPrimaryKey();
179:
180: if (getPrimaryKey() < pk) {
181: return -1;
182: } else if (getPrimaryKey() > pk) {
183: return 1;
184: } else {
185: return 0;
186: }
187: }
188:
189: public boolean equals(Object obj) {
190: if (obj == null) {
191: return false;
192: }
193:
194: PermissionImpl permission = null;
195:
196: try {
197: permission = (PermissionImpl) obj;
198: } catch (ClassCastException cce) {
199: return false;
200: }
201:
202: long pk = permission.getPrimaryKey();
203:
204: if (getPrimaryKey() == pk) {
205: return true;
206: } else {
207: return false;
208: }
209: }
210:
211: public int hashCode() {
212: return (int) getPrimaryKey();
213: }
214:
215: private long _permissionId;
216: private long _companyId;
217: private String _actionId;
218: private long _resourceId;
219: }
|