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