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