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