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