001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutSetException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.LayoutSet;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.impl.LayoutSetImpl;
042 import com.liferay.portal.model.impl.LayoutSetModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class LayoutSetPersistenceImpl extends BasePersistenceImpl<LayoutSet>
064 implements LayoutSetPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
076 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
085 new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
086 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
088 new String[] { Long.class.getName() },
089 LayoutSetModelImpl.GROUPID_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
091 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
093 new String[] { Long.class.getName() });
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID =
095 new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
096 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
097 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
098 "findByLayoutSetPrototypeUuid",
099 new String[] {
100 String.class.getName(),
101
102 "java.lang.Integer", "java.lang.Integer",
103 "com.liferay.portal.kernel.util.OrderByComparator"
104 });
105 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID =
106 new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
107 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
109 "findByLayoutSetPrototypeUuid",
110 new String[] { String.class.getName() },
111 LayoutSetModelImpl.LAYOUTSETPROTOTYPEUUID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
113 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
115 "countByLayoutSetPrototypeUuid",
116 new String[] { String.class.getName() });
117 public static final FinderPath FINDER_PATH_FETCH_BY_G_P = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
118 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
119 FINDER_CLASS_NAME_ENTITY, "fetchByG_P",
120 new String[] { Long.class.getName(), Boolean.class.getName() },
121 LayoutSetModelImpl.GROUPID_COLUMN_BITMASK |
122 LayoutSetModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
123 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
124 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
125 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
126 new String[] { Long.class.getName(), Boolean.class.getName() });
127 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
128 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
129 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
130 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
131 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
133 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
134 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
136
137
142 public void cacheResult(LayoutSet layoutSet) {
143 EntityCacheUtil.putResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
144 LayoutSetImpl.class, layoutSet.getPrimaryKey(), layoutSet);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
147 new Object[] {
148 Long.valueOf(layoutSet.getGroupId()),
149 Boolean.valueOf(layoutSet.getPrivateLayout())
150 }, layoutSet);
151
152 layoutSet.resetOriginalValues();
153 }
154
155
160 public void cacheResult(List<LayoutSet> layoutSets) {
161 for (LayoutSet layoutSet : layoutSets) {
162 if (EntityCacheUtil.getResult(
163 LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
164 LayoutSetImpl.class, layoutSet.getPrimaryKey()) == null) {
165 cacheResult(layoutSet);
166 }
167 else {
168 layoutSet.resetOriginalValues();
169 }
170 }
171 }
172
173
180 @Override
181 public void clearCache() {
182 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
183 CacheRegistryUtil.clear(LayoutSetImpl.class.getName());
184 }
185
186 EntityCacheUtil.clearCache(LayoutSetImpl.class.getName());
187
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
191 }
192
193
200 @Override
201 public void clearCache(LayoutSet layoutSet) {
202 EntityCacheUtil.removeResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
203 LayoutSetImpl.class, layoutSet.getPrimaryKey());
204
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
207
208 clearUniqueFindersCache(layoutSet);
209 }
210
211 @Override
212 public void clearCache(List<LayoutSet> layoutSets) {
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
215
216 for (LayoutSet layoutSet : layoutSets) {
217 EntityCacheUtil.removeResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
218 LayoutSetImpl.class, layoutSet.getPrimaryKey());
219
220 clearUniqueFindersCache(layoutSet);
221 }
222 }
223
224 protected void clearUniqueFindersCache(LayoutSet layoutSet) {
225 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P,
226 new Object[] {
227 Long.valueOf(layoutSet.getGroupId()),
228 Boolean.valueOf(layoutSet.getPrivateLayout())
229 });
230 }
231
232
238 public LayoutSet create(long layoutSetId) {
239 LayoutSet layoutSet = new LayoutSetImpl();
240
241 layoutSet.setNew(true);
242 layoutSet.setPrimaryKey(layoutSetId);
243
244 return layoutSet;
245 }
246
247
255 public LayoutSet remove(long layoutSetId)
256 throws NoSuchLayoutSetException, SystemException {
257 return remove(Long.valueOf(layoutSetId));
258 }
259
260
268 @Override
269 public LayoutSet remove(Serializable primaryKey)
270 throws NoSuchLayoutSetException, SystemException {
271 Session session = null;
272
273 try {
274 session = openSession();
275
276 LayoutSet layoutSet = (LayoutSet)session.get(LayoutSetImpl.class,
277 primaryKey);
278
279 if (layoutSet == null) {
280 if (_log.isWarnEnabled()) {
281 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
282 }
283
284 throw new NoSuchLayoutSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
285 primaryKey);
286 }
287
288 return remove(layoutSet);
289 }
290 catch (NoSuchLayoutSetException nsee) {
291 throw nsee;
292 }
293 catch (Exception e) {
294 throw processException(e);
295 }
296 finally {
297 closeSession(session);
298 }
299 }
300
301 @Override
302 protected LayoutSet removeImpl(LayoutSet layoutSet)
303 throws SystemException {
304 layoutSet = toUnwrappedModel(layoutSet);
305
306 Session session = null;
307
308 try {
309 session = openSession();
310
311 if (layoutSet.isCachedModel()) {
312 layoutSet = (LayoutSet)session.get(LayoutSetImpl.class,
313 layoutSet.getPrimaryKeyObj());
314 }
315
316 session.delete(layoutSet);
317 }
318 catch (Exception e) {
319 throw processException(e);
320 }
321 finally {
322 closeSession(session);
323 }
324
325 clearCache(layoutSet);
326
327 return layoutSet;
328 }
329
330 @Override
331 public LayoutSet updateImpl(com.liferay.portal.model.LayoutSet layoutSet)
332 throws SystemException {
333 layoutSet = toUnwrappedModel(layoutSet);
334
335 boolean isNew = layoutSet.isNew();
336
337 LayoutSetModelImpl layoutSetModelImpl = (LayoutSetModelImpl)layoutSet;
338
339 Session session = null;
340
341 try {
342 session = openSession();
343
344 if (layoutSet.isNew()) {
345 session.save(layoutSet);
346
347 layoutSet.setNew(false);
348 }
349 else {
350 session.merge(layoutSet);
351 }
352 }
353 catch (Exception e) {
354 throw processException(e);
355 }
356 finally {
357 closeSession(session);
358 }
359
360 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
361
362 if (isNew || !LayoutSetModelImpl.COLUMN_BITMASK_ENABLED) {
363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
364 }
365
366 else {
367 if ((layoutSetModelImpl.getColumnBitmask() &
368 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
369 Object[] args = new Object[] {
370 Long.valueOf(layoutSetModelImpl.getOriginalGroupId())
371 };
372
373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
374 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
375 args);
376
377 args = new Object[] {
378 Long.valueOf(layoutSetModelImpl.getGroupId())
379 };
380
381 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
382 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
383 args);
384 }
385
386 if ((layoutSetModelImpl.getColumnBitmask() &
387 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID.getColumnBitmask()) != 0) {
388 Object[] args = new Object[] {
389 layoutSetModelImpl.getOriginalLayoutSetPrototypeUuid()
390 };
391
392 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
393 args);
394 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID,
395 args);
396
397 args = new Object[] {
398 layoutSetModelImpl.getLayoutSetPrototypeUuid()
399 };
400
401 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
402 args);
403 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID,
404 args);
405 }
406 }
407
408 EntityCacheUtil.putResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
409 LayoutSetImpl.class, layoutSet.getPrimaryKey(), layoutSet);
410
411 if (isNew) {
412 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
413 new Object[] {
414 Long.valueOf(layoutSet.getGroupId()),
415 Boolean.valueOf(layoutSet.getPrivateLayout())
416 }, layoutSet);
417 }
418 else {
419 if ((layoutSetModelImpl.getColumnBitmask() &
420 FINDER_PATH_FETCH_BY_G_P.getColumnBitmask()) != 0) {
421 Object[] args = new Object[] {
422 Long.valueOf(layoutSetModelImpl.getOriginalGroupId()),
423 Boolean.valueOf(layoutSetModelImpl.getOriginalPrivateLayout())
424 };
425
426 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
427
428 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P, args);
429
430 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
431 new Object[] {
432 Long.valueOf(layoutSet.getGroupId()),
433 Boolean.valueOf(layoutSet.getPrivateLayout())
434 }, layoutSet);
435 }
436 }
437
438 return layoutSet;
439 }
440
441 protected LayoutSet toUnwrappedModel(LayoutSet layoutSet) {
442 if (layoutSet instanceof LayoutSetImpl) {
443 return layoutSet;
444 }
445
446 LayoutSetImpl layoutSetImpl = new LayoutSetImpl();
447
448 layoutSetImpl.setNew(layoutSet.isNew());
449 layoutSetImpl.setPrimaryKey(layoutSet.getPrimaryKey());
450
451 layoutSetImpl.setLayoutSetId(layoutSet.getLayoutSetId());
452 layoutSetImpl.setGroupId(layoutSet.getGroupId());
453 layoutSetImpl.setCompanyId(layoutSet.getCompanyId());
454 layoutSetImpl.setCreateDate(layoutSet.getCreateDate());
455 layoutSetImpl.setModifiedDate(layoutSet.getModifiedDate());
456 layoutSetImpl.setPrivateLayout(layoutSet.isPrivateLayout());
457 layoutSetImpl.setLogo(layoutSet.isLogo());
458 layoutSetImpl.setLogoId(layoutSet.getLogoId());
459 layoutSetImpl.setThemeId(layoutSet.getThemeId());
460 layoutSetImpl.setColorSchemeId(layoutSet.getColorSchemeId());
461 layoutSetImpl.setWapThemeId(layoutSet.getWapThemeId());
462 layoutSetImpl.setWapColorSchemeId(layoutSet.getWapColorSchemeId());
463 layoutSetImpl.setCss(layoutSet.getCss());
464 layoutSetImpl.setPageCount(layoutSet.getPageCount());
465 layoutSetImpl.setSettings(layoutSet.getSettings());
466 layoutSetImpl.setLayoutSetPrototypeUuid(layoutSet.getLayoutSetPrototypeUuid());
467 layoutSetImpl.setLayoutSetPrototypeLinkEnabled(layoutSet.isLayoutSetPrototypeLinkEnabled());
468
469 return layoutSetImpl;
470 }
471
472
480 @Override
481 public LayoutSet findByPrimaryKey(Serializable primaryKey)
482 throws NoSuchModelException, SystemException {
483 return findByPrimaryKey(((Long)primaryKey).longValue());
484 }
485
486
494 public LayoutSet findByPrimaryKey(long layoutSetId)
495 throws NoSuchLayoutSetException, SystemException {
496 LayoutSet layoutSet = fetchByPrimaryKey(layoutSetId);
497
498 if (layoutSet == null) {
499 if (_log.isWarnEnabled()) {
500 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetId);
501 }
502
503 throw new NoSuchLayoutSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
504 layoutSetId);
505 }
506
507 return layoutSet;
508 }
509
510
517 @Override
518 public LayoutSet fetchByPrimaryKey(Serializable primaryKey)
519 throws SystemException {
520 return fetchByPrimaryKey(((Long)primaryKey).longValue());
521 }
522
523
530 public LayoutSet fetchByPrimaryKey(long layoutSetId)
531 throws SystemException {
532 LayoutSet layoutSet = (LayoutSet)EntityCacheUtil.getResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
533 LayoutSetImpl.class, layoutSetId);
534
535 if (layoutSet == _nullLayoutSet) {
536 return null;
537 }
538
539 if (layoutSet == null) {
540 Session session = null;
541
542 boolean hasException = false;
543
544 try {
545 session = openSession();
546
547 layoutSet = (LayoutSet)session.get(LayoutSetImpl.class,
548 Long.valueOf(layoutSetId));
549 }
550 catch (Exception e) {
551 hasException = true;
552
553 throw processException(e);
554 }
555 finally {
556 if (layoutSet != null) {
557 cacheResult(layoutSet);
558 }
559 else if (!hasException) {
560 EntityCacheUtil.putResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
561 LayoutSetImpl.class, layoutSetId, _nullLayoutSet);
562 }
563
564 closeSession(session);
565 }
566 }
567
568 return layoutSet;
569 }
570
571
578 public List<LayoutSet> findByGroupId(long groupId)
579 throws SystemException {
580 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
581 }
582
583
596 public List<LayoutSet> findByGroupId(long groupId, int start, int end)
597 throws SystemException {
598 return findByGroupId(groupId, start, end, null);
599 }
600
601
615 public List<LayoutSet> findByGroupId(long groupId, int start, int end,
616 OrderByComparator orderByComparator) throws SystemException {
617 FinderPath finderPath = null;
618 Object[] finderArgs = null;
619
620 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
621 (orderByComparator == null)) {
622 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
623 finderArgs = new Object[] { groupId };
624 }
625 else {
626 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
627 finderArgs = new Object[] { groupId, start, end, orderByComparator };
628 }
629
630 List<LayoutSet> list = (List<LayoutSet>)FinderCacheUtil.getResult(finderPath,
631 finderArgs, this);
632
633 if ((list != null) && !list.isEmpty()) {
634 for (LayoutSet layoutSet : list) {
635 if ((groupId != layoutSet.getGroupId())) {
636 list = null;
637
638 break;
639 }
640 }
641 }
642
643 if (list == null) {
644 StringBundler query = null;
645
646 if (orderByComparator != null) {
647 query = new StringBundler(3 +
648 (orderByComparator.getOrderByFields().length * 3));
649 }
650 else {
651 query = new StringBundler(2);
652 }
653
654 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
655
656 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
657
658 if (orderByComparator != null) {
659 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
660 orderByComparator);
661 }
662
663 String sql = query.toString();
664
665 Session session = null;
666
667 try {
668 session = openSession();
669
670 Query q = session.createQuery(sql);
671
672 QueryPos qPos = QueryPos.getInstance(q);
673
674 qPos.add(groupId);
675
676 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(), start,
677 end);
678 }
679 catch (Exception e) {
680 throw processException(e);
681 }
682 finally {
683 if (list == null) {
684 FinderCacheUtil.removeResult(finderPath, finderArgs);
685 }
686 else {
687 cacheResult(list);
688
689 FinderCacheUtil.putResult(finderPath, finderArgs, list);
690 }
691
692 closeSession(session);
693 }
694 }
695
696 return list;
697 }
698
699
708 public LayoutSet findByGroupId_First(long groupId,
709 OrderByComparator orderByComparator)
710 throws NoSuchLayoutSetException, SystemException {
711 LayoutSet layoutSet = fetchByGroupId_First(groupId, orderByComparator);
712
713 if (layoutSet != null) {
714 return layoutSet;
715 }
716
717 StringBundler msg = new StringBundler(4);
718
719 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
720
721 msg.append("groupId=");
722 msg.append(groupId);
723
724 msg.append(StringPool.CLOSE_CURLY_BRACE);
725
726 throw new NoSuchLayoutSetException(msg.toString());
727 }
728
729
737 public LayoutSet fetchByGroupId_First(long groupId,
738 OrderByComparator orderByComparator) throws SystemException {
739 List<LayoutSet> list = findByGroupId(groupId, 0, 1, orderByComparator);
740
741 if (!list.isEmpty()) {
742 return list.get(0);
743 }
744
745 return null;
746 }
747
748
757 public LayoutSet findByGroupId_Last(long groupId,
758 OrderByComparator orderByComparator)
759 throws NoSuchLayoutSetException, SystemException {
760 LayoutSet layoutSet = fetchByGroupId_Last(groupId, orderByComparator);
761
762 if (layoutSet != null) {
763 return layoutSet;
764 }
765
766 StringBundler msg = new StringBundler(4);
767
768 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
769
770 msg.append("groupId=");
771 msg.append(groupId);
772
773 msg.append(StringPool.CLOSE_CURLY_BRACE);
774
775 throw new NoSuchLayoutSetException(msg.toString());
776 }
777
778
786 public LayoutSet fetchByGroupId_Last(long groupId,
787 OrderByComparator orderByComparator) throws SystemException {
788 int count = countByGroupId(groupId);
789
790 List<LayoutSet> list = findByGroupId(groupId, count - 1, count,
791 orderByComparator);
792
793 if (!list.isEmpty()) {
794 return list.get(0);
795 }
796
797 return null;
798 }
799
800
810 public LayoutSet[] findByGroupId_PrevAndNext(long layoutSetId,
811 long groupId, OrderByComparator orderByComparator)
812 throws NoSuchLayoutSetException, SystemException {
813 LayoutSet layoutSet = findByPrimaryKey(layoutSetId);
814
815 Session session = null;
816
817 try {
818 session = openSession();
819
820 LayoutSet[] array = new LayoutSetImpl[3];
821
822 array[0] = getByGroupId_PrevAndNext(session, layoutSet, groupId,
823 orderByComparator, true);
824
825 array[1] = layoutSet;
826
827 array[2] = getByGroupId_PrevAndNext(session, layoutSet, groupId,
828 orderByComparator, false);
829
830 return array;
831 }
832 catch (Exception e) {
833 throw processException(e);
834 }
835 finally {
836 closeSession(session);
837 }
838 }
839
840 protected LayoutSet getByGroupId_PrevAndNext(Session session,
841 LayoutSet layoutSet, long groupId, OrderByComparator orderByComparator,
842 boolean previous) {
843 StringBundler query = null;
844
845 if (orderByComparator != null) {
846 query = new StringBundler(6 +
847 (orderByComparator.getOrderByFields().length * 6));
848 }
849 else {
850 query = new StringBundler(3);
851 }
852
853 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
854
855 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
856
857 if (orderByComparator != null) {
858 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
859
860 if (orderByConditionFields.length > 0) {
861 query.append(WHERE_AND);
862 }
863
864 for (int i = 0; i < orderByConditionFields.length; i++) {
865 query.append(_ORDER_BY_ENTITY_ALIAS);
866 query.append(orderByConditionFields[i]);
867
868 if ((i + 1) < orderByConditionFields.length) {
869 if (orderByComparator.isAscending() ^ previous) {
870 query.append(WHERE_GREATER_THAN_HAS_NEXT);
871 }
872 else {
873 query.append(WHERE_LESSER_THAN_HAS_NEXT);
874 }
875 }
876 else {
877 if (orderByComparator.isAscending() ^ previous) {
878 query.append(WHERE_GREATER_THAN);
879 }
880 else {
881 query.append(WHERE_LESSER_THAN);
882 }
883 }
884 }
885
886 query.append(ORDER_BY_CLAUSE);
887
888 String[] orderByFields = orderByComparator.getOrderByFields();
889
890 for (int i = 0; i < orderByFields.length; i++) {
891 query.append(_ORDER_BY_ENTITY_ALIAS);
892 query.append(orderByFields[i]);
893
894 if ((i + 1) < orderByFields.length) {
895 if (orderByComparator.isAscending() ^ previous) {
896 query.append(ORDER_BY_ASC_HAS_NEXT);
897 }
898 else {
899 query.append(ORDER_BY_DESC_HAS_NEXT);
900 }
901 }
902 else {
903 if (orderByComparator.isAscending() ^ previous) {
904 query.append(ORDER_BY_ASC);
905 }
906 else {
907 query.append(ORDER_BY_DESC);
908 }
909 }
910 }
911 }
912
913 String sql = query.toString();
914
915 Query q = session.createQuery(sql);
916
917 q.setFirstResult(0);
918 q.setMaxResults(2);
919
920 QueryPos qPos = QueryPos.getInstance(q);
921
922 qPos.add(groupId);
923
924 if (orderByComparator != null) {
925 Object[] values = orderByComparator.getOrderByConditionValues(layoutSet);
926
927 for (Object value : values) {
928 qPos.add(value);
929 }
930 }
931
932 List<LayoutSet> list = q.list();
933
934 if (list.size() == 2) {
935 return list.get(1);
936 }
937 else {
938 return null;
939 }
940 }
941
942
949 public List<LayoutSet> findByLayoutSetPrototypeUuid(
950 String layoutSetPrototypeUuid) throws SystemException {
951 return findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid,
952 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
953 }
954
955
968 public List<LayoutSet> findByLayoutSetPrototypeUuid(
969 String layoutSetPrototypeUuid, int start, int end)
970 throws SystemException {
971 return findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid, start, end,
972 null);
973 }
974
975
989 public List<LayoutSet> findByLayoutSetPrototypeUuid(
990 String layoutSetPrototypeUuid, int start, int end,
991 OrderByComparator orderByComparator) throws SystemException {
992 FinderPath finderPath = null;
993 Object[] finderArgs = null;
994
995 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
996 (orderByComparator == null)) {
997 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID;
998 finderArgs = new Object[] { layoutSetPrototypeUuid };
999 }
1000 else {
1001 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID;
1002 finderArgs = new Object[] {
1003 layoutSetPrototypeUuid,
1004
1005 start, end, orderByComparator
1006 };
1007 }
1008
1009 List<LayoutSet> list = (List<LayoutSet>)FinderCacheUtil.getResult(finderPath,
1010 finderArgs, this);
1011
1012 if ((list != null) && !list.isEmpty()) {
1013 for (LayoutSet layoutSet : list) {
1014 if (!Validator.equals(layoutSetPrototypeUuid,
1015 layoutSet.getLayoutSetPrototypeUuid())) {
1016 list = null;
1017
1018 break;
1019 }
1020 }
1021 }
1022
1023 if (list == null) {
1024 StringBundler query = null;
1025
1026 if (orderByComparator != null) {
1027 query = new StringBundler(3 +
1028 (orderByComparator.getOrderByFields().length * 3));
1029 }
1030 else {
1031 query = new StringBundler(2);
1032 }
1033
1034 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
1035
1036 if (layoutSetPrototypeUuid == null) {
1037 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1);
1038 }
1039 else {
1040 if (layoutSetPrototypeUuid.equals(StringPool.BLANK)) {
1041 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3);
1042 }
1043 else {
1044 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2);
1045 }
1046 }
1047
1048 if (orderByComparator != null) {
1049 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1050 orderByComparator);
1051 }
1052
1053 String sql = query.toString();
1054
1055 Session session = null;
1056
1057 try {
1058 session = openSession();
1059
1060 Query q = session.createQuery(sql);
1061
1062 QueryPos qPos = QueryPos.getInstance(q);
1063
1064 if (layoutSetPrototypeUuid != null) {
1065 qPos.add(layoutSetPrototypeUuid);
1066 }
1067
1068 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(), start,
1069 end);
1070 }
1071 catch (Exception e) {
1072 throw processException(e);
1073 }
1074 finally {
1075 if (list == null) {
1076 FinderCacheUtil.removeResult(finderPath, finderArgs);
1077 }
1078 else {
1079 cacheResult(list);
1080
1081 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1082 }
1083
1084 closeSession(session);
1085 }
1086 }
1087
1088 return list;
1089 }
1090
1091
1100 public LayoutSet findByLayoutSetPrototypeUuid_First(
1101 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1102 throws NoSuchLayoutSetException, SystemException {
1103 LayoutSet layoutSet = fetchByLayoutSetPrototypeUuid_First(layoutSetPrototypeUuid,
1104 orderByComparator);
1105
1106 if (layoutSet != null) {
1107 return layoutSet;
1108 }
1109
1110 StringBundler msg = new StringBundler(4);
1111
1112 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1113
1114 msg.append("layoutSetPrototypeUuid=");
1115 msg.append(layoutSetPrototypeUuid);
1116
1117 msg.append(StringPool.CLOSE_CURLY_BRACE);
1118
1119 throw new NoSuchLayoutSetException(msg.toString());
1120 }
1121
1122
1130 public LayoutSet fetchByLayoutSetPrototypeUuid_First(
1131 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1132 throws SystemException {
1133 List<LayoutSet> list = findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid,
1134 0, 1, orderByComparator);
1135
1136 if (!list.isEmpty()) {
1137 return list.get(0);
1138 }
1139
1140 return null;
1141 }
1142
1143
1152 public LayoutSet findByLayoutSetPrototypeUuid_Last(
1153 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1154 throws NoSuchLayoutSetException, SystemException {
1155 LayoutSet layoutSet = fetchByLayoutSetPrototypeUuid_Last(layoutSetPrototypeUuid,
1156 orderByComparator);
1157
1158 if (layoutSet != null) {
1159 return layoutSet;
1160 }
1161
1162 StringBundler msg = new StringBundler(4);
1163
1164 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1165
1166 msg.append("layoutSetPrototypeUuid=");
1167 msg.append(layoutSetPrototypeUuid);
1168
1169 msg.append(StringPool.CLOSE_CURLY_BRACE);
1170
1171 throw new NoSuchLayoutSetException(msg.toString());
1172 }
1173
1174
1182 public LayoutSet fetchByLayoutSetPrototypeUuid_Last(
1183 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1184 throws SystemException {
1185 int count = countByLayoutSetPrototypeUuid(layoutSetPrototypeUuid);
1186
1187 List<LayoutSet> list = findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid,
1188 count - 1, count, orderByComparator);
1189
1190 if (!list.isEmpty()) {
1191 return list.get(0);
1192 }
1193
1194 return null;
1195 }
1196
1197
1207 public LayoutSet[] findByLayoutSetPrototypeUuid_PrevAndNext(
1208 long layoutSetId, String layoutSetPrototypeUuid,
1209 OrderByComparator orderByComparator)
1210 throws NoSuchLayoutSetException, SystemException {
1211 LayoutSet layoutSet = findByPrimaryKey(layoutSetId);
1212
1213 Session session = null;
1214
1215 try {
1216 session = openSession();
1217
1218 LayoutSet[] array = new LayoutSetImpl[3];
1219
1220 array[0] = getByLayoutSetPrototypeUuid_PrevAndNext(session,
1221 layoutSet, layoutSetPrototypeUuid, orderByComparator, true);
1222
1223 array[1] = layoutSet;
1224
1225 array[2] = getByLayoutSetPrototypeUuid_PrevAndNext(session,
1226 layoutSet, layoutSetPrototypeUuid, orderByComparator, false);
1227
1228 return array;
1229 }
1230 catch (Exception e) {
1231 throw processException(e);
1232 }
1233 finally {
1234 closeSession(session);
1235 }
1236 }
1237
1238 protected LayoutSet getByLayoutSetPrototypeUuid_PrevAndNext(
1239 Session session, LayoutSet layoutSet, String layoutSetPrototypeUuid,
1240 OrderByComparator orderByComparator, boolean previous) {
1241 StringBundler query = null;
1242
1243 if (orderByComparator != null) {
1244 query = new StringBundler(6 +
1245 (orderByComparator.getOrderByFields().length * 6));
1246 }
1247 else {
1248 query = new StringBundler(3);
1249 }
1250
1251 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
1252
1253 if (layoutSetPrototypeUuid == null) {
1254 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1);
1255 }
1256 else {
1257 if (layoutSetPrototypeUuid.equals(StringPool.BLANK)) {
1258 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3);
1259 }
1260 else {
1261 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2);
1262 }
1263 }
1264
1265 if (orderByComparator != null) {
1266 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1267
1268 if (orderByConditionFields.length > 0) {
1269 query.append(WHERE_AND);
1270 }
1271
1272 for (int i = 0; i < orderByConditionFields.length; i++) {
1273 query.append(_ORDER_BY_ENTITY_ALIAS);
1274 query.append(orderByConditionFields[i]);
1275
1276 if ((i + 1) < orderByConditionFields.length) {
1277 if (orderByComparator.isAscending() ^ previous) {
1278 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1279 }
1280 else {
1281 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1282 }
1283 }
1284 else {
1285 if (orderByComparator.isAscending() ^ previous) {
1286 query.append(WHERE_GREATER_THAN);
1287 }
1288 else {
1289 query.append(WHERE_LESSER_THAN);
1290 }
1291 }
1292 }
1293
1294 query.append(ORDER_BY_CLAUSE);
1295
1296 String[] orderByFields = orderByComparator.getOrderByFields();
1297
1298 for (int i = 0; i < orderByFields.length; i++) {
1299 query.append(_ORDER_BY_ENTITY_ALIAS);
1300 query.append(orderByFields[i]);
1301
1302 if ((i + 1) < orderByFields.length) {
1303 if (orderByComparator.isAscending() ^ previous) {
1304 query.append(ORDER_BY_ASC_HAS_NEXT);
1305 }
1306 else {
1307 query.append(ORDER_BY_DESC_HAS_NEXT);
1308 }
1309 }
1310 else {
1311 if (orderByComparator.isAscending() ^ previous) {
1312 query.append(ORDER_BY_ASC);
1313 }
1314 else {
1315 query.append(ORDER_BY_DESC);
1316 }
1317 }
1318 }
1319 }
1320
1321 String sql = query.toString();
1322
1323 Query q = session.createQuery(sql);
1324
1325 q.setFirstResult(0);
1326 q.setMaxResults(2);
1327
1328 QueryPos qPos = QueryPos.getInstance(q);
1329
1330 if (layoutSetPrototypeUuid != null) {
1331 qPos.add(layoutSetPrototypeUuid);
1332 }
1333
1334 if (orderByComparator != null) {
1335 Object[] values = orderByComparator.getOrderByConditionValues(layoutSet);
1336
1337 for (Object value : values) {
1338 qPos.add(value);
1339 }
1340 }
1341
1342 List<LayoutSet> list = q.list();
1343
1344 if (list.size() == 2) {
1345 return list.get(1);
1346 }
1347 else {
1348 return null;
1349 }
1350 }
1351
1352
1361 public LayoutSet findByG_P(long groupId, boolean privateLayout)
1362 throws NoSuchLayoutSetException, SystemException {
1363 LayoutSet layoutSet = fetchByG_P(groupId, privateLayout);
1364
1365 if (layoutSet == null) {
1366 StringBundler msg = new StringBundler(6);
1367
1368 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1369
1370 msg.append("groupId=");
1371 msg.append(groupId);
1372
1373 msg.append(", privateLayout=");
1374 msg.append(privateLayout);
1375
1376 msg.append(StringPool.CLOSE_CURLY_BRACE);
1377
1378 if (_log.isWarnEnabled()) {
1379 _log.warn(msg.toString());
1380 }
1381
1382 throw new NoSuchLayoutSetException(msg.toString());
1383 }
1384
1385 return layoutSet;
1386 }
1387
1388
1396 public LayoutSet fetchByG_P(long groupId, boolean privateLayout)
1397 throws SystemException {
1398 return fetchByG_P(groupId, privateLayout, true);
1399 }
1400
1401
1410 public LayoutSet fetchByG_P(long groupId, boolean privateLayout,
1411 boolean retrieveFromCache) throws SystemException {
1412 Object[] finderArgs = new Object[] { groupId, privateLayout };
1413
1414 Object result = null;
1415
1416 if (retrieveFromCache) {
1417 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P,
1418 finderArgs, this);
1419 }
1420
1421 if (result instanceof LayoutSet) {
1422 LayoutSet layoutSet = (LayoutSet)result;
1423
1424 if ((groupId != layoutSet.getGroupId()) ||
1425 (privateLayout != layoutSet.getPrivateLayout())) {
1426 result = null;
1427 }
1428 }
1429
1430 if (result == null) {
1431 StringBundler query = new StringBundler(3);
1432
1433 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
1434
1435 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1436
1437 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1438
1439 String sql = query.toString();
1440
1441 Session session = null;
1442
1443 try {
1444 session = openSession();
1445
1446 Query q = session.createQuery(sql);
1447
1448 QueryPos qPos = QueryPos.getInstance(q);
1449
1450 qPos.add(groupId);
1451
1452 qPos.add(privateLayout);
1453
1454 List<LayoutSet> list = q.list();
1455
1456 result = list;
1457
1458 LayoutSet layoutSet = null;
1459
1460 if (list.isEmpty()) {
1461 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
1462 finderArgs, list);
1463 }
1464 else {
1465 layoutSet = list.get(0);
1466
1467 cacheResult(layoutSet);
1468
1469 if ((layoutSet.getGroupId() != groupId) ||
1470 (layoutSet.getPrivateLayout() != privateLayout)) {
1471 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
1472 finderArgs, layoutSet);
1473 }
1474 }
1475
1476 return layoutSet;
1477 }
1478 catch (Exception e) {
1479 throw processException(e);
1480 }
1481 finally {
1482 if (result == null) {
1483 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P,
1484 finderArgs);
1485 }
1486
1487 closeSession(session);
1488 }
1489 }
1490 else {
1491 if (result instanceof List<?>) {
1492 return null;
1493 }
1494 else {
1495 return (LayoutSet)result;
1496 }
1497 }
1498 }
1499
1500
1506 public List<LayoutSet> findAll() throws SystemException {
1507 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1508 }
1509
1510
1522 public List<LayoutSet> findAll(int start, int end)
1523 throws SystemException {
1524 return findAll(start, end, null);
1525 }
1526
1527
1540 public List<LayoutSet> findAll(int start, int end,
1541 OrderByComparator orderByComparator) throws SystemException {
1542 FinderPath finderPath = null;
1543 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1544
1545 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1546 (orderByComparator == null)) {
1547 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1548 finderArgs = FINDER_ARGS_EMPTY;
1549 }
1550 else {
1551 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1552 finderArgs = new Object[] { start, end, orderByComparator };
1553 }
1554
1555 List<LayoutSet> list = (List<LayoutSet>)FinderCacheUtil.getResult(finderPath,
1556 finderArgs, this);
1557
1558 if (list == null) {
1559 StringBundler query = null;
1560 String sql = null;
1561
1562 if (orderByComparator != null) {
1563 query = new StringBundler(2 +
1564 (orderByComparator.getOrderByFields().length * 3));
1565
1566 query.append(_SQL_SELECT_LAYOUTSET);
1567
1568 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1569 orderByComparator);
1570
1571 sql = query.toString();
1572 }
1573 else {
1574 sql = _SQL_SELECT_LAYOUTSET;
1575 }
1576
1577 Session session = null;
1578
1579 try {
1580 session = openSession();
1581
1582 Query q = session.createQuery(sql);
1583
1584 if (orderByComparator == null) {
1585 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(),
1586 start, end, false);
1587
1588 Collections.sort(list);
1589 }
1590 else {
1591 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(),
1592 start, end);
1593 }
1594 }
1595 catch (Exception e) {
1596 throw processException(e);
1597 }
1598 finally {
1599 if (list == null) {
1600 FinderCacheUtil.removeResult(finderPath, finderArgs);
1601 }
1602 else {
1603 cacheResult(list);
1604
1605 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1606 }
1607
1608 closeSession(session);
1609 }
1610 }
1611
1612 return list;
1613 }
1614
1615
1621 public void removeByGroupId(long groupId) throws SystemException {
1622 for (LayoutSet layoutSet : findByGroupId(groupId)) {
1623 remove(layoutSet);
1624 }
1625 }
1626
1627
1633 public void removeByLayoutSetPrototypeUuid(String layoutSetPrototypeUuid)
1634 throws SystemException {
1635 for (LayoutSet layoutSet : findByLayoutSetPrototypeUuid(
1636 layoutSetPrototypeUuid)) {
1637 remove(layoutSet);
1638 }
1639 }
1640
1641
1649 public LayoutSet removeByG_P(long groupId, boolean privateLayout)
1650 throws NoSuchLayoutSetException, SystemException {
1651 LayoutSet layoutSet = findByG_P(groupId, privateLayout);
1652
1653 return remove(layoutSet);
1654 }
1655
1656
1661 public void removeAll() throws SystemException {
1662 for (LayoutSet layoutSet : findAll()) {
1663 remove(layoutSet);
1664 }
1665 }
1666
1667
1674 public int countByGroupId(long groupId) throws SystemException {
1675 Object[] finderArgs = new Object[] { groupId };
1676
1677 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1678 finderArgs, this);
1679
1680 if (count == null) {
1681 StringBundler query = new StringBundler(2);
1682
1683 query.append(_SQL_COUNT_LAYOUTSET_WHERE);
1684
1685 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1686
1687 String sql = query.toString();
1688
1689 Session session = null;
1690
1691 try {
1692 session = openSession();
1693
1694 Query q = session.createQuery(sql);
1695
1696 QueryPos qPos = QueryPos.getInstance(q);
1697
1698 qPos.add(groupId);
1699
1700 count = (Long)q.uniqueResult();
1701 }
1702 catch (Exception e) {
1703 throw processException(e);
1704 }
1705 finally {
1706 if (count == null) {
1707 count = Long.valueOf(0);
1708 }
1709
1710 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1711 finderArgs, count);
1712
1713 closeSession(session);
1714 }
1715 }
1716
1717 return count.intValue();
1718 }
1719
1720
1727 public int countByLayoutSetPrototypeUuid(String layoutSetPrototypeUuid)
1728 throws SystemException {
1729 Object[] finderArgs = new Object[] { layoutSetPrototypeUuid };
1730
1731 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
1732 finderArgs, this);
1733
1734 if (count == null) {
1735 StringBundler query = new StringBundler(2);
1736
1737 query.append(_SQL_COUNT_LAYOUTSET_WHERE);
1738
1739 if (layoutSetPrototypeUuid == null) {
1740 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1);
1741 }
1742 else {
1743 if (layoutSetPrototypeUuid.equals(StringPool.BLANK)) {
1744 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3);
1745 }
1746 else {
1747 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2);
1748 }
1749 }
1750
1751 String sql = query.toString();
1752
1753 Session session = null;
1754
1755 try {
1756 session = openSession();
1757
1758 Query q = session.createQuery(sql);
1759
1760 QueryPos qPos = QueryPos.getInstance(q);
1761
1762 if (layoutSetPrototypeUuid != null) {
1763 qPos.add(layoutSetPrototypeUuid);
1764 }
1765
1766 count = (Long)q.uniqueResult();
1767 }
1768 catch (Exception e) {
1769 throw processException(e);
1770 }
1771 finally {
1772 if (count == null) {
1773 count = Long.valueOf(0);
1774 }
1775
1776 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
1777 finderArgs, count);
1778
1779 closeSession(session);
1780 }
1781 }
1782
1783 return count.intValue();
1784 }
1785
1786
1794 public int countByG_P(long groupId, boolean privateLayout)
1795 throws SystemException {
1796 Object[] finderArgs = new Object[] { groupId, privateLayout };
1797
1798 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
1799 finderArgs, this);
1800
1801 if (count == null) {
1802 StringBundler query = new StringBundler(3);
1803
1804 query.append(_SQL_COUNT_LAYOUTSET_WHERE);
1805
1806 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1807
1808 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1809
1810 String sql = query.toString();
1811
1812 Session session = null;
1813
1814 try {
1815 session = openSession();
1816
1817 Query q = session.createQuery(sql);
1818
1819 QueryPos qPos = QueryPos.getInstance(q);
1820
1821 qPos.add(groupId);
1822
1823 qPos.add(privateLayout);
1824
1825 count = (Long)q.uniqueResult();
1826 }
1827 catch (Exception e) {
1828 throw processException(e);
1829 }
1830 finally {
1831 if (count == null) {
1832 count = Long.valueOf(0);
1833 }
1834
1835 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
1836 count);
1837
1838 closeSession(session);
1839 }
1840 }
1841
1842 return count.intValue();
1843 }
1844
1845
1851 public int countAll() throws SystemException {
1852 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1853 FINDER_ARGS_EMPTY, this);
1854
1855 if (count == null) {
1856 Session session = null;
1857
1858 try {
1859 session = openSession();
1860
1861 Query q = session.createQuery(_SQL_COUNT_LAYOUTSET);
1862
1863 count = (Long)q.uniqueResult();
1864 }
1865 catch (Exception e) {
1866 throw processException(e);
1867 }
1868 finally {
1869 if (count == null) {
1870 count = Long.valueOf(0);
1871 }
1872
1873 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1874 FINDER_ARGS_EMPTY, count);
1875
1876 closeSession(session);
1877 }
1878 }
1879
1880 return count.intValue();
1881 }
1882
1883
1886 public void afterPropertiesSet() {
1887 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1888 com.liferay.portal.util.PropsUtil.get(
1889 "value.object.listener.com.liferay.portal.model.LayoutSet")));
1890
1891 if (listenerClassNames.length > 0) {
1892 try {
1893 List<ModelListener<LayoutSet>> listenersList = new ArrayList<ModelListener<LayoutSet>>();
1894
1895 for (String listenerClassName : listenerClassNames) {
1896 listenersList.add((ModelListener<LayoutSet>)InstanceFactory.newInstance(
1897 listenerClassName));
1898 }
1899
1900 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1901 }
1902 catch (Exception e) {
1903 _log.error(e);
1904 }
1905 }
1906 }
1907
1908 public void destroy() {
1909 EntityCacheUtil.removeCache(LayoutSetImpl.class.getName());
1910 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1911 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1912 }
1913
1914 @BeanReference(type = AccountPersistence.class)
1915 protected AccountPersistence accountPersistence;
1916 @BeanReference(type = AddressPersistence.class)
1917 protected AddressPersistence addressPersistence;
1918 @BeanReference(type = BrowserTrackerPersistence.class)
1919 protected BrowserTrackerPersistence browserTrackerPersistence;
1920 @BeanReference(type = ClassNamePersistence.class)
1921 protected ClassNamePersistence classNamePersistence;
1922 @BeanReference(type = ClusterGroupPersistence.class)
1923 protected ClusterGroupPersistence clusterGroupPersistence;
1924 @BeanReference(type = CompanyPersistence.class)
1925 protected CompanyPersistence companyPersistence;
1926 @BeanReference(type = ContactPersistence.class)
1927 protected ContactPersistence contactPersistence;
1928 @BeanReference(type = CountryPersistence.class)
1929 protected CountryPersistence countryPersistence;
1930 @BeanReference(type = EmailAddressPersistence.class)
1931 protected EmailAddressPersistence emailAddressPersistence;
1932 @BeanReference(type = GroupPersistence.class)
1933 protected GroupPersistence groupPersistence;
1934 @BeanReference(type = ImagePersistence.class)
1935 protected ImagePersistence imagePersistence;
1936 @BeanReference(type = LayoutPersistence.class)
1937 protected LayoutPersistence layoutPersistence;
1938 @BeanReference(type = LayoutBranchPersistence.class)
1939 protected LayoutBranchPersistence layoutBranchPersistence;
1940 @BeanReference(type = LayoutPrototypePersistence.class)
1941 protected LayoutPrototypePersistence layoutPrototypePersistence;
1942 @BeanReference(type = LayoutRevisionPersistence.class)
1943 protected LayoutRevisionPersistence layoutRevisionPersistence;
1944 @BeanReference(type = LayoutSetPersistence.class)
1945 protected LayoutSetPersistence layoutSetPersistence;
1946 @BeanReference(type = LayoutSetBranchPersistence.class)
1947 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1948 @BeanReference(type = LayoutSetPrototypePersistence.class)
1949 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1950 @BeanReference(type = ListTypePersistence.class)
1951 protected ListTypePersistence listTypePersistence;
1952 @BeanReference(type = LockPersistence.class)
1953 protected LockPersistence lockPersistence;
1954 @BeanReference(type = MembershipRequestPersistence.class)
1955 protected MembershipRequestPersistence membershipRequestPersistence;
1956 @BeanReference(type = OrganizationPersistence.class)
1957 protected OrganizationPersistence organizationPersistence;
1958 @BeanReference(type = OrgGroupRolePersistence.class)
1959 protected OrgGroupRolePersistence orgGroupRolePersistence;
1960 @BeanReference(type = OrgLaborPersistence.class)
1961 protected OrgLaborPersistence orgLaborPersistence;
1962 @BeanReference(type = PasswordPolicyPersistence.class)
1963 protected PasswordPolicyPersistence passwordPolicyPersistence;
1964 @BeanReference(type = PasswordPolicyRelPersistence.class)
1965 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1966 @BeanReference(type = PasswordTrackerPersistence.class)
1967 protected PasswordTrackerPersistence passwordTrackerPersistence;
1968 @BeanReference(type = PhonePersistence.class)
1969 protected PhonePersistence phonePersistence;
1970 @BeanReference(type = PluginSettingPersistence.class)
1971 protected PluginSettingPersistence pluginSettingPersistence;
1972 @BeanReference(type = PortalPreferencesPersistence.class)
1973 protected PortalPreferencesPersistence portalPreferencesPersistence;
1974 @BeanReference(type = PortletPersistence.class)
1975 protected PortletPersistence portletPersistence;
1976 @BeanReference(type = PortletItemPersistence.class)
1977 protected PortletItemPersistence portletItemPersistence;
1978 @BeanReference(type = PortletPreferencesPersistence.class)
1979 protected PortletPreferencesPersistence portletPreferencesPersistence;
1980 @BeanReference(type = RegionPersistence.class)
1981 protected RegionPersistence regionPersistence;
1982 @BeanReference(type = ReleasePersistence.class)
1983 protected ReleasePersistence releasePersistence;
1984 @BeanReference(type = RepositoryPersistence.class)
1985 protected RepositoryPersistence repositoryPersistence;
1986 @BeanReference(type = RepositoryEntryPersistence.class)
1987 protected RepositoryEntryPersistence repositoryEntryPersistence;
1988 @BeanReference(type = ResourceActionPersistence.class)
1989 protected ResourceActionPersistence resourceActionPersistence;
1990 @BeanReference(type = ResourceBlockPersistence.class)
1991 protected ResourceBlockPersistence resourceBlockPersistence;
1992 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1993 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1994 @BeanReference(type = ResourcePermissionPersistence.class)
1995 protected ResourcePermissionPersistence resourcePermissionPersistence;
1996 @BeanReference(type = ResourceTypePermissionPersistence.class)
1997 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1998 @BeanReference(type = RolePersistence.class)
1999 protected RolePersistence rolePersistence;
2000 @BeanReference(type = ServiceComponentPersistence.class)
2001 protected ServiceComponentPersistence serviceComponentPersistence;
2002 @BeanReference(type = ShardPersistence.class)
2003 protected ShardPersistence shardPersistence;
2004 @BeanReference(type = SubscriptionPersistence.class)
2005 protected SubscriptionPersistence subscriptionPersistence;
2006 @BeanReference(type = TeamPersistence.class)
2007 protected TeamPersistence teamPersistence;
2008 @BeanReference(type = TicketPersistence.class)
2009 protected TicketPersistence ticketPersistence;
2010 @BeanReference(type = UserPersistence.class)
2011 protected UserPersistence userPersistence;
2012 @BeanReference(type = UserGroupPersistence.class)
2013 protected UserGroupPersistence userGroupPersistence;
2014 @BeanReference(type = UserGroupGroupRolePersistence.class)
2015 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2016 @BeanReference(type = UserGroupRolePersistence.class)
2017 protected UserGroupRolePersistence userGroupRolePersistence;
2018 @BeanReference(type = UserIdMapperPersistence.class)
2019 protected UserIdMapperPersistence userIdMapperPersistence;
2020 @BeanReference(type = UserNotificationEventPersistence.class)
2021 protected UserNotificationEventPersistence userNotificationEventPersistence;
2022 @BeanReference(type = UserTrackerPersistence.class)
2023 protected UserTrackerPersistence userTrackerPersistence;
2024 @BeanReference(type = UserTrackerPathPersistence.class)
2025 protected UserTrackerPathPersistence userTrackerPathPersistence;
2026 @BeanReference(type = VirtualHostPersistence.class)
2027 protected VirtualHostPersistence virtualHostPersistence;
2028 @BeanReference(type = WebDAVPropsPersistence.class)
2029 protected WebDAVPropsPersistence webDAVPropsPersistence;
2030 @BeanReference(type = WebsitePersistence.class)
2031 protected WebsitePersistence websitePersistence;
2032 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2033 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2034 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2035 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2036 private static final String _SQL_SELECT_LAYOUTSET = "SELECT layoutSet FROM LayoutSet layoutSet";
2037 private static final String _SQL_SELECT_LAYOUTSET_WHERE = "SELECT layoutSet FROM LayoutSet layoutSet WHERE ";
2038 private static final String _SQL_COUNT_LAYOUTSET = "SELECT COUNT(layoutSet) FROM LayoutSet layoutSet";
2039 private static final String _SQL_COUNT_LAYOUTSET_WHERE = "SELECT COUNT(layoutSet) FROM LayoutSet layoutSet WHERE ";
2040 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSet.groupId = ?";
2041 private static final String _FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1 =
2042 "layoutSet.layoutSetPrototypeUuid IS NULL";
2043 private static final String _FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2 =
2044 "layoutSet.layoutSetPrototypeUuid = ?";
2045 private static final String _FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3 =
2046 "(layoutSet.layoutSetPrototypeUuid IS NULL OR layoutSet.layoutSetPrototypeUuid = ?)";
2047 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSet.groupId = ? AND ";
2048 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSet.privateLayout = ?";
2049 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSet.";
2050 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSet exists with the primary key ";
2051 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSet exists with the key {";
2052 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2053 private static Log _log = LogFactoryUtil.getLog(LayoutSetPersistenceImpl.class);
2054 private static LayoutSet _nullLayoutSet = new LayoutSetImpl() {
2055 @Override
2056 public Object clone() {
2057 return this;
2058 }
2059
2060 @Override
2061 public CacheModel<LayoutSet> toCacheModel() {
2062 return _nullLayoutSetCacheModel;
2063 }
2064 };
2065
2066 private static CacheModel<LayoutSet> _nullLayoutSetCacheModel = new CacheModel<LayoutSet>() {
2067 public LayoutSet toEntityModel() {
2068 return _nullLayoutSet;
2069 }
2070 };
2071 }