001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    
026    import com.liferay.portlet.expando.model.ExpandoRow;
027    import com.liferay.portlet.expando.model.ExpandoRowModel;
028    
029    import java.io.Serializable;
030    
031    import java.sql.Types;
032    
033    import java.util.Date;
034    import java.util.HashMap;
035    import java.util.Map;
036    
037    /**
038     * The base model implementation for the ExpandoRow service. Represents a row in the "ExpandoRow" database table, with each column mapped to a property of this class.
039     *
040     * <p>
041     * This implementation and its corresponding interface {@link ExpandoRowModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ExpandoRowImpl}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see ExpandoRowImpl
046     * @see ExpandoRow
047     * @see ExpandoRowModel
048     * @generated
049     */
050    @ProviderType
051    public class ExpandoRowModelImpl extends BaseModelImpl<ExpandoRow>
052            implements ExpandoRowModel {
053            /*
054             * NOTE FOR DEVELOPERS:
055             *
056             * Never modify or reference this class directly. All methods that expect a expando row model instance should use the {@link ExpandoRow} interface instead.
057             */
058            public static final String TABLE_NAME = "ExpandoRow";
059            public static final Object[][] TABLE_COLUMNS = {
060                            { "rowId_", Types.BIGINT },
061                            { "companyId", Types.BIGINT },
062                            { "modifiedDate", Types.TIMESTAMP },
063                            { "tableId", Types.BIGINT },
064                            { "classPK", Types.BIGINT }
065                    };
066            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
067    
068            static {
069                    TABLE_COLUMNS_MAP.put("rowId_", Types.BIGINT);
070                    TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
071                    TABLE_COLUMNS_MAP.put("modifiedDate", Types.TIMESTAMP);
072                    TABLE_COLUMNS_MAP.put("tableId", Types.BIGINT);
073                    TABLE_COLUMNS_MAP.put("classPK", Types.BIGINT);
074            }
075    
076            public static final String TABLE_SQL_CREATE = "create table ExpandoRow (rowId_ LONG not null primary key,companyId LONG,modifiedDate DATE null,tableId LONG,classPK LONG)";
077            public static final String TABLE_SQL_DROP = "drop table ExpandoRow";
078            public static final String ORDER_BY_JPQL = " ORDER BY expandoRow.rowId ASC";
079            public static final String ORDER_BY_SQL = " ORDER BY ExpandoRow.rowId_ ASC";
080            public static final String DATA_SOURCE = "liferayDataSource";
081            public static final String SESSION_FACTORY = "liferaySessionFactory";
082            public static final String TX_MANAGER = "liferayTransactionManager";
083            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
085                            true);
086            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
088                            true);
089            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.column.bitmask.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
091                            true);
092            public static final long CLASSPK_COLUMN_BITMASK = 1L;
093            public static final long TABLEID_COLUMN_BITMASK = 2L;
094            public static final long ROWID_COLUMN_BITMASK = 4L;
095            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
096                                    "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoRow"));
097    
098            public ExpandoRowModelImpl() {
099            }
100    
101            @Override
102            public long getPrimaryKey() {
103                    return _rowId;
104            }
105    
106            @Override
107            public void setPrimaryKey(long primaryKey) {
108                    setRowId(primaryKey);
109            }
110    
111            @Override
112            public Serializable getPrimaryKeyObj() {
113                    return _rowId;
114            }
115    
116            @Override
117            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
118                    setPrimaryKey(((Long)primaryKeyObj).longValue());
119            }
120    
121            @Override
122            public Class<?> getModelClass() {
123                    return ExpandoRow.class;
124            }
125    
126            @Override
127            public String getModelClassName() {
128                    return ExpandoRow.class.getName();
129            }
130    
131            @Override
132            public Map<String, Object> getModelAttributes() {
133                    Map<String, Object> attributes = new HashMap<String, Object>();
134    
135                    attributes.put("rowId", getRowId());
136                    attributes.put("companyId", getCompanyId());
137                    attributes.put("modifiedDate", getModifiedDate());
138                    attributes.put("tableId", getTableId());
139                    attributes.put("classPK", getClassPK());
140    
141                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
142                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
143    
144                    return attributes;
145            }
146    
147            @Override
148            public void setModelAttributes(Map<String, Object> attributes) {
149                    Long rowId = (Long)attributes.get("rowId");
150    
151                    if (rowId != null) {
152                            setRowId(rowId);
153                    }
154    
155                    Long companyId = (Long)attributes.get("companyId");
156    
157                    if (companyId != null) {
158                            setCompanyId(companyId);
159                    }
160    
161                    Date modifiedDate = (Date)attributes.get("modifiedDate");
162    
163                    if (modifiedDate != null) {
164                            setModifiedDate(modifiedDate);
165                    }
166    
167                    Long tableId = (Long)attributes.get("tableId");
168    
169                    if (tableId != null) {
170                            setTableId(tableId);
171                    }
172    
173                    Long classPK = (Long)attributes.get("classPK");
174    
175                    if (classPK != null) {
176                            setClassPK(classPK);
177                    }
178            }
179    
180            @Override
181            public long getRowId() {
182                    return _rowId;
183            }
184    
185            @Override
186            public void setRowId(long rowId) {
187                    _rowId = rowId;
188            }
189    
190            @Override
191            public long getCompanyId() {
192                    return _companyId;
193            }
194    
195            @Override
196            public void setCompanyId(long companyId) {
197                    _companyId = companyId;
198            }
199    
200            @Override
201            public Date getModifiedDate() {
202                    return _modifiedDate;
203            }
204    
205            @Override
206            public void setModifiedDate(Date modifiedDate) {
207                    _modifiedDate = modifiedDate;
208            }
209    
210            @Override
211            public long getTableId() {
212                    return _tableId;
213            }
214    
215            @Override
216            public void setTableId(long tableId) {
217                    _columnBitmask |= TABLEID_COLUMN_BITMASK;
218    
219                    if (!_setOriginalTableId) {
220                            _setOriginalTableId = true;
221    
222                            _originalTableId = _tableId;
223                    }
224    
225                    _tableId = tableId;
226            }
227    
228            public long getOriginalTableId() {
229                    return _originalTableId;
230            }
231    
232            @Override
233            public long getClassPK() {
234                    return _classPK;
235            }
236    
237            @Override
238            public void setClassPK(long classPK) {
239                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
240    
241                    if (!_setOriginalClassPK) {
242                            _setOriginalClassPK = true;
243    
244                            _originalClassPK = _classPK;
245                    }
246    
247                    _classPK = classPK;
248            }
249    
250            public long getOriginalClassPK() {
251                    return _originalClassPK;
252            }
253    
254            public long getColumnBitmask() {
255                    return _columnBitmask;
256            }
257    
258            @Override
259            public ExpandoRow toEscapedModel() {
260                    if (_escapedModel == null) {
261                            _escapedModel = (ExpandoRow)ProxyUtil.newProxyInstance(_classLoader,
262                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
263                    }
264    
265                    return _escapedModel;
266            }
267    
268            @Override
269            public Object clone() {
270                    ExpandoRowImpl expandoRowImpl = new ExpandoRowImpl();
271    
272                    expandoRowImpl.setRowId(getRowId());
273                    expandoRowImpl.setCompanyId(getCompanyId());
274                    expandoRowImpl.setModifiedDate(getModifiedDate());
275                    expandoRowImpl.setTableId(getTableId());
276                    expandoRowImpl.setClassPK(getClassPK());
277    
278                    expandoRowImpl.resetOriginalValues();
279    
280                    return expandoRowImpl;
281            }
282    
283            @Override
284            public int compareTo(ExpandoRow expandoRow) {
285                    long primaryKey = expandoRow.getPrimaryKey();
286    
287                    if (getPrimaryKey() < primaryKey) {
288                            return -1;
289                    }
290                    else if (getPrimaryKey() > primaryKey) {
291                            return 1;
292                    }
293                    else {
294                            return 0;
295                    }
296            }
297    
298            @Override
299            public boolean equals(Object obj) {
300                    if (this == obj) {
301                            return true;
302                    }
303    
304                    if (!(obj instanceof ExpandoRow)) {
305                            return false;
306                    }
307    
308                    ExpandoRow expandoRow = (ExpandoRow)obj;
309    
310                    long primaryKey = expandoRow.getPrimaryKey();
311    
312                    if (getPrimaryKey() == primaryKey) {
313                            return true;
314                    }
315                    else {
316                            return false;
317                    }
318            }
319    
320            @Override
321            public int hashCode() {
322                    return (int)getPrimaryKey();
323            }
324    
325            @Override
326            public boolean isEntityCacheEnabled() {
327                    return ENTITY_CACHE_ENABLED;
328            }
329    
330            @Override
331            public boolean isFinderCacheEnabled() {
332                    return FINDER_CACHE_ENABLED;
333            }
334    
335            @Override
336            public void resetOriginalValues() {
337                    ExpandoRowModelImpl expandoRowModelImpl = this;
338    
339                    expandoRowModelImpl._originalTableId = expandoRowModelImpl._tableId;
340    
341                    expandoRowModelImpl._setOriginalTableId = false;
342    
343                    expandoRowModelImpl._originalClassPK = expandoRowModelImpl._classPK;
344    
345                    expandoRowModelImpl._setOriginalClassPK = false;
346    
347                    expandoRowModelImpl._columnBitmask = 0;
348            }
349    
350            @Override
351            public CacheModel<ExpandoRow> toCacheModel() {
352                    ExpandoRowCacheModel expandoRowCacheModel = new ExpandoRowCacheModel();
353    
354                    expandoRowCacheModel.rowId = getRowId();
355    
356                    expandoRowCacheModel.companyId = getCompanyId();
357    
358                    Date modifiedDate = getModifiedDate();
359    
360                    if (modifiedDate != null) {
361                            expandoRowCacheModel.modifiedDate = modifiedDate.getTime();
362                    }
363                    else {
364                            expandoRowCacheModel.modifiedDate = Long.MIN_VALUE;
365                    }
366    
367                    expandoRowCacheModel.tableId = getTableId();
368    
369                    expandoRowCacheModel.classPK = getClassPK();
370    
371                    return expandoRowCacheModel;
372            }
373    
374            @Override
375            public String toString() {
376                    StringBundler sb = new StringBundler(11);
377    
378                    sb.append("{rowId=");
379                    sb.append(getRowId());
380                    sb.append(", companyId=");
381                    sb.append(getCompanyId());
382                    sb.append(", modifiedDate=");
383                    sb.append(getModifiedDate());
384                    sb.append(", tableId=");
385                    sb.append(getTableId());
386                    sb.append(", classPK=");
387                    sb.append(getClassPK());
388                    sb.append("}");
389    
390                    return sb.toString();
391            }
392    
393            @Override
394            public String toXmlString() {
395                    StringBundler sb = new StringBundler(19);
396    
397                    sb.append("<model><model-name>");
398                    sb.append("com.liferay.portlet.expando.model.ExpandoRow");
399                    sb.append("</model-name>");
400    
401                    sb.append(
402                            "<column><column-name>rowId</column-name><column-value><![CDATA[");
403                    sb.append(getRowId());
404                    sb.append("]]></column-value></column>");
405                    sb.append(
406                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
407                    sb.append(getCompanyId());
408                    sb.append("]]></column-value></column>");
409                    sb.append(
410                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
411                    sb.append(getModifiedDate());
412                    sb.append("]]></column-value></column>");
413                    sb.append(
414                            "<column><column-name>tableId</column-name><column-value><![CDATA[");
415                    sb.append(getTableId());
416                    sb.append("]]></column-value></column>");
417                    sb.append(
418                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
419                    sb.append(getClassPK());
420                    sb.append("]]></column-value></column>");
421    
422                    sb.append("</model>");
423    
424                    return sb.toString();
425            }
426    
427            private static final ClassLoader _classLoader = ExpandoRow.class.getClassLoader();
428            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
429                            ExpandoRow.class
430                    };
431            private long _rowId;
432            private long _companyId;
433            private Date _modifiedDate;
434            private long _tableId;
435            private long _originalTableId;
436            private boolean _setOriginalTableId;
437            private long _classPK;
438            private long _originalClassPK;
439            private boolean _setOriginalClassPK;
440            private long _columnBitmask;
441            private ExpandoRow _escapedModel;
442    }