1
22
23 package com.liferay.portlet.messageboards.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.DateUtil;
27 import com.liferay.portal.kernel.util.GetterUtil;
28 import com.liferay.portal.kernel.util.HtmlUtil;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30
31 import com.liferay.portlet.expando.model.ExpandoBridge;
32 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33 import com.liferay.portlet.messageboards.model.MBMessage;
34 import com.liferay.portlet.messageboards.model.MBMessageSoap;
35
36 import java.io.Serializable;
37
38 import java.lang.reflect.Proxy;
39
40 import java.sql.Types;
41
42 import java.util.ArrayList;
43 import java.util.Date;
44 import java.util.List;
45
46
66 public class MBMessageModelImpl extends BaseModelImpl {
67 public static final String TABLE_NAME = "MBMessage";
68 public static final Object[][] TABLE_COLUMNS = {
69 { "uuid_", new Integer(Types.VARCHAR) },
70
71
72 { "messageId", new Integer(Types.BIGINT) },
73
74
75 { "companyId", new Integer(Types.BIGINT) },
76
77
78 { "userId", new Integer(Types.BIGINT) },
79
80
81 { "userName", new Integer(Types.VARCHAR) },
82
83
84 { "createDate", new Integer(Types.TIMESTAMP) },
85
86
87 { "modifiedDate", new Integer(Types.TIMESTAMP) },
88
89
90 { "categoryId", new Integer(Types.BIGINT) },
91
92
93 { "threadId", new Integer(Types.BIGINT) },
94
95
96 { "parentMessageId", new Integer(Types.BIGINT) },
97
98
99 { "subject", new Integer(Types.VARCHAR) },
100
101
102 { "body", new Integer(Types.CLOB) },
103
104
105 { "attachments", new Integer(Types.BOOLEAN) },
106
107
108 { "anonymous", new Integer(Types.BOOLEAN) }
109 };
110 public static final String TABLE_SQL_CREATE = "create table MBMessage (uuid_ VARCHAR(75) null,messageId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,threadId LONG,parentMessageId LONG,subject VARCHAR(75) null,body TEXT null,attachments BOOLEAN,anonymous BOOLEAN)";
111 public static final String TABLE_SQL_DROP = "drop table MBMessage";
112 public static final String DATA_SOURCE = "liferayDataSource";
113 public static final String SESSION_FACTORY = "liferaySessionFactory";
114 public static final String TX_MANAGER = "liferayTransactionManager";
115 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
116 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBMessage"),
117 true);
118
119 public static MBMessage toModel(MBMessageSoap soapModel) {
120 MBMessage model = new MBMessageImpl();
121
122 model.setUuid(soapModel.getUuid());
123 model.setMessageId(soapModel.getMessageId());
124 model.setCompanyId(soapModel.getCompanyId());
125 model.setUserId(soapModel.getUserId());
126 model.setUserName(soapModel.getUserName());
127 model.setCreateDate(soapModel.getCreateDate());
128 model.setModifiedDate(soapModel.getModifiedDate());
129 model.setCategoryId(soapModel.getCategoryId());
130 model.setThreadId(soapModel.getThreadId());
131 model.setParentMessageId(soapModel.getParentMessageId());
132 model.setSubject(soapModel.getSubject());
133 model.setBody(soapModel.getBody());
134 model.setAttachments(soapModel.getAttachments());
135 model.setAnonymous(soapModel.getAnonymous());
136
137 return model;
138 }
139
140 public static List<MBMessage> toModels(MBMessageSoap[] soapModels) {
141 List<MBMessage> models = new ArrayList<MBMessage>(soapModels.length);
142
143 for (MBMessageSoap soapModel : soapModels) {
144 models.add(toModel(soapModel));
145 }
146
147 return models;
148 }
149
150 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
151 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBMessage"));
152
153 public MBMessageModelImpl() {
154 }
155
156 public long getPrimaryKey() {
157 return _messageId;
158 }
159
160 public void setPrimaryKey(long pk) {
161 setMessageId(pk);
162 }
163
164 public Serializable getPrimaryKeyObj() {
165 return new Long(_messageId);
166 }
167
168 public String getUuid() {
169 return GetterUtil.getString(_uuid);
170 }
171
172 public void setUuid(String uuid) {
173 if ((uuid != null) && (uuid != _uuid)) {
174 _uuid = uuid;
175 }
176 }
177
178 public long getMessageId() {
179 return _messageId;
180 }
181
182 public void setMessageId(long messageId) {
183 if (messageId != _messageId) {
184 _messageId = messageId;
185 }
186 }
187
188 public long getCompanyId() {
189 return _companyId;
190 }
191
192 public void setCompanyId(long companyId) {
193 if (companyId != _companyId) {
194 _companyId = companyId;
195 }
196 }
197
198 public long getUserId() {
199 return _userId;
200 }
201
202 public void setUserId(long userId) {
203 if (userId != _userId) {
204 _userId = userId;
205 }
206 }
207
208 public String getUserName() {
209 return GetterUtil.getString(_userName);
210 }
211
212 public void setUserName(String userName) {
213 if (((userName == null) && (_userName != null)) ||
214 ((userName != null) && (_userName == null)) ||
215 ((userName != null) && (_userName != null) &&
216 !userName.equals(_userName))) {
217 _userName = userName;
218 }
219 }
220
221 public Date getCreateDate() {
222 return _createDate;
223 }
224
225 public void setCreateDate(Date createDate) {
226 if (((createDate == null) && (_createDate != null)) ||
227 ((createDate != null) && (_createDate == null)) ||
228 ((createDate != null) && (_createDate != null) &&
229 !createDate.equals(_createDate))) {
230 _createDate = createDate;
231 }
232 }
233
234 public Date getModifiedDate() {
235 return _modifiedDate;
236 }
237
238 public void setModifiedDate(Date modifiedDate) {
239 if (((modifiedDate == null) && (_modifiedDate != null)) ||
240 ((modifiedDate != null) && (_modifiedDate == null)) ||
241 ((modifiedDate != null) && (_modifiedDate != null) &&
242 !modifiedDate.equals(_modifiedDate))) {
243 _modifiedDate = modifiedDate;
244 }
245 }
246
247 public long getCategoryId() {
248 return _categoryId;
249 }
250
251 public void setCategoryId(long categoryId) {
252 if (categoryId != _categoryId) {
253 _categoryId = categoryId;
254 }
255 }
256
257 public long getThreadId() {
258 return _threadId;
259 }
260
261 public void setThreadId(long threadId) {
262 if (threadId != _threadId) {
263 _threadId = threadId;
264 }
265 }
266
267 public long getParentMessageId() {
268 return _parentMessageId;
269 }
270
271 public void setParentMessageId(long parentMessageId) {
272 if (parentMessageId != _parentMessageId) {
273 _parentMessageId = parentMessageId;
274 }
275 }
276
277 public String getSubject() {
278 return GetterUtil.getString(_subject);
279 }
280
281 public void setSubject(String subject) {
282 if (((subject == null) && (_subject != null)) ||
283 ((subject != null) && (_subject == null)) ||
284 ((subject != null) && (_subject != null) &&
285 !subject.equals(_subject))) {
286 _subject = subject;
287 }
288 }
289
290 public String getBody() {
291 return GetterUtil.getString(_body);
292 }
293
294 public void setBody(String body) {
295 if (((body == null) && (_body != null)) ||
296 ((body != null) && (_body == null)) ||
297 ((body != null) && (_body != null) && !body.equals(_body))) {
298 _body = body;
299 }
300 }
301
302 public boolean getAttachments() {
303 return _attachments;
304 }
305
306 public boolean isAttachments() {
307 return _attachments;
308 }
309
310 public void setAttachments(boolean attachments) {
311 if (attachments != _attachments) {
312 _attachments = attachments;
313 }
314 }
315
316 public boolean getAnonymous() {
317 return _anonymous;
318 }
319
320 public boolean isAnonymous() {
321 return _anonymous;
322 }
323
324 public void setAnonymous(boolean anonymous) {
325 if (anonymous != _anonymous) {
326 _anonymous = anonymous;
327 }
328 }
329
330 public MBMessage toEscapedModel() {
331 if (isEscapedModel()) {
332 return (MBMessage)this;
333 }
334 else {
335 MBMessage model = new MBMessageImpl();
336
337 model.setNew(isNew());
338 model.setEscapedModel(true);
339
340 model.setUuid(HtmlUtil.escape(getUuid()));
341 model.setMessageId(getMessageId());
342 model.setCompanyId(getCompanyId());
343 model.setUserId(getUserId());
344 model.setUserName(HtmlUtil.escape(getUserName()));
345 model.setCreateDate(getCreateDate());
346 model.setModifiedDate(getModifiedDate());
347 model.setCategoryId(getCategoryId());
348 model.setThreadId(getThreadId());
349 model.setParentMessageId(getParentMessageId());
350 model.setSubject(HtmlUtil.escape(getSubject()));
351 model.setBody(HtmlUtil.escape(getBody()));
352 model.setAttachments(getAttachments());
353 model.setAnonymous(getAnonymous());
354
355 model = (MBMessage)Proxy.newProxyInstance(MBMessage.class.getClassLoader(),
356 new Class[] { MBMessage.class },
357 new ReadOnlyBeanHandler(model));
358
359 return model;
360 }
361 }
362
363 public ExpandoBridge getExpandoBridge() {
364 if (_expandoBridge == null) {
365 _expandoBridge = new ExpandoBridgeImpl(MBMessage.class.getName(),
366 getPrimaryKey());
367 }
368
369 return _expandoBridge;
370 }
371
372 public Object clone() {
373 MBMessageImpl clone = new MBMessageImpl();
374
375 clone.setUuid(getUuid());
376 clone.setMessageId(getMessageId());
377 clone.setCompanyId(getCompanyId());
378 clone.setUserId(getUserId());
379 clone.setUserName(getUserName());
380 clone.setCreateDate(getCreateDate());
381 clone.setModifiedDate(getModifiedDate());
382 clone.setCategoryId(getCategoryId());
383 clone.setThreadId(getThreadId());
384 clone.setParentMessageId(getParentMessageId());
385 clone.setSubject(getSubject());
386 clone.setBody(getBody());
387 clone.setAttachments(getAttachments());
388 clone.setAnonymous(getAnonymous());
389
390 return clone;
391 }
392
393 public int compareTo(Object obj) {
394 if (obj == null) {
395 return -1;
396 }
397
398 MBMessageImpl mbMessage = (MBMessageImpl)obj;
399
400 int value = 0;
401
402 value = DateUtil.compareTo(getCreateDate(), mbMessage.getCreateDate());
403
404 if (value != 0) {
405 return value;
406 }
407
408 if (getMessageId() < mbMessage.getMessageId()) {
409 value = -1;
410 }
411 else if (getMessageId() > mbMessage.getMessageId()) {
412 value = 1;
413 }
414 else {
415 value = 0;
416 }
417
418 if (value != 0) {
419 return value;
420 }
421
422 return 0;
423 }
424
425 public boolean equals(Object obj) {
426 if (obj == null) {
427 return false;
428 }
429
430 MBMessageImpl mbMessage = null;
431
432 try {
433 mbMessage = (MBMessageImpl)obj;
434 }
435 catch (ClassCastException cce) {
436 return false;
437 }
438
439 long pk = mbMessage.getPrimaryKey();
440
441 if (getPrimaryKey() == pk) {
442 return true;
443 }
444 else {
445 return false;
446 }
447 }
448
449 public int hashCode() {
450 return (int)getPrimaryKey();
451 }
452
453 private String _uuid;
454 private long _messageId;
455 private long _companyId;
456 private long _userId;
457 private String _userName;
458 private Date _createDate;
459 private Date _modifiedDate;
460 private long _categoryId;
461 private long _threadId;
462 private long _parentMessageId;
463 private String _subject;
464 private String _body;
465 private boolean _attachments;
466 private boolean _anonymous;
467 private transient ExpandoBridge _expandoBridge;
468 }