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