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.expando.model.ExpandoBridge;
31 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 getUserName() {
229 return GetterUtil.getString(_userName);
230 }
231
232 public void setUserName(String userName) {
233 _userName = userName;
234 }
235
236 public Date getCreateDate() {
237 return _createDate;
238 }
239
240 public void setCreateDate(Date createDate) {
241 _createDate = createDate;
242 }
243
244 public Date getModifiedDate() {
245 return _modifiedDate;
246 }
247
248 public void setModifiedDate(Date modifiedDate) {
249 _modifiedDate = modifiedDate;
250 }
251
252 public long getParentCategoryId() {
253 return _parentCategoryId;
254 }
255
256 public void setParentCategoryId(long parentCategoryId) {
257 _parentCategoryId = parentCategoryId;
258 }
259
260 public String getName() {
261 return GetterUtil.getString(_name);
262 }
263
264 public void setName(String name) {
265 _name = name;
266 }
267
268 public String getDescription() {
269 return GetterUtil.getString(_description);
270 }
271
272 public void setDescription(String description) {
273 _description = description;
274 }
275
276 public int getThreadCount() {
277 return _threadCount;
278 }
279
280 public void setThreadCount(int threadCount) {
281 _threadCount = threadCount;
282 }
283
284 public int getMessageCount() {
285 return _messageCount;
286 }
287
288 public void setMessageCount(int messageCount) {
289 _messageCount = messageCount;
290 }
291
292 public Date getLastPostDate() {
293 return _lastPostDate;
294 }
295
296 public void setLastPostDate(Date lastPostDate) {
297 _lastPostDate = lastPostDate;
298 }
299
300 public MBCategory toEscapedModel() {
301 if (isEscapedModel()) {
302 return (MBCategory)this;
303 }
304 else {
305 MBCategory model = new MBCategoryImpl();
306
307 model.setNew(isNew());
308 model.setEscapedModel(true);
309
310 model.setUuid(HtmlUtil.escape(getUuid()));
311 model.setCategoryId(getCategoryId());
312 model.setGroupId(getGroupId());
313 model.setCompanyId(getCompanyId());
314 model.setUserId(getUserId());
315 model.setUserName(HtmlUtil.escape(getUserName()));
316 model.setCreateDate(getCreateDate());
317 model.setModifiedDate(getModifiedDate());
318 model.setParentCategoryId(getParentCategoryId());
319 model.setName(HtmlUtil.escape(getName()));
320 model.setDescription(HtmlUtil.escape(getDescription()));
321 model.setThreadCount(getThreadCount());
322 model.setMessageCount(getMessageCount());
323 model.setLastPostDate(getLastPostDate());
324
325 model = (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
326 new Class[] { MBCategory.class },
327 new ReadOnlyBeanHandler(model));
328
329 return model;
330 }
331 }
332
333 public ExpandoBridge getExpandoBridge() {
334 if (_expandoBridge == null) {
335 _expandoBridge = new ExpandoBridgeImpl(MBCategory.class.getName(),
336 getPrimaryKey());
337 }
338
339 return _expandoBridge;
340 }
341
342 public Object clone() {
343 MBCategoryImpl clone = new MBCategoryImpl();
344
345 clone.setUuid(getUuid());
346 clone.setCategoryId(getCategoryId());
347 clone.setGroupId(getGroupId());
348 clone.setCompanyId(getCompanyId());
349 clone.setUserId(getUserId());
350 clone.setUserName(getUserName());
351 clone.setCreateDate(getCreateDate());
352 clone.setModifiedDate(getModifiedDate());
353 clone.setParentCategoryId(getParentCategoryId());
354 clone.setName(getName());
355 clone.setDescription(getDescription());
356 clone.setThreadCount(getThreadCount());
357 clone.setMessageCount(getMessageCount());
358 clone.setLastPostDate(getLastPostDate());
359
360 return clone;
361 }
362
363 public int compareTo(MBCategory mbCategory) {
364 int value = 0;
365
366 if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
367 value = -1;
368 }
369 else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
370 value = 1;
371 }
372 else {
373 value = 0;
374 }
375
376 if (value != 0) {
377 return value;
378 }
379
380 value = getName().toLowerCase()
381 .compareTo(mbCategory.getName().toLowerCase());
382
383 if (value != 0) {
384 return value;
385 }
386
387 return 0;
388 }
389
390 public boolean equals(Object obj) {
391 if (obj == null) {
392 return false;
393 }
394
395 MBCategory mbCategory = null;
396
397 try {
398 mbCategory = (MBCategory)obj;
399 }
400 catch (ClassCastException cce) {
401 return false;
402 }
403
404 long pk = mbCategory.getPrimaryKey();
405
406 if (getPrimaryKey() == pk) {
407 return true;
408 }
409 else {
410 return false;
411 }
412 }
413
414 public int hashCode() {
415 return (int)getPrimaryKey();
416 }
417
418 public String toString() {
419 StringBuilder sb = new StringBuilder();
420
421 sb.append("{uuid=");
422 sb.append(getUuid());
423 sb.append(", categoryId=");
424 sb.append(getCategoryId());
425 sb.append(", groupId=");
426 sb.append(getGroupId());
427 sb.append(", companyId=");
428 sb.append(getCompanyId());
429 sb.append(", userId=");
430 sb.append(getUserId());
431 sb.append(", userName=");
432 sb.append(getUserName());
433 sb.append(", createDate=");
434 sb.append(getCreateDate());
435 sb.append(", modifiedDate=");
436 sb.append(getModifiedDate());
437 sb.append(", parentCategoryId=");
438 sb.append(getParentCategoryId());
439 sb.append(", name=");
440 sb.append(getName());
441 sb.append(", description=");
442 sb.append(getDescription());
443 sb.append(", threadCount=");
444 sb.append(getThreadCount());
445 sb.append(", messageCount=");
446 sb.append(getMessageCount());
447 sb.append(", lastPostDate=");
448 sb.append(getLastPostDate());
449 sb.append("}");
450
451 return sb.toString();
452 }
453
454 public String toXmlString() {
455 StringBuilder sb = new StringBuilder();
456
457 sb.append("<model><model-name>");
458 sb.append("com.liferay.portlet.messageboards.model.MBCategory");
459 sb.append("</model-name>");
460
461 sb.append(
462 "<column><column-name>uuid</column-name><column-value><![CDATA[");
463 sb.append(getUuid());
464 sb.append("]]></column-value></column>");
465 sb.append(
466 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
467 sb.append(getCategoryId());
468 sb.append("]]></column-value></column>");
469 sb.append(
470 "<column><column-name>groupId</column-name><column-value><![CDATA[");
471 sb.append(getGroupId());
472 sb.append("]]></column-value></column>");
473 sb.append(
474 "<column><column-name>companyId</column-name><column-value><![CDATA[");
475 sb.append(getCompanyId());
476 sb.append("]]></column-value></column>");
477 sb.append(
478 "<column><column-name>userId</column-name><column-value><![CDATA[");
479 sb.append(getUserId());
480 sb.append("]]></column-value></column>");
481 sb.append(
482 "<column><column-name>userName</column-name><column-value><![CDATA[");
483 sb.append(getUserName());
484 sb.append("]]></column-value></column>");
485 sb.append(
486 "<column><column-name>createDate</column-name><column-value><![CDATA[");
487 sb.append(getCreateDate());
488 sb.append("]]></column-value></column>");
489 sb.append(
490 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
491 sb.append(getModifiedDate());
492 sb.append("]]></column-value></column>");
493 sb.append(
494 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
495 sb.append(getParentCategoryId());
496 sb.append("]]></column-value></column>");
497 sb.append(
498 "<column><column-name>name</column-name><column-value><![CDATA[");
499 sb.append(getName());
500 sb.append("]]></column-value></column>");
501 sb.append(
502 "<column><column-name>description</column-name><column-value><![CDATA[");
503 sb.append(getDescription());
504 sb.append("]]></column-value></column>");
505 sb.append(
506 "<column><column-name>threadCount</column-name><column-value><![CDATA[");
507 sb.append(getThreadCount());
508 sb.append("]]></column-value></column>");
509 sb.append(
510 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
511 sb.append(getMessageCount());
512 sb.append("]]></column-value></column>");
513 sb.append(
514 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
515 sb.append(getLastPostDate());
516 sb.append("]]></column-value></column>");
517
518 sb.append("</model>");
519
520 return sb.toString();
521 }
522
523 private String _uuid;
524 private String _originalUuid;
525 private long _categoryId;
526 private long _groupId;
527 private long _originalGroupId;
528 private boolean _setOriginalGroupId;
529 private long _companyId;
530 private long _userId;
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 private transient ExpandoBridge _expandoBridge;
541 }