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.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              { "companyId", new Integer(Types.BIGINT) },
61              { "tableId", new Integer(Types.BIGINT) },
62              { "columnId", new Integer(Types.BIGINT) },
63              { "rowId_", new Integer(Types.BIGINT) },
64              { "classNameId", new Integer(Types.BIGINT) },
65              { "classPK", new Integer(Types.BIGINT) },
66              { "data_", new Integer(Types.VARCHAR) }
67          };
68      public static final String TABLE_SQL_CREATE = "create table ExpandoValue (valueId LONG not null primary key,companyId LONG,tableId LONG,columnId LONG,rowId_ LONG,classNameId LONG,classPK LONG,data_ STRING null)";
69      public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
70      public static final String ORDER_BY_JPQL = " ORDER BY expandoValue.tableId ASC, expandoValue.rowId ASC, expandoValue.columnId ASC";
71      public static final String ORDER_BY_SQL = " ORDER BY ExpandoValue.tableId ASC, ExpandoValue.rowId_ ASC, ExpandoValue.columnId ASC";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
80              true);
81  
82      public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
83          ExpandoValue model = new ExpandoValueImpl();
84  
85          model.setValueId(soapModel.getValueId());
86          model.setCompanyId(soapModel.getCompanyId());
87          model.setTableId(soapModel.getTableId());
88          model.setColumnId(soapModel.getColumnId());
89          model.setRowId(soapModel.getRowId());
90          model.setClassNameId(soapModel.getClassNameId());
91          model.setClassPK(soapModel.getClassPK());
92          model.setData(soapModel.getData());
93  
94          return model;
95      }
96  
97      public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
98          List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
99  
100         for (ExpandoValueSoap 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.portlet.expando.model.ExpandoValue"));
109 
110     public ExpandoValueModelImpl() {
111     }
112 
113     public long getPrimaryKey() {
114         return _valueId;
115     }
116 
117     public void setPrimaryKey(long pk) {
118         setValueId(pk);
119     }
120 
121     public Serializable getPrimaryKeyObj() {
122         return new Long(_valueId);
123     }
124 
125     public long getValueId() {
126         return _valueId;
127     }
128 
129     public void setValueId(long valueId) {
130         _valueId = valueId;
131     }
132 
133     public long getCompanyId() {
134         return _companyId;
135     }
136 
137     public void setCompanyId(long companyId) {
138         _companyId = companyId;
139     }
140 
141     public long getTableId() {
142         return _tableId;
143     }
144 
145     public void setTableId(long tableId) {
146         _tableId = tableId;
147 
148         if (!_setOriginalTableId) {
149             _setOriginalTableId = true;
150 
151             _originalTableId = tableId;
152         }
153     }
154 
155     public long getOriginalTableId() {
156         return _originalTableId;
157     }
158 
159     public long getColumnId() {
160         return _columnId;
161     }
162 
163     public void setColumnId(long columnId) {
164         _columnId = columnId;
165 
166         if (!_setOriginalColumnId) {
167             _setOriginalColumnId = true;
168 
169             _originalColumnId = columnId;
170         }
171     }
172 
173     public long getOriginalColumnId() {
174         return _originalColumnId;
175     }
176 
177     public long getRowId() {
178         return _rowId;
179     }
180 
181     public void setRowId(long rowId) {
182         _rowId = rowId;
183 
184         if (!_setOriginalRowId) {
185             _setOriginalRowId = true;
186 
187             _originalRowId = rowId;
188         }
189     }
190 
191     public long getOriginalRowId() {
192         return _originalRowId;
193     }
194 
195     public String getClassName() {
196         if (getClassNameId() <= 0) {
197             return StringPool.BLANK;
198         }
199 
200         return PortalUtil.getClassName(getClassNameId());
201     }
202 
203     public long getClassNameId() {
204         return _classNameId;
205     }
206 
207     public void setClassNameId(long classNameId) {
208         _classNameId = classNameId;
209     }
210 
211     public long getClassPK() {
212         return _classPK;
213     }
214 
215     public void setClassPK(long classPK) {
216         _classPK = classPK;
217 
218         if (!_setOriginalClassPK) {
219             _setOriginalClassPK = true;
220 
221             _originalClassPK = classPK;
222         }
223     }
224 
225     public long getOriginalClassPK() {
226         return _originalClassPK;
227     }
228 
229     public String getData() {
230         return GetterUtil.getString(_data);
231     }
232 
233     public void setData(String data) {
234         _data = data;
235     }
236 
237     public ExpandoValue toEscapedModel() {
238         if (isEscapedModel()) {
239             return (ExpandoValue)this;
240         }
241         else {
242             ExpandoValue model = new ExpandoValueImpl();
243 
244             model.setNew(isNew());
245             model.setEscapedModel(true);
246 
247             model.setValueId(getValueId());
248             model.setCompanyId(getCompanyId());
249             model.setTableId(getTableId());
250             model.setColumnId(getColumnId());
251             model.setRowId(getRowId());
252             model.setClassNameId(getClassNameId());
253             model.setClassPK(getClassPK());
254             model.setData(HtmlUtil.escape(getData()));
255 
256             model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
257                     new Class[] { ExpandoValue.class },
258                     new ReadOnlyBeanHandler(model));
259 
260             return model;
261         }
262     }
263 
264     public Object clone() {
265         ExpandoValueImpl clone = new ExpandoValueImpl();
266 
267         clone.setValueId(getValueId());
268         clone.setCompanyId(getCompanyId());
269         clone.setTableId(getTableId());
270         clone.setColumnId(getColumnId());
271         clone.setRowId(getRowId());
272         clone.setClassNameId(getClassNameId());
273         clone.setClassPK(getClassPK());
274         clone.setData(getData());
275 
276         return clone;
277     }
278 
279     public int compareTo(ExpandoValue expandoValue) {
280         int value = 0;
281 
282         if (getTableId() < expandoValue.getTableId()) {
283             value = -1;
284         }
285         else if (getTableId() > expandoValue.getTableId()) {
286             value = 1;
287         }
288         else {
289             value = 0;
290         }
291 
292         if (value != 0) {
293             return value;
294         }
295 
296         if (getRowId() < expandoValue.getRowId()) {
297             value = -1;
298         }
299         else if (getRowId() > expandoValue.getRowId()) {
300             value = 1;
301         }
302         else {
303             value = 0;
304         }
305 
306         if (value != 0) {
307             return value;
308         }
309 
310         if (getColumnId() < expandoValue.getColumnId()) {
311             value = -1;
312         }
313         else if (getColumnId() > expandoValue.getColumnId()) {
314             value = 1;
315         }
316         else {
317             value = 0;
318         }
319 
320         if (value != 0) {
321             return value;
322         }
323 
324         return 0;
325     }
326 
327     public boolean equals(Object obj) {
328         if (obj == null) {
329             return false;
330         }
331 
332         ExpandoValue expandoValue = null;
333 
334         try {
335             expandoValue = (ExpandoValue)obj;
336         }
337         catch (ClassCastException cce) {
338             return false;
339         }
340 
341         long pk = expandoValue.getPrimaryKey();
342 
343         if (getPrimaryKey() == pk) {
344             return true;
345         }
346         else {
347             return false;
348         }
349     }
350 
351     public int hashCode() {
352         return (int)getPrimaryKey();
353     }
354 
355     public String toString() {
356         StringBundler sb = new StringBundler(17);
357 
358         sb.append("{valueId=");
359         sb.append(getValueId());
360         sb.append(", companyId=");
361         sb.append(getCompanyId());
362         sb.append(", tableId=");
363         sb.append(getTableId());
364         sb.append(", columnId=");
365         sb.append(getColumnId());
366         sb.append(", rowId=");
367         sb.append(getRowId());
368         sb.append(", classNameId=");
369         sb.append(getClassNameId());
370         sb.append(", classPK=");
371         sb.append(getClassPK());
372         sb.append(", data=");
373         sb.append(getData());
374         sb.append("}");
375 
376         return sb.toString();
377     }
378 
379     public String toXmlString() {
380         StringBundler sb = new StringBundler(28);
381 
382         sb.append("<model><model-name>");
383         sb.append("com.liferay.portlet.expando.model.ExpandoValue");
384         sb.append("</model-name>");
385 
386         sb.append(
387             "<column><column-name>valueId</column-name><column-value><![CDATA[");
388         sb.append(getValueId());
389         sb.append("]]></column-value></column>");
390         sb.append(
391             "<column><column-name>companyId</column-name><column-value><![CDATA[");
392         sb.append(getCompanyId());
393         sb.append("]]></column-value></column>");
394         sb.append(
395             "<column><column-name>tableId</column-name><column-value><![CDATA[");
396         sb.append(getTableId());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>columnId</column-name><column-value><![CDATA[");
400         sb.append(getColumnId());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>rowId</column-name><column-value><![CDATA[");
404         sb.append(getRowId());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
408         sb.append(getClassNameId());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>classPK</column-name><column-value><![CDATA[");
412         sb.append(getClassPK());
413         sb.append("]]></column-value></column>");
414         sb.append(
415             "<column><column-name>data</column-name><column-value><![CDATA[");
416         sb.append(getData());
417         sb.append("]]></column-value></column>");
418 
419         sb.append("</model>");
420 
421         return sb.toString();
422     }
423 
424     private long _valueId;
425     private long _companyId;
426     private long _tableId;
427     private long _originalTableId;
428     private boolean _setOriginalTableId;
429     private long _columnId;
430     private long _originalColumnId;
431     private boolean _setOriginalColumnId;
432     private long _rowId;
433     private long _originalRowId;
434     private boolean _setOriginalRowId;
435     private long _classNameId;
436     private long _classPK;
437     private long _originalClassPK;
438     private boolean _setOriginalClassPK;
439     private String _data;
440 }