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