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