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