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