1   /**
2    * Copyright (c) 2000-2008 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.portlet.expando.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.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoValue;
33  import com.liferay.portlet.expando.model.ExpandoValueSoap;
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="ExpandoValueModelImpl.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 class is a model that represents the <code>ExpandoValue</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.expando.service.model.ExpandoValue
60   * @see com.liferay.portlet.expando.service.model.ExpandoValueModel
61   * @see com.liferay.portlet.expando.service.model.impl.ExpandoValueImpl
62   *
63   */
64  public class ExpandoValueModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "ExpandoValue";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "valueId", new Integer(Types.BIGINT) },
68              
69  
70              { "tableId", new Integer(Types.BIGINT) },
71              
72  
73              { "columnId", new Integer(Types.BIGINT) },
74              
75  
76              { "rowId", new Integer(Types.BIGINT) },
77              
78  
79              { "classNameId", new Integer(Types.BIGINT) },
80              
81  
82              { "classPK", new Integer(Types.BIGINT) },
83              
84  
85              { "data_", new Integer(Types.VARCHAR) }
86          };
87      public static final String TABLE_SQL_CREATE = "create table ExpandoValue (valueId LONG not null primary key,tableId LONG,columnId LONG,rowId LONG,classNameId LONG,classPK LONG,data_ VARCHAR(75) null)";
88      public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
89      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
90                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
91              true);
92  
93      public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
94          ExpandoValue model = new ExpandoValueImpl();
95  
96          model.setValueId(soapModel.getValueId());
97          model.setTableId(soapModel.getTableId());
98          model.setColumnId(soapModel.getColumnId());
99          model.setRowId(soapModel.getRowId());
100         model.setClassNameId(soapModel.getClassNameId());
101         model.setClassPK(soapModel.getClassPK());
102         model.setData(soapModel.getData());
103 
104         return model;
105     }
106 
107     public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
108         List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
109 
110         for (ExpandoValueSoap soapModel : soapModels) {
111             models.add(toModel(soapModel));
112         }
113 
114         return models;
115     }
116 
117     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
118                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
119 
120     public ExpandoValueModelImpl() {
121     }
122 
123     public long getPrimaryKey() {
124         return _valueId;
125     }
126 
127     public void setPrimaryKey(long pk) {
128         setValueId(pk);
129     }
130 
131     public Serializable getPrimaryKeyObj() {
132         return new Long(_valueId);
133     }
134 
135     public long getValueId() {
136         return _valueId;
137     }
138 
139     public void setValueId(long valueId) {
140         if (valueId != _valueId) {
141             _valueId = valueId;
142         }
143     }
144 
145     public long getTableId() {
146         return _tableId;
147     }
148 
149     public void setTableId(long tableId) {
150         if (tableId != _tableId) {
151             _tableId = tableId;
152         }
153     }
154 
155     public long getColumnId() {
156         return _columnId;
157     }
158 
159     public void setColumnId(long columnId) {
160         if (columnId != _columnId) {
161             _columnId = columnId;
162         }
163     }
164 
165     public long getRowId() {
166         return _rowId;
167     }
168 
169     public void setRowId(long rowId) {
170         if (rowId != _rowId) {
171             _rowId = rowId;
172         }
173     }
174 
175     public String getClassName() {
176         return PortalUtil.getClassName(getClassNameId());
177     }
178 
179     public long getClassNameId() {
180         return _classNameId;
181     }
182 
183     public void setClassNameId(long classNameId) {
184         if (classNameId != _classNameId) {
185             _classNameId = classNameId;
186         }
187     }
188 
189     public long getClassPK() {
190         return _classPK;
191     }
192 
193     public void setClassPK(long classPK) {
194         if (classPK != _classPK) {
195             _classPK = classPK;
196         }
197     }
198 
199     public String getData() {
200         return GetterUtil.getString(_data);
201     }
202 
203     public void setData(String data) {
204         if (((data == null) && (_data != null)) ||
205                 ((data != null) && (_data == null)) ||
206                 ((data != null) && (_data != null) && !data.equals(_data))) {
207             _data = data;
208         }
209     }
210 
211     public ExpandoValue toEscapedModel() {
212         if (isEscapedModel()) {
213             return (ExpandoValue)this;
214         }
215         else {
216             ExpandoValue model = new ExpandoValueImpl();
217 
218             model.setEscapedModel(true);
219 
220             model.setValueId(getValueId());
221             model.setTableId(getTableId());
222             model.setColumnId(getColumnId());
223             model.setRowId(getRowId());
224             model.setClassNameId(getClassNameId());
225             model.setClassPK(getClassPK());
226             model.setData(HtmlUtil.escape(getData()));
227 
228             model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
229                     new Class[] { ExpandoValue.class },
230                     new ReadOnlyBeanHandler(model));
231 
232             return model;
233         }
234     }
235 
236     public Object clone() {
237         ExpandoValueImpl clone = new ExpandoValueImpl();
238 
239         clone.setValueId(getValueId());
240         clone.setTableId(getTableId());
241         clone.setColumnId(getColumnId());
242         clone.setRowId(getRowId());
243         clone.setClassNameId(getClassNameId());
244         clone.setClassPK(getClassPK());
245         clone.setData(getData());
246 
247         return clone;
248     }
249 
250     public int compareTo(Object obj) {
251         if (obj == null) {
252             return -1;
253         }
254 
255         ExpandoValueImpl expandoValue = (ExpandoValueImpl)obj;
256 
257         int value = 0;
258 
259         if (getTableId() < expandoValue.getTableId()) {
260             value = -1;
261         }
262         else if (getTableId() > expandoValue.getTableId()) {
263             value = 1;
264         }
265         else {
266             value = 0;
267         }
268 
269         if (value != 0) {
270             return value;
271         }
272 
273         if (getRowId() < expandoValue.getRowId()) {
274             value = -1;
275         }
276         else if (getRowId() > expandoValue.getRowId()) {
277             value = 1;
278         }
279         else {
280             value = 0;
281         }
282 
283         if (value != 0) {
284             return value;
285         }
286 
287         if (getColumnId() < expandoValue.getColumnId()) {
288             value = -1;
289         }
290         else if (getColumnId() > expandoValue.getColumnId()) {
291             value = 1;
292         }
293         else {
294             value = 0;
295         }
296 
297         if (value != 0) {
298             return value;
299         }
300 
301         return 0;
302     }
303 
304     public boolean equals(Object obj) {
305         if (obj == null) {
306             return false;
307         }
308 
309         ExpandoValueImpl expandoValue = null;
310 
311         try {
312             expandoValue = (ExpandoValueImpl)obj;
313         }
314         catch (ClassCastException cce) {
315             return false;
316         }
317 
318         long pk = expandoValue.getPrimaryKey();
319 
320         if (getPrimaryKey() == pk) {
321             return true;
322         }
323         else {
324             return false;
325         }
326     }
327 
328     public int hashCode() {
329         return (int)getPrimaryKey();
330     }
331 
332     private long _valueId;
333     private long _tableId;
334     private long _columnId;
335     private long _rowId;
336     private long _classNameId;
337     private long _classPK;
338     private String _data;
339 }