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