1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.model.Permission;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="PermissionModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>Permission</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.Permission
54   * @see com.liferay.portal.service.model.PermissionModel
55   * @see com.liferay.portal.service.model.impl.PermissionImpl
56   *
57   */
58  public class PermissionModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "Permission_";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "permissionId", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "actionId", new Integer(Types.VARCHAR) },
68              
69  
70              { "resourceId", new Integer(Types.BIGINT) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table Permission_ (permissionId LONG not null primary key,companyId LONG,actionId VARCHAR(75) null,resourceId LONG)";
73      public static final String TABLE_SQL_DROP = "drop table Permission_";
74      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.Permission"),
76              true);
77      public static final boolean CACHE_ENABLED_GROUPS_PERMISSIONS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_PERMISSIONS;
78      public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = com.liferay.portal.model.impl.RoleModelImpl.CACHE_ENABLED_ROLES_PERMISSIONS;
79      public static final boolean CACHE_ENABLED_USERS_PERMISSIONS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
80      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
81                  "lock.expiration.time.com.liferay.portal.model.Permission"));
82  
83      public PermissionModelImpl() {
84      }
85  
86      public long getPrimaryKey() {
87          return _permissionId;
88      }
89  
90      public void setPrimaryKey(long pk) {
91          setPermissionId(pk);
92      }
93  
94      public Serializable getPrimaryKeyObj() {
95          return new Long(_permissionId);
96      }
97  
98      public long getPermissionId() {
99          return _permissionId;
100     }
101 
102     public void setPermissionId(long permissionId) {
103         if (permissionId != _permissionId) {
104             _permissionId = permissionId;
105         }
106     }
107 
108     public long getCompanyId() {
109         return _companyId;
110     }
111 
112     public void setCompanyId(long companyId) {
113         if (companyId != _companyId) {
114             _companyId = companyId;
115         }
116     }
117 
118     public String getActionId() {
119         return GetterUtil.getString(_actionId);
120     }
121 
122     public void setActionId(String actionId) {
123         if (((actionId == null) && (_actionId != null)) ||
124                 ((actionId != null) && (_actionId == null)) ||
125                 ((actionId != null) && (_actionId != null) &&
126                 !actionId.equals(_actionId))) {
127             _actionId = actionId;
128         }
129     }
130 
131     public long getResourceId() {
132         return _resourceId;
133     }
134 
135     public void setResourceId(long resourceId) {
136         if (resourceId != _resourceId) {
137             _resourceId = resourceId;
138         }
139     }
140 
141     public Permission toEscapedModel() {
142         if (isEscapedModel()) {
143             return (Permission)this;
144         }
145         else {
146             Permission model = new PermissionImpl();
147 
148             model.setEscapedModel(true);
149 
150             model.setPermissionId(getPermissionId());
151             model.setCompanyId(getCompanyId());
152             model.setActionId(Html.escape(getActionId()));
153             model.setResourceId(getResourceId());
154 
155             model = (Permission)Proxy.newProxyInstance(Permission.class.getClassLoader(),
156                     new Class[] { Permission.class },
157                     new ReadOnlyBeanHandler(model));
158 
159             return model;
160         }
161     }
162 
163     public Object clone() {
164         PermissionImpl clone = new PermissionImpl();
165 
166         clone.setPermissionId(getPermissionId());
167         clone.setCompanyId(getCompanyId());
168         clone.setActionId(getActionId());
169         clone.setResourceId(getResourceId());
170 
171         return clone;
172     }
173 
174     public int compareTo(Object obj) {
175         if (obj == null) {
176             return -1;
177         }
178 
179         PermissionImpl permission = (PermissionImpl)obj;
180 
181         long pk = permission.getPrimaryKey();
182 
183         if (getPrimaryKey() < pk) {
184             return -1;
185         }
186         else if (getPrimaryKey() > pk) {
187             return 1;
188         }
189         else {
190             return 0;
191         }
192     }
193 
194     public boolean equals(Object obj) {
195         if (obj == null) {
196             return false;
197         }
198 
199         PermissionImpl permission = null;
200 
201         try {
202             permission = (PermissionImpl)obj;
203         }
204         catch (ClassCastException cce) {
205             return false;
206         }
207 
208         long pk = permission.getPrimaryKey();
209 
210         if (getPrimaryKey() == pk) {
211             return true;
212         }
213         else {
214             return false;
215         }
216     }
217 
218     public int hashCode() {
219         return (int)getPrimaryKey();
220     }
221 
222     private long _permissionId;
223     private long _companyId;
224     private String _actionId;
225     private long _resourceId;
226 }