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