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