001    /**
002     * Copyright (c) 2000-2011 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                    if (!_setOriginalTableId) {
158                            _setOriginalTableId = true;
159    
160                            _originalTableId = _tableId;
161                    }
162    
163                    _tableId = tableId;
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                    if (!_setOriginalColumnId) {
176                            _setOriginalColumnId = true;
177    
178                            _originalColumnId = _columnId;
179                    }
180    
181                    _columnId = columnId;
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                    if (!_setOriginalRowId) {
194                            _setOriginalRowId = true;
195    
196                            _originalRowId = _rowId;
197                    }
198    
199                    _rowId = rowId;
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                    if (!_setOriginalClassPK) {
228                            _setOriginalClassPK = true;
229    
230                            _originalClassPK = _classPK;
231                    }
232    
233                    _classPK = classPK;
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 expandoValueImpl = new ExpandoValueImpl();
266    
267                    expandoValueImpl.setValueId(getValueId());
268    
269                    expandoValueImpl.setCompanyId(getCompanyId());
270    
271                    expandoValueImpl.setTableId(getTableId());
272    
273                    ExpandoValueModelImpl expandoValueModelImpl = expandoValueImpl;
274    
275                    expandoValueModelImpl._originalTableId = expandoValueModelImpl._tableId;
276    
277                    expandoValueModelImpl._setOriginalTableId = false;
278                    expandoValueImpl.setColumnId(getColumnId());
279    
280                    expandoValueModelImpl._originalColumnId = expandoValueModelImpl._columnId;
281    
282                    expandoValueModelImpl._setOriginalColumnId = false;
283                    expandoValueImpl.setRowId(getRowId());
284    
285                    expandoValueModelImpl._originalRowId = expandoValueModelImpl._rowId;
286    
287                    expandoValueModelImpl._setOriginalRowId = false;
288                    expandoValueImpl.setClassNameId(getClassNameId());
289    
290                    expandoValueImpl.setClassPK(getClassPK());
291    
292                    expandoValueModelImpl._originalClassPK = expandoValueModelImpl._classPK;
293    
294                    expandoValueModelImpl._setOriginalClassPK = false;
295                    expandoValueImpl.setData(getData());
296    
297                    return expandoValueImpl;
298            }
299    
300            public int compareTo(ExpandoValue expandoValue) {
301                    int value = 0;
302    
303                    if (getTableId() < expandoValue.getTableId()) {
304                            value = -1;
305                    }
306                    else if (getTableId() > expandoValue.getTableId()) {
307                            value = 1;
308                    }
309                    else {
310                            value = 0;
311                    }
312    
313                    if (value != 0) {
314                            return value;
315                    }
316    
317                    if (getRowId() < expandoValue.getRowId()) {
318                            value = -1;
319                    }
320                    else if (getRowId() > expandoValue.getRowId()) {
321                            value = 1;
322                    }
323                    else {
324                            value = 0;
325                    }
326    
327                    if (value != 0) {
328                            return value;
329                    }
330    
331                    if (getColumnId() < expandoValue.getColumnId()) {
332                            value = -1;
333                    }
334                    else if (getColumnId() > expandoValue.getColumnId()) {
335                            value = 1;
336                    }
337                    else {
338                            value = 0;
339                    }
340    
341                    if (value != 0) {
342                            return value;
343                    }
344    
345                    return 0;
346            }
347    
348            public boolean equals(Object obj) {
349                    if (obj == null) {
350                            return false;
351                    }
352    
353                    ExpandoValue expandoValue = null;
354    
355                    try {
356                            expandoValue = (ExpandoValue)obj;
357                    }
358                    catch (ClassCastException cce) {
359                            return false;
360                    }
361    
362                    long pk = expandoValue.getPrimaryKey();
363    
364                    if (getPrimaryKey() == pk) {
365                            return true;
366                    }
367                    else {
368                            return false;
369                    }
370            }
371    
372            public int hashCode() {
373                    return (int)getPrimaryKey();
374            }
375    
376            public String toString() {
377                    StringBundler sb = new StringBundler(17);
378    
379                    sb.append("{valueId=");
380                    sb.append(getValueId());
381                    sb.append(", companyId=");
382                    sb.append(getCompanyId());
383                    sb.append(", tableId=");
384                    sb.append(getTableId());
385                    sb.append(", columnId=");
386                    sb.append(getColumnId());
387                    sb.append(", rowId=");
388                    sb.append(getRowId());
389                    sb.append(", classNameId=");
390                    sb.append(getClassNameId());
391                    sb.append(", classPK=");
392                    sb.append(getClassPK());
393                    sb.append(", data=");
394                    sb.append(getData());
395                    sb.append("}");
396    
397                    return sb.toString();
398            }
399    
400            public String toXmlString() {
401                    StringBundler sb = new StringBundler(28);
402    
403                    sb.append("<model><model-name>");
404                    sb.append("com.liferay.portlet.expando.model.ExpandoValue");
405                    sb.append("</model-name>");
406    
407                    sb.append(
408                            "<column><column-name>valueId</column-name><column-value><![CDATA[");
409                    sb.append(getValueId());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
413                    sb.append(getCompanyId());
414                    sb.append("]]></column-value></column>");
415                    sb.append(
416                            "<column><column-name>tableId</column-name><column-value><![CDATA[");
417                    sb.append(getTableId());
418                    sb.append("]]></column-value></column>");
419                    sb.append(
420                            "<column><column-name>columnId</column-name><column-value><![CDATA[");
421                    sb.append(getColumnId());
422                    sb.append("]]></column-value></column>");
423                    sb.append(
424                            "<column><column-name>rowId</column-name><column-value><![CDATA[");
425                    sb.append(getRowId());
426                    sb.append("]]></column-value></column>");
427                    sb.append(
428                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
429                    sb.append(getClassNameId());
430                    sb.append("]]></column-value></column>");
431                    sb.append(
432                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
433                    sb.append(getClassPK());
434                    sb.append("]]></column-value></column>");
435                    sb.append(
436                            "<column><column-name>data</column-name><column-value><![CDATA[");
437                    sb.append(getData());
438                    sb.append("]]></column-value></column>");
439    
440                    sb.append("</model>");
441    
442                    return sb.toString();
443            }
444    
445            private long _valueId;
446            private long _companyId;
447            private long _tableId;
448            private long _originalTableId;
449            private boolean _setOriginalTableId;
450            private long _columnId;
451            private long _originalColumnId;
452            private boolean _setOriginalColumnId;
453            private long _rowId;
454            private long _originalRowId;
455            private boolean _setOriginalRowId;
456            private long _classNameId;
457            private long _classPK;
458            private long _originalClassPK;
459            private boolean _setOriginalClassPK;
460            private String _data;
461    }