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.ResourcePermission;
29  import com.liferay.portal.model.ResourcePermissionSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="ResourcePermissionModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This interface is a model that represents the ResourcePermission table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       ResourcePermissionImpl
55   * @see       com.liferay.portal.model.ResourcePermission
56   * @see       com.liferay.portal.model.ResourcePermissionModel
57   * @generated
58   */
59  public class ResourcePermissionModelImpl extends BaseModelImpl<ResourcePermission> {
60      public static final String TABLE_NAME = "ResourcePermission";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "resourcePermissionId", new Integer(Types.BIGINT) },
63              { "companyId", new Integer(Types.BIGINT) },
64              { "name", new Integer(Types.VARCHAR) },
65              { "scope", new Integer(Types.INTEGER) },
66              { "primKey", new Integer(Types.VARCHAR) },
67              { "roleId", new Integer(Types.BIGINT) },
68              { "actionIds", new Integer(Types.BIGINT) }
69          };
70      public static final String TABLE_SQL_CREATE = "create table ResourcePermission (resourcePermissionId LONG not null primary key,companyId LONG,name VARCHAR(255) null,scope INTEGER,primKey VARCHAR(255) null,roleId LONG,actionIds LONG)";
71      public static final String TABLE_SQL_DROP = "drop table ResourcePermission";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portal.model.ResourcePermission"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portal.model.ResourcePermission"),
80              true);
81  
82      public static ResourcePermission toModel(ResourcePermissionSoap soapModel) {
83          ResourcePermission model = new ResourcePermissionImpl();
84  
85          model.setResourcePermissionId(soapModel.getResourcePermissionId());
86          model.setCompanyId(soapModel.getCompanyId());
87          model.setName(soapModel.getName());
88          model.setScope(soapModel.getScope());
89          model.setPrimKey(soapModel.getPrimKey());
90          model.setRoleId(soapModel.getRoleId());
91          model.setActionIds(soapModel.getActionIds());
92  
93          return model;
94      }
95  
96      public static List<ResourcePermission> toModels(
97          ResourcePermissionSoap[] soapModels) {
98          List<ResourcePermission> models = new ArrayList<ResourcePermission>(soapModels.length);
99  
100         for (ResourcePermissionSoap soapModel : soapModels) {
101             models.add(toModel(soapModel));
102         }
103 
104         return models;
105     }
106 
107     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
108                 "lock.expiration.time.com.liferay.portal.model.ResourcePermission"));
109 
110     public ResourcePermissionModelImpl() {
111     }
112 
113     public long getPrimaryKey() {
114         return _resourcePermissionId;
115     }
116 
117     public void setPrimaryKey(long pk) {
118         setResourcePermissionId(pk);
119     }
120 
121     public Serializable getPrimaryKeyObj() {
122         return new Long(_resourcePermissionId);
123     }
124 
125     public long getResourcePermissionId() {
126         return _resourcePermissionId;
127     }
128 
129     public void setResourcePermissionId(long resourcePermissionId) {
130         _resourcePermissionId = resourcePermissionId;
131     }
132 
133     public long getCompanyId() {
134         return _companyId;
135     }
136 
137     public void setCompanyId(long companyId) {
138         _companyId = companyId;
139 
140         if (!_setOriginalCompanyId) {
141             _setOriginalCompanyId = true;
142 
143             _originalCompanyId = companyId;
144         }
145     }
146 
147     public long getOriginalCompanyId() {
148         return _originalCompanyId;
149     }
150 
151     public String getName() {
152         return GetterUtil.getString(_name);
153     }
154 
155     public void setName(String name) {
156         _name = name;
157 
158         if (_originalName == null) {
159             _originalName = name;
160         }
161     }
162 
163     public String getOriginalName() {
164         return GetterUtil.getString(_originalName);
165     }
166 
167     public int getScope() {
168         return _scope;
169     }
170 
171     public void setScope(int scope) {
172         _scope = scope;
173 
174         if (!_setOriginalScope) {
175             _setOriginalScope = true;
176 
177             _originalScope = scope;
178         }
179     }
180 
181     public int getOriginalScope() {
182         return _originalScope;
183     }
184 
185     public String getPrimKey() {
186         return GetterUtil.getString(_primKey);
187     }
188 
189     public void setPrimKey(String primKey) {
190         _primKey = primKey;
191 
192         if (_originalPrimKey == null) {
193             _originalPrimKey = primKey;
194         }
195     }
196 
197     public String getOriginalPrimKey() {
198         return GetterUtil.getString(_originalPrimKey);
199     }
200 
201     public long getRoleId() {
202         return _roleId;
203     }
204 
205     public void setRoleId(long roleId) {
206         _roleId = roleId;
207 
208         if (!_setOriginalRoleId) {
209             _setOriginalRoleId = true;
210 
211             _originalRoleId = roleId;
212         }
213     }
214 
215     public long getOriginalRoleId() {
216         return _originalRoleId;
217     }
218 
219     public long getActionIds() {
220         return _actionIds;
221     }
222 
223     public void setActionIds(long actionIds) {
224         _actionIds = actionIds;
225     }
226 
227     public ResourcePermission toEscapedModel() {
228         if (isEscapedModel()) {
229             return (ResourcePermission)this;
230         }
231         else {
232             ResourcePermission model = new ResourcePermissionImpl();
233 
234             model.setNew(isNew());
235             model.setEscapedModel(true);
236 
237             model.setResourcePermissionId(getResourcePermissionId());
238             model.setCompanyId(getCompanyId());
239             model.setName(HtmlUtil.escape(getName()));
240             model.setScope(getScope());
241             model.setPrimKey(HtmlUtil.escape(getPrimKey()));
242             model.setRoleId(getRoleId());
243             model.setActionIds(getActionIds());
244 
245             model = (ResourcePermission)Proxy.newProxyInstance(ResourcePermission.class.getClassLoader(),
246                     new Class[] { ResourcePermission.class },
247                     new ReadOnlyBeanHandler(model));
248 
249             return model;
250         }
251     }
252 
253     public Object clone() {
254         ResourcePermissionImpl clone = new ResourcePermissionImpl();
255 
256         clone.setResourcePermissionId(getResourcePermissionId());
257         clone.setCompanyId(getCompanyId());
258         clone.setName(getName());
259         clone.setScope(getScope());
260         clone.setPrimKey(getPrimKey());
261         clone.setRoleId(getRoleId());
262         clone.setActionIds(getActionIds());
263 
264         return clone;
265     }
266 
267     public int compareTo(ResourcePermission resourcePermission) {
268         long pk = resourcePermission.getPrimaryKey();
269 
270         if (getPrimaryKey() < pk) {
271             return -1;
272         }
273         else if (getPrimaryKey() > pk) {
274             return 1;
275         }
276         else {
277             return 0;
278         }
279     }
280 
281     public boolean equals(Object obj) {
282         if (obj == null) {
283             return false;
284         }
285 
286         ResourcePermission resourcePermission = null;
287 
288         try {
289             resourcePermission = (ResourcePermission)obj;
290         }
291         catch (ClassCastException cce) {
292             return false;
293         }
294 
295         long pk = resourcePermission.getPrimaryKey();
296 
297         if (getPrimaryKey() == pk) {
298             return true;
299         }
300         else {
301             return false;
302         }
303     }
304 
305     public int hashCode() {
306         return (int)getPrimaryKey();
307     }
308 
309     public String toString() {
310         StringBuilder sb = new StringBuilder();
311 
312         sb.append("{resourcePermissionId=");
313         sb.append(getResourcePermissionId());
314         sb.append(", companyId=");
315         sb.append(getCompanyId());
316         sb.append(", name=");
317         sb.append(getName());
318         sb.append(", scope=");
319         sb.append(getScope());
320         sb.append(", primKey=");
321         sb.append(getPrimKey());
322         sb.append(", roleId=");
323         sb.append(getRoleId());
324         sb.append(", actionIds=");
325         sb.append(getActionIds());
326         sb.append("}");
327 
328         return sb.toString();
329     }
330 
331     public String toXmlString() {
332         StringBuilder sb = new StringBuilder();
333 
334         sb.append("<model><model-name>");
335         sb.append("com.liferay.portal.model.ResourcePermission");
336         sb.append("</model-name>");
337 
338         sb.append(
339             "<column><column-name>resourcePermissionId</column-name><column-value><![CDATA[");
340         sb.append(getResourcePermissionId());
341         sb.append("]]></column-value></column>");
342         sb.append(
343             "<column><column-name>companyId</column-name><column-value><![CDATA[");
344         sb.append(getCompanyId());
345         sb.append("]]></column-value></column>");
346         sb.append(
347             "<column><column-name>name</column-name><column-value><![CDATA[");
348         sb.append(getName());
349         sb.append("]]></column-value></column>");
350         sb.append(
351             "<column><column-name>scope</column-name><column-value><![CDATA[");
352         sb.append(getScope());
353         sb.append("]]></column-value></column>");
354         sb.append(
355             "<column><column-name>primKey</column-name><column-value><![CDATA[");
356         sb.append(getPrimKey());
357         sb.append("]]></column-value></column>");
358         sb.append(
359             "<column><column-name>roleId</column-name><column-value><![CDATA[");
360         sb.append(getRoleId());
361         sb.append("]]></column-value></column>");
362         sb.append(
363             "<column><column-name>actionIds</column-name><column-value><![CDATA[");
364         sb.append(getActionIds());
365         sb.append("]]></column-value></column>");
366 
367         sb.append("</model>");
368 
369         return sb.toString();
370     }
371 
372     private long _resourcePermissionId;
373     private long _companyId;
374     private long _originalCompanyId;
375     private boolean _setOriginalCompanyId;
376     private String _name;
377     private String _originalName;
378     private int _scope;
379     private int _originalScope;
380     private boolean _setOriginalScope;
381     private String _primKey;
382     private String _originalPrimKey;
383     private long _roleId;
384     private long _originalRoleId;
385     private boolean _setOriginalRoleId;
386     private long _actionIds;
387 }