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