001
014
015 package com.liferay.portlet.bookmarks.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.json.JSON;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.ProxyUtil;
022 import com.liferay.portal.kernel.util.StringBundler;
023 import com.liferay.portal.kernel.util.StringPool;
024 import com.liferay.portal.model.CacheModel;
025 import com.liferay.portal.model.impl.BaseModelImpl;
026 import com.liferay.portal.service.ServiceContext;
027 import com.liferay.portal.util.PortalUtil;
028
029 import com.liferay.portlet.bookmarks.model.BookmarksFolder;
030 import com.liferay.portlet.bookmarks.model.BookmarksFolderModel;
031 import com.liferay.portlet.bookmarks.model.BookmarksFolderSoap;
032 import com.liferay.portlet.expando.model.ExpandoBridge;
033 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
034
035 import java.io.Serializable;
036
037 import java.sql.Types;
038
039 import java.util.ArrayList;
040 import java.util.Date;
041 import java.util.HashMap;
042 import java.util.List;
043 import java.util.Map;
044
045
058 @JSON(strict = true)
059 public class BookmarksFolderModelImpl extends BaseModelImpl<BookmarksFolder>
060 implements BookmarksFolderModel {
061
066 public static final String TABLE_NAME = "BookmarksFolder";
067 public static final Object[][] TABLE_COLUMNS = {
068 { "uuid_", Types.VARCHAR },
069 { "folderId", Types.BIGINT },
070 { "groupId", Types.BIGINT },
071 { "companyId", Types.BIGINT },
072 { "userId", Types.BIGINT },
073 { "userName", Types.VARCHAR },
074 { "createDate", Types.TIMESTAMP },
075 { "modifiedDate", Types.TIMESTAMP },
076 { "resourceBlockId", Types.BIGINT },
077 { "parentFolderId", Types.BIGINT },
078 { "name", Types.VARCHAR },
079 { "description", Types.VARCHAR }
080 };
081 public static final String TABLE_SQL_CREATE = "create table BookmarksFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,resourceBlockId LONG,parentFolderId LONG,name VARCHAR(75) null,description STRING null)";
082 public static final String TABLE_SQL_DROP = "drop table BookmarksFolder";
083 public static final String ORDER_BY_JPQL = " ORDER BY bookmarksFolder.parentFolderId ASC, bookmarksFolder.name ASC";
084 public static final String ORDER_BY_SQL = " ORDER BY BookmarksFolder.parentFolderId ASC, BookmarksFolder.name ASC";
085 public static final String DATA_SOURCE = "liferayDataSource";
086 public static final String SESSION_FACTORY = "liferaySessionFactory";
087 public static final String TX_MANAGER = "liferayTransactionManager";
088 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089 "value.object.entity.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
090 true);
091 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
092 "value.object.finder.cache.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
093 true);
094 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095 "value.object.column.bitmask.enabled.com.liferay.portlet.bookmarks.model.BookmarksFolder"),
096 true);
097 public static long COMPANYID_COLUMN_BITMASK = 1L;
098 public static long GROUPID_COLUMN_BITMASK = 2L;
099 public static long PARENTFOLDERID_COLUMN_BITMASK = 4L;
100 public static long RESOURCEBLOCKID_COLUMN_BITMASK = 8L;
101 public static long UUID_COLUMN_BITMASK = 16L;
102
103
109 public static BookmarksFolder toModel(BookmarksFolderSoap soapModel) {
110 if (soapModel == null) {
111 return null;
112 }
113
114 BookmarksFolder model = new BookmarksFolderImpl();
115
116 model.setUuid(soapModel.getUuid());
117 model.setFolderId(soapModel.getFolderId());
118 model.setGroupId(soapModel.getGroupId());
119 model.setCompanyId(soapModel.getCompanyId());
120 model.setUserId(soapModel.getUserId());
121 model.setUserName(soapModel.getUserName());
122 model.setCreateDate(soapModel.getCreateDate());
123 model.setModifiedDate(soapModel.getModifiedDate());
124 model.setResourceBlockId(soapModel.getResourceBlockId());
125 model.setParentFolderId(soapModel.getParentFolderId());
126 model.setName(soapModel.getName());
127 model.setDescription(soapModel.getDescription());
128
129 return model;
130 }
131
132
138 public static List<BookmarksFolder> toModels(
139 BookmarksFolderSoap[] soapModels) {
140 if (soapModels == null) {
141 return null;
142 }
143
144 List<BookmarksFolder> models = new ArrayList<BookmarksFolder>(soapModels.length);
145
146 for (BookmarksFolderSoap soapModel : soapModels) {
147 models.add(toModel(soapModel));
148 }
149
150 return models;
151 }
152
153 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
154 "lock.expiration.time.com.liferay.portlet.bookmarks.model.BookmarksFolder"));
155
156 public BookmarksFolderModelImpl() {
157 }
158
159 public long getPrimaryKey() {
160 return _folderId;
161 }
162
163 public void setPrimaryKey(long primaryKey) {
164 setFolderId(primaryKey);
165 }
166
167 public Serializable getPrimaryKeyObj() {
168 return new Long(_folderId);
169 }
170
171 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
172 setPrimaryKey(((Long)primaryKeyObj).longValue());
173 }
174
175 public Class<?> getModelClass() {
176 return BookmarksFolder.class;
177 }
178
179 public String getModelClassName() {
180 return BookmarksFolder.class.getName();
181 }
182
183 @Override
184 public Map<String, Object> getModelAttributes() {
185 Map<String, Object> attributes = new HashMap<String, Object>();
186
187 attributes.put("uuid", getUuid());
188 attributes.put("folderId", getFolderId());
189 attributes.put("groupId", getGroupId());
190 attributes.put("companyId", getCompanyId());
191 attributes.put("userId", getUserId());
192 attributes.put("userName", getUserName());
193 attributes.put("createDate", getCreateDate());
194 attributes.put("modifiedDate", getModifiedDate());
195 attributes.put("resourceBlockId", getResourceBlockId());
196 attributes.put("parentFolderId", getParentFolderId());
197 attributes.put("name", getName());
198 attributes.put("description", getDescription());
199
200 return attributes;
201 }
202
203 @Override
204 public void setModelAttributes(Map<String, Object> attributes) {
205 String uuid = (String)attributes.get("uuid");
206
207 if (uuid != null) {
208 setUuid(uuid);
209 }
210
211 Long folderId = (Long)attributes.get("folderId");
212
213 if (folderId != null) {
214 setFolderId(folderId);
215 }
216
217 Long groupId = (Long)attributes.get("groupId");
218
219 if (groupId != null) {
220 setGroupId(groupId);
221 }
222
223 Long companyId = (Long)attributes.get("companyId");
224
225 if (companyId != null) {
226 setCompanyId(companyId);
227 }
228
229 Long userId = (Long)attributes.get("userId");
230
231 if (userId != null) {
232 setUserId(userId);
233 }
234
235 String userName = (String)attributes.get("userName");
236
237 if (userName != null) {
238 setUserName(userName);
239 }
240
241 Date createDate = (Date)attributes.get("createDate");
242
243 if (createDate != null) {
244 setCreateDate(createDate);
245 }
246
247 Date modifiedDate = (Date)attributes.get("modifiedDate");
248
249 if (modifiedDate != null) {
250 setModifiedDate(modifiedDate);
251 }
252
253 Long resourceBlockId = (Long)attributes.get("resourceBlockId");
254
255 if (resourceBlockId != null) {
256 setResourceBlockId(resourceBlockId);
257 }
258
259 Long parentFolderId = (Long)attributes.get("parentFolderId");
260
261 if (parentFolderId != null) {
262 setParentFolderId(parentFolderId);
263 }
264
265 String name = (String)attributes.get("name");
266
267 if (name != null) {
268 setName(name);
269 }
270
271 String description = (String)attributes.get("description");
272
273 if (description != null) {
274 setDescription(description);
275 }
276 }
277
278 @JSON
279 public String getUuid() {
280 if (_uuid == null) {
281 return StringPool.BLANK;
282 }
283 else {
284 return _uuid;
285 }
286 }
287
288 public void setUuid(String uuid) {
289 if (_originalUuid == null) {
290 _originalUuid = _uuid;
291 }
292
293 _uuid = uuid;
294 }
295
296 public String getOriginalUuid() {
297 return GetterUtil.getString(_originalUuid);
298 }
299
300 @JSON
301 public long getFolderId() {
302 return _folderId;
303 }
304
305 public void setFolderId(long folderId) {
306 _folderId = folderId;
307 }
308
309 @JSON
310 public long getGroupId() {
311 return _groupId;
312 }
313
314 public void setGroupId(long groupId) {
315 _columnBitmask |= GROUPID_COLUMN_BITMASK;
316
317 if (!_setOriginalGroupId) {
318 _setOriginalGroupId = true;
319
320 _originalGroupId = _groupId;
321 }
322
323 _groupId = groupId;
324 }
325
326 public long getOriginalGroupId() {
327 return _originalGroupId;
328 }
329
330 @JSON
331 public long getCompanyId() {
332 return _companyId;
333 }
334
335 public void setCompanyId(long companyId) {
336 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
337
338 if (!_setOriginalCompanyId) {
339 _setOriginalCompanyId = true;
340
341 _originalCompanyId = _companyId;
342 }
343
344 _companyId = companyId;
345 }
346
347 public long getOriginalCompanyId() {
348 return _originalCompanyId;
349 }
350
351 @JSON
352 public long getUserId() {
353 return _userId;
354 }
355
356 public void setUserId(long userId) {
357 _userId = userId;
358 }
359
360 public String getUserUuid() throws SystemException {
361 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
362 }
363
364 public void setUserUuid(String userUuid) {
365 _userUuid = userUuid;
366 }
367
368 @JSON
369 public String getUserName() {
370 if (_userName == null) {
371 return StringPool.BLANK;
372 }
373 else {
374 return _userName;
375 }
376 }
377
378 public void setUserName(String userName) {
379 _userName = userName;
380 }
381
382 @JSON
383 public Date getCreateDate() {
384 return _createDate;
385 }
386
387 public void setCreateDate(Date createDate) {
388 _createDate = createDate;
389 }
390
391 @JSON
392 public Date getModifiedDate() {
393 return _modifiedDate;
394 }
395
396 public void setModifiedDate(Date modifiedDate) {
397 _modifiedDate = modifiedDate;
398 }
399
400 @JSON
401 public long getResourceBlockId() {
402 return _resourceBlockId;
403 }
404
405 public void setResourceBlockId(long resourceBlockId) {
406 _columnBitmask |= RESOURCEBLOCKID_COLUMN_BITMASK;
407
408 if (!_setOriginalResourceBlockId) {
409 _setOriginalResourceBlockId = true;
410
411 _originalResourceBlockId = _resourceBlockId;
412 }
413
414 _resourceBlockId = resourceBlockId;
415 }
416
417 public long getOriginalResourceBlockId() {
418 return _originalResourceBlockId;
419 }
420
421 @JSON
422 public long getParentFolderId() {
423 return _parentFolderId;
424 }
425
426 public void setParentFolderId(long parentFolderId) {
427 _columnBitmask = -1L;
428
429 if (!_setOriginalParentFolderId) {
430 _setOriginalParentFolderId = true;
431
432 _originalParentFolderId = _parentFolderId;
433 }
434
435 _parentFolderId = parentFolderId;
436 }
437
438 public long getOriginalParentFolderId() {
439 return _originalParentFolderId;
440 }
441
442 @JSON
443 public String getName() {
444 if (_name == null) {
445 return StringPool.BLANK;
446 }
447 else {
448 return _name;
449 }
450 }
451
452 public void setName(String name) {
453 _columnBitmask = -1L;
454
455 _name = name;
456 }
457
458 @JSON
459 public String getDescription() {
460 if (_description == null) {
461 return StringPool.BLANK;
462 }
463 else {
464 return _description;
465 }
466 }
467
468 public void setDescription(String description) {
469 _description = description;
470 }
471
472 public long getColumnBitmask() {
473 return _columnBitmask;
474 }
475
476 @Override
477 public ExpandoBridge getExpandoBridge() {
478 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
479 BookmarksFolder.class.getName(), getPrimaryKey());
480 }
481
482 @Override
483 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
484 ExpandoBridge expandoBridge = getExpandoBridge();
485
486 expandoBridge.setAttributes(serviceContext);
487 }
488
489 @Override
490 public BookmarksFolder toEscapedModel() {
491 if (_escapedModel == null) {
492 _escapedModel = (BookmarksFolder)ProxyUtil.newProxyInstance(_classLoader,
493 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
494 }
495
496 return _escapedModel;
497 }
498
499 public BookmarksFolder toUnescapedModel() {
500 return (BookmarksFolder)this;
501 }
502
503 @Override
504 public Object clone() {
505 BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
506
507 bookmarksFolderImpl.setUuid(getUuid());
508 bookmarksFolderImpl.setFolderId(getFolderId());
509 bookmarksFolderImpl.setGroupId(getGroupId());
510 bookmarksFolderImpl.setCompanyId(getCompanyId());
511 bookmarksFolderImpl.setUserId(getUserId());
512 bookmarksFolderImpl.setUserName(getUserName());
513 bookmarksFolderImpl.setCreateDate(getCreateDate());
514 bookmarksFolderImpl.setModifiedDate(getModifiedDate());
515 bookmarksFolderImpl.setResourceBlockId(getResourceBlockId());
516 bookmarksFolderImpl.setParentFolderId(getParentFolderId());
517 bookmarksFolderImpl.setName(getName());
518 bookmarksFolderImpl.setDescription(getDescription());
519
520 bookmarksFolderImpl.resetOriginalValues();
521
522 return bookmarksFolderImpl;
523 }
524
525 public int compareTo(BookmarksFolder bookmarksFolder) {
526 int value = 0;
527
528 if (getParentFolderId() < bookmarksFolder.getParentFolderId()) {
529 value = -1;
530 }
531 else if (getParentFolderId() > bookmarksFolder.getParentFolderId()) {
532 value = 1;
533 }
534 else {
535 value = 0;
536 }
537
538 if (value != 0) {
539 return value;
540 }
541
542 value = getName().toLowerCase()
543 .compareTo(bookmarksFolder.getName().toLowerCase());
544
545 if (value != 0) {
546 return value;
547 }
548
549 return 0;
550 }
551
552 @Override
553 public boolean equals(Object obj) {
554 if (this == obj) {
555 return true;
556 }
557
558 if (!(obj instanceof BookmarksFolder)) {
559 return false;
560 }
561
562 BookmarksFolder bookmarksFolder = (BookmarksFolder)obj;
563
564 long primaryKey = bookmarksFolder.getPrimaryKey();
565
566 if (getPrimaryKey() == primaryKey) {
567 return true;
568 }
569 else {
570 return false;
571 }
572 }
573
574 @Override
575 public int hashCode() {
576 return (int)getPrimaryKey();
577 }
578
579 @Override
580 public void resetOriginalValues() {
581 BookmarksFolderModelImpl bookmarksFolderModelImpl = this;
582
583 bookmarksFolderModelImpl._originalUuid = bookmarksFolderModelImpl._uuid;
584
585 bookmarksFolderModelImpl._originalGroupId = bookmarksFolderModelImpl._groupId;
586
587 bookmarksFolderModelImpl._setOriginalGroupId = false;
588
589 bookmarksFolderModelImpl._originalCompanyId = bookmarksFolderModelImpl._companyId;
590
591 bookmarksFolderModelImpl._setOriginalCompanyId = false;
592
593 bookmarksFolderModelImpl._originalResourceBlockId = bookmarksFolderModelImpl._resourceBlockId;
594
595 bookmarksFolderModelImpl._setOriginalResourceBlockId = false;
596
597 bookmarksFolderModelImpl._originalParentFolderId = bookmarksFolderModelImpl._parentFolderId;
598
599 bookmarksFolderModelImpl._setOriginalParentFolderId = false;
600
601 bookmarksFolderModelImpl._columnBitmask = 0;
602 }
603
604 @Override
605 public CacheModel<BookmarksFolder> toCacheModel() {
606 BookmarksFolderCacheModel bookmarksFolderCacheModel = new BookmarksFolderCacheModel();
607
608 bookmarksFolderCacheModel.uuid = getUuid();
609
610 String uuid = bookmarksFolderCacheModel.uuid;
611
612 if ((uuid != null) && (uuid.length() == 0)) {
613 bookmarksFolderCacheModel.uuid = null;
614 }
615
616 bookmarksFolderCacheModel.folderId = getFolderId();
617
618 bookmarksFolderCacheModel.groupId = getGroupId();
619
620 bookmarksFolderCacheModel.companyId = getCompanyId();
621
622 bookmarksFolderCacheModel.userId = getUserId();
623
624 bookmarksFolderCacheModel.userName = getUserName();
625
626 String userName = bookmarksFolderCacheModel.userName;
627
628 if ((userName != null) && (userName.length() == 0)) {
629 bookmarksFolderCacheModel.userName = null;
630 }
631
632 Date createDate = getCreateDate();
633
634 if (createDate != null) {
635 bookmarksFolderCacheModel.createDate = createDate.getTime();
636 }
637 else {
638 bookmarksFolderCacheModel.createDate = Long.MIN_VALUE;
639 }
640
641 Date modifiedDate = getModifiedDate();
642
643 if (modifiedDate != null) {
644 bookmarksFolderCacheModel.modifiedDate = modifiedDate.getTime();
645 }
646 else {
647 bookmarksFolderCacheModel.modifiedDate = Long.MIN_VALUE;
648 }
649
650 bookmarksFolderCacheModel.resourceBlockId = getResourceBlockId();
651
652 bookmarksFolderCacheModel.parentFolderId = getParentFolderId();
653
654 bookmarksFolderCacheModel.name = getName();
655
656 String name = bookmarksFolderCacheModel.name;
657
658 if ((name != null) && (name.length() == 0)) {
659 bookmarksFolderCacheModel.name = null;
660 }
661
662 bookmarksFolderCacheModel.description = getDescription();
663
664 String description = bookmarksFolderCacheModel.description;
665
666 if ((description != null) && (description.length() == 0)) {
667 bookmarksFolderCacheModel.description = null;
668 }
669
670 return bookmarksFolderCacheModel;
671 }
672
673 @Override
674 public String toString() {
675 StringBundler sb = new StringBundler(25);
676
677 sb.append("{uuid=");
678 sb.append(getUuid());
679 sb.append(", folderId=");
680 sb.append(getFolderId());
681 sb.append(", groupId=");
682 sb.append(getGroupId());
683 sb.append(", companyId=");
684 sb.append(getCompanyId());
685 sb.append(", userId=");
686 sb.append(getUserId());
687 sb.append(", userName=");
688 sb.append(getUserName());
689 sb.append(", createDate=");
690 sb.append(getCreateDate());
691 sb.append(", modifiedDate=");
692 sb.append(getModifiedDate());
693 sb.append(", resourceBlockId=");
694 sb.append(getResourceBlockId());
695 sb.append(", parentFolderId=");
696 sb.append(getParentFolderId());
697 sb.append(", name=");
698 sb.append(getName());
699 sb.append(", description=");
700 sb.append(getDescription());
701 sb.append("}");
702
703 return sb.toString();
704 }
705
706 public String toXmlString() {
707 StringBundler sb = new StringBundler(40);
708
709 sb.append("<model><model-name>");
710 sb.append("com.liferay.portlet.bookmarks.model.BookmarksFolder");
711 sb.append("</model-name>");
712
713 sb.append(
714 "<column><column-name>uuid</column-name><column-value><![CDATA[");
715 sb.append(getUuid());
716 sb.append("]]></column-value></column>");
717 sb.append(
718 "<column><column-name>folderId</column-name><column-value><![CDATA[");
719 sb.append(getFolderId());
720 sb.append("]]></column-value></column>");
721 sb.append(
722 "<column><column-name>groupId</column-name><column-value><![CDATA[");
723 sb.append(getGroupId());
724 sb.append("]]></column-value></column>");
725 sb.append(
726 "<column><column-name>companyId</column-name><column-value><![CDATA[");
727 sb.append(getCompanyId());
728 sb.append("]]></column-value></column>");
729 sb.append(
730 "<column><column-name>userId</column-name><column-value><![CDATA[");
731 sb.append(getUserId());
732 sb.append("]]></column-value></column>");
733 sb.append(
734 "<column><column-name>userName</column-name><column-value><![CDATA[");
735 sb.append(getUserName());
736 sb.append("]]></column-value></column>");
737 sb.append(
738 "<column><column-name>createDate</column-name><column-value><![CDATA[");
739 sb.append(getCreateDate());
740 sb.append("]]></column-value></column>");
741 sb.append(
742 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
743 sb.append(getModifiedDate());
744 sb.append("]]></column-value></column>");
745 sb.append(
746 "<column><column-name>resourceBlockId</column-name><column-value><![CDATA[");
747 sb.append(getResourceBlockId());
748 sb.append("]]></column-value></column>");
749 sb.append(
750 "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
751 sb.append(getParentFolderId());
752 sb.append("]]></column-value></column>");
753 sb.append(
754 "<column><column-name>name</column-name><column-value><![CDATA[");
755 sb.append(getName());
756 sb.append("]]></column-value></column>");
757 sb.append(
758 "<column><column-name>description</column-name><column-value><![CDATA[");
759 sb.append(getDescription());
760 sb.append("]]></column-value></column>");
761
762 sb.append("</model>");
763
764 return sb.toString();
765 }
766
767 private static ClassLoader _classLoader = BookmarksFolder.class.getClassLoader();
768 private static Class<?>[] _escapedModelInterfaces = new Class[] {
769 BookmarksFolder.class
770 };
771 private String _uuid;
772 private String _originalUuid;
773 private long _folderId;
774 private long _groupId;
775 private long _originalGroupId;
776 private boolean _setOriginalGroupId;
777 private long _companyId;
778 private long _originalCompanyId;
779 private boolean _setOriginalCompanyId;
780 private long _userId;
781 private String _userUuid;
782 private String _userName;
783 private Date _createDate;
784 private Date _modifiedDate;
785 private long _resourceBlockId;
786 private long _originalResourceBlockId;
787 private boolean _setOriginalResourceBlockId;
788 private long _parentFolderId;
789 private long _originalParentFolderId;
790 private boolean _setOriginalParentFolderId;
791 private String _name;
792 private String _description;
793 private long _columnBitmask;
794 private BookmarksFolder _escapedModel;
795 }