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