001    /**
002     * Copyright (c) 2000-2010 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                    _groupId = groupId;
152    
153                    if (!_setOriginalGroupId) {
154                            _setOriginalGroupId = true;
155    
156                            _originalGroupId = groupId;
157                    }
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                    _banUserId = banUserId;
223    
224                    if (!_setOriginalBanUserId) {
225                            _setOriginalBanUserId = true;
226    
227                            _originalBanUserId = banUserId;
228                    }
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 clone = new MBBanImpl();
268    
269                    clone.setBanId(getBanId());
270                    clone.setGroupId(getGroupId());
271                    clone.setCompanyId(getCompanyId());
272                    clone.setUserId(getUserId());
273                    clone.setUserName(getUserName());
274                    clone.setCreateDate(getCreateDate());
275                    clone.setModifiedDate(getModifiedDate());
276                    clone.setBanUserId(getBanUserId());
277    
278                    return clone;
279            }
280    
281            public int compareTo(MBBan mbBan) {
282                    long pk = mbBan.getPrimaryKey();
283    
284                    if (getPrimaryKey() < pk) {
285                            return -1;
286                    }
287                    else if (getPrimaryKey() > pk) {
288                            return 1;
289                    }
290                    else {
291                            return 0;
292                    }
293            }
294    
295            public boolean equals(Object obj) {
296                    if (obj == null) {
297                            return false;
298                    }
299    
300                    MBBan mbBan = null;
301    
302                    try {
303                            mbBan = (MBBan)obj;
304                    }
305                    catch (ClassCastException cce) {
306                            return false;
307                    }
308    
309                    long pk = mbBan.getPrimaryKey();
310    
311                    if (getPrimaryKey() == pk) {
312                            return true;
313                    }
314                    else {
315                            return false;
316                    }
317            }
318    
319            public int hashCode() {
320                    return (int)getPrimaryKey();
321            }
322    
323            public String toString() {
324                    StringBundler sb = new StringBundler(17);
325    
326                    sb.append("{banId=");
327                    sb.append(getBanId());
328                    sb.append(", groupId=");
329                    sb.append(getGroupId());
330                    sb.append(", companyId=");
331                    sb.append(getCompanyId());
332                    sb.append(", userId=");
333                    sb.append(getUserId());
334                    sb.append(", userName=");
335                    sb.append(getUserName());
336                    sb.append(", createDate=");
337                    sb.append(getCreateDate());
338                    sb.append(", modifiedDate=");
339                    sb.append(getModifiedDate());
340                    sb.append(", banUserId=");
341                    sb.append(getBanUserId());
342                    sb.append("}");
343    
344                    return sb.toString();
345            }
346    
347            public String toXmlString() {
348                    StringBundler sb = new StringBundler(28);
349    
350                    sb.append("<model><model-name>");
351                    sb.append("com.liferay.portlet.messageboards.model.MBBan");
352                    sb.append("</model-name>");
353    
354                    sb.append(
355                            "<column><column-name>banId</column-name><column-value><![CDATA[");
356                    sb.append(getBanId());
357                    sb.append("]]></column-value></column>");
358                    sb.append(
359                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
360                    sb.append(getGroupId());
361                    sb.append("]]></column-value></column>");
362                    sb.append(
363                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
364                    sb.append(getCompanyId());
365                    sb.append("]]></column-value></column>");
366                    sb.append(
367                            "<column><column-name>userId</column-name><column-value><![CDATA[");
368                    sb.append(getUserId());
369                    sb.append("]]></column-value></column>");
370                    sb.append(
371                            "<column><column-name>userName</column-name><column-value><![CDATA[");
372                    sb.append(getUserName());
373                    sb.append("]]></column-value></column>");
374                    sb.append(
375                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
376                    sb.append(getCreateDate());
377                    sb.append("]]></column-value></column>");
378                    sb.append(
379                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
380                    sb.append(getModifiedDate());
381                    sb.append("]]></column-value></column>");
382                    sb.append(
383                            "<column><column-name>banUserId</column-name><column-value><![CDATA[");
384                    sb.append(getBanUserId());
385                    sb.append("]]></column-value></column>");
386    
387                    sb.append("</model>");
388    
389                    return sb.toString();
390            }
391    
392            private long _banId;
393            private long _groupId;
394            private long _originalGroupId;
395            private boolean _setOriginalGroupId;
396            private long _companyId;
397            private long _userId;
398            private String _userUuid;
399            private String _userName;
400            private Date _createDate;
401            private Date _modifiedDate;
402            private long _banUserId;
403            private String _banUserUuid;
404            private long _originalBanUserId;
405            private boolean _setOriginalBanUserId;
406            private transient ExpandoBridge _expandoBridge;
407    }