001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.expando.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.util.PortalUtil;
023    
024    import com.liferay.portlet.expando.model.ExpandoValue;
025    import com.liferay.portlet.expando.model.ExpandoValueModel;
026    import com.liferay.portlet.expando.model.ExpandoValueSoap;
027    
028    import java.io.Serializable;
029    
030    import java.lang.reflect.Proxy;
031    
032    import java.sql.Types;
033    
034    import java.util.ArrayList;
035    import java.util.List;
036    
037    /**
038     * The base model implementation for the ExpandoValue service. Represents a row in the "ExpandoValue" database table, with each column mapped to a property of this class.
039     *
040     * <p>
041     * This implementation and its corresponding interface {@link com.liferay.portlet.expando.model.ExpandoValueModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ExpandoValueImpl}.
042     * </p>
043     *
044     * <p>
045     * Never modify or reference this class directly. All methods that expect a expando value model instance should use the {@link com.liferay.portlet.expando.model.ExpandoValue} interface instead.
046     * </p>
047     *
048     * @author Brian Wing Shun Chan
049     * @see ExpandoValueImpl
050     * @see com.liferay.portlet.expando.model.ExpandoValue
051     * @see com.liferay.portlet.expando.model.ExpandoValueModel
052     * @generated
053     */
054    public class ExpandoValueModelImpl extends BaseModelImpl<ExpandoValue>
055            implements ExpandoValueModel {
056            public static final String TABLE_NAME = "ExpandoValue";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "valueId", new Integer(Types.BIGINT) },
059                            { "companyId", new Integer(Types.BIGINT) },
060                            { "tableId", new Integer(Types.BIGINT) },
061                            { "columnId", new Integer(Types.BIGINT) },
062                            { "rowId_", new Integer(Types.BIGINT) },
063                            { "classNameId", new Integer(Types.BIGINT) },
064                            { "classPK", new Integer(Types.BIGINT) },
065                            { "data_", new Integer(Types.VARCHAR) }
066                    };
067            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)";
068            public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
069            public static final String ORDER_BY_JPQL = " ORDER BY expandoValue.tableId ASC, expandoValue.rowId ASC, expandoValue.columnId ASC";
070            public static final String ORDER_BY_SQL = " ORDER BY ExpandoValue.tableId ASC, ExpandoValue.rowId_ ASC, ExpandoValue.columnId ASC";
071            public static final String DATA_SOURCE = "liferayDataSource";
072            public static final String SESSION_FACTORY = "liferaySessionFactory";
073            public static final String TX_MANAGER = "liferayTransactionManager";
074            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
076                            true);
077            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
079                            true);
080    
081            /**
082             * Converts the soap model instance into a normal model instance.
083             *
084             * @param soapModel the soap model instance to convert
085             * @return the normal model instance
086             */
087            public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
088                    ExpandoValue model = new ExpandoValueImpl();
089    
090                    model.setValueId(soapModel.getValueId());
091                    model.setCompanyId(soapModel.getCompanyId());
092                    model.setTableId(soapModel.getTableId());
093                    model.setColumnId(soapModel.getColumnId());
094                    model.setRowId(soapModel.getRowId());
095                    model.setClassNameId(soapModel.getClassNameId());
096                    model.setClassPK(soapModel.getClassPK());
097                    model.setData(soapModel.getData());
098    
099                    return model;
100            }
101    
102            /**
103             * Converts the soap model instances into normal model instances.
104             *
105             * @param soapModels the soap model instances to convert
106             * @return the normal model instances
107             */
108            public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
109                    List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
110    
111                    for (ExpandoValueSoap soapModel : soapModels) {
112                            models.add(toModel(soapModel));
113                    }
114    
115                    return models;
116            }
117    
118            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
119                                    "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
120    
121            public ExpandoValueModelImpl() {
122            }
123    
124            public long getPrimaryKey() {
125                    return _valueId;
126            }
127    
128            public void setPrimaryKey(long pk) {
129                    setValueId(pk);
130            }
131    
132            public Serializable getPrimaryKeyObj() {
133                    return new Long(_valueId);
134            }
135    
136            public long getValueId() {
137                    return _valueId;
138            }
139    
140            public void setValueId(long valueId) {
141                    _valueId = valueId;
142            }
143    
144            public long getCompanyId() {
145                    return _companyId;
146            }
147    
148            public void setCompanyId(long companyId) {
149                    _companyId = companyId;
150            }
151    
152            public long getTableId() {
153                    return _tableId;
154            }
155    
156            public void setTableId(long tableId) {
157                    _tableId = tableId;
158    
159                    if (!_setOriginalTableId) {
160                            _setOriginalTableId = true;
161    
162                            _originalTableId = tableId;
163                    }
164            }
165    
166            public long getOriginalTableId() {
167                    return _originalTableId;
168            }
169    
170            public long getColumnId() {
171                    return _columnId;
172            }
173    
174            public void setColumnId(long columnId) {
175                    _columnId = columnId;
176    
177                    if (!_setOriginalColumnId) {
178                            _setOriginalColumnId = true;
179    
180                            _originalColumnId = columnId;
181                    }
182            }
183    
184            public long getOriginalColumnId() {
185                    return _originalColumnId;
186            }
187    
188            public long getRowId() {
189                    return _rowId;
190            }
191    
192            public void setRowId(long rowId) {
193                    _rowId = rowId;
194    
195                    if (!_setOriginalRowId) {
196                            _setOriginalRowId = true;
197    
198                            _originalRowId = rowId;
199                    }
200            }
201    
202            public long getOriginalRowId() {
203                    return _originalRowId;
204            }
205    
206            public String getClassName() {
207                    if (getClassNameId() <= 0) {
208                            return StringPool.BLANK;
209                    }
210    
211                    return PortalUtil.getClassName(getClassNameId());
212            }
213    
214            public long getClassNameId() {
215                    return _classNameId;
216            }
217    
218            public void setClassNameId(long classNameId) {
219                    _classNameId = classNameId;
220            }
221    
222            public long getClassPK() {
223                    return _classPK;
224            }
225    
226            public void setClassPK(long classPK) {
227                    _classPK = classPK;
228    
229                    if (!_setOriginalClassPK) {
230                            _setOriginalClassPK = true;
231    
232                            _originalClassPK = classPK;
233                    }
234            }
235    
236            public long getOriginalClassPK() {
237                    return _originalClassPK;
238            }
239    
240            public String getData() {
241                    if (_data == null) {
242                            return StringPool.BLANK;
243                    }
244                    else {
245                            return _data;
246                    }
247            }
248    
249            public void setData(String data) {
250                    _data = data;
251            }
252    
253            public ExpandoValue toEscapedModel() {
254                    if (isEscapedModel()) {
255                            return (ExpandoValue)this;
256                    }
257                    else {
258                            return (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
259                                    new Class[] { ExpandoValue.class },
260                                    new AutoEscapeBeanHandler(this));
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    }