1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.expando.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.kernel.util.StringPool;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.expando.model.ExpandoValue;
26  import com.liferay.portlet.expando.model.ExpandoValueSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="ExpandoValueModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the ExpandoValue table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       ExpandoValueImpl
52   * @see       com.liferay.portlet.expando.model.ExpandoValue
53   * @see       com.liferay.portlet.expando.model.ExpandoValueModel
54   * @generated
55   */
56  public class ExpandoValueModelImpl extends BaseModelImpl<ExpandoValue> {
57      public static final String TABLE_NAME = "ExpandoValue";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "valueId", new Integer(Types.BIGINT) },
60              { "tableId", new Integer(Types.BIGINT) },
61              { "columnId", new Integer(Types.BIGINT) },
62              { "rowId_", new Integer(Types.BIGINT) },
63              { "classNameId", new Integer(Types.BIGINT) },
64              { "classPK", new Integer(Types.BIGINT) },
65              { "data_", new Integer(Types.VARCHAR) }
66          };
67      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_ STRING null)";
68      public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
69      public static final String ORDER_BY_JPQL = " ORDER BY expandoValue.tableId ASC, expandoValue.rowId ASC, expandoValue.columnId ASC";
70      public static final String ORDER_BY_SQL = " ORDER BY ExpandoValue.tableId ASC, ExpandoValue.rowId_ ASC, ExpandoValue.columnId ASC";
71      public static final String DATA_SOURCE = "liferayDataSource";
72      public static final String SESSION_FACTORY = "liferaySessionFactory";
73      public static final String TX_MANAGER = "liferayTransactionManager";
74      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
75                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
76              true);
77      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
79              true);
80  
81      public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
82          ExpandoValue model = new ExpandoValueImpl();
83  
84          model.setValueId(soapModel.getValueId());
85          model.setTableId(soapModel.getTableId());
86          model.setColumnId(soapModel.getColumnId());
87          model.setRowId(soapModel.getRowId());
88          model.setClassNameId(soapModel.getClassNameId());
89          model.setClassPK(soapModel.getClassPK());
90          model.setData(soapModel.getData());
91  
92          return model;
93      }
94  
95      public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
96          List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
97  
98          for (ExpandoValueSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
107 
108     public ExpandoValueModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _valueId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setValueId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_valueId);
121     }
122 
123     public long getValueId() {
124         return _valueId;
125     }
126 
127     public void setValueId(long valueId) {
128         _valueId = valueId;
129     }
130 
131     public long getTableId() {
132         return _tableId;
133     }
134 
135     public void setTableId(long tableId) {
136         _tableId = tableId;
137 
138         if (!_setOriginalTableId) {
139             _setOriginalTableId = true;
140 
141             _originalTableId = tableId;
142         }
143     }
144 
145     public long getOriginalTableId() {
146         return _originalTableId;
147     }
148 
149     public long getColumnId() {
150         return _columnId;
151     }
152 
153     public void setColumnId(long columnId) {
154         _columnId = columnId;
155 
156         if (!_setOriginalColumnId) {
157             _setOriginalColumnId = true;
158 
159             _originalColumnId = columnId;
160         }
161     }
162 
163     public long getOriginalColumnId() {
164         return _originalColumnId;
165     }
166 
167     public long getRowId() {
168         return _rowId;
169     }
170 
171     public void setRowId(long rowId) {
172         _rowId = rowId;
173 
174         if (!_setOriginalRowId) {
175             _setOriginalRowId = true;
176 
177             _originalRowId = rowId;
178         }
179     }
180 
181     public long getOriginalRowId() {
182         return _originalRowId;
183     }
184 
185     public String getClassName() {
186         if (getClassNameId() <= 0) {
187             return StringPool.BLANK;
188         }
189 
190         return PortalUtil.getClassName(getClassNameId());
191     }
192 
193     public long getClassNameId() {
194         return _classNameId;
195     }
196 
197     public void setClassNameId(long classNameId) {
198         _classNameId = classNameId;
199     }
200 
201     public long getClassPK() {
202         return _classPK;
203     }
204 
205     public void setClassPK(long classPK) {
206         _classPK = classPK;
207 
208         if (!_setOriginalClassPK) {
209             _setOriginalClassPK = true;
210 
211             _originalClassPK = classPK;
212         }
213     }
214 
215     public long getOriginalClassPK() {
216         return _originalClassPK;
217     }
218 
219     public String getData() {
220         return GetterUtil.getString(_data);
221     }
222 
223     public void setData(String data) {
224         _data = data;
225     }
226 
227     public ExpandoValue toEscapedModel() {
228         if (isEscapedModel()) {
229             return (ExpandoValue)this;
230         }
231         else {
232             ExpandoValue model = new ExpandoValueImpl();
233 
234             model.setNew(isNew());
235             model.setEscapedModel(true);
236 
237             model.setValueId(getValueId());
238             model.setTableId(getTableId());
239             model.setColumnId(getColumnId());
240             model.setRowId(getRowId());
241             model.setClassNameId(getClassNameId());
242             model.setClassPK(getClassPK());
243             model.setData(HtmlUtil.escape(getData()));
244 
245             model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
246                     new Class[] { ExpandoValue.class },
247                     new ReadOnlyBeanHandler(model));
248 
249             return model;
250         }
251     }
252 
253     public Object clone() {
254         ExpandoValueImpl clone = new ExpandoValueImpl();
255 
256         clone.setValueId(getValueId());
257         clone.setTableId(getTableId());
258         clone.setColumnId(getColumnId());
259         clone.setRowId(getRowId());
260         clone.setClassNameId(getClassNameId());
261         clone.setClassPK(getClassPK());
262         clone.setData(getData());
263 
264         return clone;
265     }
266 
267     public int compareTo(ExpandoValue expandoValue) {
268         int value = 0;
269 
270         if (getTableId() < expandoValue.getTableId()) {
271             value = -1;
272         }
273         else if (getTableId() > expandoValue.getTableId()) {
274             value = 1;
275         }
276         else {
277             value = 0;
278         }
279 
280         if (value != 0) {
281             return value;
282         }
283 
284         if (getRowId() < expandoValue.getRowId()) {
285             value = -1;
286         }
287         else if (getRowId() > expandoValue.getRowId()) {
288             value = 1;
289         }
290         else {
291             value = 0;
292         }
293 
294         if (value != 0) {
295             return value;
296         }
297 
298         if (getColumnId() < expandoValue.getColumnId()) {
299             value = -1;
300         }
301         else if (getColumnId() > expandoValue.getColumnId()) {
302             value = 1;
303         }
304         else {
305             value = 0;
306         }
307 
308         if (value != 0) {
309             return value;
310         }
311 
312         return 0;
313     }
314 
315     public boolean equals(Object obj) {
316         if (obj == null) {
317             return false;
318         }
319 
320         ExpandoValue expandoValue = null;
321 
322         try {
323             expandoValue = (ExpandoValue)obj;
324         }
325         catch (ClassCastException cce) {
326             return false;
327         }
328 
329         long pk = expandoValue.getPrimaryKey();
330 
331         if (getPrimaryKey() == pk) {
332             return true;
333         }
334         else {
335             return false;
336         }
337     }
338 
339     public int hashCode() {
340         return (int)getPrimaryKey();
341     }
342 
343     public String toString() {
344         StringBundler sb = new StringBundler(15);
345 
346         sb.append("{valueId=");
347         sb.append(getValueId());
348         sb.append(", tableId=");
349         sb.append(getTableId());
350         sb.append(", columnId=");
351         sb.append(getColumnId());
352         sb.append(", rowId=");
353         sb.append(getRowId());
354         sb.append(", classNameId=");
355         sb.append(getClassNameId());
356         sb.append(", classPK=");
357         sb.append(getClassPK());
358         sb.append(", data=");
359         sb.append(getData());
360         sb.append("}");
361 
362         return sb.toString();
363     }
364 
365     public String toXmlString() {
366         StringBundler sb = new StringBundler(25);
367 
368         sb.append("<model><model-name>");
369         sb.append("com.liferay.portlet.expando.model.ExpandoValue");
370         sb.append("</model-name>");
371 
372         sb.append(
373             "<column><column-name>valueId</column-name><column-value><![CDATA[");
374         sb.append(getValueId());
375         sb.append("]]></column-value></column>");
376         sb.append(
377             "<column><column-name>tableId</column-name><column-value><![CDATA[");
378         sb.append(getTableId());
379         sb.append("]]></column-value></column>");
380         sb.append(
381             "<column><column-name>columnId</column-name><column-value><![CDATA[");
382         sb.append(getColumnId());
383         sb.append("]]></column-value></column>");
384         sb.append(
385             "<column><column-name>rowId</column-name><column-value><![CDATA[");
386         sb.append(getRowId());
387         sb.append("]]></column-value></column>");
388         sb.append(
389             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
390         sb.append(getClassNameId());
391         sb.append("]]></column-value></column>");
392         sb.append(
393             "<column><column-name>classPK</column-name><column-value><![CDATA[");
394         sb.append(getClassPK());
395         sb.append("]]></column-value></column>");
396         sb.append(
397             "<column><column-name>data</column-name><column-value><![CDATA[");
398         sb.append(getData());
399         sb.append("]]></column-value></column>");
400 
401         sb.append("</model>");
402 
403         return sb.toString();
404     }
405 
406     private long _valueId;
407     private long _tableId;
408     private long _originalTableId;
409     private boolean _setOriginalTableId;
410     private long _columnId;
411     private long _originalColumnId;
412     private boolean _setOriginalColumnId;
413     private long _rowId;
414     private long _originalRowId;
415     private boolean _setOriginalRowId;
416     private long _classNameId;
417     private long _classPK;
418     private long _originalClassPK;
419     private boolean _setOriginalClassPK;
420     private String _data;
421 }