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