001    /**
002     * Copyright (c) 2000-2011 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.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.messageboards.model.MBBan;
029    import com.liferay.portlet.messageboards.model.MBBanModel;
030    import com.liferay.portlet.messageboards.model.MBBanSoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * 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.
044     *
045     * <p>
046     * 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}.
047     * </p>
048     *
049     * <p>
050     * 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.
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    public class MBBanModelImpl extends BaseModelImpl<MBBan> implements MBBanModel {
060            public static final String TABLE_NAME = "MBBan";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "banId", new Integer(Types.BIGINT) },
063                            { "groupId", new Integer(Types.BIGINT) },
064                            { "companyId", new Integer(Types.BIGINT) },
065                            { "userId", new Integer(Types.BIGINT) },
066                            { "userName", new Integer(Types.VARCHAR) },
067                            { "createDate", new Integer(Types.TIMESTAMP) },
068                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
069                            { "banUserId", new Integer(Types.BIGINT) }
070                    };
071            public static final String TABLE_SQL_CREATE = "create table MBBan (banId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,banUserId LONG)";
072            public static final String TABLE_SQL_DROP = "drop table MBBan";
073            public static final String DATA_SOURCE = "liferayDataSource";
074            public static final String SESSION_FACTORY = "liferaySessionFactory";
075            public static final String TX_MANAGER = "liferayTransactionManager";
076            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
078                            true);
079            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
081                            true);
082    
083            /**
084             * Converts the soap model instance into a normal model instance.
085             *
086             * @param soapModel the soap model instance to convert
087             * @return the normal model instance
088             */
089            public static MBBan toModel(MBBanSoap soapModel) {
090                    MBBan model = new MBBanImpl();
091    
092                    model.setBanId(soapModel.getBanId());
093                    model.setGroupId(soapModel.getGroupId());
094                    model.setCompanyId(soapModel.getCompanyId());
095                    model.setUserId(soapModel.getUserId());
096                    model.setUserName(soapModel.getUserName());
097                    model.setCreateDate(soapModel.getCreateDate());
098                    model.setModifiedDate(soapModel.getModifiedDate());
099                    model.setBanUserId(soapModel.getBanUserId());
100    
101                    return model;
102            }
103    
104            /**
105             * Converts the soap model instances into normal model instances.
106             *
107             * @param soapModels the soap model instances to convert
108             * @return the normal model instances
109             */
110            public static List<MBBan> toModels(MBBanSoap[] soapModels) {
111                    List<MBBan> models = new ArrayList<MBBan>(soapModels.length);
112    
113                    for (MBBanSoap soapModel : soapModels) {
114                            models.add(toModel(soapModel));
115                    }
116    
117                    return models;
118            }
119    
120            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
121                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBBan"));
122    
123            public MBBanModelImpl() {
124            }
125    
126            public long getPrimaryKey() {
127                    return _banId;
128            }
129    
130            public void setPrimaryKey(long pk) {
131                    setBanId(pk);
132            }
133    
134            public Serializable getPrimaryKeyObj() {
135                    return new Long(_banId);
136            }
137    
138            public long getBanId() {
139                    return _banId;
140            }
141    
142            public void setBanId(long banId) {
143                    _banId = banId;
144            }
145    
146            public long getGroupId() {
147                    return _groupId;
148            }
149    
150            public void setGroupId(long groupId) {
151                    if (!_setOriginalGroupId) {
152                            _setOriginalGroupId = true;
153    
154                            _originalGroupId = _groupId;
155                    }
156    
157                    _groupId = groupId;
158            }
159    
160            public long getOriginalGroupId() {
161                    return _originalGroupId;
162            }
163    
164            public long getCompanyId() {
165                    return _companyId;
166            }
167    
168            public void setCompanyId(long companyId) {
169                    _companyId = companyId;
170            }
171    
172            public long getUserId() {
173                    return _userId;
174            }
175    
176            public void setUserId(long userId) {
177                    _userId = userId;
178            }
179    
180            public String getUserUuid() throws SystemException {
181                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
182            }
183    
184            public void setUserUuid(String userUuid) {
185                    _userUuid = userUuid;
186            }
187    
188            public String getUserName() {
189                    if (_userName == null) {
190                            return StringPool.BLANK;
191                    }
192                    else {
193                            return _userName;
194                    }
195            }
196    
197            public void setUserName(String userName) {
198                    _userName = userName;
199            }
200    
201            public Date getCreateDate() {
202                    return _createDate;
203            }
204    
205            public void setCreateDate(Date createDate) {
206                    _createDate = createDate;
207            }
208    
209            public Date getModifiedDate() {
210                    return _modifiedDate;
211            }
212    
213            public void setModifiedDate(Date modifiedDate) {
214                    _modifiedDate = modifiedDate;
215            }
216    
217            public long getBanUserId() {
218                    return _banUserId;
219            }
220    
221            public void setBanUserId(long banUserId) {
222                    if (!_setOriginalBanUserId) {
223                            _setOriginalBanUserId = true;
224    
225                            _originalBanUserId = _banUserId;
226                    }
227    
228                    _banUserId = banUserId;
229            }
230    
231            public String getBanUserUuid() throws SystemException {
232                    return PortalUtil.getUserValue(getBanUserId(), "uuid", _banUserUuid);
233            }
234    
235            public void setBanUserUuid(String banUserUuid) {
236                    _banUserUuid = banUserUuid;
237            }
238    
239            public long getOriginalBanUserId() {
240                    return _originalBanUserId;
241            }
242    
243            public MBBan toEscapedModel() {
244                    if (isEscapedModel()) {
245                            return (MBBan)this;
246                    }
247                    else {
248                            return (MBBan)Proxy.newProxyInstance(MBBan.class.getClassLoader(),
249                                    new Class[] { MBBan.class }, new AutoEscapeBeanHandler(this));
250                    }
251            }
252    
253            public ExpandoBridge getExpandoBridge() {
254                    if (_expandoBridge == null) {
255                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
256                                            MBBan.class.getName(), getPrimaryKey());
257                    }
258    
259                    return _expandoBridge;
260            }
261    
262            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
263                    getExpandoBridge().setAttributes(serviceContext);
264            }
265    
266            public Object clone() {
267                    MBBanImpl mbBanImpl = new MBBanImpl();
268    
269                    mbBanImpl.setBanId(getBanId());
270    
271                    mbBanImpl.setGroupId(getGroupId());
272    
273                    MBBanModelImpl mbBanModelImpl = mbBanImpl;
274    
275                    mbBanModelImpl._originalGroupId = mbBanModelImpl._groupId;
276    
277                    mbBanModelImpl._setOriginalGroupId = false;
278                    mbBanImpl.setCompanyId(getCompanyId());
279    
280                    mbBanImpl.setUserId(getUserId());
281    
282                    mbBanImpl.setUserName(getUserName());
283    
284                    mbBanImpl.setCreateDate(getCreateDate());
285    
286                    mbBanImpl.setModifiedDate(getModifiedDate());
287    
288                    mbBanImpl.setBanUserId(getBanUserId());
289    
290                    mbBanModelImpl._originalBanUserId = mbBanModelImpl._banUserId;
291    
292                    mbBanModelImpl._setOriginalBanUserId = false;
293    
294                    return mbBanImpl;
295            }
296    
297            public int compareTo(MBBan mbBan) {
298                    long pk = mbBan.getPrimaryKey();
299    
300                    if (getPrimaryKey() < pk) {
301                            return -1;
302                    }
303                    else if (getPrimaryKey() > pk) {
304                            return 1;
305                    }
306                    else {
307                            return 0;
308                    }
309            }
310    
311            public boolean equals(Object obj) {
312                    if (obj == null) {
313                            return false;
314                    }
315    
316                    MBBan mbBan = null;
317    
318                    try {
319                            mbBan = (MBBan)obj;
320                    }
321                    catch (ClassCastException cce) {
322                            return false;
323                    }
324    
325                    long pk = mbBan.getPrimaryKey();
326    
327                    if (getPrimaryKey() == pk) {
328                            return true;
329                    }
330                    else {
331                            return false;
332                    }
333            }
334    
335            public int hashCode() {
336                    return (int)getPrimaryKey();
337            }
338    
339            public String toString() {
340                    StringBundler sb = new StringBundler(17);
341    
342                    sb.append("{banId=");
343                    sb.append(getBanId());
344                    sb.append(", groupId=");
345                    sb.append(getGroupId());
346                    sb.append(", companyId=");
347                    sb.append(getCompanyId());
348                    sb.append(", userId=");
349                    sb.append(getUserId());
350                    sb.append(", userName=");
351                    sb.append(getUserName());
352                    sb.append(", createDate=");
353                    sb.append(getCreateDate());
354                    sb.append(", modifiedDate=");
355                    sb.append(getModifiedDate());
356                    sb.append(", banUserId=");
357                    sb.append(getBanUserId());
358                    sb.append("}");
359    
360                    return sb.toString();
361            }
362    
363            public String toXmlString() {
364                    StringBundler sb = new StringBundler(28);
365    
366                    sb.append("<model><model-name>");
367                    sb.append("com.liferay.portlet.messageboards.model.MBBan");
368                    sb.append("</model-name>");
369    
370                    sb.append(
371                            "<column><column-name>banId</column-name><column-value><![CDATA[");
372                    sb.append(getBanId());
373                    sb.append("]]></column-value></column>");
374                    sb.append(
375                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
376                    sb.append(getGroupId());
377                    sb.append("]]></column-value></column>");
378                    sb.append(
379                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
380                    sb.append(getCompanyId());
381                    sb.append("]]></column-value></column>");
382                    sb.append(
383                            "<column><column-name>userId</column-name><column-value><![CDATA[");
384                    sb.append(getUserId());
385                    sb.append("]]></column-value></column>");
386                    sb.append(
387                            "<column><column-name>userName</column-name><column-value><![CDATA[");
388                    sb.append(getUserName());
389                    sb.append("]]></column-value></column>");
390                    sb.append(
391                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
392                    sb.append(getCreateDate());
393                    sb.append("]]></column-value></column>");
394                    sb.append(
395                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
396                    sb.append(getModifiedDate());
397                    sb.append("]]></column-value></column>");
398                    sb.append(
399                            "<column><column-name>banUserId</column-name><column-value><![CDATA[");
400                    sb.append(getBanUserId());
401                    sb.append("]]></column-value></column>");
402    
403                    sb.append("</model>");
404    
405                    return sb.toString();
406            }
407    
408            private long _banId;
409            private long _groupId;
410            private long _originalGroupId;
411            private boolean _setOriginalGroupId;
412            private long _companyId;
413            private long _userId;
414            private String _userUuid;
415            private String _userName;
416            private Date _createDate;
417            private Date _modifiedDate;
418            private long _banUserId;
419            private String _banUserUuid;
420            private long _originalBanUserId;
421            private boolean _setOriginalBanUserId;
422            private transient ExpandoBridge _expandoBridge;
423    }