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.util.GetterUtil;
023    import com.liferay.portal.kernel.util.ProxyUtil;
024    import com.liferay.portal.kernel.util.StringBundler;
025    import com.liferay.portal.kernel.util.StringPool;
026    import com.liferay.portal.model.CacheModel;
027    import com.liferay.portal.model.User;
028    import com.liferay.portal.model.impl.BaseModelImpl;
029    import com.liferay.portal.service.ServiceContext;
030    import com.liferay.portal.service.UserLocalServiceUtil;
031    import com.liferay.portal.util.PortalUtil;
032    
033    import com.liferay.portlet.expando.model.ExpandoBridge;
034    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
035    import com.liferay.portlet.exportimport.lar.StagedModelType;
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 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 MBBan
060     * @see 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 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            public boolean hasSetModifiedDate() {
419                    return _setModifiedDate;
420            }
421    
422            @Override
423            public void setModifiedDate(Date modifiedDate) {
424                    _setModifiedDate = true;
425    
426                    _modifiedDate = modifiedDate;
427            }
428    
429            @JSON
430            @Override
431            public long getBanUserId() {
432                    return _banUserId;
433            }
434    
435            @Override
436            public void setBanUserId(long banUserId) {
437                    _columnBitmask |= BANUSERID_COLUMN_BITMASK;
438    
439                    if (!_setOriginalBanUserId) {
440                            _setOriginalBanUserId = true;
441    
442                            _originalBanUserId = _banUserId;
443                    }
444    
445                    _banUserId = banUserId;
446            }
447    
448            @Override
449            public String getBanUserUuid() {
450                    try {
451                            User user = UserLocalServiceUtil.getUserById(getBanUserId());
452    
453                            return user.getUuid();
454                    }
455                    catch (PortalException pe) {
456                            return StringPool.BLANK;
457                    }
458            }
459    
460            @Override
461            public void setBanUserUuid(String banUserUuid) {
462            }
463    
464            public long getOriginalBanUserId() {
465                    return _originalBanUserId;
466            }
467    
468            @Override
469            public StagedModelType getStagedModelType() {
470                    return new StagedModelType(PortalUtil.getClassNameId(
471                                    MBBan.class.getName()));
472            }
473    
474            public long getColumnBitmask() {
475                    return _columnBitmask;
476            }
477    
478            @Override
479            public ExpandoBridge getExpandoBridge() {
480                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
481                            MBBan.class.getName(), getPrimaryKey());
482            }
483    
484            @Override
485            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
486                    ExpandoBridge expandoBridge = getExpandoBridge();
487    
488                    expandoBridge.setAttributes(serviceContext);
489            }
490    
491            @Override
492            public MBBan toEscapedModel() {
493                    if (_escapedModel == null) {
494                            _escapedModel = (MBBan)ProxyUtil.newProxyInstance(_classLoader,
495                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
496                    }
497    
498                    return _escapedModel;
499            }
500    
501            @Override
502            public Object clone() {
503                    MBBanImpl mbBanImpl = new MBBanImpl();
504    
505                    mbBanImpl.setUuid(getUuid());
506                    mbBanImpl.setBanId(getBanId());
507                    mbBanImpl.setGroupId(getGroupId());
508                    mbBanImpl.setCompanyId(getCompanyId());
509                    mbBanImpl.setUserId(getUserId());
510                    mbBanImpl.setUserName(getUserName());
511                    mbBanImpl.setCreateDate(getCreateDate());
512                    mbBanImpl.setModifiedDate(getModifiedDate());
513                    mbBanImpl.setBanUserId(getBanUserId());
514    
515                    mbBanImpl.resetOriginalValues();
516    
517                    return mbBanImpl;
518            }
519    
520            @Override
521            public int compareTo(MBBan mbBan) {
522                    long primaryKey = mbBan.getPrimaryKey();
523    
524                    if (getPrimaryKey() < primaryKey) {
525                            return -1;
526                    }
527                    else if (getPrimaryKey() > primaryKey) {
528                            return 1;
529                    }
530                    else {
531                            return 0;
532                    }
533            }
534    
535            @Override
536            public boolean equals(Object obj) {
537                    if (this == obj) {
538                            return true;
539                    }
540    
541                    if (!(obj instanceof MBBan)) {
542                            return false;
543                    }
544    
545                    MBBan mbBan = (MBBan)obj;
546    
547                    long primaryKey = mbBan.getPrimaryKey();
548    
549                    if (getPrimaryKey() == primaryKey) {
550                            return true;
551                    }
552                    else {
553                            return false;
554                    }
555            }
556    
557            @Override
558            public int hashCode() {
559                    return (int)getPrimaryKey();
560            }
561    
562            @Override
563            public boolean isEntityCacheEnabled() {
564                    return ENTITY_CACHE_ENABLED;
565            }
566    
567            @Override
568            public boolean isFinderCacheEnabled() {
569                    return FINDER_CACHE_ENABLED;
570            }
571    
572            @Override
573            public void resetOriginalValues() {
574                    MBBanModelImpl mbBanModelImpl = this;
575    
576                    mbBanModelImpl._originalUuid = mbBanModelImpl._uuid;
577    
578                    mbBanModelImpl._originalGroupId = mbBanModelImpl._groupId;
579    
580                    mbBanModelImpl._setOriginalGroupId = false;
581    
582                    mbBanModelImpl._originalCompanyId = mbBanModelImpl._companyId;
583    
584                    mbBanModelImpl._setOriginalCompanyId = false;
585    
586                    mbBanModelImpl._originalUserId = mbBanModelImpl._userId;
587    
588                    mbBanModelImpl._setOriginalUserId = false;
589    
590                    mbBanModelImpl._setModifiedDate = false;
591    
592                    mbBanModelImpl._originalBanUserId = mbBanModelImpl._banUserId;
593    
594                    mbBanModelImpl._setOriginalBanUserId = false;
595    
596                    mbBanModelImpl._columnBitmask = 0;
597            }
598    
599            @Override
600            public CacheModel<MBBan> toCacheModel() {
601                    MBBanCacheModel mbBanCacheModel = new MBBanCacheModel();
602    
603                    mbBanCacheModel.uuid = getUuid();
604    
605                    String uuid = mbBanCacheModel.uuid;
606    
607                    if ((uuid != null) && (uuid.length() == 0)) {
608                            mbBanCacheModel.uuid = null;
609                    }
610    
611                    mbBanCacheModel.banId = getBanId();
612    
613                    mbBanCacheModel.groupId = getGroupId();
614    
615                    mbBanCacheModel.companyId = getCompanyId();
616    
617                    mbBanCacheModel.userId = getUserId();
618    
619                    mbBanCacheModel.userName = getUserName();
620    
621                    String userName = mbBanCacheModel.userName;
622    
623                    if ((userName != null) && (userName.length() == 0)) {
624                            mbBanCacheModel.userName = null;
625                    }
626    
627                    Date createDate = getCreateDate();
628    
629                    if (createDate != null) {
630                            mbBanCacheModel.createDate = createDate.getTime();
631                    }
632                    else {
633                            mbBanCacheModel.createDate = Long.MIN_VALUE;
634                    }
635    
636                    Date modifiedDate = getModifiedDate();
637    
638                    if (modifiedDate != null) {
639                            mbBanCacheModel.modifiedDate = modifiedDate.getTime();
640                    }
641                    else {
642                            mbBanCacheModel.modifiedDate = Long.MIN_VALUE;
643                    }
644    
645                    mbBanCacheModel.banUserId = getBanUserId();
646    
647                    return mbBanCacheModel;
648            }
649    
650            @Override
651            public String toString() {
652                    StringBundler sb = new StringBundler(19);
653    
654                    sb.append("{uuid=");
655                    sb.append(getUuid());
656                    sb.append(", banId=");
657                    sb.append(getBanId());
658                    sb.append(", groupId=");
659                    sb.append(getGroupId());
660                    sb.append(", companyId=");
661                    sb.append(getCompanyId());
662                    sb.append(", userId=");
663                    sb.append(getUserId());
664                    sb.append(", userName=");
665                    sb.append(getUserName());
666                    sb.append(", createDate=");
667                    sb.append(getCreateDate());
668                    sb.append(", modifiedDate=");
669                    sb.append(getModifiedDate());
670                    sb.append(", banUserId=");
671                    sb.append(getBanUserId());
672                    sb.append("}");
673    
674                    return sb.toString();
675            }
676    
677            @Override
678            public String toXmlString() {
679                    StringBundler sb = new StringBundler(31);
680    
681                    sb.append("<model><model-name>");
682                    sb.append("com.liferay.portlet.messageboards.model.MBBan");
683                    sb.append("</model-name>");
684    
685                    sb.append(
686                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
687                    sb.append(getUuid());
688                    sb.append("]]></column-value></column>");
689                    sb.append(
690                            "<column><column-name>banId</column-name><column-value><![CDATA[");
691                    sb.append(getBanId());
692                    sb.append("]]></column-value></column>");
693                    sb.append(
694                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
695                    sb.append(getGroupId());
696                    sb.append("]]></column-value></column>");
697                    sb.append(
698                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
699                    sb.append(getCompanyId());
700                    sb.append("]]></column-value></column>");
701                    sb.append(
702                            "<column><column-name>userId</column-name><column-value><![CDATA[");
703                    sb.append(getUserId());
704                    sb.append("]]></column-value></column>");
705                    sb.append(
706                            "<column><column-name>userName</column-name><column-value><![CDATA[");
707                    sb.append(getUserName());
708                    sb.append("]]></column-value></column>");
709                    sb.append(
710                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
711                    sb.append(getCreateDate());
712                    sb.append("]]></column-value></column>");
713                    sb.append(
714                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
715                    sb.append(getModifiedDate());
716                    sb.append("]]></column-value></column>");
717                    sb.append(
718                            "<column><column-name>banUserId</column-name><column-value><![CDATA[");
719                    sb.append(getBanUserId());
720                    sb.append("]]></column-value></column>");
721    
722                    sb.append("</model>");
723    
724                    return sb.toString();
725            }
726    
727            private static final ClassLoader _classLoader = MBBan.class.getClassLoader();
728            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
729                            MBBan.class
730                    };
731            private String _uuid;
732            private String _originalUuid;
733            private long _banId;
734            private long _groupId;
735            private long _originalGroupId;
736            private boolean _setOriginalGroupId;
737            private long _companyId;
738            private long _originalCompanyId;
739            private boolean _setOriginalCompanyId;
740            private long _userId;
741            private long _originalUserId;
742            private boolean _setOriginalUserId;
743            private String _userName;
744            private Date _createDate;
745            private Date _modifiedDate;
746            private boolean _setModifiedDate;
747            private long _banUserId;
748            private long _originalBanUserId;
749            private boolean _setOriginalBanUserId;
750            private long _columnBitmask;
751            private MBBan _escapedModel;
752    }