1
14
15 package com.liferay.portlet.messageboards.model.impl;
16
17 import com.liferay.portal.SystemException;
18 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
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.util.PortalUtil;
24
25 import com.liferay.portlet.messageboards.model.MBCategory;
26 import com.liferay.portlet.messageboards.model.MBCategorySoap;
27
28 import java.io.Serializable;
29
30 import java.lang.reflect.Proxy;
31
32 import java.sql.Types;
33
34 import java.util.ArrayList;
35 import java.util.Date;
36 import java.util.List;
37
38
57 public class MBCategoryModelImpl extends BaseModelImpl<MBCategory> {
58 public static final String TABLE_NAME = "MBCategory";
59 public static final Object[][] TABLE_COLUMNS = {
60 { "uuid_", new Integer(Types.VARCHAR) },
61 { "categoryId", new Integer(Types.BIGINT) },
62 { "groupId", new Integer(Types.BIGINT) },
63 { "companyId", new Integer(Types.BIGINT) },
64 { "userId", new Integer(Types.BIGINT) },
65 { "userName", new Integer(Types.VARCHAR) },
66 { "createDate", new Integer(Types.TIMESTAMP) },
67 { "modifiedDate", new Integer(Types.TIMESTAMP) },
68 { "parentCategoryId", new Integer(Types.BIGINT) },
69 { "name", new Integer(Types.VARCHAR) },
70 { "description", new Integer(Types.VARCHAR) },
71 { "threadCount", new Integer(Types.INTEGER) },
72 { "messageCount", new Integer(Types.INTEGER) },
73 { "lastPostDate", new Integer(Types.TIMESTAMP) }
74 };
75 public static final String TABLE_SQL_CREATE = "create table MBCategory (uuid_ VARCHAR(75) null,categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,name VARCHAR(75) null,description STRING null,threadCount INTEGER,messageCount INTEGER,lastPostDate DATE null)";
76 public static final String TABLE_SQL_DROP = "drop table MBCategory";
77 public static final String ORDER_BY_JPQL = " ORDER BY mbCategory.parentCategoryId ASC, mbCategory.name ASC";
78 public static final String ORDER_BY_SQL = " ORDER BY MBCategory.parentCategoryId ASC, MBCategory.name ASC";
79 public static final String DATA_SOURCE = "liferayDataSource";
80 public static final String SESSION_FACTORY = "liferaySessionFactory";
81 public static final String TX_MANAGER = "liferayTransactionManager";
82 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
84 true);
85 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
87 true);
88
89 public static MBCategory toModel(MBCategorySoap soapModel) {
90 MBCategory model = new MBCategoryImpl();
91
92 model.setUuid(soapModel.getUuid());
93 model.setCategoryId(soapModel.getCategoryId());
94 model.setGroupId(soapModel.getGroupId());
95 model.setCompanyId(soapModel.getCompanyId());
96 model.setUserId(soapModel.getUserId());
97 model.setUserName(soapModel.getUserName());
98 model.setCreateDate(soapModel.getCreateDate());
99 model.setModifiedDate(soapModel.getModifiedDate());
100 model.setParentCategoryId(soapModel.getParentCategoryId());
101 model.setName(soapModel.getName());
102 model.setDescription(soapModel.getDescription());
103 model.setThreadCount(soapModel.getThreadCount());
104 model.setMessageCount(soapModel.getMessageCount());
105 model.setLastPostDate(soapModel.getLastPostDate());
106
107 return model;
108 }
109
110 public static List<MBCategory> toModels(MBCategorySoap[] soapModels) {
111 List<MBCategory> models = new ArrayList<MBCategory>(soapModels.length);
112
113 for (MBCategorySoap soapModel : soapModels) {
114 models.add(toModel(soapModel));
115 }
116
117 return models;
118 }
119
120 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
121 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategory"));
122
123 public MBCategoryModelImpl() {
124 }
125
126 public long getPrimaryKey() {
127 return _categoryId;
128 }
129
130 public void setPrimaryKey(long pk) {
131 setCategoryId(pk);
132 }
133
134 public Serializable getPrimaryKeyObj() {
135 return new Long(_categoryId);
136 }
137
138 public String getUuid() {
139 return GetterUtil.getString(_uuid);
140 }
141
142 public void setUuid(String uuid) {
143 _uuid = uuid;
144
145 if (_originalUuid == null) {
146 _originalUuid = uuid;
147 }
148 }
149
150 public String getOriginalUuid() {
151 return GetterUtil.getString(_originalUuid);
152 }
153
154 public long getCategoryId() {
155 return _categoryId;
156 }
157
158 public void setCategoryId(long categoryId) {
159 _categoryId = categoryId;
160 }
161
162 public long getGroupId() {
163 return _groupId;
164 }
165
166 public void setGroupId(long groupId) {
167 _groupId = groupId;
168
169 if (!_setOriginalGroupId) {
170 _setOriginalGroupId = true;
171
172 _originalGroupId = groupId;
173 }
174 }
175
176 public long getOriginalGroupId() {
177 return _originalGroupId;
178 }
179
180 public long getCompanyId() {
181 return _companyId;
182 }
183
184 public void setCompanyId(long companyId) {
185 _companyId = companyId;
186 }
187
188 public long getUserId() {
189 return _userId;
190 }
191
192 public void setUserId(long userId) {
193 _userId = userId;
194 }
195
196 public String getUserUuid() throws SystemException {
197 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
198 }
199
200 public void setUserUuid(String userUuid) {
201 _userUuid = userUuid;
202 }
203
204 public String getUserName() {
205 return GetterUtil.getString(_userName);
206 }
207
208 public void setUserName(String userName) {
209 _userName = userName;
210 }
211
212 public Date getCreateDate() {
213 return _createDate;
214 }
215
216 public void setCreateDate(Date createDate) {
217 _createDate = createDate;
218 }
219
220 public Date getModifiedDate() {
221 return _modifiedDate;
222 }
223
224 public void setModifiedDate(Date modifiedDate) {
225 _modifiedDate = modifiedDate;
226 }
227
228 public long getParentCategoryId() {
229 return _parentCategoryId;
230 }
231
232 public void setParentCategoryId(long parentCategoryId) {
233 _parentCategoryId = parentCategoryId;
234 }
235
236 public String getName() {
237 return GetterUtil.getString(_name);
238 }
239
240 public void setName(String name) {
241 _name = name;
242 }
243
244 public String getDescription() {
245 return GetterUtil.getString(_description);
246 }
247
248 public void setDescription(String description) {
249 _description = description;
250 }
251
252 public int getThreadCount() {
253 return _threadCount;
254 }
255
256 public void setThreadCount(int threadCount) {
257 _threadCount = threadCount;
258 }
259
260 public int getMessageCount() {
261 return _messageCount;
262 }
263
264 public void setMessageCount(int messageCount) {
265 _messageCount = messageCount;
266 }
267
268 public Date getLastPostDate() {
269 return _lastPostDate;
270 }
271
272 public void setLastPostDate(Date lastPostDate) {
273 _lastPostDate = lastPostDate;
274 }
275
276 public MBCategory toEscapedModel() {
277 if (isEscapedModel()) {
278 return (MBCategory)this;
279 }
280 else {
281 MBCategory model = new MBCategoryImpl();
282
283 model.setNew(isNew());
284 model.setEscapedModel(true);
285
286 model.setUuid(HtmlUtil.escape(getUuid()));
287 model.setCategoryId(getCategoryId());
288 model.setGroupId(getGroupId());
289 model.setCompanyId(getCompanyId());
290 model.setUserId(getUserId());
291 model.setUserName(HtmlUtil.escape(getUserName()));
292 model.setCreateDate(getCreateDate());
293 model.setModifiedDate(getModifiedDate());
294 model.setParentCategoryId(getParentCategoryId());
295 model.setName(HtmlUtil.escape(getName()));
296 model.setDescription(HtmlUtil.escape(getDescription()));
297 model.setThreadCount(getThreadCount());
298 model.setMessageCount(getMessageCount());
299 model.setLastPostDate(getLastPostDate());
300
301 model = (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
302 new Class[] { MBCategory.class },
303 new ReadOnlyBeanHandler(model));
304
305 return model;
306 }
307 }
308
309 public Object clone() {
310 MBCategoryImpl clone = new MBCategoryImpl();
311
312 clone.setUuid(getUuid());
313 clone.setCategoryId(getCategoryId());
314 clone.setGroupId(getGroupId());
315 clone.setCompanyId(getCompanyId());
316 clone.setUserId(getUserId());
317 clone.setUserName(getUserName());
318 clone.setCreateDate(getCreateDate());
319 clone.setModifiedDate(getModifiedDate());
320 clone.setParentCategoryId(getParentCategoryId());
321 clone.setName(getName());
322 clone.setDescription(getDescription());
323 clone.setThreadCount(getThreadCount());
324 clone.setMessageCount(getMessageCount());
325 clone.setLastPostDate(getLastPostDate());
326
327 return clone;
328 }
329
330 public int compareTo(MBCategory mbCategory) {
331 int value = 0;
332
333 if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
334 value = -1;
335 }
336 else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
337 value = 1;
338 }
339 else {
340 value = 0;
341 }
342
343 if (value != 0) {
344 return value;
345 }
346
347 value = getName().toLowerCase()
348 .compareTo(mbCategory.getName().toLowerCase());
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 MBCategory mbCategory = null;
363
364 try {
365 mbCategory = (MBCategory)obj;
366 }
367 catch (ClassCastException cce) {
368 return false;
369 }
370
371 long pk = mbCategory.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(29);
387
388 sb.append("{uuid=");
389 sb.append(getUuid());
390 sb.append(", categoryId=");
391 sb.append(getCategoryId());
392 sb.append(", groupId=");
393 sb.append(getGroupId());
394 sb.append(", companyId=");
395 sb.append(getCompanyId());
396 sb.append(", userId=");
397 sb.append(getUserId());
398 sb.append(", userName=");
399 sb.append(getUserName());
400 sb.append(", createDate=");
401 sb.append(getCreateDate());
402 sb.append(", modifiedDate=");
403 sb.append(getModifiedDate());
404 sb.append(", parentCategoryId=");
405 sb.append(getParentCategoryId());
406 sb.append(", name=");
407 sb.append(getName());
408 sb.append(", description=");
409 sb.append(getDescription());
410 sb.append(", threadCount=");
411 sb.append(getThreadCount());
412 sb.append(", messageCount=");
413 sb.append(getMessageCount());
414 sb.append(", lastPostDate=");
415 sb.append(getLastPostDate());
416 sb.append("}");
417
418 return sb.toString();
419 }
420
421 public String toXmlString() {
422 StringBundler sb = new StringBundler(46);
423
424 sb.append("<model><model-name>");
425 sb.append("com.liferay.portlet.messageboards.model.MBCategory");
426 sb.append("</model-name>");
427
428 sb.append(
429 "<column><column-name>uuid</column-name><column-value><![CDATA[");
430 sb.append(getUuid());
431 sb.append("]]></column-value></column>");
432 sb.append(
433 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
434 sb.append(getCategoryId());
435 sb.append("]]></column-value></column>");
436 sb.append(
437 "<column><column-name>groupId</column-name><column-value><![CDATA[");
438 sb.append(getGroupId());
439 sb.append("]]></column-value></column>");
440 sb.append(
441 "<column><column-name>companyId</column-name><column-value><![CDATA[");
442 sb.append(getCompanyId());
443 sb.append("]]></column-value></column>");
444 sb.append(
445 "<column><column-name>userId</column-name><column-value><![CDATA[");
446 sb.append(getUserId());
447 sb.append("]]></column-value></column>");
448 sb.append(
449 "<column><column-name>userName</column-name><column-value><![CDATA[");
450 sb.append(getUserName());
451 sb.append("]]></column-value></column>");
452 sb.append(
453 "<column><column-name>createDate</column-name><column-value><![CDATA[");
454 sb.append(getCreateDate());
455 sb.append("]]></column-value></column>");
456 sb.append(
457 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
458 sb.append(getModifiedDate());
459 sb.append("]]></column-value></column>");
460 sb.append(
461 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
462 sb.append(getParentCategoryId());
463 sb.append("]]></column-value></column>");
464 sb.append(
465 "<column><column-name>name</column-name><column-value><![CDATA[");
466 sb.append(getName());
467 sb.append("]]></column-value></column>");
468 sb.append(
469 "<column><column-name>description</column-name><column-value><![CDATA[");
470 sb.append(getDescription());
471 sb.append("]]></column-value></column>");
472 sb.append(
473 "<column><column-name>threadCount</column-name><column-value><![CDATA[");
474 sb.append(getThreadCount());
475 sb.append("]]></column-value></column>");
476 sb.append(
477 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
478 sb.append(getMessageCount());
479 sb.append("]]></column-value></column>");
480 sb.append(
481 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
482 sb.append(getLastPostDate());
483 sb.append("]]></column-value></column>");
484
485 sb.append("</model>");
486
487 return sb.toString();
488 }
489
490 private String _uuid;
491 private String _originalUuid;
492 private long _categoryId;
493 private long _groupId;
494 private long _originalGroupId;
495 private boolean _setOriginalGroupId;
496 private long _companyId;
497 private long _userId;
498 private String _userUuid;
499 private String _userName;
500 private Date _createDate;
501 private Date _modifiedDate;
502 private long _parentCategoryId;
503 private String _name;
504 private String _description;
505 private int _threadCount;
506 private int _messageCount;
507 private Date _lastPostDate;
508 }