1
22
23 package com.liferay.portlet.messageboards.model.impl;
24
25 import com.liferay.portal.kernel.util.DateUtil;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.model.impl.BaseModelImpl;
28 import com.liferay.portal.util.PropsUtil;
29
30 import java.io.Serializable;
31
32 import java.sql.Types;
33
34 import java.util.Date;
35
36
56 public class MBThreadModelImpl extends BaseModelImpl {
57 public static String TABLE_NAME = "MBThread";
58 public static Object[][] TABLE_COLUMNS = {
59 { "threadId", new Integer(Types.BIGINT) },
60 { "categoryId", new Integer(Types.BIGINT) },
61 { "rootMessageId", new Integer(Types.BIGINT) },
62 { "messageCount", new Integer(Types.INTEGER) },
63 { "viewCount", new Integer(Types.INTEGER) },
64 { "lastPostByUserId", new Integer(Types.BIGINT) },
65 { "lastPostDate", new Integer(Types.TIMESTAMP) },
66 { "priority", new Integer(Types.DOUBLE) }
67 };
68 public static String TABLE_SQL_CREATE = "create table MBThread (threadId LONG not null primary key,categoryId LONG,rootMessageId LONG,messageCount INTEGER,viewCount INTEGER,lastPostByUserId LONG,lastPostDate DATE null,priority DOUBLE)";
69 public static String TABLE_SQL_DROP = "drop table MBThread";
70 public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
71 "xss.allow.com.liferay.portlet.messageboards.model.MBThread"),
72 XSS_ALLOW);
73 public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
74 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThreadModel"));
75
76 public MBThreadModelImpl() {
77 }
78
79 public long getPrimaryKey() {
80 return _threadId;
81 }
82
83 public void setPrimaryKey(long pk) {
84 setThreadId(pk);
85 }
86
87 public Serializable getPrimaryKeyObj() {
88 return new Long(_threadId);
89 }
90
91 public long getThreadId() {
92 return _threadId;
93 }
94
95 public void setThreadId(long threadId) {
96 if (threadId != _threadId) {
97 _threadId = threadId;
98 }
99 }
100
101 public long getCategoryId() {
102 return _categoryId;
103 }
104
105 public void setCategoryId(long categoryId) {
106 if (categoryId != _categoryId) {
107 _categoryId = categoryId;
108 }
109 }
110
111 public long getRootMessageId() {
112 return _rootMessageId;
113 }
114
115 public void setRootMessageId(long rootMessageId) {
116 if (rootMessageId != _rootMessageId) {
117 _rootMessageId = rootMessageId;
118 }
119 }
120
121 public int getMessageCount() {
122 return _messageCount;
123 }
124
125 public void setMessageCount(int messageCount) {
126 if (messageCount != _messageCount) {
127 _messageCount = messageCount;
128 }
129 }
130
131 public int getViewCount() {
132 return _viewCount;
133 }
134
135 public void setViewCount(int viewCount) {
136 if (viewCount != _viewCount) {
137 _viewCount = viewCount;
138 }
139 }
140
141 public long getLastPostByUserId() {
142 return _lastPostByUserId;
143 }
144
145 public void setLastPostByUserId(long lastPostByUserId) {
146 if (lastPostByUserId != _lastPostByUserId) {
147 _lastPostByUserId = lastPostByUserId;
148 }
149 }
150
151 public Date getLastPostDate() {
152 return _lastPostDate;
153 }
154
155 public void setLastPostDate(Date lastPostDate) {
156 if (((lastPostDate == null) && (_lastPostDate != null)) ||
157 ((lastPostDate != null) && (_lastPostDate == null)) ||
158 ((lastPostDate != null) && (_lastPostDate != null) &&
159 !lastPostDate.equals(_lastPostDate))) {
160 _lastPostDate = lastPostDate;
161 }
162 }
163
164 public double getPriority() {
165 return _priority;
166 }
167
168 public void setPriority(double priority) {
169 if (priority != _priority) {
170 _priority = priority;
171 }
172 }
173
174 public Object clone() {
175 MBThreadImpl clone = new MBThreadImpl();
176 clone.setThreadId(getThreadId());
177 clone.setCategoryId(getCategoryId());
178 clone.setRootMessageId(getRootMessageId());
179 clone.setMessageCount(getMessageCount());
180 clone.setViewCount(getViewCount());
181 clone.setLastPostByUserId(getLastPostByUserId());
182 clone.setLastPostDate(getLastPostDate());
183 clone.setPriority(getPriority());
184
185 return clone;
186 }
187
188 public int compareTo(Object obj) {
189 if (obj == null) {
190 return -1;
191 }
192
193 MBThreadImpl mbThread = (MBThreadImpl)obj;
194 int value = 0;
195
196 if (getPriority() < mbThread.getPriority()) {
197 value = -1;
198 }
199 else if (getPriority() > mbThread.getPriority()) {
200 value = 1;
201 }
202 else {
203 value = 0;
204 }
205
206 value = value * -1;
207
208 if (value != 0) {
209 return value;
210 }
211
212 value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
213 value = value * -1;
214
215 if (value != 0) {
216 return value;
217 }
218
219 return 0;
220 }
221
222 public boolean equals(Object obj) {
223 if (obj == null) {
224 return false;
225 }
226
227 MBThreadImpl mbThread = null;
228
229 try {
230 mbThread = (MBThreadImpl)obj;
231 }
232 catch (ClassCastException cce) {
233 return false;
234 }
235
236 long pk = mbThread.getPrimaryKey();
237
238 if (getPrimaryKey() == pk) {
239 return true;
240 }
241 else {
242 return false;
243 }
244 }
245
246 public int hashCode() {
247 return (int)getPrimaryKey();
248 }
249
250 private long _threadId;
251 private long _categoryId;
252 private long _rootMessageId;
253 private int _messageCount;
254 private int _viewCount;
255 private long _lastPostByUserId;
256 private Date _lastPostDate;
257 private double _priority;
258 }