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