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