1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchLayoutSetPrototypeException;
18 import com.liferay.portal.NoSuchModelException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24 import com.liferay.portal.kernel.dao.orm.FinderPath;
25 import com.liferay.portal.kernel.dao.orm.Query;
26 import com.liferay.portal.kernel.dao.orm.QueryPos;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.dao.orm.Session;
29 import com.liferay.portal.kernel.exception.SystemException;
30 import com.liferay.portal.kernel.log.Log;
31 import com.liferay.portal.kernel.log.LogFactoryUtil;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.OrderByComparator;
34 import com.liferay.portal.kernel.util.StringBundler;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.model.LayoutSetPrototype;
38 import com.liferay.portal.model.ModelListener;
39 import com.liferay.portal.model.impl.LayoutSetPrototypeImpl;
40 import com.liferay.portal.model.impl.LayoutSetPrototypeModelImpl;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import java.io.Serializable;
44
45 import java.util.ArrayList;
46 import java.util.Collections;
47 import java.util.List;
48
49
62 public class LayoutSetPrototypePersistenceImpl extends BasePersistenceImpl<LayoutSetPrototype>
63 implements LayoutSetPrototypePersistence {
64 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetPrototypeImpl.class.getName();
65 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66 ".List";
67 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
68 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
69 FINDER_CLASS_NAME_LIST, "findByCompanyId",
70 new String[] { Long.class.getName() });
71 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
72 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
73 FINDER_CLASS_NAME_LIST, "findByCompanyId",
74 new String[] {
75 Long.class.getName(),
76
77 "java.lang.Integer", "java.lang.Integer",
78 "com.liferay.portal.kernel.util.OrderByComparator"
79 });
80 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
81 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
82 FINDER_CLASS_NAME_LIST, "countByCompanyId",
83 new String[] { Long.class.getName() });
84 public static final FinderPath FINDER_PATH_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
85 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
86 FINDER_CLASS_NAME_LIST, "findByC_A",
87 new String[] { Long.class.getName(), Boolean.class.getName() });
88 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
89 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
90 FINDER_CLASS_NAME_LIST, "findByC_A",
91 new String[] {
92 Long.class.getName(), Boolean.class.getName(),
93
94 "java.lang.Integer", "java.lang.Integer",
95 "com.liferay.portal.kernel.util.OrderByComparator"
96 });
97 public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
98 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "countByC_A",
100 new String[] { Long.class.getName(), Boolean.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
102 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
104 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
105 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
106 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
107
108 public void cacheResult(LayoutSetPrototype layoutSetPrototype) {
109 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
110 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
111 layoutSetPrototype);
112 }
113
114 public void cacheResult(List<LayoutSetPrototype> layoutSetPrototypes) {
115 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
116 if (EntityCacheUtil.getResult(
117 LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
118 LayoutSetPrototypeImpl.class,
119 layoutSetPrototype.getPrimaryKey(), this) == null) {
120 cacheResult(layoutSetPrototype);
121 }
122 }
123 }
124
125 public void clearCache() {
126 CacheRegistry.clear(LayoutSetPrototypeImpl.class.getName());
127 EntityCacheUtil.clearCache(LayoutSetPrototypeImpl.class.getName());
128 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
129 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
130 }
131
132 public LayoutSetPrototype create(long layoutSetPrototypeId) {
133 LayoutSetPrototype layoutSetPrototype = new LayoutSetPrototypeImpl();
134
135 layoutSetPrototype.setNew(true);
136 layoutSetPrototype.setPrimaryKey(layoutSetPrototypeId);
137
138 return layoutSetPrototype;
139 }
140
141 public LayoutSetPrototype remove(Serializable primaryKey)
142 throws NoSuchModelException, SystemException {
143 return remove(((Long)primaryKey).longValue());
144 }
145
146 public LayoutSetPrototype remove(long layoutSetPrototypeId)
147 throws NoSuchLayoutSetPrototypeException, SystemException {
148 Session session = null;
149
150 try {
151 session = openSession();
152
153 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
154 new Long(layoutSetPrototypeId));
155
156 if (layoutSetPrototype == null) {
157 if (_log.isWarnEnabled()) {
158 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
159 layoutSetPrototypeId);
160 }
161
162 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
163 layoutSetPrototypeId);
164 }
165
166 return remove(layoutSetPrototype);
167 }
168 catch (NoSuchLayoutSetPrototypeException nsee) {
169 throw nsee;
170 }
171 catch (Exception e) {
172 throw processException(e);
173 }
174 finally {
175 closeSession(session);
176 }
177 }
178
179 public LayoutSetPrototype remove(LayoutSetPrototype layoutSetPrototype)
180 throws SystemException {
181 for (ModelListener<LayoutSetPrototype> listener : listeners) {
182 listener.onBeforeRemove(layoutSetPrototype);
183 }
184
185 layoutSetPrototype = removeImpl(layoutSetPrototype);
186
187 for (ModelListener<LayoutSetPrototype> listener : listeners) {
188 listener.onAfterRemove(layoutSetPrototype);
189 }
190
191 return layoutSetPrototype;
192 }
193
194 protected LayoutSetPrototype removeImpl(
195 LayoutSetPrototype layoutSetPrototype) throws SystemException {
196 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
197
198 Session session = null;
199
200 try {
201 session = openSession();
202
203 if (layoutSetPrototype.isCachedModel() ||
204 BatchSessionUtil.isEnabled()) {
205 Object staleObject = session.get(LayoutSetPrototypeImpl.class,
206 layoutSetPrototype.getPrimaryKeyObj());
207
208 if (staleObject != null) {
209 session.evict(staleObject);
210 }
211 }
212
213 session.delete(layoutSetPrototype);
214
215 session.flush();
216 }
217 catch (Exception e) {
218 throw processException(e);
219 }
220 finally {
221 closeSession(session);
222 }
223
224 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
225
226 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
227 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
228
229 return layoutSetPrototype;
230 }
231
232 public LayoutSetPrototype updateImpl(
233 com.liferay.portal.model.LayoutSetPrototype layoutSetPrototype,
234 boolean merge) throws SystemException {
235 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
236
237 Session session = null;
238
239 try {
240 session = openSession();
241
242 BatchSessionUtil.update(session, layoutSetPrototype, merge);
243
244 layoutSetPrototype.setNew(false);
245 }
246 catch (Exception e) {
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252
253 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
254
255 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
256 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
257 layoutSetPrototype);
258
259 return layoutSetPrototype;
260 }
261
262 protected LayoutSetPrototype toUnwrappedModel(
263 LayoutSetPrototype layoutSetPrototype) {
264 if (layoutSetPrototype instanceof LayoutSetPrototypeImpl) {
265 return layoutSetPrototype;
266 }
267
268 LayoutSetPrototypeImpl layoutSetPrototypeImpl = new LayoutSetPrototypeImpl();
269
270 layoutSetPrototypeImpl.setNew(layoutSetPrototype.isNew());
271 layoutSetPrototypeImpl.setPrimaryKey(layoutSetPrototype.getPrimaryKey());
272
273 layoutSetPrototypeImpl.setLayoutSetPrototypeId(layoutSetPrototype.getLayoutSetPrototypeId());
274 layoutSetPrototypeImpl.setCompanyId(layoutSetPrototype.getCompanyId());
275 layoutSetPrototypeImpl.setName(layoutSetPrototype.getName());
276 layoutSetPrototypeImpl.setDescription(layoutSetPrototype.getDescription());
277 layoutSetPrototypeImpl.setSettings(layoutSetPrototype.getSettings());
278 layoutSetPrototypeImpl.setActive(layoutSetPrototype.isActive());
279
280 return layoutSetPrototypeImpl;
281 }
282
283 public LayoutSetPrototype findByPrimaryKey(Serializable primaryKey)
284 throws NoSuchModelException, SystemException {
285 return findByPrimaryKey(((Long)primaryKey).longValue());
286 }
287
288 public LayoutSetPrototype findByPrimaryKey(long layoutSetPrototypeId)
289 throws NoSuchLayoutSetPrototypeException, SystemException {
290 LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(layoutSetPrototypeId);
291
292 if (layoutSetPrototype == null) {
293 if (_log.isWarnEnabled()) {
294 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
295 layoutSetPrototypeId);
296 }
297
298 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
299 layoutSetPrototypeId);
300 }
301
302 return layoutSetPrototype;
303 }
304
305 public LayoutSetPrototype fetchByPrimaryKey(Serializable primaryKey)
306 throws SystemException {
307 return fetchByPrimaryKey(((Long)primaryKey).longValue());
308 }
309
310 public LayoutSetPrototype fetchByPrimaryKey(long layoutSetPrototypeId)
311 throws SystemException {
312 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)EntityCacheUtil.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
313 LayoutSetPrototypeImpl.class, layoutSetPrototypeId, this);
314
315 if (layoutSetPrototype == null) {
316 Session session = null;
317
318 try {
319 session = openSession();
320
321 layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
322 new Long(layoutSetPrototypeId));
323 }
324 catch (Exception e) {
325 throw processException(e);
326 }
327 finally {
328 if (layoutSetPrototype != null) {
329 cacheResult(layoutSetPrototype);
330 }
331
332 closeSession(session);
333 }
334 }
335
336 return layoutSetPrototype;
337 }
338
339 public List<LayoutSetPrototype> findByCompanyId(long companyId)
340 throws SystemException {
341 Object[] finderArgs = new Object[] { new Long(companyId) };
342
343 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
344 finderArgs, this);
345
346 if (list == null) {
347 Session session = null;
348
349 try {
350 session = openSession();
351
352 StringBundler query = new StringBundler(2);
353
354 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
355
356 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
357
358 String sql = query.toString();
359
360 Query q = session.createQuery(sql);
361
362 QueryPos qPos = QueryPos.getInstance(q);
363
364 qPos.add(companyId);
365
366 list = q.list();
367 }
368 catch (Exception e) {
369 throw processException(e);
370 }
371 finally {
372 if (list == null) {
373 list = new ArrayList<LayoutSetPrototype>();
374 }
375
376 cacheResult(list);
377
378 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
379 finderArgs, list);
380
381 closeSession(session);
382 }
383 }
384
385 return list;
386 }
387
388 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
389 int end) throws SystemException {
390 return findByCompanyId(companyId, start, end, null);
391 }
392
393 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
394 int end, OrderByComparator obc) throws SystemException {
395 Object[] finderArgs = new Object[] {
396 new Long(companyId),
397
398 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
399 };
400
401 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
402 finderArgs, this);
403
404 if (list == null) {
405 Session session = null;
406
407 try {
408 session = openSession();
409
410 StringBundler query = null;
411
412 if (obc != null) {
413 query = new StringBundler(3 +
414 (obc.getOrderByFields().length * 3));
415 }
416 else {
417 query = new StringBundler(2);
418 }
419
420 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
421
422 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
423
424 if (obc != null) {
425 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
426 }
427
428 String sql = query.toString();
429
430 Query q = session.createQuery(sql);
431
432 QueryPos qPos = QueryPos.getInstance(q);
433
434 qPos.add(companyId);
435
436 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
437 getDialect(), start, end);
438 }
439 catch (Exception e) {
440 throw processException(e);
441 }
442 finally {
443 if (list == null) {
444 list = new ArrayList<LayoutSetPrototype>();
445 }
446
447 cacheResult(list);
448
449 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
450 finderArgs, list);
451
452 closeSession(session);
453 }
454 }
455
456 return list;
457 }
458
459 public LayoutSetPrototype findByCompanyId_First(long companyId,
460 OrderByComparator obc)
461 throws NoSuchLayoutSetPrototypeException, SystemException {
462 List<LayoutSetPrototype> list = findByCompanyId(companyId, 0, 1, obc);
463
464 if (list.isEmpty()) {
465 StringBundler msg = new StringBundler(4);
466
467 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
468
469 msg.append("companyId=");
470 msg.append(companyId);
471
472 msg.append(StringPool.CLOSE_CURLY_BRACE);
473
474 throw new NoSuchLayoutSetPrototypeException(msg.toString());
475 }
476 else {
477 return list.get(0);
478 }
479 }
480
481 public LayoutSetPrototype findByCompanyId_Last(long companyId,
482 OrderByComparator obc)
483 throws NoSuchLayoutSetPrototypeException, SystemException {
484 int count = countByCompanyId(companyId);
485
486 List<LayoutSetPrototype> list = findByCompanyId(companyId, count - 1,
487 count, obc);
488
489 if (list.isEmpty()) {
490 StringBundler msg = new StringBundler(4);
491
492 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
493
494 msg.append("companyId=");
495 msg.append(companyId);
496
497 msg.append(StringPool.CLOSE_CURLY_BRACE);
498
499 throw new NoSuchLayoutSetPrototypeException(msg.toString());
500 }
501 else {
502 return list.get(0);
503 }
504 }
505
506 public LayoutSetPrototype[] findByCompanyId_PrevAndNext(
507 long layoutSetPrototypeId, long companyId, OrderByComparator obc)
508 throws NoSuchLayoutSetPrototypeException, SystemException {
509 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
510
511 int count = countByCompanyId(companyId);
512
513 Session session = null;
514
515 try {
516 session = openSession();
517
518 StringBundler query = null;
519
520 if (obc != null) {
521 query = new StringBundler(3 +
522 (obc.getOrderByFields().length * 3));
523 }
524 else {
525 query = new StringBundler(2);
526 }
527
528 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
529
530 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
531
532 if (obc != null) {
533 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
534 }
535
536 String sql = query.toString();
537
538 Query q = session.createQuery(sql);
539
540 QueryPos qPos = QueryPos.getInstance(q);
541
542 qPos.add(companyId);
543
544 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
545 layoutSetPrototype);
546
547 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
548
549 array[0] = (LayoutSetPrototype)objArray[0];
550 array[1] = (LayoutSetPrototype)objArray[1];
551 array[2] = (LayoutSetPrototype)objArray[2];
552
553 return array;
554 }
555 catch (Exception e) {
556 throw processException(e);
557 }
558 finally {
559 closeSession(session);
560 }
561 }
562
563 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active)
564 throws SystemException {
565 Object[] finderArgs = new Object[] {
566 new Long(companyId), Boolean.valueOf(active)
567 };
568
569 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_A,
570 finderArgs, this);
571
572 if (list == null) {
573 Session session = null;
574
575 try {
576 session = openSession();
577
578 StringBundler query = new StringBundler(3);
579
580 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
581
582 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
583
584 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
585
586 String sql = query.toString();
587
588 Query q = session.createQuery(sql);
589
590 QueryPos qPos = QueryPos.getInstance(q);
591
592 qPos.add(companyId);
593
594 qPos.add(active);
595
596 list = q.list();
597 }
598 catch (Exception e) {
599 throw processException(e);
600 }
601 finally {
602 if (list == null) {
603 list = new ArrayList<LayoutSetPrototype>();
604 }
605
606 cacheResult(list);
607
608 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_A, finderArgs,
609 list);
610
611 closeSession(session);
612 }
613 }
614
615 return list;
616 }
617
618 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
619 int start, int end) throws SystemException {
620 return findByC_A(companyId, active, start, end, null);
621 }
622
623 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
624 int start, int end, OrderByComparator obc) throws SystemException {
625 Object[] finderArgs = new Object[] {
626 new Long(companyId), Boolean.valueOf(active),
627
628 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
629 };
630
631 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_A,
632 finderArgs, this);
633
634 if (list == null) {
635 Session session = null;
636
637 try {
638 session = openSession();
639
640 StringBundler query = null;
641
642 if (obc != null) {
643 query = new StringBundler(4 +
644 (obc.getOrderByFields().length * 3));
645 }
646 else {
647 query = new StringBundler(3);
648 }
649
650 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
651
652 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
653
654 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
655
656 if (obc != null) {
657 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
658 }
659
660 String sql = query.toString();
661
662 Query q = session.createQuery(sql);
663
664 QueryPos qPos = QueryPos.getInstance(q);
665
666 qPos.add(companyId);
667
668 qPos.add(active);
669
670 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
671 getDialect(), start, end);
672 }
673 catch (Exception e) {
674 throw processException(e);
675 }
676 finally {
677 if (list == null) {
678 list = new ArrayList<LayoutSetPrototype>();
679 }
680
681 cacheResult(list);
682
683 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_A,
684 finderArgs, list);
685
686 closeSession(session);
687 }
688 }
689
690 return list;
691 }
692
693 public LayoutSetPrototype findByC_A_First(long companyId, boolean active,
694 OrderByComparator obc)
695 throws NoSuchLayoutSetPrototypeException, SystemException {
696 List<LayoutSetPrototype> list = findByC_A(companyId, active, 0, 1, obc);
697
698 if (list.isEmpty()) {
699 StringBundler msg = new StringBundler(6);
700
701 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
702
703 msg.append("companyId=");
704 msg.append(companyId);
705
706 msg.append(", active=");
707 msg.append(active);
708
709 msg.append(StringPool.CLOSE_CURLY_BRACE);
710
711 throw new NoSuchLayoutSetPrototypeException(msg.toString());
712 }
713 else {
714 return list.get(0);
715 }
716 }
717
718 public LayoutSetPrototype findByC_A_Last(long companyId, boolean active,
719 OrderByComparator obc)
720 throws NoSuchLayoutSetPrototypeException, SystemException {
721 int count = countByC_A(companyId, active);
722
723 List<LayoutSetPrototype> list = findByC_A(companyId, active, count - 1,
724 count, obc);
725
726 if (list.isEmpty()) {
727 StringBundler msg = new StringBundler(6);
728
729 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
730
731 msg.append("companyId=");
732 msg.append(companyId);
733
734 msg.append(", active=");
735 msg.append(active);
736
737 msg.append(StringPool.CLOSE_CURLY_BRACE);
738
739 throw new NoSuchLayoutSetPrototypeException(msg.toString());
740 }
741 else {
742 return list.get(0);
743 }
744 }
745
746 public LayoutSetPrototype[] findByC_A_PrevAndNext(
747 long layoutSetPrototypeId, long companyId, boolean active,
748 OrderByComparator obc)
749 throws NoSuchLayoutSetPrototypeException, SystemException {
750 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
751
752 int count = countByC_A(companyId, active);
753
754 Session session = null;
755
756 try {
757 session = openSession();
758
759 StringBundler query = null;
760
761 if (obc != null) {
762 query = new StringBundler(4 +
763 (obc.getOrderByFields().length * 3));
764 }
765 else {
766 query = new StringBundler(3);
767 }
768
769 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
770
771 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
772
773 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
774
775 if (obc != null) {
776 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
777 }
778
779 String sql = query.toString();
780
781 Query q = session.createQuery(sql);
782
783 QueryPos qPos = QueryPos.getInstance(q);
784
785 qPos.add(companyId);
786
787 qPos.add(active);
788
789 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
790 layoutSetPrototype);
791
792 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
793
794 array[0] = (LayoutSetPrototype)objArray[0];
795 array[1] = (LayoutSetPrototype)objArray[1];
796 array[2] = (LayoutSetPrototype)objArray[2];
797
798 return array;
799 }
800 catch (Exception e) {
801 throw processException(e);
802 }
803 finally {
804 closeSession(session);
805 }
806 }
807
808 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
809 throws SystemException {
810 Session session = null;
811
812 try {
813 session = openSession();
814
815 dynamicQuery.compile(session);
816
817 return dynamicQuery.list();
818 }
819 catch (Exception e) {
820 throw processException(e);
821 }
822 finally {
823 closeSession(session);
824 }
825 }
826
827 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
828 int start, int end) throws SystemException {
829 Session session = null;
830
831 try {
832 session = openSession();
833
834 dynamicQuery.setLimit(start, end);
835
836 dynamicQuery.compile(session);
837
838 return dynamicQuery.list();
839 }
840 catch (Exception e) {
841 throw processException(e);
842 }
843 finally {
844 closeSession(session);
845 }
846 }
847
848 public List<LayoutSetPrototype> findAll() throws SystemException {
849 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
850 }
851
852 public List<LayoutSetPrototype> findAll(int start, int end)
853 throws SystemException {
854 return findAll(start, end, null);
855 }
856
857 public List<LayoutSetPrototype> findAll(int start, int end,
858 OrderByComparator obc) throws SystemException {
859 Object[] finderArgs = new Object[] {
860 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
861 };
862
863 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
864 finderArgs, this);
865
866 if (list == null) {
867 Session session = null;
868
869 try {
870 session = openSession();
871
872 StringBundler query = null;
873 String sql = null;
874
875 if (obc != null) {
876 query = new StringBundler(2 +
877 (obc.getOrderByFields().length * 3));
878
879 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE);
880
881 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
882
883 sql = query.toString();
884 }
885
886 sql = _SQL_SELECT_LAYOUTSETPROTOTYPE;
887
888 Query q = session.createQuery(sql);
889
890 if (obc == null) {
891 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
892 getDialect(), start, end, false);
893
894 Collections.sort(list);
895 }
896 else {
897 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
898 getDialect(), start, end);
899 }
900 }
901 catch (Exception e) {
902 throw processException(e);
903 }
904 finally {
905 if (list == null) {
906 list = new ArrayList<LayoutSetPrototype>();
907 }
908
909 cacheResult(list);
910
911 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
912
913 closeSession(session);
914 }
915 }
916
917 return list;
918 }
919
920 public void removeByCompanyId(long companyId) throws SystemException {
921 for (LayoutSetPrototype layoutSetPrototype : findByCompanyId(companyId)) {
922 remove(layoutSetPrototype);
923 }
924 }
925
926 public void removeByC_A(long companyId, boolean active)
927 throws SystemException {
928 for (LayoutSetPrototype layoutSetPrototype : findByC_A(companyId, active)) {
929 remove(layoutSetPrototype);
930 }
931 }
932
933 public void removeAll() throws SystemException {
934 for (LayoutSetPrototype layoutSetPrototype : findAll()) {
935 remove(layoutSetPrototype);
936 }
937 }
938
939 public int countByCompanyId(long companyId) throws SystemException {
940 Object[] finderArgs = new Object[] { new Long(companyId) };
941
942 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
943 finderArgs, this);
944
945 if (count == null) {
946 Session session = null;
947
948 try {
949 session = openSession();
950
951 StringBundler query = new StringBundler(2);
952
953 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
954
955 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
956
957 String sql = query.toString();
958
959 Query q = session.createQuery(sql);
960
961 QueryPos qPos = QueryPos.getInstance(q);
962
963 qPos.add(companyId);
964
965 count = (Long)q.uniqueResult();
966 }
967 catch (Exception e) {
968 throw processException(e);
969 }
970 finally {
971 if (count == null) {
972 count = Long.valueOf(0);
973 }
974
975 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
976 finderArgs, count);
977
978 closeSession(session);
979 }
980 }
981
982 return count.intValue();
983 }
984
985 public int countByC_A(long companyId, boolean active)
986 throws SystemException {
987 Object[] finderArgs = new Object[] {
988 new Long(companyId), Boolean.valueOf(active)
989 };
990
991 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_A,
992 finderArgs, this);
993
994 if (count == null) {
995 Session session = null;
996
997 try {
998 session = openSession();
999
1000 StringBundler query = new StringBundler(3);
1001
1002 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1003
1004 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
1005
1006 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
1007
1008 String sql = query.toString();
1009
1010 Query q = session.createQuery(sql);
1011
1012 QueryPos qPos = QueryPos.getInstance(q);
1013
1014 qPos.add(companyId);
1015
1016 qPos.add(active);
1017
1018 count = (Long)q.uniqueResult();
1019 }
1020 catch (Exception e) {
1021 throw processException(e);
1022 }
1023 finally {
1024 if (count == null) {
1025 count = Long.valueOf(0);
1026 }
1027
1028 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_A, finderArgs,
1029 count);
1030
1031 closeSession(session);
1032 }
1033 }
1034
1035 return count.intValue();
1036 }
1037
1038 public int countAll() throws SystemException {
1039 Object[] finderArgs = new Object[0];
1040
1041 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1042 finderArgs, this);
1043
1044 if (count == null) {
1045 Session session = null;
1046
1047 try {
1048 session = openSession();
1049
1050 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETPROTOTYPE);
1051
1052 count = (Long)q.uniqueResult();
1053 }
1054 catch (Exception e) {
1055 throw processException(e);
1056 }
1057 finally {
1058 if (count == null) {
1059 count = Long.valueOf(0);
1060 }
1061
1062 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1063 count);
1064
1065 closeSession(session);
1066 }
1067 }
1068
1069 return count.intValue();
1070 }
1071
1072 public void afterPropertiesSet() {
1073 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1074 com.liferay.portal.util.PropsUtil.get(
1075 "value.object.listener.com.liferay.portal.model.LayoutSetPrototype")));
1076
1077 if (listenerClassNames.length > 0) {
1078 try {
1079 List<ModelListener<LayoutSetPrototype>> listenersList = new ArrayList<ModelListener<LayoutSetPrototype>>();
1080
1081 for (String listenerClassName : listenerClassNames) {
1082 listenersList.add((ModelListener<LayoutSetPrototype>)Class.forName(
1083 listenerClassName).newInstance());
1084 }
1085
1086 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1087 }
1088 catch (Exception e) {
1089 _log.error(e);
1090 }
1091 }
1092 }
1093
1094 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
1095 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1096 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
1097 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1098 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
1099 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1100 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
1101 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1102 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
1103 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1104 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
1105 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1106 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
1107 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1108 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
1109 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1110 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
1111 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1112 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
1113 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1114 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
1115 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1116 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPrototypePersistence")
1117 protected com.liferay.portal.service.persistence.LayoutPrototypePersistence layoutPrototypePersistence;
1118 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
1119 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1120 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPrototypePersistence")
1121 protected com.liferay.portal.service.persistence.LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1122 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
1123 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1124 @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
1125 protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
1126 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
1127 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1128 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
1129 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1130 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
1131 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1132 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
1133 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1134 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
1135 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1136 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
1137 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1138 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
1139 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1140 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
1141 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1142 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
1143 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1144 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
1145 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1146 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
1147 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1148 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
1149 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1150 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
1151 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1152 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
1153 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1154 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
1155 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1156 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
1157 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1158 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
1159 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1160 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
1161 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1162 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
1163 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1164 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
1165 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1166 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
1167 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1168 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
1169 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1170 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
1171 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1172 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
1173 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1174 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
1175 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1176 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
1177 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1178 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence")
1179 protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1180 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
1181 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1182 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
1183 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1184 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
1185 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1186 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
1187 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1188 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
1189 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1190 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
1191 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1192 @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence")
1193 protected com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1194 @BeanReference(name = "com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence")
1195 protected com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1196 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype";
1197 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE ";
1198 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype";
1199 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype WHERE ";
1200 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
1201 private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "layoutSetPrototype.companyId = ? AND ";
1202 private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "layoutSetPrototype.active = ?";
1203 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetPrototype.";
1204 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetPrototype exists with the primary key ";
1205 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetPrototype exists with the key {";
1206 private static Log _log = LogFactoryUtil.getLog(LayoutSetPrototypePersistenceImpl.class);
1207}