1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.ResourceAction;
22  import com.liferay.portal.model.ResourceActionSoap;
23  import com.liferay.portal.service.ServiceContext;
24  
25  import com.liferay.portlet.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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="ResourceActionModelImpl.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 interface is a model that represents the ResourceAction table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       ResourceActionImpl
52   * @see       com.liferay.portal.model.ResourceAction
53   * @see       com.liferay.portal.model.ResourceActionModel
54   * @generated
55   */
56  public class ResourceActionModelImpl extends BaseModelImpl<ResourceAction> {
57      public static final String TABLE_NAME = "ResourceAction";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "resourceActionId", new Integer(Types.BIGINT) },
60              { "name", new Integer(Types.VARCHAR) },
61              { "actionId", new Integer(Types.VARCHAR) },
62              { "bitwiseValue", new Integer(Types.BIGINT) }
63          };
64      public static final String TABLE_SQL_CREATE = "create table ResourceAction (resourceActionId LONG not null primary key,name VARCHAR(255) null,actionId VARCHAR(75) null,bitwiseValue LONG)";
65      public static final String TABLE_SQL_DROP = "drop table ResourceAction";
66      public static final String ORDER_BY_JPQL = " ORDER BY resourceAction.name ASC, resourceAction.bitwiseValue ASC";
67      public static final String ORDER_BY_SQL = " ORDER BY ResourceAction.name ASC, ResourceAction.bitwiseValue ASC";
68      public static final String DATA_SOURCE = "liferayDataSource";
69      public static final String SESSION_FACTORY = "liferaySessionFactory";
70      public static final String TX_MANAGER = "liferayTransactionManager";
71      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72                  "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceAction"),
73              true);
74      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceAction"),
76              true);
77  
78      public static ResourceAction toModel(ResourceActionSoap soapModel) {
79          ResourceAction model = new ResourceActionImpl();
80  
81          model.setResourceActionId(soapModel.getResourceActionId());
82          model.setName(soapModel.getName());
83          model.setActionId(soapModel.getActionId());
84          model.setBitwiseValue(soapModel.getBitwiseValue());
85  
86          return model;
87      }
88  
89      public static List<ResourceAction> toModels(ResourceActionSoap[] soapModels) {
90          List<ResourceAction> models = new ArrayList<ResourceAction>(soapModels.length);
91  
92          for (ResourceActionSoap soapModel : soapModels) {
93              models.add(toModel(soapModel));
94          }
95  
96          return models;
97      }
98  
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portal.model.ResourceAction"));
101 
102     public ResourceActionModelImpl() {
103     }
104 
105     public long getPrimaryKey() {
106         return _resourceActionId;
107     }
108 
109     public void setPrimaryKey(long pk) {
110         setResourceActionId(pk);
111     }
112 
113     public Serializable getPrimaryKeyObj() {
114         return new Long(_resourceActionId);
115     }
116 
117     public long getResourceActionId() {
118         return _resourceActionId;
119     }
120 
121     public void setResourceActionId(long resourceActionId) {
122         _resourceActionId = resourceActionId;
123     }
124 
125     public String getName() {
126         if (_name == null) {
127             return StringPool.BLANK;
128         }
129         else {
130             return _name;
131         }
132     }
133 
134     public void setName(String name) {
135         _name = name;
136 
137         if (_originalName == null) {
138             _originalName = name;
139         }
140     }
141 
142     public String getOriginalName() {
143         return GetterUtil.getString(_originalName);
144     }
145 
146     public String getActionId() {
147         if (_actionId == null) {
148             return StringPool.BLANK;
149         }
150         else {
151             return _actionId;
152         }
153     }
154 
155     public void setActionId(String actionId) {
156         _actionId = actionId;
157 
158         if (_originalActionId == null) {
159             _originalActionId = actionId;
160         }
161     }
162 
163     public String getOriginalActionId() {
164         return GetterUtil.getString(_originalActionId);
165     }
166 
167     public long getBitwiseValue() {
168         return _bitwiseValue;
169     }
170 
171     public void setBitwiseValue(long bitwiseValue) {
172         _bitwiseValue = bitwiseValue;
173     }
174 
175     public ResourceAction toEscapedModel() {
176         if (isEscapedModel()) {
177             return (ResourceAction)this;
178         }
179         else {
180             return (ResourceAction)Proxy.newProxyInstance(ResourceAction.class.getClassLoader(),
181                 new Class[] { ResourceAction.class },
182                 new AutoEscapeBeanHandler(this));
183         }
184     }
185 
186     public ExpandoBridge getExpandoBridge() {
187         if (_expandoBridge == null) {
188             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ResourceAction.class.getName(),
189                     getPrimaryKey());
190         }
191 
192         return _expandoBridge;
193     }
194 
195     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
196         getExpandoBridge().setAttributes(serviceContext);
197     }
198 
199     public Object clone() {
200         ResourceActionImpl clone = new ResourceActionImpl();
201 
202         clone.setResourceActionId(getResourceActionId());
203         clone.setName(getName());
204         clone.setActionId(getActionId());
205         clone.setBitwiseValue(getBitwiseValue());
206 
207         return clone;
208     }
209 
210     public int compareTo(ResourceAction resourceAction) {
211         int value = 0;
212 
213         value = getName().compareTo(resourceAction.getName());
214 
215         if (value != 0) {
216             return value;
217         }
218 
219         if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
220             value = -1;
221         }
222         else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
223             value = 1;
224         }
225         else {
226             value = 0;
227         }
228 
229         if (value != 0) {
230             return value;
231         }
232 
233         return 0;
234     }
235 
236     public boolean equals(Object obj) {
237         if (obj == null) {
238             return false;
239         }
240 
241         ResourceAction resourceAction = null;
242 
243         try {
244             resourceAction = (ResourceAction)obj;
245         }
246         catch (ClassCastException cce) {
247             return false;
248         }
249 
250         long pk = resourceAction.getPrimaryKey();
251 
252         if (getPrimaryKey() == pk) {
253             return true;
254         }
255         else {
256             return false;
257         }
258     }
259 
260     public int hashCode() {
261         return (int)getPrimaryKey();
262     }
263 
264     public String toString() {
265         StringBundler sb = new StringBundler(9);
266 
267         sb.append("{resourceActionId=");
268         sb.append(getResourceActionId());
269         sb.append(", name=");
270         sb.append(getName());
271         sb.append(", actionId=");
272         sb.append(getActionId());
273         sb.append(", bitwiseValue=");
274         sb.append(getBitwiseValue());
275         sb.append("}");
276 
277         return sb.toString();
278     }
279 
280     public String toXmlString() {
281         StringBundler sb = new StringBundler(16);
282 
283         sb.append("<model><model-name>");
284         sb.append("com.liferay.portal.model.ResourceAction");
285         sb.append("</model-name>");
286 
287         sb.append(
288             "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
289         sb.append(getResourceActionId());
290         sb.append("]]></column-value></column>");
291         sb.append(
292             "<column><column-name>name</column-name><column-value><![CDATA[");
293         sb.append(getName());
294         sb.append("]]></column-value></column>");
295         sb.append(
296             "<column><column-name>actionId</column-name><column-value><![CDATA[");
297         sb.append(getActionId());
298         sb.append("]]></column-value></column>");
299         sb.append(
300             "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
301         sb.append(getBitwiseValue());
302         sb.append("]]></column-value></column>");
303 
304         sb.append("</model>");
305 
306         return sb.toString();
307     }
308 
309     private long _resourceActionId;
310     private String _name;
311     private String _originalName;
312     private String _actionId;
313     private String _originalActionId;
314     private long _bitwiseValue;
315     private transient ExpandoBridge _expandoBridge;
316 }