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