1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.messageboards.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.service.ServiceContext;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.expando.model.ExpandoBridge;
27  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
28  import com.liferay.portlet.messageboards.model.MBBan;
29  import com.liferay.portlet.messageboards.model.MBBanSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.Date;
39  import java.util.List;
40  
41  /**
42   * <a href="MBBanModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This interface is a model that represents the MBBan table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       MBBanImpl
56   * @see       com.liferay.portlet.messageboards.model.MBBan
57   * @see       com.liferay.portlet.messageboards.model.MBBanModel
58   * @generated
59   */
60  public class MBBanModelImpl extends BaseModelImpl<MBBan> {
61      public static final String TABLE_NAME = "MBBan";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "banId", new Integer(Types.BIGINT) },
64              { "groupId", new Integer(Types.BIGINT) },
65              { "companyId", new Integer(Types.BIGINT) },
66              { "userId", new Integer(Types.BIGINT) },
67              { "userName", new Integer(Types.VARCHAR) },
68              { "createDate", new Integer(Types.TIMESTAMP) },
69              { "modifiedDate", new Integer(Types.TIMESTAMP) },
70              { "banUserId", new Integer(Types.BIGINT) }
71          };
72      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)";
73      public static final String TABLE_SQL_DROP = "drop table MBBan";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
82              true);
83  
84      public static MBBan toModel(MBBanSoap soapModel) {
85          MBBan model = new MBBanImpl();
86  
87          model.setBanId(soapModel.getBanId());
88          model.setGroupId(soapModel.getGroupId());
89          model.setCompanyId(soapModel.getCompanyId());
90          model.setUserId(soapModel.getUserId());
91          model.setUserName(soapModel.getUserName());
92          model.setCreateDate(soapModel.getCreateDate());
93          model.setModifiedDate(soapModel.getModifiedDate());
94          model.setBanUserId(soapModel.getBanUserId());
95  
96          return model;
97      }
98  
99      public static List<MBBan> toModels(MBBanSoap[] soapModels) {
100         List<MBBan> models = new ArrayList<MBBan>(soapModels.length);
101 
102         for (MBBanSoap soapModel : soapModels) {
103             models.add(toModel(soapModel));
104         }
105 
106         return models;
107     }
108 
109     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
110                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBBan"));
111 
112     public MBBanModelImpl() {
113     }
114 
115     public long getPrimaryKey() {
116         return _banId;
117     }
118 
119     public void setPrimaryKey(long pk) {
120         setBanId(pk);
121     }
122 
123     public Serializable getPrimaryKeyObj() {
124         return new Long(_banId);
125     }
126 
127     public long getBanId() {
128         return _banId;
129     }
130 
131     public void setBanId(long banId) {
132         _banId = banId;
133     }
134 
135     public long getGroupId() {
136         return _groupId;
137     }
138 
139     public void setGroupId(long groupId) {
140         _groupId = groupId;
141 
142         if (!_setOriginalGroupId) {
143             _setOriginalGroupId = true;
144 
145             _originalGroupId = groupId;
146         }
147     }
148 
149     public long getOriginalGroupId() {
150         return _originalGroupId;
151     }
152 
153     public long getCompanyId() {
154         return _companyId;
155     }
156 
157     public void setCompanyId(long companyId) {
158         _companyId = companyId;
159     }
160 
161     public long getUserId() {
162         return _userId;
163     }
164 
165     public void setUserId(long userId) {
166         _userId = userId;
167     }
168 
169     public String getUserUuid() throws SystemException {
170         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
171     }
172 
173     public void setUserUuid(String userUuid) {
174         _userUuid = userUuid;
175     }
176 
177     public String getUserName() {
178         return GetterUtil.getString(_userName);
179     }
180 
181     public void setUserName(String userName) {
182         _userName = userName;
183     }
184 
185     public Date getCreateDate() {
186         return _createDate;
187     }
188 
189     public void setCreateDate(Date createDate) {
190         _createDate = createDate;
191     }
192 
193     public Date getModifiedDate() {
194         return _modifiedDate;
195     }
196 
197     public void setModifiedDate(Date modifiedDate) {
198         _modifiedDate = modifiedDate;
199     }
200 
201     public long getBanUserId() {
202         return _banUserId;
203     }
204 
205     public void setBanUserId(long banUserId) {
206         _banUserId = banUserId;
207 
208         if (!_setOriginalBanUserId) {
209             _setOriginalBanUserId = true;
210 
211             _originalBanUserId = banUserId;
212         }
213     }
214 
215     public String getBanUserUuid() throws SystemException {
216         return PortalUtil.getUserValue(getBanUserId(), "uuid", _banUserUuid);
217     }
218 
219     public void setBanUserUuid(String banUserUuid) {
220         _banUserUuid = banUserUuid;
221     }
222 
223     public long getOriginalBanUserId() {
224         return _originalBanUserId;
225     }
226 
227     public MBBan toEscapedModel() {
228         if (isEscapedModel()) {
229             return (MBBan)this;
230         }
231         else {
232             MBBan model = new MBBanImpl();
233 
234             model.setNew(isNew());
235             model.setEscapedModel(true);
236 
237             model.setBanId(getBanId());
238             model.setGroupId(getGroupId());
239             model.setCompanyId(getCompanyId());
240             model.setUserId(getUserId());
241             model.setUserName(HtmlUtil.escape(getUserName()));
242             model.setCreateDate(getCreateDate());
243             model.setModifiedDate(getModifiedDate());
244             model.setBanUserId(getBanUserId());
245 
246             model = (MBBan)Proxy.newProxyInstance(MBBan.class.getClassLoader(),
247                     new Class[] { MBBan.class }, new ReadOnlyBeanHandler(model));
248 
249             return model;
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 }