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