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