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