001
014
015 package com.liferay.portlet.messageboards.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.impl.BaseModelImpl;
023 import com.liferay.portal.service.ServiceContext;
024 import com.liferay.portal.util.PortalUtil;
025
026 import com.liferay.portlet.expando.model.ExpandoBridge;
027 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028 import com.liferay.portlet.messageboards.model.MBCategory;
029 import com.liferay.portlet.messageboards.model.MBCategoryModel;
030 import com.liferay.portlet.messageboards.model.MBCategorySoap;
031
032 import java.io.Serializable;
033
034 import java.lang.reflect.Proxy;
035
036 import java.sql.Types;
037
038 import java.util.ArrayList;
039 import java.util.Date;
040 import java.util.List;
041
042
059 public class MBCategoryModelImpl extends BaseModelImpl<MBCategory>
060 implements MBCategoryModel {
061 public static final String TABLE_NAME = "MBCategory";
062 public static final Object[][] TABLE_COLUMNS = {
063 { "uuid_", new Integer(Types.VARCHAR) },
064 { "categoryId", new Integer(Types.BIGINT) },
065 { "groupId", new Integer(Types.BIGINT) },
066 { "companyId", new Integer(Types.BIGINT) },
067 { "userId", new Integer(Types.BIGINT) },
068 { "userName", new Integer(Types.VARCHAR) },
069 { "createDate", new Integer(Types.TIMESTAMP) },
070 { "modifiedDate", new Integer(Types.TIMESTAMP) },
071 { "parentCategoryId", new Integer(Types.BIGINT) },
072 { "name", new Integer(Types.VARCHAR) },
073 { "description", new Integer(Types.VARCHAR) },
074 { "threadCount", new Integer(Types.INTEGER) },
075 { "messageCount", new Integer(Types.INTEGER) },
076 { "lastPostDate", new Integer(Types.TIMESTAMP) }
077 };
078 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)";
079 public static final String TABLE_SQL_DROP = "drop table MBCategory";
080 public static final String ORDER_BY_JPQL = " ORDER BY mbCategory.parentCategoryId ASC, mbCategory.name ASC";
081 public static final String ORDER_BY_SQL = " ORDER BY MBCategory.parentCategoryId ASC, MBCategory.name ASC";
082 public static final String DATA_SOURCE = "liferayDataSource";
083 public static final String SESSION_FACTORY = "liferaySessionFactory";
084 public static final String TX_MANAGER = "liferayTransactionManager";
085 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
087 true);
088 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
090 true);
091
092
098 public static MBCategory toModel(MBCategorySoap soapModel) {
099 MBCategory model = new MBCategoryImpl();
100
101 model.setUuid(soapModel.getUuid());
102 model.setCategoryId(soapModel.getCategoryId());
103 model.setGroupId(soapModel.getGroupId());
104 model.setCompanyId(soapModel.getCompanyId());
105 model.setUserId(soapModel.getUserId());
106 model.setUserName(soapModel.getUserName());
107 model.setCreateDate(soapModel.getCreateDate());
108 model.setModifiedDate(soapModel.getModifiedDate());
109 model.setParentCategoryId(soapModel.getParentCategoryId());
110 model.setName(soapModel.getName());
111 model.setDescription(soapModel.getDescription());
112 model.setThreadCount(soapModel.getThreadCount());
113 model.setMessageCount(soapModel.getMessageCount());
114 model.setLastPostDate(soapModel.getLastPostDate());
115
116 return model;
117 }
118
119
125 public static List<MBCategory> toModels(MBCategorySoap[] soapModels) {
126 List<MBCategory> models = new ArrayList<MBCategory>(soapModels.length);
127
128 for (MBCategorySoap soapModel : soapModels) {
129 models.add(toModel(soapModel));
130 }
131
132 return models;
133 }
134
135 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
136 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategory"));
137
138 public MBCategoryModelImpl() {
139 }
140
141 public long getPrimaryKey() {
142 return _categoryId;
143 }
144
145 public void setPrimaryKey(long pk) {
146 setCategoryId(pk);
147 }
148
149 public Serializable getPrimaryKeyObj() {
150 return new Long(_categoryId);
151 }
152
153 public String getUuid() {
154 if (_uuid == null) {
155 return StringPool.BLANK;
156 }
157 else {
158 return _uuid;
159 }
160 }
161
162 public void setUuid(String uuid) {
163 if (_originalUuid == null) {
164 _originalUuid = _uuid;
165 }
166
167 _uuid = uuid;
168 }
169
170 public String getOriginalUuid() {
171 return GetterUtil.getString(_originalUuid);
172 }
173
174 public long getCategoryId() {
175 return _categoryId;
176 }
177
178 public void setCategoryId(long categoryId) {
179 _categoryId = categoryId;
180 }
181
182 public long getGroupId() {
183 return _groupId;
184 }
185
186 public void setGroupId(long groupId) {
187 if (!_setOriginalGroupId) {
188 _setOriginalGroupId = true;
189
190 _originalGroupId = _groupId;
191 }
192
193 _groupId = groupId;
194 }
195
196 public long getOriginalGroupId() {
197 return _originalGroupId;
198 }
199
200 public long getCompanyId() {
201 return _companyId;
202 }
203
204 public void setCompanyId(long companyId) {
205 _companyId = companyId;
206 }
207
208 public long getUserId() {
209 return _userId;
210 }
211
212 public void setUserId(long userId) {
213 _userId = userId;
214 }
215
216 public String getUserUuid() throws SystemException {
217 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
218 }
219
220 public void setUserUuid(String userUuid) {
221 _userUuid = userUuid;
222 }
223
224 public String getUserName() {
225 if (_userName == null) {
226 return StringPool.BLANK;
227 }
228 else {
229 return _userName;
230 }
231 }
232
233 public void setUserName(String userName) {
234 _userName = userName;
235 }
236
237 public Date getCreateDate() {
238 return _createDate;
239 }
240
241 public void setCreateDate(Date createDate) {
242 _createDate = createDate;
243 }
244
245 public Date getModifiedDate() {
246 return _modifiedDate;
247 }
248
249 public void setModifiedDate(Date modifiedDate) {
250 _modifiedDate = modifiedDate;
251 }
252
253 public long getParentCategoryId() {
254 return _parentCategoryId;
255 }
256
257 public void setParentCategoryId(long parentCategoryId) {
258 _parentCategoryId = parentCategoryId;
259 }
260
261 public String getName() {
262 if (_name == null) {
263 return StringPool.BLANK;
264 }
265 else {
266 return _name;
267 }
268 }
269
270 public void setName(String name) {
271 _name = name;
272 }
273
274 public String getDescription() {
275 if (_description == null) {
276 return StringPool.BLANK;
277 }
278 else {
279 return _description;
280 }
281 }
282
283 public void setDescription(String description) {
284 _description = description;
285 }
286
287 public int getThreadCount() {
288 return _threadCount;
289 }
290
291 public void setThreadCount(int threadCount) {
292 _threadCount = threadCount;
293 }
294
295 public int getMessageCount() {
296 return _messageCount;
297 }
298
299 public void setMessageCount(int messageCount) {
300 _messageCount = messageCount;
301 }
302
303 public Date getLastPostDate() {
304 return _lastPostDate;
305 }
306
307 public void setLastPostDate(Date lastPostDate) {
308 _lastPostDate = lastPostDate;
309 }
310
311 public MBCategory toEscapedModel() {
312 if (isEscapedModel()) {
313 return (MBCategory)this;
314 }
315 else {
316 return (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
317 new Class[] { MBCategory.class },
318 new AutoEscapeBeanHandler(this));
319 }
320 }
321
322 public ExpandoBridge getExpandoBridge() {
323 if (_expandoBridge == null) {
324 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
325 MBCategory.class.getName(), getPrimaryKey());
326 }
327
328 return _expandoBridge;
329 }
330
331 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
332 getExpandoBridge().setAttributes(serviceContext);
333 }
334
335 public Object clone() {
336 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
337
338 mbCategoryImpl.setUuid(getUuid());
339
340 MBCategoryModelImpl mbCategoryModelImpl = mbCategoryImpl;
341
342 mbCategoryModelImpl._originalUuid = mbCategoryModelImpl._uuid;
343
344 mbCategoryImpl.setCategoryId(getCategoryId());
345
346 mbCategoryImpl.setGroupId(getGroupId());
347
348 mbCategoryModelImpl._originalGroupId = mbCategoryModelImpl._groupId;
349
350 mbCategoryModelImpl._setOriginalGroupId = false;
351 mbCategoryImpl.setCompanyId(getCompanyId());
352
353 mbCategoryImpl.setUserId(getUserId());
354
355 mbCategoryImpl.setUserName(getUserName());
356
357 mbCategoryImpl.setCreateDate(getCreateDate());
358
359 mbCategoryImpl.setModifiedDate(getModifiedDate());
360
361 mbCategoryImpl.setParentCategoryId(getParentCategoryId());
362
363 mbCategoryImpl.setName(getName());
364
365 mbCategoryImpl.setDescription(getDescription());
366
367 mbCategoryImpl.setThreadCount(getThreadCount());
368
369 mbCategoryImpl.setMessageCount(getMessageCount());
370
371 mbCategoryImpl.setLastPostDate(getLastPostDate());
372
373 return mbCategoryImpl;
374 }
375
376 public int compareTo(MBCategory mbCategory) {
377 int value = 0;
378
379 if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
380 value = -1;
381 }
382 else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
383 value = 1;
384 }
385 else {
386 value = 0;
387 }
388
389 if (value != 0) {
390 return value;
391 }
392
393 value = getName().toLowerCase()
394 .compareTo(mbCategory.getName().toLowerCase());
395
396 if (value != 0) {
397 return value;
398 }
399
400 return 0;
401 }
402
403 public boolean equals(Object obj) {
404 if (obj == null) {
405 return false;
406 }
407
408 MBCategory mbCategory = null;
409
410 try {
411 mbCategory = (MBCategory)obj;
412 }
413 catch (ClassCastException cce) {
414 return false;
415 }
416
417 long pk = mbCategory.getPrimaryKey();
418
419 if (getPrimaryKey() == pk) {
420 return true;
421 }
422 else {
423 return false;
424 }
425 }
426
427 public int hashCode() {
428 return (int)getPrimaryKey();
429 }
430
431 public String toString() {
432 StringBundler sb = new StringBundler(29);
433
434 sb.append("{uuid=");
435 sb.append(getUuid());
436 sb.append(", categoryId=");
437 sb.append(getCategoryId());
438 sb.append(", groupId=");
439 sb.append(getGroupId());
440 sb.append(", companyId=");
441 sb.append(getCompanyId());
442 sb.append(", userId=");
443 sb.append(getUserId());
444 sb.append(", userName=");
445 sb.append(getUserName());
446 sb.append(", createDate=");
447 sb.append(getCreateDate());
448 sb.append(", modifiedDate=");
449 sb.append(getModifiedDate());
450 sb.append(", parentCategoryId=");
451 sb.append(getParentCategoryId());
452 sb.append(", name=");
453 sb.append(getName());
454 sb.append(", description=");
455 sb.append(getDescription());
456 sb.append(", threadCount=");
457 sb.append(getThreadCount());
458 sb.append(", messageCount=");
459 sb.append(getMessageCount());
460 sb.append(", lastPostDate=");
461 sb.append(getLastPostDate());
462 sb.append("}");
463
464 return sb.toString();
465 }
466
467 public String toXmlString() {
468 StringBundler sb = new StringBundler(46);
469
470 sb.append("<model><model-name>");
471 sb.append("com.liferay.portlet.messageboards.model.MBCategory");
472 sb.append("</model-name>");
473
474 sb.append(
475 "<column><column-name>uuid</column-name><column-value><![CDATA[");
476 sb.append(getUuid());
477 sb.append("]]></column-value></column>");
478 sb.append(
479 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
480 sb.append(getCategoryId());
481 sb.append("]]></column-value></column>");
482 sb.append(
483 "<column><column-name>groupId</column-name><column-value><![CDATA[");
484 sb.append(getGroupId());
485 sb.append("]]></column-value></column>");
486 sb.append(
487 "<column><column-name>companyId</column-name><column-value><![CDATA[");
488 sb.append(getCompanyId());
489 sb.append("]]></column-value></column>");
490 sb.append(
491 "<column><column-name>userId</column-name><column-value><![CDATA[");
492 sb.append(getUserId());
493 sb.append("]]></column-value></column>");
494 sb.append(
495 "<column><column-name>userName</column-name><column-value><![CDATA[");
496 sb.append(getUserName());
497 sb.append("]]></column-value></column>");
498 sb.append(
499 "<column><column-name>createDate</column-name><column-value><![CDATA[");
500 sb.append(getCreateDate());
501 sb.append("]]></column-value></column>");
502 sb.append(
503 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
504 sb.append(getModifiedDate());
505 sb.append("]]></column-value></column>");
506 sb.append(
507 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
508 sb.append(getParentCategoryId());
509 sb.append("]]></column-value></column>");
510 sb.append(
511 "<column><column-name>name</column-name><column-value><![CDATA[");
512 sb.append(getName());
513 sb.append("]]></column-value></column>");
514 sb.append(
515 "<column><column-name>description</column-name><column-value><![CDATA[");
516 sb.append(getDescription());
517 sb.append("]]></column-value></column>");
518 sb.append(
519 "<column><column-name>threadCount</column-name><column-value><![CDATA[");
520 sb.append(getThreadCount());
521 sb.append("]]></column-value></column>");
522 sb.append(
523 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
524 sb.append(getMessageCount());
525 sb.append("]]></column-value></column>");
526 sb.append(
527 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
528 sb.append(getLastPostDate());
529 sb.append("]]></column-value></column>");
530
531 sb.append("</model>");
532
533 return sb.toString();
534 }
535
536 private String _uuid;
537 private String _originalUuid;
538 private long _categoryId;
539 private long _groupId;
540 private long _originalGroupId;
541 private boolean _setOriginalGroupId;
542 private long _companyId;
543 private long _userId;
544 private String _userUuid;
545 private String _userName;
546 private Date _createDate;
547 private Date _modifiedDate;
548 private long _parentCategoryId;
549 private String _name;
550 private String _description;
551 private int _threadCount;
552 private int _messageCount;
553 private Date _lastPostDate;
554 private transient ExpandoBridge _expandoBridge;
555 }