1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Permission;
26  import com.liferay.portal.model.PermissionSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="PermissionModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>Permission</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.Permission
53   * @see com.liferay.portal.model.PermissionModel
54   * @see com.liferay.portal.model.impl.PermissionImpl
55   *
56   */
57  public class PermissionModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "Permission_";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "permissionId", new Integer(Types.BIGINT) },
61              
62  
63              { "companyId", new Integer(Types.BIGINT) },
64              
65  
66              { "actionId", new Integer(Types.VARCHAR) },
67              
68  
69              { "resourceId", new Integer(Types.BIGINT) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table Permission_ (permissionId LONG not null primary key,companyId LONG,actionId VARCHAR(75) null,resourceId LONG)";
72      public static final String TABLE_SQL_DROP = "drop table Permission_";
73      public static final String DATA_SOURCE = "liferayDataSource";
74      public static final String SESSION_FACTORY = "liferaySessionFactory";
75      public static final String TX_MANAGER = "liferayTransactionManager";
76      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portal.model.Permission"),
78              true);
79  
80      public static Permission toModel(PermissionSoap soapModel) {
81          Permission model = new PermissionImpl();
82  
83          model.setPermissionId(soapModel.getPermissionId());
84          model.setCompanyId(soapModel.getCompanyId());
85          model.setActionId(soapModel.getActionId());
86          model.setResourceId(soapModel.getResourceId());
87  
88          return model;
89      }
90  
91      public static List<Permission> toModels(PermissionSoap[] soapModels) {
92          List<Permission> models = new ArrayList<Permission>(soapModels.length);
93  
94          for (PermissionSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final boolean CACHE_ENABLED_GROUPS_PERMISSIONS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_PERMISSIONS;
102     public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = com.liferay.portal.model.impl.RoleModelImpl.CACHE_ENABLED_ROLES_PERMISSIONS;
103     public static final boolean CACHE_ENABLED_USERS_PERMISSIONS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_PERMISSIONS;
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portal.model.Permission"));
106 
107     public PermissionModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _permissionId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setPermissionId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_permissionId);
120     }
121 
122     public long getPermissionId() {
123         return _permissionId;
124     }
125 
126     public void setPermissionId(long permissionId) {
127         if (permissionId != _permissionId) {
128             _permissionId = permissionId;
129         }
130     }
131 
132     public long getCompanyId() {
133         return _companyId;
134     }
135 
136     public void setCompanyId(long companyId) {
137         if (companyId != _companyId) {
138             _companyId = companyId;
139         }
140     }
141 
142     public String getActionId() {
143         return GetterUtil.getString(_actionId);
144     }
145 
146     public void setActionId(String actionId) {
147         if (((actionId == null) && (_actionId != null)) ||
148                 ((actionId != null) && (_actionId == null)) ||
149                 ((actionId != null) && (_actionId != null) &&
150                 !actionId.equals(_actionId))) {
151             _actionId = actionId;
152         }
153     }
154 
155     public long getResourceId() {
156         return _resourceId;
157     }
158 
159     public void setResourceId(long resourceId) {
160         if (resourceId != _resourceId) {
161             _resourceId = resourceId;
162         }
163     }
164 
165     public Permission toEscapedModel() {
166         if (isEscapedModel()) {
167             return (Permission)this;
168         }
169         else {
170             Permission model = new PermissionImpl();
171 
172             model.setNew(isNew());
173             model.setEscapedModel(true);
174 
175             model.setPermissionId(getPermissionId());
176             model.setCompanyId(getCompanyId());
177             model.setActionId(HtmlUtil.escape(getActionId()));
178             model.setResourceId(getResourceId());
179 
180             model = (Permission)Proxy.newProxyInstance(Permission.class.getClassLoader(),
181                     new Class[] { Permission.class },
182                     new ReadOnlyBeanHandler(model));
183 
184             return model;
185         }
186     }
187 
188     public Object clone() {
189         PermissionImpl clone = new PermissionImpl();
190 
191         clone.setPermissionId(getPermissionId());
192         clone.setCompanyId(getCompanyId());
193         clone.setActionId(getActionId());
194         clone.setResourceId(getResourceId());
195 
196         return clone;
197     }
198 
199     public int compareTo(Object obj) {
200         if (obj == null) {
201             return -1;
202         }
203 
204         PermissionImpl permission = (PermissionImpl)obj;
205 
206         long pk = permission.getPrimaryKey();
207 
208         if (getPrimaryKey() < pk) {
209             return -1;
210         }
211         else if (getPrimaryKey() > pk) {
212             return 1;
213         }
214         else {
215             return 0;
216         }
217     }
218 
219     public boolean equals(Object obj) {
220         if (obj == null) {
221             return false;
222         }
223 
224         PermissionImpl permission = null;
225 
226         try {
227             permission = (PermissionImpl)obj;
228         }
229         catch (ClassCastException cce) {
230             return false;
231         }
232 
233         long pk = permission.getPrimaryKey();
234 
235         if (getPrimaryKey() == pk) {
236             return true;
237         }
238         else {
239             return false;
240         }
241     }
242 
243     public int hashCode() {
244         return (int)getPrimaryKey();
245     }
246 
247     private long _permissionId;
248     private long _companyId;
249     private String _actionId;
250     private long _resourceId;
251 }