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.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.HtmlUtil;
22  import com.liferay.portal.kernel.util.StringBundler;
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         return GetterUtil.getString(_statusByUserName);
248     }
249 
250     public void setStatusByUserName(String statusByUserName) {
251         _statusByUserName = statusByUserName;
252     }
253 
254     public Date getStatusDate() {
255         return _statusDate;
256     }
257 
258     public void setStatusDate(Date statusDate) {
259         _statusDate = statusDate;
260     }
261 
262     public MBThread toEscapedModel() {
263         if (isEscapedModel()) {
264             return (MBThread)this;
265         }
266         else {
267             MBThread model = new MBThreadImpl();
268 
269             model.setNew(isNew());
270             model.setEscapedModel(true);
271 
272             model.setThreadId(getThreadId());
273             model.setGroupId(getGroupId());
274             model.setCategoryId(getCategoryId());
275             model.setRootMessageId(getRootMessageId());
276             model.setMessageCount(getMessageCount());
277             model.setViewCount(getViewCount());
278             model.setLastPostByUserId(getLastPostByUserId());
279             model.setLastPostDate(getLastPostDate());
280             model.setPriority(getPriority());
281             model.setStatus(getStatus());
282             model.setStatusByUserId(getStatusByUserId());
283             model.setStatusByUserName(HtmlUtil.escape(getStatusByUserName()));
284             model.setStatusDate(getStatusDate());
285 
286             model = (MBThread)Proxy.newProxyInstance(MBThread.class.getClassLoader(),
287                     new Class[] { MBThread.class },
288                     new ReadOnlyBeanHandler(model));
289 
290             return model;
291         }
292     }
293 
294     public ExpandoBridge getExpandoBridge() {
295         if (_expandoBridge == null) {
296             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
297                     MBThread.class.getName(), getPrimaryKey());
298         }
299 
300         return _expandoBridge;
301     }
302 
303     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
304         getExpandoBridge().setAttributes(serviceContext);
305     }
306 
307     public Object clone() {
308         MBThreadImpl clone = new MBThreadImpl();
309 
310         clone.setThreadId(getThreadId());
311         clone.setGroupId(getGroupId());
312         clone.setCategoryId(getCategoryId());
313         clone.setRootMessageId(getRootMessageId());
314         clone.setMessageCount(getMessageCount());
315         clone.setViewCount(getViewCount());
316         clone.setLastPostByUserId(getLastPostByUserId());
317         clone.setLastPostDate(getLastPostDate());
318         clone.setPriority(getPriority());
319         clone.setStatus(getStatus());
320         clone.setStatusByUserId(getStatusByUserId());
321         clone.setStatusByUserName(getStatusByUserName());
322         clone.setStatusDate(getStatusDate());
323 
324         return clone;
325     }
326 
327     public int compareTo(MBThread mbThread) {
328         int value = 0;
329 
330         if (getPriority() < mbThread.getPriority()) {
331             value = -1;
332         }
333         else if (getPriority() > mbThread.getPriority()) {
334             value = 1;
335         }
336         else {
337             value = 0;
338         }
339 
340         value = value * -1;
341 
342         if (value != 0) {
343             return value;
344         }
345 
346         value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
347 
348         value = value * -1;
349 
350         if (value != 0) {
351             return value;
352         }
353 
354         return 0;
355     }
356 
357     public boolean equals(Object obj) {
358         if (obj == null) {
359             return false;
360         }
361 
362         MBThread mbThread = null;
363 
364         try {
365             mbThread = (MBThread)obj;
366         }
367         catch (ClassCastException cce) {
368             return false;
369         }
370 
371         long pk = mbThread.getPrimaryKey();
372 
373         if (getPrimaryKey() == pk) {
374             return true;
375         }
376         else {
377             return false;
378         }
379     }
380 
381     public int hashCode() {
382         return (int)getPrimaryKey();
383     }
384 
385     public String toString() {
386         StringBundler sb = new StringBundler(27);
387 
388         sb.append("{threadId=");
389         sb.append(getThreadId());
390         sb.append(", groupId=");
391         sb.append(getGroupId());
392         sb.append(", categoryId=");
393         sb.append(getCategoryId());
394         sb.append(", rootMessageId=");
395         sb.append(getRootMessageId());
396         sb.append(", messageCount=");
397         sb.append(getMessageCount());
398         sb.append(", viewCount=");
399         sb.append(getViewCount());
400         sb.append(", lastPostByUserId=");
401         sb.append(getLastPostByUserId());
402         sb.append(", lastPostDate=");
403         sb.append(getLastPostDate());
404         sb.append(", priority=");
405         sb.append(getPriority());
406         sb.append(", status=");
407         sb.append(getStatus());
408         sb.append(", statusByUserId=");
409         sb.append(getStatusByUserId());
410         sb.append(", statusByUserName=");
411         sb.append(getStatusByUserName());
412         sb.append(", statusDate=");
413         sb.append(getStatusDate());
414         sb.append("}");
415 
416         return sb.toString();
417     }
418 
419     public String toXmlString() {
420         StringBundler sb = new StringBundler(43);
421 
422         sb.append("<model><model-name>");
423         sb.append("com.liferay.portlet.messageboards.model.MBThread");
424         sb.append("</model-name>");
425 
426         sb.append(
427             "<column><column-name>threadId</column-name><column-value><![CDATA[");
428         sb.append(getThreadId());
429         sb.append("]]></column-value></column>");
430         sb.append(
431             "<column><column-name>groupId</column-name><column-value><![CDATA[");
432         sb.append(getGroupId());
433         sb.append("]]></column-value></column>");
434         sb.append(
435             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
436         sb.append(getCategoryId());
437         sb.append("]]></column-value></column>");
438         sb.append(
439             "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
440         sb.append(getRootMessageId());
441         sb.append("]]></column-value></column>");
442         sb.append(
443             "<column><column-name>messageCount</column-name><column-value><![CDATA[");
444         sb.append(getMessageCount());
445         sb.append("]]></column-value></column>");
446         sb.append(
447             "<column><column-name>viewCount</column-name><column-value><![CDATA[");
448         sb.append(getViewCount());
449         sb.append("]]></column-value></column>");
450         sb.append(
451             "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
452         sb.append(getLastPostByUserId());
453         sb.append("]]></column-value></column>");
454         sb.append(
455             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
456         sb.append(getLastPostDate());
457         sb.append("]]></column-value></column>");
458         sb.append(
459             "<column><column-name>priority</column-name><column-value><![CDATA[");
460         sb.append(getPriority());
461         sb.append("]]></column-value></column>");
462         sb.append(
463             "<column><column-name>status</column-name><column-value><![CDATA[");
464         sb.append(getStatus());
465         sb.append("]]></column-value></column>");
466         sb.append(
467             "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
468         sb.append(getStatusByUserId());
469         sb.append("]]></column-value></column>");
470         sb.append(
471             "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
472         sb.append(getStatusByUserName());
473         sb.append("]]></column-value></column>");
474         sb.append(
475             "<column><column-name>statusDate</column-name><column-value><![CDATA[");
476         sb.append(getStatusDate());
477         sb.append("]]></column-value></column>");
478 
479         sb.append("</model>");
480 
481         return sb.toString();
482     }
483 
484     private long _threadId;
485     private long _groupId;
486     private long _categoryId;
487     private long _rootMessageId;
488     private int _messageCount;
489     private int _viewCount;
490     private long _lastPostByUserId;
491     private String _lastPostByUserUuid;
492     private Date _lastPostDate;
493     private double _priority;
494     private int _status;
495     private long _statusByUserId;
496     private String _statusByUserUuid;
497     private String _statusByUserName;
498     private Date _statusDate;
499     private transient ExpandoBridge _expandoBridge;
500 }