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.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.kernel.util.StringPool;
23  import com.liferay.portal.model.impl.BaseModelImpl;
24  import com.liferay.portal.service.ServiceContext;
25  import com.liferay.portal.util.PortalUtil;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29  import com.liferay.portlet.messageboards.model.MBThread;
30  import com.liferay.portlet.messageboards.model.MBThreadSoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="MBThreadModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This interface is a model that represents the MBThread table in the
52   * database.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       MBThreadImpl
57   * @see       com.liferay.portlet.messageboards.model.MBThread
58   * @see       com.liferay.portlet.messageboards.model.MBThreadModel
59   * @generated
60   */
61  public class MBThreadModelImpl extends BaseModelImpl<MBThread> {
62      public static final String TABLE_NAME = "MBThread";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "threadId", new Integer(Types.BIGINT) },
65              { "groupId", new Integer(Types.BIGINT) },
66              { "categoryId", new Integer(Types.BIGINT) },
67              { "rootMessageId", new Integer(Types.BIGINT) },
68              { "messageCount", new Integer(Types.INTEGER) },
69              { "viewCount", new Integer(Types.INTEGER) },
70              { "lastPostByUserId", new Integer(Types.BIGINT) },
71              { "lastPostDate", new Integer(Types.TIMESTAMP) },
72              { "priority", new Integer(Types.DOUBLE) },
73              { "status", new Integer(Types.INTEGER) },
74              { "statusByUserId", new Integer(Types.BIGINT) },
75              { "statusByUserName", new Integer(Types.VARCHAR) },
76              { "statusDate", new Integer(Types.TIMESTAMP) }
77          };
78      public static final String TABLE_SQL_CREATE = "create table MBThread (threadId LONG not null primary key,groupId LONG,categoryId LONG,rootMessageId LONG,messageCount INTEGER,viewCount INTEGER,lastPostByUserId LONG,lastPostDate DATE null,priority DOUBLE,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
79      public static final String TABLE_SQL_DROP = "drop table MBThread";
80      public static final String ORDER_BY_JPQL = " ORDER BY mbThread.priority DESC, mbThread.lastPostDate DESC";
81      public static final String ORDER_BY_SQL = " ORDER BY MBThread.priority DESC, MBThread.lastPostDate DESC";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
87              true);
88      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
90              true);
91  
92      public static MBThread toModel(MBThreadSoap soapModel) {
93          MBThread model = new MBThreadImpl();
94  
95          model.setThreadId(soapModel.getThreadId());
96          model.setGroupId(soapModel.getGroupId());
97          model.setCategoryId(soapModel.getCategoryId());
98          model.setRootMessageId(soapModel.getRootMessageId());
99          model.setMessageCount(soapModel.getMessageCount());
100         model.setViewCount(soapModel.getViewCount());
101         model.setLastPostByUserId(soapModel.getLastPostByUserId());
102         model.setLastPostDate(soapModel.getLastPostDate());
103         model.setPriority(soapModel.getPriority());
104         model.setStatus(soapModel.getStatus());
105         model.setStatusByUserId(soapModel.getStatusByUserId());
106         model.setStatusByUserName(soapModel.getStatusByUserName());
107         model.setStatusDate(soapModel.getStatusDate());
108 
109         return model;
110     }
111 
112     public static List<MBThread> toModels(MBThreadSoap[] soapModels) {
113         List<MBThread> models = new ArrayList<MBThread>(soapModels.length);
114 
115         for (MBThreadSoap soapModel : soapModels) {
116             models.add(toModel(soapModel));
117         }
118 
119         return models;
120     }
121 
122     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThread"));
124 
125     public MBThreadModelImpl() {
126     }
127 
128     public long getPrimaryKey() {
129         return _threadId;
130     }
131 
132     public void setPrimaryKey(long pk) {
133         setThreadId(pk);
134     }
135 
136     public Serializable getPrimaryKeyObj() {
137         return new Long(_threadId);
138     }
139 
140     public long getThreadId() {
141         return _threadId;
142     }
143 
144     public void setThreadId(long threadId) {
145         _threadId = threadId;
146     }
147 
148     public long getGroupId() {
149         return _groupId;
150     }
151 
152     public void setGroupId(long groupId) {
153         _groupId = groupId;
154     }
155 
156     public long getCategoryId() {
157         return _categoryId;
158     }
159 
160     public void setCategoryId(long categoryId) {
161         _categoryId = categoryId;
162     }
163 
164     public long getRootMessageId() {
165         return _rootMessageId;
166     }
167 
168     public void setRootMessageId(long rootMessageId) {
169         _rootMessageId = rootMessageId;
170     }
171 
172     public int getMessageCount() {
173         return _messageCount;
174     }
175 
176     public void setMessageCount(int messageCount) {
177         _messageCount = messageCount;
178     }
179 
180     public int getViewCount() {
181         return _viewCount;
182     }
183 
184     public void setViewCount(int viewCount) {
185         _viewCount = viewCount;
186     }
187 
188     public long getLastPostByUserId() {
189         return _lastPostByUserId;
190     }
191 
192     public void setLastPostByUserId(long lastPostByUserId) {
193         _lastPostByUserId = lastPostByUserId;
194     }
195 
196     public String getLastPostByUserUuid() throws SystemException {
197         return PortalUtil.getUserValue(getLastPostByUserId(), "uuid",
198             _lastPostByUserUuid);
199     }
200 
201     public void setLastPostByUserUuid(String lastPostByUserUuid) {
202         _lastPostByUserUuid = lastPostByUserUuid;
203     }
204 
205     public Date getLastPostDate() {
206         return _lastPostDate;
207     }
208 
209     public void setLastPostDate(Date lastPostDate) {
210         _lastPostDate = lastPostDate;
211     }
212 
213     public double getPriority() {
214         return _priority;
215     }
216 
217     public void setPriority(double priority) {
218         _priority = priority;
219     }
220 
221     public int getStatus() {
222         return _status;
223     }
224 
225     public void setStatus(int status) {
226         _status = status;
227     }
228 
229     public long getStatusByUserId() {
230         return _statusByUserId;
231     }
232 
233     public void setStatusByUserId(long statusByUserId) {
234         _statusByUserId = statusByUserId;
235     }
236 
237     public String getStatusByUserUuid() throws SystemException {
238         return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
239             _statusByUserUuid);
240     }
241 
242     public void setStatusByUserUuid(String statusByUserUuid) {
243         _statusByUserUuid = statusByUserUuid;
244     }
245 
246     public String getStatusByUserName() {
247         if (_statusByUserName == null) {
248             return StringPool.BLANK;
249         }
250         else {
251             return _statusByUserName;
252         }
253     }
254 
255     public void setStatusByUserName(String statusByUserName) {
256         _statusByUserName = statusByUserName;
257     }
258 
259     public Date getStatusDate() {
260         return _statusDate;
261     }
262 
263     public void setStatusDate(Date statusDate) {
264         _statusDate = statusDate;
265     }
266 
267     public MBThread toEscapedModel() {
268         if (isEscapedModel()) {
269             return (MBThread)this;
270         }
271         else {
272             return (MBThread)Proxy.newProxyInstance(MBThread.class.getClassLoader(),
273                 new Class[] { MBThread.class }, new AutoEscapeBeanHandler(this));
274         }
275     }
276 
277     public ExpandoBridge getExpandoBridge() {
278         if (_expandoBridge == null) {
279             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
280                     MBThread.class.getName(), getPrimaryKey());
281         }
282 
283         return _expandoBridge;
284     }
285 
286     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
287         getExpandoBridge().setAttributes(serviceContext);
288     }
289 
290     public Object clone() {
291         MBThreadImpl clone = new MBThreadImpl();
292 
293         clone.setThreadId(getThreadId());
294         clone.setGroupId(getGroupId());
295         clone.setCategoryId(getCategoryId());
296         clone.setRootMessageId(getRootMessageId());
297         clone.setMessageCount(getMessageCount());
298         clone.setViewCount(getViewCount());
299         clone.setLastPostByUserId(getLastPostByUserId());
300         clone.setLastPostDate(getLastPostDate());
301         clone.setPriority(getPriority());
302         clone.setStatus(getStatus());
303         clone.setStatusByUserId(getStatusByUserId());
304         clone.setStatusByUserName(getStatusByUserName());
305         clone.setStatusDate(getStatusDate());
306 
307         return clone;
308     }
309 
310     public int compareTo(MBThread mbThread) {
311         int value = 0;
312 
313         if (getPriority() < mbThread.getPriority()) {
314             value = -1;
315         }
316         else if (getPriority() > mbThread.getPriority()) {
317             value = 1;
318         }
319         else {
320             value = 0;
321         }
322 
323         value = value * -1;
324 
325         if (value != 0) {
326             return value;
327         }
328 
329         value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
330 
331         value = value * -1;
332 
333         if (value != 0) {
334             return value;
335         }
336 
337         return 0;
338     }
339 
340     public boolean equals(Object obj) {
341         if (obj == null) {
342             return false;
343         }
344 
345         MBThread mbThread = null;
346 
347         try {
348             mbThread = (MBThread)obj;
349         }
350         catch (ClassCastException cce) {
351             return false;
352         }
353 
354         long pk = mbThread.getPrimaryKey();
355 
356         if (getPrimaryKey() == pk) {
357             return true;
358         }
359         else {
360             return false;
361         }
362     }
363 
364     public int hashCode() {
365         return (int)getPrimaryKey();
366     }
367 
368     public String toString() {
369         StringBundler sb = new StringBundler(27);
370 
371         sb.append("{threadId=");
372         sb.append(getThreadId());
373         sb.append(", groupId=");
374         sb.append(getGroupId());
375         sb.append(", categoryId=");
376         sb.append(getCategoryId());
377         sb.append(", rootMessageId=");
378         sb.append(getRootMessageId());
379         sb.append(", messageCount=");
380         sb.append(getMessageCount());
381         sb.append(", viewCount=");
382         sb.append(getViewCount());
383         sb.append(", lastPostByUserId=");
384         sb.append(getLastPostByUserId());
385         sb.append(", lastPostDate=");
386         sb.append(getLastPostDate());
387         sb.append(", priority=");
388         sb.append(getPriority());
389         sb.append(", status=");
390         sb.append(getStatus());
391         sb.append(", statusByUserId=");
392         sb.append(getStatusByUserId());
393         sb.append(", statusByUserName=");
394         sb.append(getStatusByUserName());
395         sb.append(", statusDate=");
396         sb.append(getStatusDate());
397         sb.append("}");
398 
399         return sb.toString();
400     }
401 
402     public String toXmlString() {
403         StringBundler sb = new StringBundler(43);
404 
405         sb.append("<model><model-name>");
406         sb.append("com.liferay.portlet.messageboards.model.MBThread");
407         sb.append("</model-name>");
408 
409         sb.append(
410             "<column><column-name>threadId</column-name><column-value><![CDATA[");
411         sb.append(getThreadId());
412         sb.append("]]></column-value></column>");
413         sb.append(
414             "<column><column-name>groupId</column-name><column-value><![CDATA[");
415         sb.append(getGroupId());
416         sb.append("]]></column-value></column>");
417         sb.append(
418             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
419         sb.append(getCategoryId());
420         sb.append("]]></column-value></column>");
421         sb.append(
422             "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
423         sb.append(getRootMessageId());
424         sb.append("]]></column-value></column>");
425         sb.append(
426             "<column><column-name>messageCount</column-name><column-value><![CDATA[");
427         sb.append(getMessageCount());
428         sb.append("]]></column-value></column>");
429         sb.append(
430             "<column><column-name>viewCount</column-name><column-value><![CDATA[");
431         sb.append(getViewCount());
432         sb.append("]]></column-value></column>");
433         sb.append(
434             "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
435         sb.append(getLastPostByUserId());
436         sb.append("]]></column-value></column>");
437         sb.append(
438             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
439         sb.append(getLastPostDate());
440         sb.append("]]></column-value></column>");
441         sb.append(
442             "<column><column-name>priority</column-name><column-value><![CDATA[");
443         sb.append(getPriority());
444         sb.append("]]></column-value></column>");
445         sb.append(
446             "<column><column-name>status</column-name><column-value><![CDATA[");
447         sb.append(getStatus());
448         sb.append("]]></column-value></column>");
449         sb.append(
450             "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
451         sb.append(getStatusByUserId());
452         sb.append("]]></column-value></column>");
453         sb.append(
454             "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
455         sb.append(getStatusByUserName());
456         sb.append("]]></column-value></column>");
457         sb.append(
458             "<column><column-name>statusDate</column-name><column-value><![CDATA[");
459         sb.append(getStatusDate());
460         sb.append("]]></column-value></column>");
461 
462         sb.append("</model>");
463 
464         return sb.toString();
465     }
466 
467     private long _threadId;
468     private long _groupId;
469     private long _categoryId;
470     private long _rootMessageId;
471     private int _messageCount;
472     private int _viewCount;
473     private long _lastPostByUserId;
474     private String _lastPostByUserUuid;
475     private Date _lastPostDate;
476     private double _priority;
477     private int _status;
478     private long _statusByUserId;
479     private String _statusByUserUuid;
480     private String _statusByUserName;
481     private Date _statusDate;
482     private transient ExpandoBridge _expandoBridge;
483 }