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.json.JSON;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.impl.BaseModelImpl;
026    import com.liferay.portal.service.ServiceContext;
027    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    import com.liferay.portlet.messageboards.model.MBBan;
032    import com.liferay.portlet.messageboards.model.MBBanModel;
033    import com.liferay.portlet.messageboards.model.MBBanSoap;
034    
035    import java.io.Serializable;
036    
037    import java.sql.Types;
038    
039    import java.util.ArrayList;
040    import java.util.Date;
041    import java.util.List;
042    
043    /**
044     * The base model implementation for the MBBan service. Represents a row in the "MBBan" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link com.liferay.portlet.messageboards.model.MBBanModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link MBBanImpl}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see MBBanImpl
052     * @see com.liferay.portlet.messageboards.model.MBBan
053     * @see com.liferay.portlet.messageboards.model.MBBanModel
054     * @generated
055     */
056    @JSON(strict = true)
057    public class MBBanModelImpl extends BaseModelImpl<MBBan> implements MBBanModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this class directly. All methods that expect a message boards ban model instance should use the {@link com.liferay.portlet.messageboards.model.MBBan} interface instead.
062             */
063            public static final String TABLE_NAME = "MBBan";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "banId", Types.BIGINT },
066                            { "groupId", Types.BIGINT },
067                            { "companyId", Types.BIGINT },
068                            { "userId", Types.BIGINT },
069                            { "userName", Types.VARCHAR },
070                            { "createDate", Types.TIMESTAMP },
071                            { "modifiedDate", Types.TIMESTAMP },
072                            { "banUserId", Types.BIGINT }
073                    };
074            public static final String TABLE_SQL_CREATE = "create table MBBan (banId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,banUserId LONG)";
075            public static final String TABLE_SQL_DROP = "drop table MBBan";
076            public static final String DATA_SOURCE = "liferayDataSource";
077            public static final String SESSION_FACTORY = "liferaySessionFactory";
078            public static final String TX_MANAGER = "liferayTransactionManager";
079            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
081                            true);
082            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
084                            true);
085            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.column.bitmask.enabled.com.liferay.portlet.messageboards.model.MBBan"),
087                            true);
088            public static long BANUSERID_COLUMN_BITMASK = 1L;
089            public static long GROUPID_COLUMN_BITMASK = 2L;
090            public static long USERID_COLUMN_BITMASK = 4L;
091    
092            /**
093             * Converts the soap model instance into a normal model instance.
094             *
095             * @param soapModel the soap model instance to convert
096             * @return the normal model instance
097             */
098            public static MBBan toModel(MBBanSoap soapModel) {
099                    MBBan model = new MBBanImpl();
100    
101                    model.setBanId(soapModel.getBanId());
102                    model.setGroupId(soapModel.getGroupId());
103                    model.setCompanyId(soapModel.getCompanyId());
104                    model.setUserId(soapModel.getUserId());
105                    model.setUserName(soapModel.getUserName());
106                    model.setCreateDate(soapModel.getCreateDate());
107                    model.setModifiedDate(soapModel.getModifiedDate());
108                    model.setBanUserId(soapModel.getBanUserId());
109    
110                    return model;
111            }
112    
113            /**
114             * Converts the soap model instances into normal model instances.
115             *
116             * @param soapModels the soap model instances to convert
117             * @return the normal model instances
118             */
119            public static List<MBBan> toModels(MBBanSoap[] soapModels) {
120                    List<MBBan> models = new ArrayList<MBBan>(soapModels.length);
121    
122                    for (MBBanSoap soapModel : soapModels) {
123                            models.add(toModel(soapModel));
124                    }
125    
126                    return models;
127            }
128    
129            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBBan"));
131    
132            public MBBanModelImpl() {
133            }
134    
135            public long getPrimaryKey() {
136                    return _banId;
137            }
138    
139            public void setPrimaryKey(long primaryKey) {
140                    setBanId(primaryKey);
141            }
142    
143            public Serializable getPrimaryKeyObj() {
144                    return new Long(_banId);
145            }
146    
147            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
148                    setPrimaryKey(((Long)primaryKeyObj).longValue());
149            }
150    
151            public Class<?> getModelClass() {
152                    return MBBan.class;
153            }
154    
155            public String getModelClassName() {
156                    return MBBan.class.getName();
157            }
158    
159            @JSON
160            public long getBanId() {
161                    return _banId;
162            }
163    
164            public void setBanId(long banId) {
165                    _banId = banId;
166            }
167    
168            @JSON
169            public long getGroupId() {
170                    return _groupId;
171            }
172    
173            public void setGroupId(long groupId) {
174                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
175    
176                    if (!_setOriginalGroupId) {
177                            _setOriginalGroupId = true;
178    
179                            _originalGroupId = _groupId;
180                    }
181    
182                    _groupId = groupId;
183            }
184    
185            public long getOriginalGroupId() {
186                    return _originalGroupId;
187            }
188    
189            @JSON
190            public long getCompanyId() {
191                    return _companyId;
192            }
193    
194            public void setCompanyId(long companyId) {
195                    _companyId = companyId;
196            }
197    
198            @JSON
199            public long getUserId() {
200                    return _userId;
201            }
202    
203            public void setUserId(long userId) {
204                    _columnBitmask |= USERID_COLUMN_BITMASK;
205    
206                    if (!_setOriginalUserId) {
207                            _setOriginalUserId = true;
208    
209                            _originalUserId = _userId;
210                    }
211    
212                    _userId = userId;
213            }
214    
215            public String getUserUuid() throws SystemException {
216                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
217            }
218    
219            public void setUserUuid(String userUuid) {
220                    _userUuid = userUuid;
221            }
222    
223            public long getOriginalUserId() {
224                    return _originalUserId;
225            }
226    
227            @JSON
228            public String getUserName() {
229                    if (_userName == null) {
230                            return StringPool.BLANK;
231                    }
232                    else {
233                            return _userName;
234                    }
235            }
236    
237            public void setUserName(String userName) {
238                    _userName = userName;
239            }
240    
241            @JSON
242            public Date getCreateDate() {
243                    return _createDate;
244            }
245    
246            public void setCreateDate(Date createDate) {
247                    _createDate = createDate;
248            }
249    
250            @JSON
251            public Date getModifiedDate() {
252                    return _modifiedDate;
253            }
254    
255            public void setModifiedDate(Date modifiedDate) {
256                    _modifiedDate = modifiedDate;
257            }
258    
259            @JSON
260            public long getBanUserId() {
261                    return _banUserId;
262            }
263    
264            public void setBanUserId(long banUserId) {
265                    _columnBitmask |= BANUSERID_COLUMN_BITMASK;
266    
267                    if (!_setOriginalBanUserId) {
268                            _setOriginalBanUserId = true;
269    
270                            _originalBanUserId = _banUserId;
271                    }
272    
273                    _banUserId = banUserId;
274            }
275    
276            public String getBanUserUuid() throws SystemException {
277                    return PortalUtil.getUserValue(getBanUserId(), "uuid", _banUserUuid);
278            }
279    
280            public void setBanUserUuid(String banUserUuid) {
281                    _banUserUuid = banUserUuid;
282            }
283    
284            public long getOriginalBanUserId() {
285                    return _originalBanUserId;
286            }
287    
288            public long getColumnBitmask() {
289                    return _columnBitmask;
290            }
291    
292            @Override
293            public MBBan toEscapedModel() {
294                    if (_escapedModelProxy == null) {
295                            _escapedModelProxy = (MBBan)ProxyUtil.newProxyInstance(_classLoader,
296                                            _escapedModelProxyInterfaces,
297                                            new AutoEscapeBeanHandler(this));
298                    }
299    
300                    return _escapedModelProxy;
301            }
302    
303            @Override
304            public ExpandoBridge getExpandoBridge() {
305                    if (_expandoBridge == null) {
306                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
307                                            MBBan.class.getName(), getPrimaryKey());
308                    }
309    
310                    return _expandoBridge;
311            }
312    
313            @Override
314            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
315                    getExpandoBridge().setAttributes(serviceContext);
316            }
317    
318            @Override
319            public Object clone() {
320                    MBBanImpl mbBanImpl = new MBBanImpl();
321    
322                    mbBanImpl.setBanId(getBanId());
323                    mbBanImpl.setGroupId(getGroupId());
324                    mbBanImpl.setCompanyId(getCompanyId());
325                    mbBanImpl.setUserId(getUserId());
326                    mbBanImpl.setUserName(getUserName());
327                    mbBanImpl.setCreateDate(getCreateDate());
328                    mbBanImpl.setModifiedDate(getModifiedDate());
329                    mbBanImpl.setBanUserId(getBanUserId());
330    
331                    mbBanImpl.resetOriginalValues();
332    
333                    return mbBanImpl;
334            }
335    
336            public int compareTo(MBBan mbBan) {
337                    long primaryKey = mbBan.getPrimaryKey();
338    
339                    if (getPrimaryKey() < primaryKey) {
340                            return -1;
341                    }
342                    else if (getPrimaryKey() > primaryKey) {
343                            return 1;
344                    }
345                    else {
346                            return 0;
347                    }
348            }
349    
350            @Override
351            public boolean equals(Object obj) {
352                    if (obj == null) {
353                            return false;
354                    }
355    
356                    MBBan mbBan = null;
357    
358                    try {
359                            mbBan = (MBBan)obj;
360                    }
361                    catch (ClassCastException cce) {
362                            return false;
363                    }
364    
365                    long primaryKey = mbBan.getPrimaryKey();
366    
367                    if (getPrimaryKey() == primaryKey) {
368                            return true;
369                    }
370                    else {
371                            return false;
372                    }
373            }
374    
375            @Override
376            public int hashCode() {
377                    return (int)getPrimaryKey();
378            }
379    
380            @Override
381            public void resetOriginalValues() {
382                    MBBanModelImpl mbBanModelImpl = this;
383    
384                    mbBanModelImpl._originalGroupId = mbBanModelImpl._groupId;
385    
386                    mbBanModelImpl._setOriginalGroupId = false;
387    
388                    mbBanModelImpl._originalUserId = mbBanModelImpl._userId;
389    
390                    mbBanModelImpl._setOriginalUserId = false;
391    
392                    mbBanModelImpl._originalBanUserId = mbBanModelImpl._banUserId;
393    
394                    mbBanModelImpl._setOriginalBanUserId = false;
395    
396                    mbBanModelImpl._columnBitmask = 0;
397            }
398    
399            @Override
400            public CacheModel<MBBan> toCacheModel() {
401                    MBBanCacheModel mbBanCacheModel = new MBBanCacheModel();
402    
403                    mbBanCacheModel.banId = getBanId();
404    
405                    mbBanCacheModel.groupId = getGroupId();
406    
407                    mbBanCacheModel.companyId = getCompanyId();
408    
409                    mbBanCacheModel.userId = getUserId();
410    
411                    mbBanCacheModel.userName = getUserName();
412    
413                    String userName = mbBanCacheModel.userName;
414    
415                    if ((userName != null) && (userName.length() == 0)) {
416                            mbBanCacheModel.userName = null;
417                    }
418    
419                    Date createDate = getCreateDate();
420    
421                    if (createDate != null) {
422                            mbBanCacheModel.createDate = createDate.getTime();
423                    }
424                    else {
425                            mbBanCacheModel.createDate = Long.MIN_VALUE;
426                    }
427    
428                    Date modifiedDate = getModifiedDate();
429    
430                    if (modifiedDate != null) {
431                            mbBanCacheModel.modifiedDate = modifiedDate.getTime();
432                    }
433                    else {
434                            mbBanCacheModel.modifiedDate = Long.MIN_VALUE;
435                    }
436    
437                    mbBanCacheModel.banUserId = getBanUserId();
438    
439                    return mbBanCacheModel;
440            }
441    
442            @Override
443            public String toString() {
444                    StringBundler sb = new StringBundler(17);
445    
446                    sb.append("{banId=");
447                    sb.append(getBanId());
448                    sb.append(", groupId=");
449                    sb.append(getGroupId());
450                    sb.append(", companyId=");
451                    sb.append(getCompanyId());
452                    sb.append(", userId=");
453                    sb.append(getUserId());
454                    sb.append(", userName=");
455                    sb.append(getUserName());
456                    sb.append(", createDate=");
457                    sb.append(getCreateDate());
458                    sb.append(", modifiedDate=");
459                    sb.append(getModifiedDate());
460                    sb.append(", banUserId=");
461                    sb.append(getBanUserId());
462                    sb.append("}");
463    
464                    return sb.toString();
465            }
466    
467            public String toXmlString() {
468                    StringBundler sb = new StringBundler(28);
469    
470                    sb.append("<model><model-name>");
471                    sb.append("com.liferay.portlet.messageboards.model.MBBan");
472                    sb.append("</model-name>");
473    
474                    sb.append(
475                            "<column><column-name>banId</column-name><column-value><![CDATA[");
476                    sb.append(getBanId());
477                    sb.append("]]></column-value></column>");
478                    sb.append(
479                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
480                    sb.append(getGroupId());
481                    sb.append("]]></column-value></column>");
482                    sb.append(
483                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
484                    sb.append(getCompanyId());
485                    sb.append("]]></column-value></column>");
486                    sb.append(
487                            "<column><column-name>userId</column-name><column-value><![CDATA[");
488                    sb.append(getUserId());
489                    sb.append("]]></column-value></column>");
490                    sb.append(
491                            "<column><column-name>userName</column-name><column-value><![CDATA[");
492                    sb.append(getUserName());
493                    sb.append("]]></column-value></column>");
494                    sb.append(
495                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
496                    sb.append(getCreateDate());
497                    sb.append("]]></column-value></column>");
498                    sb.append(
499                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
500                    sb.append(getModifiedDate());
501                    sb.append("]]></column-value></column>");
502                    sb.append(
503                            "<column><column-name>banUserId</column-name><column-value><![CDATA[");
504                    sb.append(getBanUserId());
505                    sb.append("]]></column-value></column>");
506    
507                    sb.append("</model>");
508    
509                    return sb.toString();
510            }
511    
512            private static ClassLoader _classLoader = MBBan.class.getClassLoader();
513            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
514                            MBBan.class
515                    };
516            private long _banId;
517            private long _groupId;
518            private long _originalGroupId;
519            private boolean _setOriginalGroupId;
520            private long _companyId;
521            private long _userId;
522            private String _userUuid;
523            private long _originalUserId;
524            private boolean _setOriginalUserId;
525            private String _userName;
526            private Date _createDate;
527            private Date _modifiedDate;
528            private long _banUserId;
529            private String _banUserUuid;
530            private long _originalBanUserId;
531            private boolean _setOriginalBanUserId;
532            private transient ExpandoBridge _expandoBridge;
533            private long _columnBitmask;
534            private MBBan _escapedModelProxy;
535    }