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