1   /**
2    * Copyright (c) 2000-2009 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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Permission;
29  import com.liferay.portal.model.PermissionSoap;
30  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="PermissionModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>Permission</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.model.Permission
59   * @see com.liferay.portal.model.PermissionModel
60   * @see com.liferay.portal.model.impl.PermissionImpl
61   *
62   */
63  public class PermissionModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "Permission_";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "permissionId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "actionId", new Integer(Types.VARCHAR) },
73              
74  
75              { "resourceId", new Integer(Types.BIGINT) }
76          };
77      public static final String TABLE_SQL_CREATE = "create table Permission_ (permissionId LONG not null primary key,companyId LONG,actionId VARCHAR(75) null,resourceId LONG)";
78      public static final String TABLE_SQL_DROP = "drop table Permission_";
79      public static final String DATA_SOURCE = "liferayDataSource";
80      public static final String SESSION_FACTORY = "liferaySessionFactory";
81      public static final String TX_MANAGER = "liferayTransactionManager";
82      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portal.model.Permission"),
84              true);
85  
86      public static Permission toModel(PermissionSoap soapModel) {
87          Permission model = new PermissionImpl();
88  
89          model.setPermissionId(soapModel.getPermissionId());
90          model.setCompanyId(soapModel.getCompanyId());
91          model.setActionId(soapModel.getActionId());
92          model.setResourceId(soapModel.getResourceId());
93  
94          return model;
95      }
96  
97      public static List<Permission> toModels(PermissionSoap[] soapModels) {
98          List<Permission> models = new ArrayList<Permission>(soapModels.length);
99  
100         for (PermissionSoap soapModel : soapModels) {
101             models.add(toModel(soapModel));
102         }
103 
104         return models;
105     }
106 
107     public static final boolean CACHE_ENABLED_GROUPS_PERMISSIONS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_PERMISSIONS;
108     public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = com.liferay.portal.model.impl.RoleModelImpl.CACHE_ENABLED_ROLES_PERMISSIONS;
109     public static final boolean CACHE_ENABLED_USERS_PERMISSIONS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portal.model.Permission"));
112 
113     public PermissionModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _permissionId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setPermissionId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_permissionId);
126     }
127 
128     public long getPermissionId() {
129         return _permissionId;
130     }
131 
132     public void setPermissionId(long permissionId) {
133         if (permissionId != _permissionId) {
134             _permissionId = permissionId;
135         }
136     }
137 
138     public long getCompanyId() {
139         return _companyId;
140     }
141 
142     public void setCompanyId(long companyId) {
143         if (companyId != _companyId) {
144             _companyId = companyId;
145         }
146     }
147 
148     public String getActionId() {
149         return GetterUtil.getString(_actionId);
150     }
151 
152     public void setActionId(String actionId) {
153         if (((actionId == null) && (_actionId != null)) ||
154                 ((actionId != null) && (_actionId == null)) ||
155                 ((actionId != null) && (_actionId != null) &&
156                 !actionId.equals(_actionId))) {
157             _actionId = actionId;
158         }
159     }
160 
161     public long getResourceId() {
162         return _resourceId;
163     }
164 
165     public void setResourceId(long resourceId) {
166         if (resourceId != _resourceId) {
167             _resourceId = resourceId;
168         }
169     }
170 
171     public Permission toEscapedModel() {
172         if (isEscapedModel()) {
173             return (Permission)this;
174         }
175         else {
176             Permission model = new PermissionImpl();
177 
178             model.setNew(isNew());
179             model.setEscapedModel(true);
180 
181             model.setPermissionId(getPermissionId());
182             model.setCompanyId(getCompanyId());
183             model.setActionId(HtmlUtil.escape(getActionId()));
184             model.setResourceId(getResourceId());
185 
186             model = (Permission)Proxy.newProxyInstance(Permission.class.getClassLoader(),
187                     new Class[] { Permission.class },
188                     new ReadOnlyBeanHandler(model));
189 
190             return model;
191         }
192     }
193 
194     public ExpandoBridge getExpandoBridge() {
195         if (_expandoBridge == null) {
196             _expandoBridge = new ExpandoBridgeImpl(Permission.class.getName(),
197                     getPrimaryKey());
198         }
199 
200         return _expandoBridge;
201     }
202 
203     public Object clone() {
204         PermissionImpl clone = new PermissionImpl();
205 
206         clone.setPermissionId(getPermissionId());
207         clone.setCompanyId(getCompanyId());
208         clone.setActionId(getActionId());
209         clone.setResourceId(getResourceId());
210 
211         return clone;
212     }
213 
214     public int compareTo(Object obj) {
215         if (obj == null) {
216             return -1;
217         }
218 
219         PermissionImpl permission = (PermissionImpl)obj;
220 
221         long pk = permission.getPrimaryKey();
222 
223         if (getPrimaryKey() < pk) {
224             return -1;
225         }
226         else if (getPrimaryKey() > pk) {
227             return 1;
228         }
229         else {
230             return 0;
231         }
232     }
233 
234     public boolean equals(Object obj) {
235         if (obj == null) {
236             return false;
237         }
238 
239         PermissionImpl permission = null;
240 
241         try {
242             permission = (PermissionImpl)obj;
243         }
244         catch (ClassCastException cce) {
245             return false;
246         }
247 
248         long pk = permission.getPrimaryKey();
249 
250         if (getPrimaryKey() == pk) {
251             return true;
252         }
253         else {
254             return false;
255         }
256     }
257 
258     public int hashCode() {
259         return (int)getPrimaryKey();
260     }
261 
262     private long _permissionId;
263     private long _companyId;
264     private String _actionId;
265     private long _resourceId;
266     private transient ExpandoBridge _expandoBridge;
267 }