1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.NoSuchResourcePermissionException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.exception.SystemException;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.kernel.util.Validator;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.model.ResourcePermission;
39 import com.liferay.portal.model.impl.ResourcePermissionImpl;
40 import com.liferay.portal.model.impl.ResourcePermissionModelImpl;
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 ResourcePermissionPersistenceImpl extends BasePersistenceImpl<ResourcePermission>
63 implements ResourcePermissionPersistence {
64 public static final String FINDER_CLASS_NAME_ENTITY = ResourcePermissionImpl.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_ROLEID = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
68 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
69 FINDER_CLASS_NAME_LIST, "findByRoleId",
70 new String[] { Long.class.getName() });
71 public static final FinderPath FINDER_PATH_FIND_BY_OBC_ROLEID = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
72 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
73 FINDER_CLASS_NAME_LIST, "findByRoleId",
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_ROLEID = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
81 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
82 FINDER_CLASS_NAME_LIST, "countByRoleId",
83 new String[] { Long.class.getName() });
84 public static final FinderPath FINDER_PATH_FIND_BY_R_S = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
85 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
86 FINDER_CLASS_NAME_LIST, "findByR_S",
87 new String[] { Long.class.getName(), Integer.class.getName() });
88 public static final FinderPath FINDER_PATH_FIND_BY_OBC_R_S = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
89 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
90 FINDER_CLASS_NAME_LIST, "findByR_S",
91 new String[] {
92 Long.class.getName(), Integer.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_R_S = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
98 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "countByR_S",
100 new String[] { Long.class.getName(), Integer.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_C_N_S = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
102 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findByC_N_S",
104 new String[] {
105 Long.class.getName(), String.class.getName(),
106 Integer.class.getName()
107 });
108 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_N_S = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
109 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
110 FINDER_CLASS_NAME_LIST, "findByC_N_S",
111 new String[] {
112 Long.class.getName(), String.class.getName(),
113 Integer.class.getName(),
114
115 "java.lang.Integer", "java.lang.Integer",
116 "com.liferay.portal.kernel.util.OrderByComparator"
117 });
118 public static final FinderPath FINDER_PATH_COUNT_BY_C_N_S = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
119 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
120 FINDER_CLASS_NAME_LIST, "countByC_N_S",
121 new String[] {
122 Long.class.getName(), String.class.getName(),
123 Integer.class.getName()
124 });
125 public static final FinderPath FINDER_PATH_FIND_BY_C_N_S_P = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
126 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
127 FINDER_CLASS_NAME_LIST, "findByC_N_S_P",
128 new String[] {
129 Long.class.getName(), String.class.getName(),
130 Integer.class.getName(), String.class.getName()
131 });
132 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_N_S_P = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
133 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_LIST, "findByC_N_S_P",
135 new String[] {
136 Long.class.getName(), String.class.getName(),
137 Integer.class.getName(), String.class.getName(),
138
139 "java.lang.Integer", "java.lang.Integer",
140 "com.liferay.portal.kernel.util.OrderByComparator"
141 });
142 public static final FinderPath FINDER_PATH_COUNT_BY_C_N_S_P = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
143 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
144 FINDER_CLASS_NAME_LIST, "countByC_N_S_P",
145 new String[] {
146 Long.class.getName(), String.class.getName(),
147 Integer.class.getName(), String.class.getName()
148 });
149 public static final FinderPath FINDER_PATH_FETCH_BY_C_N_S_P_R = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
150 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
151 FINDER_CLASS_NAME_ENTITY, "fetchByC_N_S_P_R",
152 new String[] {
153 Long.class.getName(), String.class.getName(),
154 Integer.class.getName(), String.class.getName(),
155 Long.class.getName()
156 });
157 public static final FinderPath FINDER_PATH_COUNT_BY_C_N_S_P_R = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
158 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
159 FINDER_CLASS_NAME_LIST, "countByC_N_S_P_R",
160 new String[] {
161 Long.class.getName(), String.class.getName(),
162 Integer.class.getName(), String.class.getName(),
163 Long.class.getName()
164 });
165 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
166 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
167 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
168 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
169 ResourcePermissionModelImpl.FINDER_CACHE_ENABLED,
170 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
171
172 public void cacheResult(ResourcePermission resourcePermission) {
173 EntityCacheUtil.putResult(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
174 ResourcePermissionImpl.class, resourcePermission.getPrimaryKey(),
175 resourcePermission);
176
177 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
178 new Object[] {
179 new Long(resourcePermission.getCompanyId()),
180
181 resourcePermission.getName(),
182 new Integer(resourcePermission.getScope()),
183
184 resourcePermission.getPrimKey(),
185 new Long(resourcePermission.getRoleId())
186 }, resourcePermission);
187 }
188
189 public void cacheResult(List<ResourcePermission> resourcePermissions) {
190 for (ResourcePermission resourcePermission : resourcePermissions) {
191 if (EntityCacheUtil.getResult(
192 ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
193 ResourcePermissionImpl.class,
194 resourcePermission.getPrimaryKey(), this) == null) {
195 cacheResult(resourcePermission);
196 }
197 }
198 }
199
200 public void clearCache() {
201 CacheRegistry.clear(ResourcePermissionImpl.class.getName());
202 EntityCacheUtil.clearCache(ResourcePermissionImpl.class.getName());
203 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
204 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
205 }
206
207 public ResourcePermission create(long resourcePermissionId) {
208 ResourcePermission resourcePermission = new ResourcePermissionImpl();
209
210 resourcePermission.setNew(true);
211 resourcePermission.setPrimaryKey(resourcePermissionId);
212
213 return resourcePermission;
214 }
215
216 public ResourcePermission remove(Serializable primaryKey)
217 throws NoSuchModelException, SystemException {
218 return remove(((Long)primaryKey).longValue());
219 }
220
221 public ResourcePermission remove(long resourcePermissionId)
222 throws NoSuchResourcePermissionException, SystemException {
223 Session session = null;
224
225 try {
226 session = openSession();
227
228 ResourcePermission resourcePermission = (ResourcePermission)session.get(ResourcePermissionImpl.class,
229 new Long(resourcePermissionId));
230
231 if (resourcePermission == null) {
232 if (_log.isWarnEnabled()) {
233 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
234 resourcePermissionId);
235 }
236
237 throw new NoSuchResourcePermissionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
238 resourcePermissionId);
239 }
240
241 return remove(resourcePermission);
242 }
243 catch (NoSuchResourcePermissionException nsee) {
244 throw nsee;
245 }
246 catch (Exception e) {
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252 }
253
254 public ResourcePermission remove(ResourcePermission resourcePermission)
255 throws SystemException {
256 for (ModelListener<ResourcePermission> listener : listeners) {
257 listener.onBeforeRemove(resourcePermission);
258 }
259
260 resourcePermission = removeImpl(resourcePermission);
261
262 for (ModelListener<ResourcePermission> listener : listeners) {
263 listener.onAfterRemove(resourcePermission);
264 }
265
266 return resourcePermission;
267 }
268
269 protected ResourcePermission removeImpl(
270 ResourcePermission resourcePermission) throws SystemException {
271 resourcePermission = toUnwrappedModel(resourcePermission);
272
273 Session session = null;
274
275 try {
276 session = openSession();
277
278 if (resourcePermission.isCachedModel() ||
279 BatchSessionUtil.isEnabled()) {
280 Object staleObject = session.get(ResourcePermissionImpl.class,
281 resourcePermission.getPrimaryKeyObj());
282
283 if (staleObject != null) {
284 session.evict(staleObject);
285 }
286 }
287
288 session.delete(resourcePermission);
289
290 session.flush();
291 }
292 catch (Exception e) {
293 throw processException(e);
294 }
295 finally {
296 closeSession(session);
297 }
298
299 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
300
301 ResourcePermissionModelImpl resourcePermissionModelImpl = (ResourcePermissionModelImpl)resourcePermission;
302
303 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
304 new Object[] {
305 new Long(resourcePermissionModelImpl.getOriginalCompanyId()),
306
307 resourcePermissionModelImpl.getOriginalName(),
308 new Integer(resourcePermissionModelImpl.getOriginalScope()),
309
310 resourcePermissionModelImpl.getOriginalPrimKey(),
311 new Long(resourcePermissionModelImpl.getOriginalRoleId())
312 });
313
314 EntityCacheUtil.removeResult(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
315 ResourcePermissionImpl.class, resourcePermission.getPrimaryKey());
316
317 return resourcePermission;
318 }
319
320 public ResourcePermission updateImpl(
321 com.liferay.portal.model.ResourcePermission resourcePermission,
322 boolean merge) throws SystemException {
323 resourcePermission = toUnwrappedModel(resourcePermission);
324
325 boolean isNew = resourcePermission.isNew();
326
327 ResourcePermissionModelImpl resourcePermissionModelImpl = (ResourcePermissionModelImpl)resourcePermission;
328
329 Session session = null;
330
331 try {
332 session = openSession();
333
334 BatchSessionUtil.update(session, resourcePermission, merge);
335
336 resourcePermission.setNew(false);
337 }
338 catch (Exception e) {
339 throw processException(e);
340 }
341 finally {
342 closeSession(session);
343 }
344
345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
346
347 EntityCacheUtil.putResult(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
348 ResourcePermissionImpl.class, resourcePermission.getPrimaryKey(),
349 resourcePermission);
350
351 if (!isNew &&
352 ((resourcePermission.getCompanyId() != resourcePermissionModelImpl.getOriginalCompanyId()) ||
353 !Validator.equals(resourcePermission.getName(),
354 resourcePermissionModelImpl.getOriginalName()) ||
355 (resourcePermission.getScope() != resourcePermissionModelImpl.getOriginalScope()) ||
356 !Validator.equals(resourcePermission.getPrimKey(),
357 resourcePermissionModelImpl.getOriginalPrimKey()) ||
358 (resourcePermission.getRoleId() != resourcePermissionModelImpl.getOriginalRoleId()))) {
359 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
360 new Object[] {
361 new Long(resourcePermissionModelImpl.getOriginalCompanyId()),
362
363 resourcePermissionModelImpl.getOriginalName(),
364 new Integer(resourcePermissionModelImpl.getOriginalScope()),
365
366 resourcePermissionModelImpl.getOriginalPrimKey(),
367 new Long(resourcePermissionModelImpl.getOriginalRoleId())
368 });
369 }
370
371 if (isNew ||
372 ((resourcePermission.getCompanyId() != resourcePermissionModelImpl.getOriginalCompanyId()) ||
373 !Validator.equals(resourcePermission.getName(),
374 resourcePermissionModelImpl.getOriginalName()) ||
375 (resourcePermission.getScope() != resourcePermissionModelImpl.getOriginalScope()) ||
376 !Validator.equals(resourcePermission.getPrimKey(),
377 resourcePermissionModelImpl.getOriginalPrimKey()) ||
378 (resourcePermission.getRoleId() != resourcePermissionModelImpl.getOriginalRoleId()))) {
379 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
380 new Object[] {
381 new Long(resourcePermission.getCompanyId()),
382
383 resourcePermission.getName(),
384 new Integer(resourcePermission.getScope()),
385
386 resourcePermission.getPrimKey(),
387 new Long(resourcePermission.getRoleId())
388 }, resourcePermission);
389 }
390
391 return resourcePermission;
392 }
393
394 protected ResourcePermission toUnwrappedModel(
395 ResourcePermission resourcePermission) {
396 if (resourcePermission instanceof ResourcePermissionImpl) {
397 return resourcePermission;
398 }
399
400 ResourcePermissionImpl resourcePermissionImpl = new ResourcePermissionImpl();
401
402 resourcePermissionImpl.setNew(resourcePermission.isNew());
403 resourcePermissionImpl.setPrimaryKey(resourcePermission.getPrimaryKey());
404
405 resourcePermissionImpl.setResourcePermissionId(resourcePermission.getResourcePermissionId());
406 resourcePermissionImpl.setCompanyId(resourcePermission.getCompanyId());
407 resourcePermissionImpl.setName(resourcePermission.getName());
408 resourcePermissionImpl.setScope(resourcePermission.getScope());
409 resourcePermissionImpl.setPrimKey(resourcePermission.getPrimKey());
410 resourcePermissionImpl.setRoleId(resourcePermission.getRoleId());
411 resourcePermissionImpl.setActionIds(resourcePermission.getActionIds());
412
413 return resourcePermissionImpl;
414 }
415
416 public ResourcePermission findByPrimaryKey(Serializable primaryKey)
417 throws NoSuchModelException, SystemException {
418 return findByPrimaryKey(((Long)primaryKey).longValue());
419 }
420
421 public ResourcePermission findByPrimaryKey(long resourcePermissionId)
422 throws NoSuchResourcePermissionException, SystemException {
423 ResourcePermission resourcePermission = fetchByPrimaryKey(resourcePermissionId);
424
425 if (resourcePermission == null) {
426 if (_log.isWarnEnabled()) {
427 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
428 resourcePermissionId);
429 }
430
431 throw new NoSuchResourcePermissionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
432 resourcePermissionId);
433 }
434
435 return resourcePermission;
436 }
437
438 public ResourcePermission fetchByPrimaryKey(Serializable primaryKey)
439 throws SystemException {
440 return fetchByPrimaryKey(((Long)primaryKey).longValue());
441 }
442
443 public ResourcePermission fetchByPrimaryKey(long resourcePermissionId)
444 throws SystemException {
445 ResourcePermission resourcePermission = (ResourcePermission)EntityCacheUtil.getResult(ResourcePermissionModelImpl.ENTITY_CACHE_ENABLED,
446 ResourcePermissionImpl.class, resourcePermissionId, this);
447
448 if (resourcePermission == null) {
449 Session session = null;
450
451 try {
452 session = openSession();
453
454 resourcePermission = (ResourcePermission)session.get(ResourcePermissionImpl.class,
455 new Long(resourcePermissionId));
456 }
457 catch (Exception e) {
458 throw processException(e);
459 }
460 finally {
461 if (resourcePermission != null) {
462 cacheResult(resourcePermission);
463 }
464
465 closeSession(session);
466 }
467 }
468
469 return resourcePermission;
470 }
471
472 public List<ResourcePermission> findByRoleId(long roleId)
473 throws SystemException {
474 Object[] finderArgs = new Object[] { new Long(roleId) };
475
476 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ROLEID,
477 finderArgs, this);
478
479 if (list == null) {
480 Session session = null;
481
482 try {
483 session = openSession();
484
485 StringBundler query = new StringBundler(2);
486
487 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
488
489 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
490
491 String sql = query.toString();
492
493 Query q = session.createQuery(sql);
494
495 QueryPos qPos = QueryPos.getInstance(q);
496
497 qPos.add(roleId);
498
499 list = q.list();
500 }
501 catch (Exception e) {
502 throw processException(e);
503 }
504 finally {
505 if (list == null) {
506 list = new ArrayList<ResourcePermission>();
507 }
508
509 cacheResult(list);
510
511 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ROLEID,
512 finderArgs, list);
513
514 closeSession(session);
515 }
516 }
517
518 return list;
519 }
520
521 public List<ResourcePermission> findByRoleId(long roleId, int start, int end)
522 throws SystemException {
523 return findByRoleId(roleId, start, end, null);
524 }
525
526 public List<ResourcePermission> findByRoleId(long roleId, int start,
527 int end, OrderByComparator orderByComparator) throws SystemException {
528 Object[] finderArgs = new Object[] {
529 new Long(roleId),
530
531 String.valueOf(start), String.valueOf(end),
532 String.valueOf(orderByComparator)
533 };
534
535 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_ROLEID,
536 finderArgs, this);
537
538 if (list == null) {
539 Session session = null;
540
541 try {
542 session = openSession();
543
544 StringBundler query = null;
545
546 if (orderByComparator != null) {
547 query = new StringBundler(3 +
548 (orderByComparator.getOrderByFields().length * 3));
549 }
550 else {
551 query = new StringBundler(2);
552 }
553
554 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
555
556 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
557
558 if (orderByComparator != null) {
559 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
560 orderByComparator);
561 }
562
563 String sql = query.toString();
564
565 Query q = session.createQuery(sql);
566
567 QueryPos qPos = QueryPos.getInstance(q);
568
569 qPos.add(roleId);
570
571 list = (List<ResourcePermission>)QueryUtil.list(q,
572 getDialect(), start, end);
573 }
574 catch (Exception e) {
575 throw processException(e);
576 }
577 finally {
578 if (list == null) {
579 list = new ArrayList<ResourcePermission>();
580 }
581
582 cacheResult(list);
583
584 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_ROLEID,
585 finderArgs, list);
586
587 closeSession(session);
588 }
589 }
590
591 return list;
592 }
593
594 public ResourcePermission findByRoleId_First(long roleId,
595 OrderByComparator orderByComparator)
596 throws NoSuchResourcePermissionException, SystemException {
597 List<ResourcePermission> list = findByRoleId(roleId, 0, 1,
598 orderByComparator);
599
600 if (list.isEmpty()) {
601 StringBundler msg = new StringBundler(4);
602
603 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
604
605 msg.append("roleId=");
606 msg.append(roleId);
607
608 msg.append(StringPool.CLOSE_CURLY_BRACE);
609
610 throw new NoSuchResourcePermissionException(msg.toString());
611 }
612 else {
613 return list.get(0);
614 }
615 }
616
617 public ResourcePermission findByRoleId_Last(long roleId,
618 OrderByComparator orderByComparator)
619 throws NoSuchResourcePermissionException, SystemException {
620 int count = countByRoleId(roleId);
621
622 List<ResourcePermission> list = findByRoleId(roleId, count - 1, count,
623 orderByComparator);
624
625 if (list.isEmpty()) {
626 StringBundler msg = new StringBundler(4);
627
628 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
629
630 msg.append("roleId=");
631 msg.append(roleId);
632
633 msg.append(StringPool.CLOSE_CURLY_BRACE);
634
635 throw new NoSuchResourcePermissionException(msg.toString());
636 }
637 else {
638 return list.get(0);
639 }
640 }
641
642 public ResourcePermission[] findByRoleId_PrevAndNext(
643 long resourcePermissionId, long roleId,
644 OrderByComparator orderByComparator)
645 throws NoSuchResourcePermissionException, SystemException {
646 ResourcePermission resourcePermission = findByPrimaryKey(resourcePermissionId);
647
648 int count = countByRoleId(roleId);
649
650 Session session = null;
651
652 try {
653 session = openSession();
654
655 StringBundler query = null;
656
657 if (orderByComparator != null) {
658 query = new StringBundler(3 +
659 (orderByComparator.getOrderByFields().length * 3));
660 }
661 else {
662 query = new StringBundler(2);
663 }
664
665 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
666
667 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
668
669 if (orderByComparator != null) {
670 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
671 orderByComparator);
672 }
673
674 String sql = query.toString();
675
676 Query q = session.createQuery(sql);
677
678 QueryPos qPos = QueryPos.getInstance(q);
679
680 qPos.add(roleId);
681
682 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
683 orderByComparator, resourcePermission);
684
685 ResourcePermission[] array = new ResourcePermissionImpl[3];
686
687 array[0] = (ResourcePermission)objArray[0];
688 array[1] = (ResourcePermission)objArray[1];
689 array[2] = (ResourcePermission)objArray[2];
690
691 return array;
692 }
693 catch (Exception e) {
694 throw processException(e);
695 }
696 finally {
697 closeSession(session);
698 }
699 }
700
701 public List<ResourcePermission> findByR_S(long roleId, int scope)
702 throws SystemException {
703 Object[] finderArgs = new Object[] { new Long(roleId), new Integer(scope) };
704
705 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_R_S,
706 finderArgs, this);
707
708 if (list == null) {
709 Session session = null;
710
711 try {
712 session = openSession();
713
714 StringBundler query = new StringBundler(3);
715
716 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
717
718 query.append(_FINDER_COLUMN_R_S_ROLEID_2);
719
720 query.append(_FINDER_COLUMN_R_S_SCOPE_2);
721
722 String sql = query.toString();
723
724 Query q = session.createQuery(sql);
725
726 QueryPos qPos = QueryPos.getInstance(q);
727
728 qPos.add(roleId);
729
730 qPos.add(scope);
731
732 list = q.list();
733 }
734 catch (Exception e) {
735 throw processException(e);
736 }
737 finally {
738 if (list == null) {
739 list = new ArrayList<ResourcePermission>();
740 }
741
742 cacheResult(list);
743
744 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_R_S, finderArgs,
745 list);
746
747 closeSession(session);
748 }
749 }
750
751 return list;
752 }
753
754 public List<ResourcePermission> findByR_S(long roleId, int scope,
755 int start, int end) throws SystemException {
756 return findByR_S(roleId, scope, start, end, null);
757 }
758
759 public List<ResourcePermission> findByR_S(long roleId, int scope,
760 int start, int end, OrderByComparator orderByComparator)
761 throws SystemException {
762 Object[] finderArgs = new Object[] {
763 new Long(roleId), new Integer(scope),
764
765 String.valueOf(start), String.valueOf(end),
766 String.valueOf(orderByComparator)
767 };
768
769 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_R_S,
770 finderArgs, this);
771
772 if (list == null) {
773 Session session = null;
774
775 try {
776 session = openSession();
777
778 StringBundler query = null;
779
780 if (orderByComparator != null) {
781 query = new StringBundler(4 +
782 (orderByComparator.getOrderByFields().length * 3));
783 }
784 else {
785 query = new StringBundler(3);
786 }
787
788 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
789
790 query.append(_FINDER_COLUMN_R_S_ROLEID_2);
791
792 query.append(_FINDER_COLUMN_R_S_SCOPE_2);
793
794 if (orderByComparator != null) {
795 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
796 orderByComparator);
797 }
798
799 String sql = query.toString();
800
801 Query q = session.createQuery(sql);
802
803 QueryPos qPos = QueryPos.getInstance(q);
804
805 qPos.add(roleId);
806
807 qPos.add(scope);
808
809 list = (List<ResourcePermission>)QueryUtil.list(q,
810 getDialect(), start, end);
811 }
812 catch (Exception e) {
813 throw processException(e);
814 }
815 finally {
816 if (list == null) {
817 list = new ArrayList<ResourcePermission>();
818 }
819
820 cacheResult(list);
821
822 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_R_S,
823 finderArgs, list);
824
825 closeSession(session);
826 }
827 }
828
829 return list;
830 }
831
832 public ResourcePermission findByR_S_First(long roleId, int scope,
833 OrderByComparator orderByComparator)
834 throws NoSuchResourcePermissionException, SystemException {
835 List<ResourcePermission> list = findByR_S(roleId, scope, 0, 1,
836 orderByComparator);
837
838 if (list.isEmpty()) {
839 StringBundler msg = new StringBundler(6);
840
841 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
842
843 msg.append("roleId=");
844 msg.append(roleId);
845
846 msg.append(", scope=");
847 msg.append(scope);
848
849 msg.append(StringPool.CLOSE_CURLY_BRACE);
850
851 throw new NoSuchResourcePermissionException(msg.toString());
852 }
853 else {
854 return list.get(0);
855 }
856 }
857
858 public ResourcePermission findByR_S_Last(long roleId, int scope,
859 OrderByComparator orderByComparator)
860 throws NoSuchResourcePermissionException, SystemException {
861 int count = countByR_S(roleId, scope);
862
863 List<ResourcePermission> list = findByR_S(roleId, scope, count - 1,
864 count, orderByComparator);
865
866 if (list.isEmpty()) {
867 StringBundler msg = new StringBundler(6);
868
869 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
870
871 msg.append("roleId=");
872 msg.append(roleId);
873
874 msg.append(", scope=");
875 msg.append(scope);
876
877 msg.append(StringPool.CLOSE_CURLY_BRACE);
878
879 throw new NoSuchResourcePermissionException(msg.toString());
880 }
881 else {
882 return list.get(0);
883 }
884 }
885
886 public ResourcePermission[] findByR_S_PrevAndNext(
887 long resourcePermissionId, long roleId, int scope,
888 OrderByComparator orderByComparator)
889 throws NoSuchResourcePermissionException, SystemException {
890 ResourcePermission resourcePermission = findByPrimaryKey(resourcePermissionId);
891
892 int count = countByR_S(roleId, scope);
893
894 Session session = null;
895
896 try {
897 session = openSession();
898
899 StringBundler query = null;
900
901 if (orderByComparator != null) {
902 query = new StringBundler(4 +
903 (orderByComparator.getOrderByFields().length * 3));
904 }
905 else {
906 query = new StringBundler(3);
907 }
908
909 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
910
911 query.append(_FINDER_COLUMN_R_S_ROLEID_2);
912
913 query.append(_FINDER_COLUMN_R_S_SCOPE_2);
914
915 if (orderByComparator != null) {
916 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
917 orderByComparator);
918 }
919
920 String sql = query.toString();
921
922 Query q = session.createQuery(sql);
923
924 QueryPos qPos = QueryPos.getInstance(q);
925
926 qPos.add(roleId);
927
928 qPos.add(scope);
929
930 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
931 orderByComparator, resourcePermission);
932
933 ResourcePermission[] array = new ResourcePermissionImpl[3];
934
935 array[0] = (ResourcePermission)objArray[0];
936 array[1] = (ResourcePermission)objArray[1];
937 array[2] = (ResourcePermission)objArray[2];
938
939 return array;
940 }
941 catch (Exception e) {
942 throw processException(e);
943 }
944 finally {
945 closeSession(session);
946 }
947 }
948
949 public List<ResourcePermission> findByC_N_S(long companyId, String name,
950 int scope) throws SystemException {
951 Object[] finderArgs = new Object[] {
952 new Long(companyId),
953
954 name, new Integer(scope)
955 };
956
957 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_N_S,
958 finderArgs, this);
959
960 if (list == null) {
961 Session session = null;
962
963 try {
964 session = openSession();
965
966 StringBundler query = new StringBundler(4);
967
968 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
969
970 query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
971
972 if (name == null) {
973 query.append(_FINDER_COLUMN_C_N_S_NAME_1);
974 }
975 else {
976 if (name.equals(StringPool.BLANK)) {
977 query.append(_FINDER_COLUMN_C_N_S_NAME_3);
978 }
979 else {
980 query.append(_FINDER_COLUMN_C_N_S_NAME_2);
981 }
982 }
983
984 query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
985
986 String sql = query.toString();
987
988 Query q = session.createQuery(sql);
989
990 QueryPos qPos = QueryPos.getInstance(q);
991
992 qPos.add(companyId);
993
994 if (name != null) {
995 qPos.add(name);
996 }
997
998 qPos.add(scope);
999
1000 list = q.list();
1001 }
1002 catch (Exception e) {
1003 throw processException(e);
1004 }
1005 finally {
1006 if (list == null) {
1007 list = new ArrayList<ResourcePermission>();
1008 }
1009
1010 cacheResult(list);
1011
1012 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_N_S,
1013 finderArgs, list);
1014
1015 closeSession(session);
1016 }
1017 }
1018
1019 return list;
1020 }
1021
1022 public List<ResourcePermission> findByC_N_S(long companyId, String name,
1023 int scope, int start, int end) throws SystemException {
1024 return findByC_N_S(companyId, name, scope, start, end, null);
1025 }
1026
1027 public List<ResourcePermission> findByC_N_S(long companyId, String name,
1028 int scope, int start, int end, OrderByComparator orderByComparator)
1029 throws SystemException {
1030 Object[] finderArgs = new Object[] {
1031 new Long(companyId),
1032
1033 name, new Integer(scope),
1034
1035 String.valueOf(start), String.valueOf(end),
1036 String.valueOf(orderByComparator)
1037 };
1038
1039 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_N_S,
1040 finderArgs, this);
1041
1042 if (list == null) {
1043 Session session = null;
1044
1045 try {
1046 session = openSession();
1047
1048 StringBundler query = null;
1049
1050 if (orderByComparator != null) {
1051 query = new StringBundler(5 +
1052 (orderByComparator.getOrderByFields().length * 3));
1053 }
1054 else {
1055 query = new StringBundler(4);
1056 }
1057
1058 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
1059
1060 query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
1061
1062 if (name == null) {
1063 query.append(_FINDER_COLUMN_C_N_S_NAME_1);
1064 }
1065 else {
1066 if (name.equals(StringPool.BLANK)) {
1067 query.append(_FINDER_COLUMN_C_N_S_NAME_3);
1068 }
1069 else {
1070 query.append(_FINDER_COLUMN_C_N_S_NAME_2);
1071 }
1072 }
1073
1074 query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
1075
1076 if (orderByComparator != null) {
1077 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1078 orderByComparator);
1079 }
1080
1081 String sql = query.toString();
1082
1083 Query q = session.createQuery(sql);
1084
1085 QueryPos qPos = QueryPos.getInstance(q);
1086
1087 qPos.add(companyId);
1088
1089 if (name != null) {
1090 qPos.add(name);
1091 }
1092
1093 qPos.add(scope);
1094
1095 list = (List<ResourcePermission>)QueryUtil.list(q,
1096 getDialect(), start, end);
1097 }
1098 catch (Exception e) {
1099 throw processException(e);
1100 }
1101 finally {
1102 if (list == null) {
1103 list = new ArrayList<ResourcePermission>();
1104 }
1105
1106 cacheResult(list);
1107
1108 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_N_S,
1109 finderArgs, list);
1110
1111 closeSession(session);
1112 }
1113 }
1114
1115 return list;
1116 }
1117
1118 public ResourcePermission findByC_N_S_First(long companyId, String name,
1119 int scope, OrderByComparator orderByComparator)
1120 throws NoSuchResourcePermissionException, SystemException {
1121 List<ResourcePermission> list = findByC_N_S(companyId, name, scope, 0,
1122 1, orderByComparator);
1123
1124 if (list.isEmpty()) {
1125 StringBundler msg = new StringBundler(8);
1126
1127 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1128
1129 msg.append("companyId=");
1130 msg.append(companyId);
1131
1132 msg.append(", name=");
1133 msg.append(name);
1134
1135 msg.append(", scope=");
1136 msg.append(scope);
1137
1138 msg.append(StringPool.CLOSE_CURLY_BRACE);
1139
1140 throw new NoSuchResourcePermissionException(msg.toString());
1141 }
1142 else {
1143 return list.get(0);
1144 }
1145 }
1146
1147 public ResourcePermission findByC_N_S_Last(long companyId, String name,
1148 int scope, OrderByComparator orderByComparator)
1149 throws NoSuchResourcePermissionException, SystemException {
1150 int count = countByC_N_S(companyId, name, scope);
1151
1152 List<ResourcePermission> list = findByC_N_S(companyId, name, scope,
1153 count - 1, count, orderByComparator);
1154
1155 if (list.isEmpty()) {
1156 StringBundler msg = new StringBundler(8);
1157
1158 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1159
1160 msg.append("companyId=");
1161 msg.append(companyId);
1162
1163 msg.append(", name=");
1164 msg.append(name);
1165
1166 msg.append(", scope=");
1167 msg.append(scope);
1168
1169 msg.append(StringPool.CLOSE_CURLY_BRACE);
1170
1171 throw new NoSuchResourcePermissionException(msg.toString());
1172 }
1173 else {
1174 return list.get(0);
1175 }
1176 }
1177
1178 public ResourcePermission[] findByC_N_S_PrevAndNext(
1179 long resourcePermissionId, long companyId, String name, int scope,
1180 OrderByComparator orderByComparator)
1181 throws NoSuchResourcePermissionException, SystemException {
1182 ResourcePermission resourcePermission = findByPrimaryKey(resourcePermissionId);
1183
1184 int count = countByC_N_S(companyId, name, scope);
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 StringBundler query = null;
1192
1193 if (orderByComparator != null) {
1194 query = new StringBundler(5 +
1195 (orderByComparator.getOrderByFields().length * 3));
1196 }
1197 else {
1198 query = new StringBundler(4);
1199 }
1200
1201 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
1202
1203 query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
1204
1205 if (name == null) {
1206 query.append(_FINDER_COLUMN_C_N_S_NAME_1);
1207 }
1208 else {
1209 if (name.equals(StringPool.BLANK)) {
1210 query.append(_FINDER_COLUMN_C_N_S_NAME_3);
1211 }
1212 else {
1213 query.append(_FINDER_COLUMN_C_N_S_NAME_2);
1214 }
1215 }
1216
1217 query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
1218
1219 if (orderByComparator != null) {
1220 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1221 orderByComparator);
1222 }
1223
1224 String sql = query.toString();
1225
1226 Query q = session.createQuery(sql);
1227
1228 QueryPos qPos = QueryPos.getInstance(q);
1229
1230 qPos.add(companyId);
1231
1232 if (name != null) {
1233 qPos.add(name);
1234 }
1235
1236 qPos.add(scope);
1237
1238 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1239 orderByComparator, resourcePermission);
1240
1241 ResourcePermission[] array = new ResourcePermissionImpl[3];
1242
1243 array[0] = (ResourcePermission)objArray[0];
1244 array[1] = (ResourcePermission)objArray[1];
1245 array[2] = (ResourcePermission)objArray[2];
1246
1247 return array;
1248 }
1249 catch (Exception e) {
1250 throw processException(e);
1251 }
1252 finally {
1253 closeSession(session);
1254 }
1255 }
1256
1257 public List<ResourcePermission> findByC_N_S_P(long companyId, String name,
1258 int scope, String primKey) throws SystemException {
1259 Object[] finderArgs = new Object[] {
1260 new Long(companyId),
1261
1262 name, new Integer(scope),
1263
1264 primKey
1265 };
1266
1267 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_N_S_P,
1268 finderArgs, this);
1269
1270 if (list == null) {
1271 Session session = null;
1272
1273 try {
1274 session = openSession();
1275
1276 StringBundler query = new StringBundler(5);
1277
1278 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
1279
1280 query.append(_FINDER_COLUMN_C_N_S_P_COMPANYID_2);
1281
1282 if (name == null) {
1283 query.append(_FINDER_COLUMN_C_N_S_P_NAME_1);
1284 }
1285 else {
1286 if (name.equals(StringPool.BLANK)) {
1287 query.append(_FINDER_COLUMN_C_N_S_P_NAME_3);
1288 }
1289 else {
1290 query.append(_FINDER_COLUMN_C_N_S_P_NAME_2);
1291 }
1292 }
1293
1294 query.append(_FINDER_COLUMN_C_N_S_P_SCOPE_2);
1295
1296 if (primKey == null) {
1297 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_1);
1298 }
1299 else {
1300 if (primKey.equals(StringPool.BLANK)) {
1301 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_3);
1302 }
1303 else {
1304 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_2);
1305 }
1306 }
1307
1308 String sql = query.toString();
1309
1310 Query q = session.createQuery(sql);
1311
1312 QueryPos qPos = QueryPos.getInstance(q);
1313
1314 qPos.add(companyId);
1315
1316 if (name != null) {
1317 qPos.add(name);
1318 }
1319
1320 qPos.add(scope);
1321
1322 if (primKey != null) {
1323 qPos.add(primKey);
1324 }
1325
1326 list = q.list();
1327 }
1328 catch (Exception e) {
1329 throw processException(e);
1330 }
1331 finally {
1332 if (list == null) {
1333 list = new ArrayList<ResourcePermission>();
1334 }
1335
1336 cacheResult(list);
1337
1338 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_N_S_P,
1339 finderArgs, list);
1340
1341 closeSession(session);
1342 }
1343 }
1344
1345 return list;
1346 }
1347
1348 public List<ResourcePermission> findByC_N_S_P(long companyId, String name,
1349 int scope, String primKey, int start, int end)
1350 throws SystemException {
1351 return findByC_N_S_P(companyId, name, scope, primKey, start, end, null);
1352 }
1353
1354 public List<ResourcePermission> findByC_N_S_P(long companyId, String name,
1355 int scope, String primKey, int start, int end,
1356 OrderByComparator orderByComparator) throws SystemException {
1357 Object[] finderArgs = new Object[] {
1358 new Long(companyId),
1359
1360 name, new Integer(scope),
1361
1362 primKey,
1363
1364 String.valueOf(start), String.valueOf(end),
1365 String.valueOf(orderByComparator)
1366 };
1367
1368 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_N_S_P,
1369 finderArgs, this);
1370
1371 if (list == null) {
1372 Session session = null;
1373
1374 try {
1375 session = openSession();
1376
1377 StringBundler query = null;
1378
1379 if (orderByComparator != null) {
1380 query = new StringBundler(6 +
1381 (orderByComparator.getOrderByFields().length * 3));
1382 }
1383 else {
1384 query = new StringBundler(5);
1385 }
1386
1387 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
1388
1389 query.append(_FINDER_COLUMN_C_N_S_P_COMPANYID_2);
1390
1391 if (name == null) {
1392 query.append(_FINDER_COLUMN_C_N_S_P_NAME_1);
1393 }
1394 else {
1395 if (name.equals(StringPool.BLANK)) {
1396 query.append(_FINDER_COLUMN_C_N_S_P_NAME_3);
1397 }
1398 else {
1399 query.append(_FINDER_COLUMN_C_N_S_P_NAME_2);
1400 }
1401 }
1402
1403 query.append(_FINDER_COLUMN_C_N_S_P_SCOPE_2);
1404
1405 if (primKey == null) {
1406 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_1);
1407 }
1408 else {
1409 if (primKey.equals(StringPool.BLANK)) {
1410 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_3);
1411 }
1412 else {
1413 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_2);
1414 }
1415 }
1416
1417 if (orderByComparator != null) {
1418 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1419 orderByComparator);
1420 }
1421
1422 String sql = query.toString();
1423
1424 Query q = session.createQuery(sql);
1425
1426 QueryPos qPos = QueryPos.getInstance(q);
1427
1428 qPos.add(companyId);
1429
1430 if (name != null) {
1431 qPos.add(name);
1432 }
1433
1434 qPos.add(scope);
1435
1436 if (primKey != null) {
1437 qPos.add(primKey);
1438 }
1439
1440 list = (List<ResourcePermission>)QueryUtil.list(q,
1441 getDialect(), start, end);
1442 }
1443 catch (Exception e) {
1444 throw processException(e);
1445 }
1446 finally {
1447 if (list == null) {
1448 list = new ArrayList<ResourcePermission>();
1449 }
1450
1451 cacheResult(list);
1452
1453 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_N_S_P,
1454 finderArgs, list);
1455
1456 closeSession(session);
1457 }
1458 }
1459
1460 return list;
1461 }
1462
1463 public ResourcePermission findByC_N_S_P_First(long companyId, String name,
1464 int scope, String primKey, OrderByComparator orderByComparator)
1465 throws NoSuchResourcePermissionException, SystemException {
1466 List<ResourcePermission> list = findByC_N_S_P(companyId, name, scope,
1467 primKey, 0, 1, orderByComparator);
1468
1469 if (list.isEmpty()) {
1470 StringBundler msg = new StringBundler(10);
1471
1472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1473
1474 msg.append("companyId=");
1475 msg.append(companyId);
1476
1477 msg.append(", name=");
1478 msg.append(name);
1479
1480 msg.append(", scope=");
1481 msg.append(scope);
1482
1483 msg.append(", primKey=");
1484 msg.append(primKey);
1485
1486 msg.append(StringPool.CLOSE_CURLY_BRACE);
1487
1488 throw new NoSuchResourcePermissionException(msg.toString());
1489 }
1490 else {
1491 return list.get(0);
1492 }
1493 }
1494
1495 public ResourcePermission findByC_N_S_P_Last(long companyId, String name,
1496 int scope, String primKey, OrderByComparator orderByComparator)
1497 throws NoSuchResourcePermissionException, SystemException {
1498 int count = countByC_N_S_P(companyId, name, scope, primKey);
1499
1500 List<ResourcePermission> list = findByC_N_S_P(companyId, name, scope,
1501 primKey, count - 1, count, orderByComparator);
1502
1503 if (list.isEmpty()) {
1504 StringBundler msg = new StringBundler(10);
1505
1506 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1507
1508 msg.append("companyId=");
1509 msg.append(companyId);
1510
1511 msg.append(", name=");
1512 msg.append(name);
1513
1514 msg.append(", scope=");
1515 msg.append(scope);
1516
1517 msg.append(", primKey=");
1518 msg.append(primKey);
1519
1520 msg.append(StringPool.CLOSE_CURLY_BRACE);
1521
1522 throw new NoSuchResourcePermissionException(msg.toString());
1523 }
1524 else {
1525 return list.get(0);
1526 }
1527 }
1528
1529 public ResourcePermission[] findByC_N_S_P_PrevAndNext(
1530 long resourcePermissionId, long companyId, String name, int scope,
1531 String primKey, OrderByComparator orderByComparator)
1532 throws NoSuchResourcePermissionException, SystemException {
1533 ResourcePermission resourcePermission = findByPrimaryKey(resourcePermissionId);
1534
1535 int count = countByC_N_S_P(companyId, name, scope, primKey);
1536
1537 Session session = null;
1538
1539 try {
1540 session = openSession();
1541
1542 StringBundler query = null;
1543
1544 if (orderByComparator != null) {
1545 query = new StringBundler(6 +
1546 (orderByComparator.getOrderByFields().length * 3));
1547 }
1548 else {
1549 query = new StringBundler(5);
1550 }
1551
1552 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
1553
1554 query.append(_FINDER_COLUMN_C_N_S_P_COMPANYID_2);
1555
1556 if (name == null) {
1557 query.append(_FINDER_COLUMN_C_N_S_P_NAME_1);
1558 }
1559 else {
1560 if (name.equals(StringPool.BLANK)) {
1561 query.append(_FINDER_COLUMN_C_N_S_P_NAME_3);
1562 }
1563 else {
1564 query.append(_FINDER_COLUMN_C_N_S_P_NAME_2);
1565 }
1566 }
1567
1568 query.append(_FINDER_COLUMN_C_N_S_P_SCOPE_2);
1569
1570 if (primKey == null) {
1571 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_1);
1572 }
1573 else {
1574 if (primKey.equals(StringPool.BLANK)) {
1575 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_3);
1576 }
1577 else {
1578 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_2);
1579 }
1580 }
1581
1582 if (orderByComparator != null) {
1583 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1584 orderByComparator);
1585 }
1586
1587 String sql = query.toString();
1588
1589 Query q = session.createQuery(sql);
1590
1591 QueryPos qPos = QueryPos.getInstance(q);
1592
1593 qPos.add(companyId);
1594
1595 if (name != null) {
1596 qPos.add(name);
1597 }
1598
1599 qPos.add(scope);
1600
1601 if (primKey != null) {
1602 qPos.add(primKey);
1603 }
1604
1605 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1606 orderByComparator, resourcePermission);
1607
1608 ResourcePermission[] array = new ResourcePermissionImpl[3];
1609
1610 array[0] = (ResourcePermission)objArray[0];
1611 array[1] = (ResourcePermission)objArray[1];
1612 array[2] = (ResourcePermission)objArray[2];
1613
1614 return array;
1615 }
1616 catch (Exception e) {
1617 throw processException(e);
1618 }
1619 finally {
1620 closeSession(session);
1621 }
1622 }
1623
1624 public ResourcePermission findByC_N_S_P_R(long companyId, String name,
1625 int scope, String primKey, long roleId)
1626 throws NoSuchResourcePermissionException, SystemException {
1627 ResourcePermission resourcePermission = fetchByC_N_S_P_R(companyId,
1628 name, scope, primKey, roleId);
1629
1630 if (resourcePermission == null) {
1631 StringBundler msg = new StringBundler(12);
1632
1633 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1634
1635 msg.append("companyId=");
1636 msg.append(companyId);
1637
1638 msg.append(", name=");
1639 msg.append(name);
1640
1641 msg.append(", scope=");
1642 msg.append(scope);
1643
1644 msg.append(", primKey=");
1645 msg.append(primKey);
1646
1647 msg.append(", roleId=");
1648 msg.append(roleId);
1649
1650 msg.append(StringPool.CLOSE_CURLY_BRACE);
1651
1652 if (_log.isWarnEnabled()) {
1653 _log.warn(msg.toString());
1654 }
1655
1656 throw new NoSuchResourcePermissionException(msg.toString());
1657 }
1658
1659 return resourcePermission;
1660 }
1661
1662 public ResourcePermission fetchByC_N_S_P_R(long companyId, String name,
1663 int scope, String primKey, long roleId) throws SystemException {
1664 return fetchByC_N_S_P_R(companyId, name, scope, primKey, roleId, true);
1665 }
1666
1667 public ResourcePermission fetchByC_N_S_P_R(long companyId, String name,
1668 int scope, String primKey, long roleId, boolean retrieveFromCache)
1669 throws SystemException {
1670 Object[] finderArgs = new Object[] {
1671 new Long(companyId),
1672
1673 name, new Integer(scope),
1674
1675 primKey, new Long(roleId)
1676 };
1677
1678 Object result = null;
1679
1680 if (retrieveFromCache) {
1681 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
1682 finderArgs, this);
1683 }
1684
1685 if (result == null) {
1686 Session session = null;
1687
1688 try {
1689 session = openSession();
1690
1691 StringBundler query = new StringBundler(6);
1692
1693 query.append(_SQL_SELECT_RESOURCEPERMISSION_WHERE);
1694
1695 query.append(_FINDER_COLUMN_C_N_S_P_R_COMPANYID_2);
1696
1697 if (name == null) {
1698 query.append(_FINDER_COLUMN_C_N_S_P_R_NAME_1);
1699 }
1700 else {
1701 if (name.equals(StringPool.BLANK)) {
1702 query.append(_FINDER_COLUMN_C_N_S_P_R_NAME_3);
1703 }
1704 else {
1705 query.append(_FINDER_COLUMN_C_N_S_P_R_NAME_2);
1706 }
1707 }
1708
1709 query.append(_FINDER_COLUMN_C_N_S_P_R_SCOPE_2);
1710
1711 if (primKey == null) {
1712 query.append(_FINDER_COLUMN_C_N_S_P_R_PRIMKEY_1);
1713 }
1714 else {
1715 if (primKey.equals(StringPool.BLANK)) {
1716 query.append(_FINDER_COLUMN_C_N_S_P_R_PRIMKEY_3);
1717 }
1718 else {
1719 query.append(_FINDER_COLUMN_C_N_S_P_R_PRIMKEY_2);
1720 }
1721 }
1722
1723 query.append(_FINDER_COLUMN_C_N_S_P_R_ROLEID_2);
1724
1725 String sql = query.toString();
1726
1727 Query q = session.createQuery(sql);
1728
1729 QueryPos qPos = QueryPos.getInstance(q);
1730
1731 qPos.add(companyId);
1732
1733 if (name != null) {
1734 qPos.add(name);
1735 }
1736
1737 qPos.add(scope);
1738
1739 if (primKey != null) {
1740 qPos.add(primKey);
1741 }
1742
1743 qPos.add(roleId);
1744
1745 List<ResourcePermission> list = q.list();
1746
1747 result = list;
1748
1749 ResourcePermission resourcePermission = null;
1750
1751 if (list.isEmpty()) {
1752 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
1753 finderArgs, list);
1754 }
1755 else {
1756 resourcePermission = list.get(0);
1757
1758 cacheResult(resourcePermission);
1759
1760 if ((resourcePermission.getCompanyId() != companyId) ||
1761 (resourcePermission.getName() == null) ||
1762 !resourcePermission.getName().equals(name) ||
1763 (resourcePermission.getScope() != scope) ||
1764 (resourcePermission.getPrimKey() == null) ||
1765 !resourcePermission.getPrimKey().equals(primKey) ||
1766 (resourcePermission.getRoleId() != roleId)) {
1767 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
1768 finderArgs, resourcePermission);
1769 }
1770 }
1771
1772 return resourcePermission;
1773 }
1774 catch (Exception e) {
1775 throw processException(e);
1776 }
1777 finally {
1778 if (result == null) {
1779 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N_S_P_R,
1780 finderArgs, new ArrayList<ResourcePermission>());
1781 }
1782
1783 closeSession(session);
1784 }
1785 }
1786 else {
1787 if (result instanceof List<?>) {
1788 return null;
1789 }
1790 else {
1791 return (ResourcePermission)result;
1792 }
1793 }
1794 }
1795
1796 public List<ResourcePermission> findAll() throws SystemException {
1797 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1798 }
1799
1800 public List<ResourcePermission> findAll(int start, int end)
1801 throws SystemException {
1802 return findAll(start, end, null);
1803 }
1804
1805 public List<ResourcePermission> findAll(int start, int end,
1806 OrderByComparator orderByComparator) throws SystemException {
1807 Object[] finderArgs = new Object[] {
1808 String.valueOf(start), String.valueOf(end),
1809 String.valueOf(orderByComparator)
1810 };
1811
1812 List<ResourcePermission> list = (List<ResourcePermission>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1813 finderArgs, this);
1814
1815 if (list == null) {
1816 Session session = null;
1817
1818 try {
1819 session = openSession();
1820
1821 StringBundler query = null;
1822 String sql = null;
1823
1824 if (orderByComparator != null) {
1825 query = new StringBundler(2 +
1826 (orderByComparator.getOrderByFields().length * 3));
1827
1828 query.append(_SQL_SELECT_RESOURCEPERMISSION);
1829
1830 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1831 orderByComparator);
1832
1833 sql = query.toString();
1834 }
1835
1836 sql = _SQL_SELECT_RESOURCEPERMISSION;
1837
1838 Query q = session.createQuery(sql);
1839
1840 if (orderByComparator == null) {
1841 list = (List<ResourcePermission>)QueryUtil.list(q,
1842 getDialect(), start, end, false);
1843
1844 Collections.sort(list);
1845 }
1846 else {
1847 list = (List<ResourcePermission>)QueryUtil.list(q,
1848 getDialect(), start, end);
1849 }
1850 }
1851 catch (Exception e) {
1852 throw processException(e);
1853 }
1854 finally {
1855 if (list == null) {
1856 list = new ArrayList<ResourcePermission>();
1857 }
1858
1859 cacheResult(list);
1860
1861 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1862
1863 closeSession(session);
1864 }
1865 }
1866
1867 return list;
1868 }
1869
1870 public void removeByRoleId(long roleId) throws SystemException {
1871 for (ResourcePermission resourcePermission : findByRoleId(roleId)) {
1872 remove(resourcePermission);
1873 }
1874 }
1875
1876 public void removeByR_S(long roleId, int scope) throws SystemException {
1877 for (ResourcePermission resourcePermission : findByR_S(roleId, scope)) {
1878 remove(resourcePermission);
1879 }
1880 }
1881
1882 public void removeByC_N_S(long companyId, String name, int scope)
1883 throws SystemException {
1884 for (ResourcePermission resourcePermission : findByC_N_S(companyId,
1885 name, scope)) {
1886 remove(resourcePermission);
1887 }
1888 }
1889
1890 public void removeByC_N_S_P(long companyId, String name, int scope,
1891 String primKey) throws SystemException {
1892 for (ResourcePermission resourcePermission : findByC_N_S_P(companyId,
1893 name, scope, primKey)) {
1894 remove(resourcePermission);
1895 }
1896 }
1897
1898 public void removeByC_N_S_P_R(long companyId, String name, int scope,
1899 String primKey, long roleId)
1900 throws NoSuchResourcePermissionException, SystemException {
1901 ResourcePermission resourcePermission = findByC_N_S_P_R(companyId,
1902 name, scope, primKey, roleId);
1903
1904 remove(resourcePermission);
1905 }
1906
1907 public void removeAll() throws SystemException {
1908 for (ResourcePermission resourcePermission : findAll()) {
1909 remove(resourcePermission);
1910 }
1911 }
1912
1913 public int countByRoleId(long roleId) throws SystemException {
1914 Object[] finderArgs = new Object[] { new Long(roleId) };
1915
1916 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ROLEID,
1917 finderArgs, this);
1918
1919 if (count == null) {
1920 Session session = null;
1921
1922 try {
1923 session = openSession();
1924
1925 StringBundler query = new StringBundler(2);
1926
1927 query.append(_SQL_COUNT_RESOURCEPERMISSION_WHERE);
1928
1929 query.append(_FINDER_COLUMN_ROLEID_ROLEID_2);
1930
1931 String sql = query.toString();
1932
1933 Query q = session.createQuery(sql);
1934
1935 QueryPos qPos = QueryPos.getInstance(q);
1936
1937 qPos.add(roleId);
1938
1939 count = (Long)q.uniqueResult();
1940 }
1941 catch (Exception e) {
1942 throw processException(e);
1943 }
1944 finally {
1945 if (count == null) {
1946 count = Long.valueOf(0);
1947 }
1948
1949 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ROLEID,
1950 finderArgs, count);
1951
1952 closeSession(session);
1953 }
1954 }
1955
1956 return count.intValue();
1957 }
1958
1959 public int countByR_S(long roleId, int scope) throws SystemException {
1960 Object[] finderArgs = new Object[] { new Long(roleId), new Integer(scope) };
1961
1962 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_S,
1963 finderArgs, this);
1964
1965 if (count == null) {
1966 Session session = null;
1967
1968 try {
1969 session = openSession();
1970
1971 StringBundler query = new StringBundler(3);
1972
1973 query.append(_SQL_COUNT_RESOURCEPERMISSION_WHERE);
1974
1975 query.append(_FINDER_COLUMN_R_S_ROLEID_2);
1976
1977 query.append(_FINDER_COLUMN_R_S_SCOPE_2);
1978
1979 String sql = query.toString();
1980
1981 Query q = session.createQuery(sql);
1982
1983 QueryPos qPos = QueryPos.getInstance(q);
1984
1985 qPos.add(roleId);
1986
1987 qPos.add(scope);
1988
1989 count = (Long)q.uniqueResult();
1990 }
1991 catch (Exception e) {
1992 throw processException(e);
1993 }
1994 finally {
1995 if (count == null) {
1996 count = Long.valueOf(0);
1997 }
1998
1999 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_S, finderArgs,
2000 count);
2001
2002 closeSession(session);
2003 }
2004 }
2005
2006 return count.intValue();
2007 }
2008
2009 public int countByC_N_S(long companyId, String name, int scope)
2010 throws SystemException {
2011 Object[] finderArgs = new Object[] {
2012 new Long(companyId),
2013
2014 name, new Integer(scope)
2015 };
2016
2017 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N_S,
2018 finderArgs, this);
2019
2020 if (count == null) {
2021 Session session = null;
2022
2023 try {
2024 session = openSession();
2025
2026 StringBundler query = new StringBundler(4);
2027
2028 query.append(_SQL_COUNT_RESOURCEPERMISSION_WHERE);
2029
2030 query.append(_FINDER_COLUMN_C_N_S_COMPANYID_2);
2031
2032 if (name == null) {
2033 query.append(_FINDER_COLUMN_C_N_S_NAME_1);
2034 }
2035 else {
2036 if (name.equals(StringPool.BLANK)) {
2037 query.append(_FINDER_COLUMN_C_N_S_NAME_3);
2038 }
2039 else {
2040 query.append(_FINDER_COLUMN_C_N_S_NAME_2);
2041 }
2042 }
2043
2044 query.append(_FINDER_COLUMN_C_N_S_SCOPE_2);
2045
2046 String sql = query.toString();
2047
2048 Query q = session.createQuery(sql);
2049
2050 QueryPos qPos = QueryPos.getInstance(q);
2051
2052 qPos.add(companyId);
2053
2054 if (name != null) {
2055 qPos.add(name);
2056 }
2057
2058 qPos.add(scope);
2059
2060 count = (Long)q.uniqueResult();
2061 }
2062 catch (Exception e) {
2063 throw processException(e);
2064 }
2065 finally {
2066 if (count == null) {
2067 count = Long.valueOf(0);
2068 }
2069
2070 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N_S,
2071 finderArgs, count);
2072
2073 closeSession(session);
2074 }
2075 }
2076
2077 return count.intValue();
2078 }
2079
2080 public int countByC_N_S_P(long companyId, String name, int scope,
2081 String primKey) throws SystemException {
2082 Object[] finderArgs = new Object[] {
2083 new Long(companyId),
2084
2085 name, new Integer(scope),
2086
2087 primKey
2088 };
2089
2090 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N_S_P,
2091 finderArgs, this);
2092
2093 if (count == null) {
2094 Session session = null;
2095
2096 try {
2097 session = openSession();
2098
2099 StringBundler query = new StringBundler(5);
2100
2101 query.append(_SQL_COUNT_RESOURCEPERMISSION_WHERE);
2102
2103 query.append(_FINDER_COLUMN_C_N_S_P_COMPANYID_2);
2104
2105 if (name == null) {
2106 query.append(_FINDER_COLUMN_C_N_S_P_NAME_1);
2107 }
2108 else {
2109 if (name.equals(StringPool.BLANK)) {
2110 query.append(_FINDER_COLUMN_C_N_S_P_NAME_3);
2111 }
2112 else {
2113 query.append(_FINDER_COLUMN_C_N_S_P_NAME_2);
2114 }
2115 }
2116
2117 query.append(_FINDER_COLUMN_C_N_S_P_SCOPE_2);
2118
2119 if (primKey == null) {
2120 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_1);
2121 }
2122 else {
2123 if (primKey.equals(StringPool.BLANK)) {
2124 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_3);
2125 }
2126 else {
2127 query.append(_FINDER_COLUMN_C_N_S_P_PRIMKEY_2);
2128 }
2129 }
2130
2131 String sql = query.toString();
2132
2133 Query q = session.createQuery(sql);
2134
2135 QueryPos qPos = QueryPos.getInstance(q);
2136
2137 qPos.add(companyId);
2138
2139 if (name != null) {
2140 qPos.add(name);
2141 }
2142
2143 qPos.add(scope);
2144
2145 if (primKey != null) {
2146 qPos.add(primKey);
2147 }
2148
2149 count = (Long)q.uniqueResult();
2150 }
2151 catch (Exception e) {
2152 throw processException(e);
2153 }
2154 finally {
2155 if (count == null) {
2156 count = Long.valueOf(0);
2157 }
2158
2159 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N_S_P,
2160 finderArgs, count);
2161
2162 closeSession(session);
2163 }
2164 }
2165
2166 return count.intValue();
2167 }
2168
2169 public int countByC_N_S_P_R(long companyId, String name, int scope,
2170 String primKey, long roleId) throws SystemException {
2171 Object[] finderArgs = new Object[] {
2172 new Long(companyId),
2173
2174 name, new Integer(scope),
2175
2176 primKey, new Long(roleId)
2177 };
2178
2179 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N_S_P_R,
2180 finderArgs, this);
2181
2182 if (count == null) {
2183 Session session = null;
2184
2185 try {
2186 session = openSession();
2187
2188 StringBundler query = new StringBundler(6);
2189
2190 query.append(_SQL_COUNT_RESOURCEPERMISSION_WHERE);
2191
2192 query.append(_FINDER_COLUMN_C_N_S_P_R_COMPANYID_2);
2193
2194 if (name == null) {
2195 query.append(_FINDER_COLUMN_C_N_S_P_R_NAME_1);
2196 }
2197 else {
2198 if (name.equals(StringPool.BLANK)) {
2199 query.append(_FINDER_COLUMN_C_N_S_P_R_NAME_3);
2200 }
2201 else {
2202 query.append(_FINDER_COLUMN_C_N_S_P_R_NAME_2);
2203 }
2204 }
2205
2206 query.append(_FINDER_COLUMN_C_N_S_P_R_SCOPE_2);
2207
2208 if (primKey == null) {
2209 query.append(_FINDER_COLUMN_C_N_S_P_R_PRIMKEY_1);
2210 }
2211 else {
2212 if (primKey.equals(StringPool.BLANK)) {
2213 query.append(_FINDER_COLUMN_C_N_S_P_R_PRIMKEY_3);
2214 }
2215 else {
2216 query.append(_FINDER_COLUMN_C_N_S_P_R_PRIMKEY_2);
2217 }
2218 }
2219
2220 query.append(_FINDER_COLUMN_C_N_S_P_R_ROLEID_2);
2221
2222 String sql = query.toString();
2223
2224 Query q = session.createQuery(sql);
2225
2226 QueryPos qPos = QueryPos.getInstance(q);
2227
2228 qPos.add(companyId);
2229
2230 if (name != null) {
2231 qPos.add(name);
2232 }
2233
2234 qPos.add(scope);
2235
2236 if (primKey != null) {
2237 qPos.add(primKey);
2238 }
2239
2240 qPos.add(roleId);
2241
2242 count = (Long)q.uniqueResult();
2243 }
2244 catch (Exception e) {
2245 throw processException(e);
2246 }
2247 finally {
2248 if (count == null) {
2249 count = Long.valueOf(0);
2250 }
2251
2252 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N_S_P_R,
2253 finderArgs, count);
2254
2255 closeSession(session);
2256 }
2257 }
2258
2259 return count.intValue();
2260 }
2261
2262 public int countAll() throws SystemException {
2263 Object[] finderArgs = new Object[0];
2264
2265 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2266 finderArgs, this);
2267
2268 if (count == null) {
2269 Session session = null;
2270
2271 try {
2272 session = openSession();
2273
2274 Query q = session.createQuery(_SQL_COUNT_RESOURCEPERMISSION);
2275
2276 count = (Long)q.uniqueResult();
2277 }
2278 catch (Exception e) {
2279 throw processException(e);
2280 }
2281 finally {
2282 if (count == null) {
2283 count = Long.valueOf(0);
2284 }
2285
2286 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2287 count);
2288
2289 closeSession(session);
2290 }
2291 }
2292
2293 return count.intValue();
2294 }
2295
2296 public void afterPropertiesSet() {
2297 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2298 com.liferay.portal.util.PropsUtil.get(
2299 "value.object.listener.com.liferay.portal.model.ResourcePermission")));
2300
2301 if (listenerClassNames.length > 0) {
2302 try {
2303 List<ModelListener<ResourcePermission>> listenersList = new ArrayList<ModelListener<ResourcePermission>>();
2304
2305 for (String listenerClassName : listenerClassNames) {
2306 listenersList.add((ModelListener<ResourcePermission>)Class.forName(
2307 listenerClassName).newInstance());
2308 }
2309
2310 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2311 }
2312 catch (Exception e) {
2313 _log.error(e);
2314 }
2315 }
2316 }
2317
2318 @BeanReference(type = AccountPersistence.class)
2319 protected AccountPersistence accountPersistence;
2320 @BeanReference(type = AddressPersistence.class)
2321 protected AddressPersistence addressPersistence;
2322 @BeanReference(type = BrowserTrackerPersistence.class)
2323 protected BrowserTrackerPersistence browserTrackerPersistence;
2324 @BeanReference(type = ClassNamePersistence.class)
2325 protected ClassNamePersistence classNamePersistence;
2326 @BeanReference(type = CompanyPersistence.class)
2327 protected CompanyPersistence companyPersistence;
2328 @BeanReference(type = ContactPersistence.class)
2329 protected ContactPersistence contactPersistence;
2330 @BeanReference(type = CountryPersistence.class)
2331 protected CountryPersistence countryPersistence;
2332 @BeanReference(type = EmailAddressPersistence.class)
2333 protected EmailAddressPersistence emailAddressPersistence;
2334 @BeanReference(type = GroupPersistence.class)
2335 protected GroupPersistence groupPersistence;
2336 @BeanReference(type = ImagePersistence.class)
2337 protected ImagePersistence imagePersistence;
2338 @BeanReference(type = LayoutPersistence.class)
2339 protected LayoutPersistence layoutPersistence;
2340 @BeanReference(type = LayoutPrototypePersistence.class)
2341 protected LayoutPrototypePersistence layoutPrototypePersistence;
2342 @BeanReference(type = LayoutSetPersistence.class)
2343 protected LayoutSetPersistence layoutSetPersistence;
2344 @BeanReference(type = LayoutSetPrototypePersistence.class)
2345 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2346 @BeanReference(type = ListTypePersistence.class)
2347 protected ListTypePersistence listTypePersistence;
2348 @BeanReference(type = LockPersistence.class)
2349 protected LockPersistence lockPersistence;
2350 @BeanReference(type = MembershipRequestPersistence.class)
2351 protected MembershipRequestPersistence membershipRequestPersistence;
2352 @BeanReference(type = OrganizationPersistence.class)
2353 protected OrganizationPersistence organizationPersistence;
2354 @BeanReference(type = OrgGroupPermissionPersistence.class)
2355 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2356 @BeanReference(type = OrgGroupRolePersistence.class)
2357 protected OrgGroupRolePersistence orgGroupRolePersistence;
2358 @BeanReference(type = OrgLaborPersistence.class)
2359 protected OrgLaborPersistence orgLaborPersistence;
2360 @BeanReference(type = PasswordPolicyPersistence.class)
2361 protected PasswordPolicyPersistence passwordPolicyPersistence;
2362 @BeanReference(type = PasswordPolicyRelPersistence.class)
2363 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2364 @BeanReference(type = PasswordTrackerPersistence.class)
2365 protected PasswordTrackerPersistence passwordTrackerPersistence;
2366 @BeanReference(type = PermissionPersistence.class)
2367 protected PermissionPersistence permissionPersistence;
2368 @BeanReference(type = PhonePersistence.class)
2369 protected PhonePersistence phonePersistence;
2370 @BeanReference(type = PluginSettingPersistence.class)
2371 protected PluginSettingPersistence pluginSettingPersistence;
2372 @BeanReference(type = PortletPersistence.class)
2373 protected PortletPersistence portletPersistence;
2374 @BeanReference(type = PortletItemPersistence.class)
2375 protected PortletItemPersistence portletItemPersistence;
2376 @BeanReference(type = PortletPreferencesPersistence.class)
2377 protected PortletPreferencesPersistence portletPreferencesPersistence;
2378 @BeanReference(type = RegionPersistence.class)
2379 protected RegionPersistence regionPersistence;
2380 @BeanReference(type = ReleasePersistence.class)
2381 protected ReleasePersistence releasePersistence;
2382 @BeanReference(type = ResourcePersistence.class)
2383 protected ResourcePersistence resourcePersistence;
2384 @BeanReference(type = ResourceActionPersistence.class)
2385 protected ResourceActionPersistence resourceActionPersistence;
2386 @BeanReference(type = ResourceCodePersistence.class)
2387 protected ResourceCodePersistence resourceCodePersistence;
2388 @BeanReference(type = ResourcePermissionPersistence.class)
2389 protected ResourcePermissionPersistence resourcePermissionPersistence;
2390 @BeanReference(type = RolePersistence.class)
2391 protected RolePersistence rolePersistence;
2392 @BeanReference(type = ServiceComponentPersistence.class)
2393 protected ServiceComponentPersistence serviceComponentPersistence;
2394 @BeanReference(type = ShardPersistence.class)
2395 protected ShardPersistence shardPersistence;
2396 @BeanReference(type = SubscriptionPersistence.class)
2397 protected SubscriptionPersistence subscriptionPersistence;
2398 @BeanReference(type = TeamPersistence.class)
2399 protected TeamPersistence teamPersistence;
2400 @BeanReference(type = UserPersistence.class)
2401 protected UserPersistence userPersistence;
2402 @BeanReference(type = UserGroupPersistence.class)
2403 protected UserGroupPersistence userGroupPersistence;
2404 @BeanReference(type = UserGroupGroupRolePersistence.class)
2405 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2406 @BeanReference(type = UserGroupRolePersistence.class)
2407 protected UserGroupRolePersistence userGroupRolePersistence;
2408 @BeanReference(type = UserIdMapperPersistence.class)
2409 protected UserIdMapperPersistence userIdMapperPersistence;
2410 @BeanReference(type = UserTrackerPersistence.class)
2411 protected UserTrackerPersistence userTrackerPersistence;
2412 @BeanReference(type = UserTrackerPathPersistence.class)
2413 protected UserTrackerPathPersistence userTrackerPathPersistence;
2414 @BeanReference(type = WebDAVPropsPersistence.class)
2415 protected WebDAVPropsPersistence webDAVPropsPersistence;
2416 @BeanReference(type = WebsitePersistence.class)
2417 protected WebsitePersistence websitePersistence;
2418 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2419 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2420 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2421 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2422 private static final String _SQL_SELECT_RESOURCEPERMISSION = "SELECT resourcePermission FROM ResourcePermission resourcePermission";
2423 private static final String _SQL_SELECT_RESOURCEPERMISSION_WHERE = "SELECT resourcePermission FROM ResourcePermission resourcePermission WHERE ";
2424 private static final String _SQL_COUNT_RESOURCEPERMISSION = "SELECT COUNT(resourcePermission) FROM ResourcePermission resourcePermission";
2425 private static final String _SQL_COUNT_RESOURCEPERMISSION_WHERE = "SELECT COUNT(resourcePermission) FROM ResourcePermission resourcePermission WHERE ";
2426 private static final String _FINDER_COLUMN_ROLEID_ROLEID_2 = "resourcePermission.roleId = ?";
2427 private static final String _FINDER_COLUMN_R_S_ROLEID_2 = "resourcePermission.roleId = ? AND ";
2428 private static final String _FINDER_COLUMN_R_S_SCOPE_2 = "resourcePermission.scope = ?";
2429 private static final String _FINDER_COLUMN_C_N_S_COMPANYID_2 = "resourcePermission.companyId = ? AND ";
2430 private static final String _FINDER_COLUMN_C_N_S_NAME_1 = "resourcePermission.name IS NULL AND ";
2431 private static final String _FINDER_COLUMN_C_N_S_NAME_2 = "resourcePermission.name = ? AND ";
2432 private static final String _FINDER_COLUMN_C_N_S_NAME_3 = "(resourcePermission.name IS NULL OR resourcePermission.name = ?) AND ";
2433 private static final String _FINDER_COLUMN_C_N_S_SCOPE_2 = "resourcePermission.scope = ?";
2434 private static final String _FINDER_COLUMN_C_N_S_P_COMPANYID_2 = "resourcePermission.companyId = ? AND ";
2435 private static final String _FINDER_COLUMN_C_N_S_P_NAME_1 = "resourcePermission.name IS NULL AND ";
2436 private static final String _FINDER_COLUMN_C_N_S_P_NAME_2 = "resourcePermission.name = ? AND ";
2437 private static final String _FINDER_COLUMN_C_N_S_P_NAME_3 = "(resourcePermission.name IS NULL OR resourcePermission.name = ?) AND ";
2438 private static final String _FINDER_COLUMN_C_N_S_P_SCOPE_2 = "resourcePermission.scope = ? AND ";
2439 private static final String _FINDER_COLUMN_C_N_S_P_PRIMKEY_1 = "resourcePermission.primKey IS NULL";
2440 private static final String _FINDER_COLUMN_C_N_S_P_PRIMKEY_2 = "resourcePermission.primKey = ?";
2441 private static final String _FINDER_COLUMN_C_N_S_P_PRIMKEY_3 = "(resourcePermission.primKey IS NULL OR resourcePermission.primKey = ?)";
2442 private static final String _FINDER_COLUMN_C_N_S_P_R_COMPANYID_2 = "resourcePermission.companyId = ? AND ";
2443 private static final String _FINDER_COLUMN_C_N_S_P_R_NAME_1 = "resourcePermission.name IS NULL AND ";
2444 private static final String _FINDER_COLUMN_C_N_S_P_R_NAME_2 = "resourcePermission.name = ? AND ";
2445 private static final String _FINDER_COLUMN_C_N_S_P_R_NAME_3 = "(resourcePermission.name IS NULL OR resourcePermission.name = ?) AND ";
2446 private static final String _FINDER_COLUMN_C_N_S_P_R_SCOPE_2 = "resourcePermission.scope = ? AND ";
2447 private static final String _FINDER_COLUMN_C_N_S_P_R_PRIMKEY_1 = "resourcePermission.primKey IS NULL AND ";
2448 private static final String _FINDER_COLUMN_C_N_S_P_R_PRIMKEY_2 = "resourcePermission.primKey = ? AND ";
2449 private static final String _FINDER_COLUMN_C_N_S_P_R_PRIMKEY_3 = "(resourcePermission.primKey IS NULL OR resourcePermission.primKey = ?) AND ";
2450 private static final String _FINDER_COLUMN_C_N_S_P_R_ROLEID_2 = "resourcePermission.roleId = ?";
2451 private static final String _ORDER_BY_ENTITY_ALIAS = "resourcePermission.";
2452 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ResourcePermission exists with the primary key ";
2453 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ResourcePermission exists with the key {";
2454 private static Log _log = LogFactoryUtil.getLog(ResourcePermissionPersistenceImpl.class);
2455}