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.messageboards.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.ProxyUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.impl.BaseModelImpl;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    import com.liferay.portlet.messageboards.model.MBThreadFlag;
030    import com.liferay.portlet.messageboards.model.MBThreadFlagModel;
031    
032    import java.io.Serializable;
033    
034    import java.sql.Types;
035    
036    import java.util.Date;
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * The base model implementation for the MBThreadFlag service. Represents a row in the "MBThreadFlag" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portlet.messageboards.model.MBThreadFlagModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link MBThreadFlagImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see MBThreadFlagImpl
049     * @see com.liferay.portlet.messageboards.model.MBThreadFlag
050     * @see com.liferay.portlet.messageboards.model.MBThreadFlagModel
051     * @generated
052     */
053    public class MBThreadFlagModelImpl extends BaseModelImpl<MBThreadFlag>
054            implements MBThreadFlagModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a message boards thread flag model instance should use the {@link com.liferay.portlet.messageboards.model.MBThreadFlag} interface instead.
059             */
060            public static final String TABLE_NAME = "MBThreadFlag";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "threadFlagId", Types.BIGINT },
063                            { "userId", Types.BIGINT },
064                            { "modifiedDate", Types.TIMESTAMP },
065                            { "threadId", Types.BIGINT }
066                    };
067            public static final String TABLE_SQL_CREATE = "create table MBThreadFlag (threadFlagId LONG not null primary key,userId LONG,modifiedDate DATE null,threadId LONG)";
068            public static final String TABLE_SQL_DROP = "drop table MBThreadFlag";
069            public static final String ORDER_BY_JPQL = " ORDER BY mbThreadFlag.threadFlagId ASC";
070            public static final String ORDER_BY_SQL = " ORDER BY MBThreadFlag.threadFlagId 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.messageboards.model.MBThreadFlag"),
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.messageboards.model.MBThreadFlag"),
079                            true);
080            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.column.bitmask.enabled.com.liferay.portlet.messageboards.model.MBThreadFlag"),
082                            true);
083            public static long THREADID_COLUMN_BITMASK = 1L;
084            public static long USERID_COLUMN_BITMASK = 2L;
085            public static long THREADFLAGID_COLUMN_BITMASK = 4L;
086            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
087                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThreadFlag"));
088    
089            public MBThreadFlagModelImpl() {
090            }
091    
092            public long getPrimaryKey() {
093                    return _threadFlagId;
094            }
095    
096            public void setPrimaryKey(long primaryKey) {
097                    setThreadFlagId(primaryKey);
098            }
099    
100            public Serializable getPrimaryKeyObj() {
101                    return new Long(_threadFlagId);
102            }
103    
104            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
105                    setPrimaryKey(((Long)primaryKeyObj).longValue());
106            }
107    
108            public Class<?> getModelClass() {
109                    return MBThreadFlag.class;
110            }
111    
112            public String getModelClassName() {
113                    return MBThreadFlag.class.getName();
114            }
115    
116            @Override
117            public Map<String, Object> getModelAttributes() {
118                    Map<String, Object> attributes = new HashMap<String, Object>();
119    
120                    attributes.put("threadFlagId", getThreadFlagId());
121                    attributes.put("userId", getUserId());
122                    attributes.put("modifiedDate", getModifiedDate());
123                    attributes.put("threadId", getThreadId());
124    
125                    return attributes;
126            }
127    
128            @Override
129            public void setModelAttributes(Map<String, Object> attributes) {
130                    Long threadFlagId = (Long)attributes.get("threadFlagId");
131    
132                    if (threadFlagId != null) {
133                            setThreadFlagId(threadFlagId);
134                    }
135    
136                    Long userId = (Long)attributes.get("userId");
137    
138                    if (userId != null) {
139                            setUserId(userId);
140                    }
141    
142                    Date modifiedDate = (Date)attributes.get("modifiedDate");
143    
144                    if (modifiedDate != null) {
145                            setModifiedDate(modifiedDate);
146                    }
147    
148                    Long threadId = (Long)attributes.get("threadId");
149    
150                    if (threadId != null) {
151                            setThreadId(threadId);
152                    }
153            }
154    
155            public long getThreadFlagId() {
156                    return _threadFlagId;
157            }
158    
159            public void setThreadFlagId(long threadFlagId) {
160                    _threadFlagId = threadFlagId;
161            }
162    
163            public long getUserId() {
164                    return _userId;
165            }
166    
167            public void setUserId(long userId) {
168                    _columnBitmask |= USERID_COLUMN_BITMASK;
169    
170                    if (!_setOriginalUserId) {
171                            _setOriginalUserId = true;
172    
173                            _originalUserId = _userId;
174                    }
175    
176                    _userId = userId;
177            }
178    
179            public String getUserUuid() throws SystemException {
180                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
181            }
182    
183            public void setUserUuid(String userUuid) {
184                    _userUuid = userUuid;
185            }
186    
187            public long getOriginalUserId() {
188                    return _originalUserId;
189            }
190    
191            public Date getModifiedDate() {
192                    return _modifiedDate;
193            }
194    
195            public void setModifiedDate(Date modifiedDate) {
196                    _modifiedDate = modifiedDate;
197            }
198    
199            public long getThreadId() {
200                    return _threadId;
201            }
202    
203            public void setThreadId(long threadId) {
204                    _columnBitmask |= THREADID_COLUMN_BITMASK;
205    
206                    if (!_setOriginalThreadId) {
207                            _setOriginalThreadId = true;
208    
209                            _originalThreadId = _threadId;
210                    }
211    
212                    _threadId = threadId;
213            }
214    
215            public long getOriginalThreadId() {
216                    return _originalThreadId;
217            }
218    
219            public long getColumnBitmask() {
220                    return _columnBitmask;
221            }
222    
223            @Override
224            public ExpandoBridge getExpandoBridge() {
225                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
226                            MBThreadFlag.class.getName(), getPrimaryKey());
227            }
228    
229            @Override
230            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
231                    ExpandoBridge expandoBridge = getExpandoBridge();
232    
233                    expandoBridge.setAttributes(serviceContext);
234            }
235    
236            @Override
237            public MBThreadFlag toEscapedModel() {
238                    if (_escapedModel == null) {
239                            _escapedModel = (MBThreadFlag)ProxyUtil.newProxyInstance(_classLoader,
240                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
241                    }
242    
243                    return _escapedModel;
244            }
245    
246            @Override
247            public Object clone() {
248                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
249    
250                    mbThreadFlagImpl.setThreadFlagId(getThreadFlagId());
251                    mbThreadFlagImpl.setUserId(getUserId());
252                    mbThreadFlagImpl.setModifiedDate(getModifiedDate());
253                    mbThreadFlagImpl.setThreadId(getThreadId());
254    
255                    mbThreadFlagImpl.resetOriginalValues();
256    
257                    return mbThreadFlagImpl;
258            }
259    
260            public int compareTo(MBThreadFlag mbThreadFlag) {
261                    long primaryKey = mbThreadFlag.getPrimaryKey();
262    
263                    if (getPrimaryKey() < primaryKey) {
264                            return -1;
265                    }
266                    else if (getPrimaryKey() > primaryKey) {
267                            return 1;
268                    }
269                    else {
270                            return 0;
271                    }
272            }
273    
274            @Override
275            public boolean equals(Object obj) {
276                    if (obj == null) {
277                            return false;
278                    }
279    
280                    MBThreadFlag mbThreadFlag = null;
281    
282                    try {
283                            mbThreadFlag = (MBThreadFlag)obj;
284                    }
285                    catch (ClassCastException cce) {
286                            return false;
287                    }
288    
289                    long primaryKey = mbThreadFlag.getPrimaryKey();
290    
291                    if (getPrimaryKey() == primaryKey) {
292                            return true;
293                    }
294                    else {
295                            return false;
296                    }
297            }
298    
299            @Override
300            public int hashCode() {
301                    return (int)getPrimaryKey();
302            }
303    
304            @Override
305            public void resetOriginalValues() {
306                    MBThreadFlagModelImpl mbThreadFlagModelImpl = this;
307    
308                    mbThreadFlagModelImpl._originalUserId = mbThreadFlagModelImpl._userId;
309    
310                    mbThreadFlagModelImpl._setOriginalUserId = false;
311    
312                    mbThreadFlagModelImpl._originalThreadId = mbThreadFlagModelImpl._threadId;
313    
314                    mbThreadFlagModelImpl._setOriginalThreadId = false;
315    
316                    mbThreadFlagModelImpl._columnBitmask = 0;
317            }
318    
319            @Override
320            public CacheModel<MBThreadFlag> toCacheModel() {
321                    MBThreadFlagCacheModel mbThreadFlagCacheModel = new MBThreadFlagCacheModel();
322    
323                    mbThreadFlagCacheModel.threadFlagId = getThreadFlagId();
324    
325                    mbThreadFlagCacheModel.userId = getUserId();
326    
327                    Date modifiedDate = getModifiedDate();
328    
329                    if (modifiedDate != null) {
330                            mbThreadFlagCacheModel.modifiedDate = modifiedDate.getTime();
331                    }
332                    else {
333                            mbThreadFlagCacheModel.modifiedDate = Long.MIN_VALUE;
334                    }
335    
336                    mbThreadFlagCacheModel.threadId = getThreadId();
337    
338                    return mbThreadFlagCacheModel;
339            }
340    
341            @Override
342            public String toString() {
343                    StringBundler sb = new StringBundler(9);
344    
345                    sb.append("{threadFlagId=");
346                    sb.append(getThreadFlagId());
347                    sb.append(", userId=");
348                    sb.append(getUserId());
349                    sb.append(", modifiedDate=");
350                    sb.append(getModifiedDate());
351                    sb.append(", threadId=");
352                    sb.append(getThreadId());
353                    sb.append("}");
354    
355                    return sb.toString();
356            }
357    
358            public String toXmlString() {
359                    StringBundler sb = new StringBundler(16);
360    
361                    sb.append("<model><model-name>");
362                    sb.append("com.liferay.portlet.messageboards.model.MBThreadFlag");
363                    sb.append("</model-name>");
364    
365                    sb.append(
366                            "<column><column-name>threadFlagId</column-name><column-value><![CDATA[");
367                    sb.append(getThreadFlagId());
368                    sb.append("]]></column-value></column>");
369                    sb.append(
370                            "<column><column-name>userId</column-name><column-value><![CDATA[");
371                    sb.append(getUserId());
372                    sb.append("]]></column-value></column>");
373                    sb.append(
374                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
375                    sb.append(getModifiedDate());
376                    sb.append("]]></column-value></column>");
377                    sb.append(
378                            "<column><column-name>threadId</column-name><column-value><![CDATA[");
379                    sb.append(getThreadId());
380                    sb.append("]]></column-value></column>");
381    
382                    sb.append("</model>");
383    
384                    return sb.toString();
385            }
386    
387            private static ClassLoader _classLoader = MBThreadFlag.class.getClassLoader();
388            private static Class<?>[] _escapedModelInterfaces = new Class[] {
389                            MBThreadFlag.class
390                    };
391            private long _threadFlagId;
392            private long _userId;
393            private String _userUuid;
394            private long _originalUserId;
395            private boolean _setOriginalUserId;
396            private Date _modifiedDate;
397            private long _threadId;
398            private long _originalThreadId;
399            private boolean _setOriginalThreadId;
400            private long _columnBitmask;
401            private MBThreadFlag _escapedModel;
402    }