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 class is a model that represents the <code>ResourceAction</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.model.ResourceAction
56   * @see com.liferay.portal.model.ResourceActionModel
57   * @see com.liferay.portal.model.impl.ResourceActionImpl
58   *
59   */
60  public class ResourceActionModelImpl extends BaseModelImpl<ResourceAction> {
61      public static final String TABLE_NAME = "ResourceAction";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "resourceActionId", new Integer(Types.BIGINT) },
64              
65  
66              { "name", new Integer(Types.VARCHAR) },
67              
68  
69              { "actionId", new Integer(Types.VARCHAR) },
70              
71  
72              { "bitwiseValue", new Integer(Types.BIGINT) }
73          };
74      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)";
75      public static final String TABLE_SQL_DROP = "drop table ResourceAction";
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 Object clone() {
197         ResourceActionImpl clone = new ResourceActionImpl();
198 
199         clone.setResourceActionId(getResourceActionId());
200         clone.setName(getName());
201         clone.setActionId(getActionId());
202         clone.setBitwiseValue(getBitwiseValue());
203 
204         return clone;
205     }
206 
207     public int compareTo(ResourceAction resourceAction) {
208         int value = 0;
209 
210         value = getName().compareTo(resourceAction.getName());
211 
212         if (value != 0) {
213             return value;
214         }
215 
216         if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
217             value = -1;
218         }
219         else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
220             value = 1;
221         }
222         else {
223             value = 0;
224         }
225 
226         if (value != 0) {
227             return value;
228         }
229 
230         return 0;
231     }
232 
233     public boolean equals(Object obj) {
234         if (obj == null) {
235             return false;
236         }
237 
238         ResourceAction resourceAction = null;
239 
240         try {
241             resourceAction = (ResourceAction)obj;
242         }
243         catch (ClassCastException cce) {
244             return false;
245         }
246 
247         long pk = resourceAction.getPrimaryKey();
248 
249         if (getPrimaryKey() == pk) {
250             return true;
251         }
252         else {
253             return false;
254         }
255     }
256 
257     public int hashCode() {
258         return (int)getPrimaryKey();
259     }
260 
261     public String toString() {
262         StringBuilder sb = new StringBuilder();
263 
264         sb.append("{resourceActionId=");
265         sb.append(getResourceActionId());
266         sb.append(", name=");
267         sb.append(getName());
268         sb.append(", actionId=");
269         sb.append(getActionId());
270         sb.append(", bitwiseValue=");
271         sb.append(getBitwiseValue());
272         sb.append("}");
273 
274         return sb.toString();
275     }
276 
277     public String toXmlString() {
278         StringBuilder sb = new StringBuilder();
279 
280         sb.append("<model><model-name>");
281         sb.append("com.liferay.portal.model.ResourceAction");
282         sb.append("</model-name>");
283 
284         sb.append(
285             "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
286         sb.append(getResourceActionId());
287         sb.append("]]></column-value></column>");
288         sb.append(
289             "<column><column-name>name</column-name><column-value><![CDATA[");
290         sb.append(getName());
291         sb.append("]]></column-value></column>");
292         sb.append(
293             "<column><column-name>actionId</column-name><column-value><![CDATA[");
294         sb.append(getActionId());
295         sb.append("]]></column-value></column>");
296         sb.append(
297             "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
298         sb.append(getBitwiseValue());
299         sb.append("]]></column-value></column>");
300 
301         sb.append("</model>");
302 
303         return sb.toString();
304     }
305 
306     private long _resourceActionId;
307     private String _name;
308     private String _originalName;
309     private String _actionId;
310     private String _originalActionId;
311     private long _bitwiseValue;
312 }