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