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    
038    /**
039     * 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.
040     *
041     * <p>
042     * 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}.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see MBThreadFlagImpl
047     * @see com.liferay.portlet.messageboards.model.MBThreadFlag
048     * @see com.liferay.portlet.messageboards.model.MBThreadFlagModel
049     * @generated
050     */
051    public class MBThreadFlagModelImpl extends BaseModelImpl<MBThreadFlag>
052            implements MBThreadFlagModel {
053            /*
054             * NOTE FOR DEVELOPERS:
055             *
056             * 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.
057             */
058            public static final String TABLE_NAME = "MBThreadFlag";
059            public static final Object[][] TABLE_COLUMNS = {
060                            { "threadFlagId", Types.BIGINT },
061                            { "userId", Types.BIGINT },
062                            { "modifiedDate", Types.TIMESTAMP },
063                            { "threadId", Types.BIGINT }
064                    };
065            public static final String TABLE_SQL_CREATE = "create table MBThreadFlag (threadFlagId LONG not null primary key,userId LONG,modifiedDate DATE null,threadId LONG)";
066            public static final String TABLE_SQL_DROP = "drop table MBThreadFlag";
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.messageboards.model.MBThreadFlag"),
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.messageboards.model.MBThreadFlag"),
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.messageboards.model.MBThreadFlag"),
078                            true);
079            public static long THREADID_COLUMN_BITMASK = 1L;
080            public static long USERID_COLUMN_BITMASK = 2L;
081            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
082                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThreadFlag"));
083    
084            public MBThreadFlagModelImpl() {
085            }
086    
087            public long getPrimaryKey() {
088                    return _threadFlagId;
089            }
090    
091            public void setPrimaryKey(long primaryKey) {
092                    setThreadFlagId(primaryKey);
093            }
094    
095            public Serializable getPrimaryKeyObj() {
096                    return new Long(_threadFlagId);
097            }
098    
099            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
100                    setPrimaryKey(((Long)primaryKeyObj).longValue());
101            }
102    
103            public Class<?> getModelClass() {
104                    return MBThreadFlag.class;
105            }
106    
107            public String getModelClassName() {
108                    return MBThreadFlag.class.getName();
109            }
110    
111            public long getThreadFlagId() {
112                    return _threadFlagId;
113            }
114    
115            public void setThreadFlagId(long threadFlagId) {
116                    _threadFlagId = threadFlagId;
117            }
118    
119            public long getUserId() {
120                    return _userId;
121            }
122    
123            public void setUserId(long userId) {
124                    _columnBitmask |= USERID_COLUMN_BITMASK;
125    
126                    if (!_setOriginalUserId) {
127                            _setOriginalUserId = true;
128    
129                            _originalUserId = _userId;
130                    }
131    
132                    _userId = userId;
133            }
134    
135            public String getUserUuid() throws SystemException {
136                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
137            }
138    
139            public void setUserUuid(String userUuid) {
140                    _userUuid = userUuid;
141            }
142    
143            public long getOriginalUserId() {
144                    return _originalUserId;
145            }
146    
147            public Date getModifiedDate() {
148                    return _modifiedDate;
149            }
150    
151            public void setModifiedDate(Date modifiedDate) {
152                    _modifiedDate = modifiedDate;
153            }
154    
155            public long getThreadId() {
156                    return _threadId;
157            }
158    
159            public void setThreadId(long threadId) {
160                    _columnBitmask |= THREADID_COLUMN_BITMASK;
161    
162                    if (!_setOriginalThreadId) {
163                            _setOriginalThreadId = true;
164    
165                            _originalThreadId = _threadId;
166                    }
167    
168                    _threadId = threadId;
169            }
170    
171            public long getOriginalThreadId() {
172                    return _originalThreadId;
173            }
174    
175            public long getColumnBitmask() {
176                    return _columnBitmask;
177            }
178    
179            @Override
180            public MBThreadFlag toEscapedModel() {
181                    if (_escapedModelProxy == null) {
182                            _escapedModelProxy = (MBThreadFlag)ProxyUtil.newProxyInstance(_classLoader,
183                                            _escapedModelProxyInterfaces,
184                                            new AutoEscapeBeanHandler(this));
185                    }
186    
187                    return _escapedModelProxy;
188            }
189    
190            @Override
191            public ExpandoBridge getExpandoBridge() {
192                    if (_expandoBridge == null) {
193                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
194                                            MBThreadFlag.class.getName(), getPrimaryKey());
195                    }
196    
197                    return _expandoBridge;
198            }
199    
200            @Override
201            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
202                    getExpandoBridge().setAttributes(serviceContext);
203            }
204    
205            @Override
206            public Object clone() {
207                    MBThreadFlagImpl mbThreadFlagImpl = new MBThreadFlagImpl();
208    
209                    mbThreadFlagImpl.setThreadFlagId(getThreadFlagId());
210                    mbThreadFlagImpl.setUserId(getUserId());
211                    mbThreadFlagImpl.setModifiedDate(getModifiedDate());
212                    mbThreadFlagImpl.setThreadId(getThreadId());
213    
214                    mbThreadFlagImpl.resetOriginalValues();
215    
216                    return mbThreadFlagImpl;
217            }
218    
219            public int compareTo(MBThreadFlag mbThreadFlag) {
220                    long primaryKey = mbThreadFlag.getPrimaryKey();
221    
222                    if (getPrimaryKey() < primaryKey) {
223                            return -1;
224                    }
225                    else if (getPrimaryKey() > primaryKey) {
226                            return 1;
227                    }
228                    else {
229                            return 0;
230                    }
231            }
232    
233            @Override
234            public boolean equals(Object obj) {
235                    if (obj == null) {
236                            return false;
237                    }
238    
239                    MBThreadFlag mbThreadFlag = null;
240    
241                    try {
242                            mbThreadFlag = (MBThreadFlag)obj;
243                    }
244                    catch (ClassCastException cce) {
245                            return false;
246                    }
247    
248                    long primaryKey = mbThreadFlag.getPrimaryKey();
249    
250                    if (getPrimaryKey() == primaryKey) {
251                            return true;
252                    }
253                    else {
254                            return false;
255                    }
256            }
257    
258            @Override
259            public int hashCode() {
260                    return (int)getPrimaryKey();
261            }
262    
263            @Override
264            public void resetOriginalValues() {
265                    MBThreadFlagModelImpl mbThreadFlagModelImpl = this;
266    
267                    mbThreadFlagModelImpl._originalUserId = mbThreadFlagModelImpl._userId;
268    
269                    mbThreadFlagModelImpl._setOriginalUserId = false;
270    
271                    mbThreadFlagModelImpl._originalThreadId = mbThreadFlagModelImpl._threadId;
272    
273                    mbThreadFlagModelImpl._setOriginalThreadId = false;
274    
275                    mbThreadFlagModelImpl._columnBitmask = 0;
276            }
277    
278            @Override
279            public CacheModel<MBThreadFlag> toCacheModel() {
280                    MBThreadFlagCacheModel mbThreadFlagCacheModel = new MBThreadFlagCacheModel();
281    
282                    mbThreadFlagCacheModel.threadFlagId = getThreadFlagId();
283    
284                    mbThreadFlagCacheModel.userId = getUserId();
285    
286                    Date modifiedDate = getModifiedDate();
287    
288                    if (modifiedDate != null) {
289                            mbThreadFlagCacheModel.modifiedDate = modifiedDate.getTime();
290                    }
291                    else {
292                            mbThreadFlagCacheModel.modifiedDate = Long.MIN_VALUE;
293                    }
294    
295                    mbThreadFlagCacheModel.threadId = getThreadId();
296    
297                    return mbThreadFlagCacheModel;
298            }
299    
300            @Override
301            public String toString() {
302                    StringBundler sb = new StringBundler(9);
303    
304                    sb.append("{threadFlagId=");
305                    sb.append(getThreadFlagId());
306                    sb.append(", userId=");
307                    sb.append(getUserId());
308                    sb.append(", modifiedDate=");
309                    sb.append(getModifiedDate());
310                    sb.append(", threadId=");
311                    sb.append(getThreadId());
312                    sb.append("}");
313    
314                    return sb.toString();
315            }
316    
317            public String toXmlString() {
318                    StringBundler sb = new StringBundler(16);
319    
320                    sb.append("<model><model-name>");
321                    sb.append("com.liferay.portlet.messageboards.model.MBThreadFlag");
322                    sb.append("</model-name>");
323    
324                    sb.append(
325                            "<column><column-name>threadFlagId</column-name><column-value><![CDATA[");
326                    sb.append(getThreadFlagId());
327                    sb.append("]]></column-value></column>");
328                    sb.append(
329                            "<column><column-name>userId</column-name><column-value><![CDATA[");
330                    sb.append(getUserId());
331                    sb.append("]]></column-value></column>");
332                    sb.append(
333                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
334                    sb.append(getModifiedDate());
335                    sb.append("]]></column-value></column>");
336                    sb.append(
337                            "<column><column-name>threadId</column-name><column-value><![CDATA[");
338                    sb.append(getThreadId());
339                    sb.append("]]></column-value></column>");
340    
341                    sb.append("</model>");
342    
343                    return sb.toString();
344            }
345    
346            private static ClassLoader _classLoader = MBThreadFlag.class.getClassLoader();
347            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
348                            MBThreadFlag.class
349                    };
350            private long _threadFlagId;
351            private long _userId;
352            private String _userUuid;
353            private long _originalUserId;
354            private boolean _setOriginalUserId;
355            private Date _modifiedDate;
356            private long _threadId;
357            private long _originalThreadId;
358            private boolean _setOriginalThreadId;
359            private transient ExpandoBridge _expandoBridge;
360            private long _columnBitmask;
361            private MBThreadFlag _escapedModelProxy;
362    }