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