1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
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         return GetterUtil.getString(_name);
127     }
128 
129     public void setName(String name) {
130         _name = name;
131 
132         if (_originalName == null) {
133             _originalName = name;
134         }
135     }
136 
137     public String getOriginalName() {
138         return GetterUtil.getString(_originalName);
139     }
140 
141     public String getActionId() {
142         return GetterUtil.getString(_actionId);
143     }
144 
145     public void setActionId(String actionId) {
146         _actionId = actionId;
147 
148         if (_originalActionId == null) {
149             _originalActionId = actionId;
150         }
151     }
152 
153     public String getOriginalActionId() {
154         return GetterUtil.getString(_originalActionId);
155     }
156 
157     public long getBitwiseValue() {
158         return _bitwiseValue;
159     }
160 
161     public void setBitwiseValue(long bitwiseValue) {
162         _bitwiseValue = bitwiseValue;
163     }
164 
165     public ResourceAction toEscapedModel() {
166         if (isEscapedModel()) {
167             return (ResourceAction)this;
168         }
169         else {
170             ResourceAction model = new ResourceActionImpl();
171 
172             model.setNew(isNew());
173             model.setEscapedModel(true);
174 
175             model.setResourceActionId(getResourceActionId());
176             model.setName(HtmlUtil.escape(getName()));
177             model.setActionId(HtmlUtil.escape(getActionId()));
178             model.setBitwiseValue(getBitwiseValue());
179 
180             model = (ResourceAction)Proxy.newProxyInstance(ResourceAction.class.getClassLoader(),
181                     new Class[] { ResourceAction.class },
182                     new ReadOnlyBeanHandler(model));
183 
184             return model;
185         }
186     }
187 
188     public ExpandoBridge getExpandoBridge() {
189         if (_expandoBridge == null) {
190             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
191                     ResourceAction.class.getName(), getPrimaryKey());
192         }
193 
194         return _expandoBridge;
195     }
196 
197     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
198         getExpandoBridge().setAttributes(serviceContext);
199     }
200 
201     public Object clone() {
202         ResourceActionImpl clone = new ResourceActionImpl();
203 
204         clone.setResourceActionId(getResourceActionId());
205         clone.setName(getName());
206         clone.setActionId(getActionId());
207         clone.setBitwiseValue(getBitwiseValue());
208 
209         return clone;
210     }
211 
212     public int compareTo(ResourceAction resourceAction) {
213         int value = 0;
214 
215         value = getName().compareTo(resourceAction.getName());
216 
217         if (value != 0) {
218             return value;
219         }
220 
221         if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
222             value = -1;
223         }
224         else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
225             value = 1;
226         }
227         else {
228             value = 0;
229         }
230 
231         if (value != 0) {
232             return value;
233         }
234 
235         return 0;
236     }
237 
238     public boolean equals(Object obj) {
239         if (obj == null) {
240             return false;
241         }
242 
243         ResourceAction resourceAction = null;
244 
245         try {
246             resourceAction = (ResourceAction)obj;
247         }
248         catch (ClassCastException cce) {
249             return false;
250         }
251 
252         long pk = resourceAction.getPrimaryKey();
253 
254         if (getPrimaryKey() == pk) {
255             return true;
256         }
257         else {
258             return false;
259         }
260     }
261 
262     public int hashCode() {
263         return (int)getPrimaryKey();
264     }
265 
266     public String toString() {
267         StringBundler sb = new StringBundler(9);
268 
269         sb.append("{resourceActionId=");
270         sb.append(getResourceActionId());
271         sb.append(", name=");
272         sb.append(getName());
273         sb.append(", actionId=");
274         sb.append(getActionId());
275         sb.append(", bitwiseValue=");
276         sb.append(getBitwiseValue());
277         sb.append("}");
278 
279         return sb.toString();
280     }
281 
282     public String toXmlString() {
283         StringBundler sb = new StringBundler(16);
284 
285         sb.append("<model><model-name>");
286         sb.append("com.liferay.portal.model.ResourceAction");
287         sb.append("</model-name>");
288 
289         sb.append(
290             "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
291         sb.append(getResourceActionId());
292         sb.append("]]></column-value></column>");
293         sb.append(
294             "<column><column-name>name</column-name><column-value><![CDATA[");
295         sb.append(getName());
296         sb.append("]]></column-value></column>");
297         sb.append(
298             "<column><column-name>actionId</column-name><column-value><![CDATA[");
299         sb.append(getActionId());
300         sb.append("]]></column-value></column>");
301         sb.append(
302             "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
303         sb.append(getBitwiseValue());
304         sb.append("]]></column-value></column>");
305 
306         sb.append("</model>");
307 
308         return sb.toString();
309     }
310 
311     private long _resourceActionId;
312     private String _name;
313     private String _originalName;
314     private String _actionId;
315     private String _originalActionId;
316     private long _bitwiseValue;
317     private transient ExpandoBridge _expandoBridge;
318 }