1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.StringBundler;
29  import com.liferay.portal.kernel.util.StringPool;
30  import com.liferay.portal.model.impl.BaseModelImpl;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.expando.model.ExpandoValue;
34  import com.liferay.portlet.expando.model.ExpandoValueSoap;
35  
36  import java.io.Serializable;
37  
38  import java.lang.reflect.Proxy;
39  
40  import java.sql.Types;
41  
42  import java.util.ArrayList;
43  import java.util.List;
44  
45  /**
46   * <a href="ExpandoValueModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This interface is a model that represents the ExpandoValue table in the
55   * database.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       ExpandoValueImpl
60   * @see       com.liferay.portlet.expando.model.ExpandoValue
61   * @see       com.liferay.portlet.expando.model.ExpandoValueModel
62   * @generated
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              { "companyId", new Integer(Types.BIGINT) },
69              { "tableId", new Integer(Types.BIGINT) },
70              { "columnId", new Integer(Types.BIGINT) },
71              { "rowId_", new Integer(Types.BIGINT) },
72              { "classNameId", new Integer(Types.BIGINT) },
73              { "classPK", new Integer(Types.BIGINT) },
74              { "data_", new Integer(Types.VARCHAR) }
75          };
76      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)";
77      public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
78      public static final String ORDER_BY_JPQL = " ORDER BY expandoValue.tableId ASC, expandoValue.rowId ASC, expandoValue.columnId ASC";
79      public static final String ORDER_BY_SQL = " ORDER BY ExpandoValue.tableId ASC, ExpandoValue.rowId_ ASC, ExpandoValue.columnId ASC";
80      public static final String DATA_SOURCE = "liferayDataSource";
81      public static final String SESSION_FACTORY = "liferaySessionFactory";
82      public static final String TX_MANAGER = "liferayTransactionManager";
83      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
85              true);
86      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
88              true);
89  
90      public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
91          ExpandoValue model = new ExpandoValueImpl();
92  
93          model.setValueId(soapModel.getValueId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setTableId(soapModel.getTableId());
96          model.setColumnId(soapModel.getColumnId());
97          model.setRowId(soapModel.getRowId());
98          model.setClassNameId(soapModel.getClassNameId());
99          model.setClassPK(soapModel.getClassPK());
100         model.setData(soapModel.getData());
101 
102         return model;
103     }
104 
105     public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
106         List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
107 
108         for (ExpandoValueSoap soapModel : soapModels) {
109             models.add(toModel(soapModel));
110         }
111 
112         return models;
113     }
114 
115     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
116                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
117 
118     public ExpandoValueModelImpl() {
119     }
120 
121     public long getPrimaryKey() {
122         return _valueId;
123     }
124 
125     public void setPrimaryKey(long pk) {
126         setValueId(pk);
127     }
128 
129     public Serializable getPrimaryKeyObj() {
130         return new Long(_valueId);
131     }
132 
133     public long getValueId() {
134         return _valueId;
135     }
136 
137     public void setValueId(long valueId) {
138         _valueId = valueId;
139     }
140 
141     public long getCompanyId() {
142         return _companyId;
143     }
144 
145     public void setCompanyId(long companyId) {
146         _companyId = companyId;
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.setCompanyId(getCompanyId());
257             model.setTableId(getTableId());
258             model.setColumnId(getColumnId());
259             model.setRowId(getRowId());
260             model.setClassNameId(getClassNameId());
261             model.setClassPK(getClassPK());
262             model.setData(HtmlUtil.escape(getData()));
263 
264             model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
265                     new Class[] { ExpandoValue.class },
266                     new ReadOnlyBeanHandler(model));
267 
268             return model;
269         }
270     }
271 
272     public Object clone() {
273         ExpandoValueImpl clone = new ExpandoValueImpl();
274 
275         clone.setValueId(getValueId());
276         clone.setCompanyId(getCompanyId());
277         clone.setTableId(getTableId());
278         clone.setColumnId(getColumnId());
279         clone.setRowId(getRowId());
280         clone.setClassNameId(getClassNameId());
281         clone.setClassPK(getClassPK());
282         clone.setData(getData());
283 
284         return clone;
285     }
286 
287     public int compareTo(ExpandoValue expandoValue) {
288         int value = 0;
289 
290         if (getTableId() < expandoValue.getTableId()) {
291             value = -1;
292         }
293         else if (getTableId() > expandoValue.getTableId()) {
294             value = 1;
295         }
296         else {
297             value = 0;
298         }
299 
300         if (value != 0) {
301             return value;
302         }
303 
304         if (getRowId() < expandoValue.getRowId()) {
305             value = -1;
306         }
307         else if (getRowId() > expandoValue.getRowId()) {
308             value = 1;
309         }
310         else {
311             value = 0;
312         }
313 
314         if (value != 0) {
315             return value;
316         }
317 
318         if (getColumnId() < expandoValue.getColumnId()) {
319             value = -1;
320         }
321         else if (getColumnId() > expandoValue.getColumnId()) {
322             value = 1;
323         }
324         else {
325             value = 0;
326         }
327 
328         if (value != 0) {
329             return value;
330         }
331 
332         return 0;
333     }
334 
335     public boolean equals(Object obj) {
336         if (obj == null) {
337             return false;
338         }
339 
340         ExpandoValue expandoValue = null;
341 
342         try {
343             expandoValue = (ExpandoValue)obj;
344         }
345         catch (ClassCastException cce) {
346             return false;
347         }
348 
349         long pk = expandoValue.getPrimaryKey();
350 
351         if (getPrimaryKey() == pk) {
352             return true;
353         }
354         else {
355             return false;
356         }
357     }
358 
359     public int hashCode() {
360         return (int)getPrimaryKey();
361     }
362 
363     public String toString() {
364         StringBundler sb = new StringBundler(17);
365 
366         sb.append("{valueId=");
367         sb.append(getValueId());
368         sb.append(", companyId=");
369         sb.append(getCompanyId());
370         sb.append(", tableId=");
371         sb.append(getTableId());
372         sb.append(", columnId=");
373         sb.append(getColumnId());
374         sb.append(", rowId=");
375         sb.append(getRowId());
376         sb.append(", classNameId=");
377         sb.append(getClassNameId());
378         sb.append(", classPK=");
379         sb.append(getClassPK());
380         sb.append(", data=");
381         sb.append(getData());
382         sb.append("}");
383 
384         return sb.toString();
385     }
386 
387     public String toXmlString() {
388         StringBundler sb = new StringBundler(28);
389 
390         sb.append("<model><model-name>");
391         sb.append("com.liferay.portlet.expando.model.ExpandoValue");
392         sb.append("</model-name>");
393 
394         sb.append(
395             "<column><column-name>valueId</column-name><column-value><![CDATA[");
396         sb.append(getValueId());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>companyId</column-name><column-value><![CDATA[");
400         sb.append(getCompanyId());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>tableId</column-name><column-value><![CDATA[");
404         sb.append(getTableId());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>columnId</column-name><column-value><![CDATA[");
408         sb.append(getColumnId());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>rowId</column-name><column-value><![CDATA[");
412         sb.append(getRowId());
413         sb.append("]]></column-value></column>");
414         sb.append(
415             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
416         sb.append(getClassNameId());
417         sb.append("]]></column-value></column>");
418         sb.append(
419             "<column><column-name>classPK</column-name><column-value><![CDATA[");
420         sb.append(getClassPK());
421         sb.append("]]></column-value></column>");
422         sb.append(
423             "<column><column-name>data</column-name><column-value><![CDATA[");
424         sb.append(getData());
425         sb.append("]]></column-value></column>");
426 
427         sb.append("</model>");
428 
429         return sb.toString();
430     }
431 
432     private long _valueId;
433     private long _companyId;
434     private long _tableId;
435     private long _originalTableId;
436     private boolean _setOriginalTableId;
437     private long _columnId;
438     private long _originalColumnId;
439     private boolean _setOriginalColumnId;
440     private long _rowId;
441     private long _originalRowId;
442     private boolean _setOriginalRowId;
443     private long _classNameId;
444     private long _classPK;
445     private long _originalClassPK;
446     private boolean _setOriginalClassPK;
447     private String _data;
448 }