001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchRoleException;
019 import com.liferay.portal.kernel.annotation.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.Role;
047 import com.liferay.portal.model.impl.RoleImpl;
048 import com.liferay.portal.model.impl.RoleModelImpl;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056 import java.util.Set;
057
058
074 public class RolePersistenceImpl extends BasePersistenceImpl<Role>
075 implements RolePersistence {
076 public static final String FINDER_CLASS_NAME_ENTITY = RoleImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
078 ".List";
079 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
080 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
081 "findByCompanyId",
082 new String[] {
083 Long.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
089 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
090 "countByCompanyId", new String[] { Long.class.getName() });
091 public static final FinderPath FINDER_PATH_FIND_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
092 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
093 "findBySubtype",
094 new String[] {
095 String.class.getName(),
096
097 "java.lang.Integer", "java.lang.Integer",
098 "com.liferay.portal.kernel.util.OrderByComparator"
099 });
100 public static final FinderPath FINDER_PATH_COUNT_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
101 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
102 "countBySubtype", new String[] { String.class.getName() });
103 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
104 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
105 "fetchByC_N",
106 new String[] { Long.class.getName(), String.class.getName() });
107 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
108 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109 "countByC_N",
110 new String[] { Long.class.getName(), String.class.getName() });
111 public static final FinderPath FINDER_PATH_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
112 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113 "findByT_S",
114 new String[] {
115 Integer.class.getName(), String.class.getName(),
116
117 "java.lang.Integer", "java.lang.Integer",
118 "com.liferay.portal.kernel.util.OrderByComparator"
119 });
120 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
121 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122 "countByT_S",
123 new String[] { Integer.class.getName(), String.class.getName() });
124 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
125 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
126 "fetchByC_C_C",
127 new String[] {
128 Long.class.getName(), Long.class.getName(), Long.class.getName()
129 });
130 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
131 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
132 "countByC_C_C",
133 new String[] {
134 Long.class.getName(), Long.class.getName(), Long.class.getName()
135 });
136 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
137 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
138 "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
140 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
141 "countAll", new String[0]);
142
143
148 public void cacheResult(Role role) {
149 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
150 RoleImpl.class, role.getPrimaryKey(), role);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
153 new Object[] { new Long(role.getCompanyId()), role.getName() }, role);
154
155 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
156 new Object[] {
157 new Long(role.getCompanyId()), new Long(role.getClassNameId()),
158 new Long(role.getClassPK())
159 }, role);
160 }
161
162
167 public void cacheResult(List<Role> roles) {
168 for (Role role : roles) {
169 if (EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
170 RoleImpl.class, role.getPrimaryKey(), this) == null) {
171 cacheResult(role);
172 }
173 }
174 }
175
176
183 public void clearCache() {
184 CacheRegistryUtil.clear(RoleImpl.class.getName());
185 EntityCacheUtil.clearCache(RoleImpl.class.getName());
186 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
187 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
188 }
189
190
197 public void clearCache(Role role) {
198 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
199 RoleImpl.class, role.getPrimaryKey());
200
201 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
202 new Object[] { new Long(role.getCompanyId()), role.getName() });
203
204 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
205 new Object[] {
206 new Long(role.getCompanyId()), new Long(role.getClassNameId()),
207 new Long(role.getClassPK())
208 });
209 }
210
211
217 public Role create(long roleId) {
218 Role role = new RoleImpl();
219
220 role.setNew(true);
221 role.setPrimaryKey(roleId);
222
223 return role;
224 }
225
226
234 public Role remove(Serializable primaryKey)
235 throws NoSuchModelException, SystemException {
236 return remove(((Long)primaryKey).longValue());
237 }
238
239
247 public Role remove(long roleId) throws NoSuchRoleException, SystemException {
248 Session session = null;
249
250 try {
251 session = openSession();
252
253 Role role = (Role)session.get(RoleImpl.class, new Long(roleId));
254
255 if (role == null) {
256 if (_log.isWarnEnabled()) {
257 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
258 }
259
260 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
261 roleId);
262 }
263
264 return remove(role);
265 }
266 catch (NoSuchRoleException nsee) {
267 throw nsee;
268 }
269 catch (Exception e) {
270 throw processException(e);
271 }
272 finally {
273 closeSession(session);
274 }
275 }
276
277 protected Role removeImpl(Role role) throws SystemException {
278 role = toUnwrappedModel(role);
279
280 try {
281 clearGroups.clear(role.getPrimaryKey());
282 }
283 catch (Exception e) {
284 throw processException(e);
285 }
286 finally {
287 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
288 }
289
290 try {
291 clearPermissions.clear(role.getPrimaryKey());
292 }
293 catch (Exception e) {
294 throw processException(e);
295 }
296 finally {
297 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
298 }
299
300 try {
301 clearUsers.clear(role.getPrimaryKey());
302 }
303 catch (Exception e) {
304 throw processException(e);
305 }
306 finally {
307 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
308 }
309
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 if (role.isCachedModel() || BatchSessionUtil.isEnabled()) {
316 Object staleObject = session.get(RoleImpl.class,
317 role.getPrimaryKeyObj());
318
319 if (staleObject != null) {
320 session.evict(staleObject);
321 }
322 }
323
324 session.delete(role);
325
326 session.flush();
327 }
328 catch (Exception e) {
329 throw processException(e);
330 }
331 finally {
332 closeSession(session);
333 }
334
335 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
336
337 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
338
339 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
340 new Object[] {
341 new Long(roleModelImpl.getOriginalCompanyId()),
342
343 roleModelImpl.getOriginalName()
344 });
345
346 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
347 new Object[] {
348 new Long(roleModelImpl.getOriginalCompanyId()),
349 new Long(roleModelImpl.getOriginalClassNameId()),
350 new Long(roleModelImpl.getOriginalClassPK())
351 });
352
353 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
354 RoleImpl.class, role.getPrimaryKey());
355
356 return role;
357 }
358
359 public Role updateImpl(com.liferay.portal.model.Role role, boolean merge)
360 throws SystemException {
361 role = toUnwrappedModel(role);
362
363 boolean isNew = role.isNew();
364
365 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
366
367 Session session = null;
368
369 try {
370 session = openSession();
371
372 BatchSessionUtil.update(session, role, merge);
373
374 role.setNew(false);
375 }
376 catch (Exception e) {
377 throw processException(e);
378 }
379 finally {
380 closeSession(session);
381 }
382
383 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
384
385 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
386 RoleImpl.class, role.getPrimaryKey(), role);
387
388 if (!isNew &&
389 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
390 !Validator.equals(role.getName(),
391 roleModelImpl.getOriginalName()))) {
392 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
393 new Object[] {
394 new Long(roleModelImpl.getOriginalCompanyId()),
395
396 roleModelImpl.getOriginalName()
397 });
398 }
399
400 if (isNew ||
401 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
402 !Validator.equals(role.getName(),
403 roleModelImpl.getOriginalName()))) {
404 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
405 new Object[] { new Long(role.getCompanyId()), role.getName() },
406 role);
407 }
408
409 if (!isNew &&
410 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
411 (role.getClassNameId() != roleModelImpl.getOriginalClassNameId()) ||
412 (role.getClassPK() != roleModelImpl.getOriginalClassPK()))) {
413 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
414 new Object[] {
415 new Long(roleModelImpl.getOriginalCompanyId()),
416 new Long(roleModelImpl.getOriginalClassNameId()),
417 new Long(roleModelImpl.getOriginalClassPK())
418 });
419 }
420
421 if (isNew ||
422 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
423 (role.getClassNameId() != roleModelImpl.getOriginalClassNameId()) ||
424 (role.getClassPK() != roleModelImpl.getOriginalClassPK()))) {
425 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
426 new Object[] {
427 new Long(role.getCompanyId()),
428 new Long(role.getClassNameId()), new Long(role.getClassPK())
429 }, role);
430 }
431
432 return role;
433 }
434
435 protected Role toUnwrappedModel(Role role) {
436 if (role instanceof RoleImpl) {
437 return role;
438 }
439
440 RoleImpl roleImpl = new RoleImpl();
441
442 roleImpl.setNew(role.isNew());
443 roleImpl.setPrimaryKey(role.getPrimaryKey());
444
445 roleImpl.setRoleId(role.getRoleId());
446 roleImpl.setCompanyId(role.getCompanyId());
447 roleImpl.setClassNameId(role.getClassNameId());
448 roleImpl.setClassPK(role.getClassPK());
449 roleImpl.setName(role.getName());
450 roleImpl.setTitle(role.getTitle());
451 roleImpl.setDescription(role.getDescription());
452 roleImpl.setType(role.getType());
453 roleImpl.setSubtype(role.getSubtype());
454
455 return roleImpl;
456 }
457
458
466 public Role findByPrimaryKey(Serializable primaryKey)
467 throws NoSuchModelException, SystemException {
468 return findByPrimaryKey(((Long)primaryKey).longValue());
469 }
470
471
479 public Role findByPrimaryKey(long roleId)
480 throws NoSuchRoleException, SystemException {
481 Role role = fetchByPrimaryKey(roleId);
482
483 if (role == null) {
484 if (_log.isWarnEnabled()) {
485 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
486 }
487
488 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
489 roleId);
490 }
491
492 return role;
493 }
494
495
502 public Role fetchByPrimaryKey(Serializable primaryKey)
503 throws SystemException {
504 return fetchByPrimaryKey(((Long)primaryKey).longValue());
505 }
506
507
514 public Role fetchByPrimaryKey(long roleId) throws SystemException {
515 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
516 RoleImpl.class, roleId, this);
517
518 if (role == null) {
519 Session session = null;
520
521 try {
522 session = openSession();
523
524 role = (Role)session.get(RoleImpl.class, new Long(roleId));
525 }
526 catch (Exception e) {
527 throw processException(e);
528 }
529 finally {
530 if (role != null) {
531 cacheResult(role);
532 }
533
534 closeSession(session);
535 }
536 }
537
538 return role;
539 }
540
541
548 public List<Role> findByCompanyId(long companyId) throws SystemException {
549 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
550 null);
551 }
552
553
566 public List<Role> findByCompanyId(long companyId, int start, int end)
567 throws SystemException {
568 return findByCompanyId(companyId, start, end, null);
569 }
570
571
585 public List<Role> findByCompanyId(long companyId, int start, int end,
586 OrderByComparator orderByComparator) throws SystemException {
587 Object[] finderArgs = new Object[] {
588 companyId,
589
590 String.valueOf(start), String.valueOf(end),
591 String.valueOf(orderByComparator)
592 };
593
594 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
595 finderArgs, this);
596
597 if (list == null) {
598 Session session = null;
599
600 try {
601 session = openSession();
602
603 StringBundler query = null;
604
605 if (orderByComparator != null) {
606 query = new StringBundler(3 +
607 (orderByComparator.getOrderByFields().length * 3));
608 }
609 else {
610 query = new StringBundler(3);
611 }
612
613 query.append(_SQL_SELECT_ROLE_WHERE);
614
615 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
616
617 if (orderByComparator != null) {
618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
619 orderByComparator);
620 }
621
622 else {
623 query.append(RoleModelImpl.ORDER_BY_JPQL);
624 }
625
626 String sql = query.toString();
627
628 Query q = session.createQuery(sql);
629
630 QueryPos qPos = QueryPos.getInstance(q);
631
632 qPos.add(companyId);
633
634 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
635 }
636 catch (Exception e) {
637 throw processException(e);
638 }
639 finally {
640 if (list == null) {
641 list = new ArrayList<Role>();
642 }
643
644 cacheResult(list);
645
646 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
647 finderArgs, list);
648
649 closeSession(session);
650 }
651 }
652
653 return list;
654 }
655
656
669 public Role findByCompanyId_First(long companyId,
670 OrderByComparator orderByComparator)
671 throws NoSuchRoleException, SystemException {
672 List<Role> list = findByCompanyId(companyId, 0, 1, orderByComparator);
673
674 if (list.isEmpty()) {
675 StringBundler msg = new StringBundler(4);
676
677 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
678
679 msg.append("companyId=");
680 msg.append(companyId);
681
682 msg.append(StringPool.CLOSE_CURLY_BRACE);
683
684 throw new NoSuchRoleException(msg.toString());
685 }
686 else {
687 return list.get(0);
688 }
689 }
690
691
704 public Role findByCompanyId_Last(long companyId,
705 OrderByComparator orderByComparator)
706 throws NoSuchRoleException, SystemException {
707 int count = countByCompanyId(companyId);
708
709 List<Role> list = findByCompanyId(companyId, count - 1, count,
710 orderByComparator);
711
712 if (list.isEmpty()) {
713 StringBundler msg = new StringBundler(4);
714
715 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
716
717 msg.append("companyId=");
718 msg.append(companyId);
719
720 msg.append(StringPool.CLOSE_CURLY_BRACE);
721
722 throw new NoSuchRoleException(msg.toString());
723 }
724 else {
725 return list.get(0);
726 }
727 }
728
729
743 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
744 OrderByComparator orderByComparator)
745 throws NoSuchRoleException, SystemException {
746 Role role = findByPrimaryKey(roleId);
747
748 Session session = null;
749
750 try {
751 session = openSession();
752
753 Role[] array = new RoleImpl[3];
754
755 array[0] = getByCompanyId_PrevAndNext(session, role, companyId,
756 orderByComparator, true);
757
758 array[1] = role;
759
760 array[2] = getByCompanyId_PrevAndNext(session, role, companyId,
761 orderByComparator, false);
762
763 return array;
764 }
765 catch (Exception e) {
766 throw processException(e);
767 }
768 finally {
769 closeSession(session);
770 }
771 }
772
773 protected Role getByCompanyId_PrevAndNext(Session session, Role role,
774 long companyId, OrderByComparator orderByComparator, boolean previous) {
775 StringBundler query = null;
776
777 if (orderByComparator != null) {
778 query = new StringBundler(6 +
779 (orderByComparator.getOrderByFields().length * 6));
780 }
781 else {
782 query = new StringBundler(3);
783 }
784
785 query.append(_SQL_SELECT_ROLE_WHERE);
786
787 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
788
789 if (orderByComparator != null) {
790 String[] orderByFields = orderByComparator.getOrderByFields();
791
792 if (orderByFields.length > 0) {
793 query.append(WHERE_AND);
794 }
795
796 for (int i = 0; i < orderByFields.length; i++) {
797 query.append(_ORDER_BY_ENTITY_ALIAS);
798 query.append(orderByFields[i]);
799
800 if ((i + 1) < orderByFields.length) {
801 if (orderByComparator.isAscending() ^ previous) {
802 query.append(WHERE_GREATER_THAN_HAS_NEXT);
803 }
804 else {
805 query.append(WHERE_LESSER_THAN_HAS_NEXT);
806 }
807 }
808 else {
809 if (orderByComparator.isAscending() ^ previous) {
810 query.append(WHERE_GREATER_THAN);
811 }
812 else {
813 query.append(WHERE_LESSER_THAN);
814 }
815 }
816 }
817
818 query.append(ORDER_BY_CLAUSE);
819
820 for (int i = 0; i < orderByFields.length; i++) {
821 query.append(_ORDER_BY_ENTITY_ALIAS);
822 query.append(orderByFields[i]);
823
824 if ((i + 1) < orderByFields.length) {
825 if (orderByComparator.isAscending() ^ previous) {
826 query.append(ORDER_BY_ASC_HAS_NEXT);
827 }
828 else {
829 query.append(ORDER_BY_DESC_HAS_NEXT);
830 }
831 }
832 else {
833 if (orderByComparator.isAscending() ^ previous) {
834 query.append(ORDER_BY_ASC);
835 }
836 else {
837 query.append(ORDER_BY_DESC);
838 }
839 }
840 }
841 }
842
843 else {
844 query.append(RoleModelImpl.ORDER_BY_JPQL);
845 }
846
847 String sql = query.toString();
848
849 Query q = session.createQuery(sql);
850
851 q.setFirstResult(0);
852 q.setMaxResults(2);
853
854 QueryPos qPos = QueryPos.getInstance(q);
855
856 qPos.add(companyId);
857
858 if (orderByComparator != null) {
859 Object[] values = orderByComparator.getOrderByValues(role);
860
861 for (Object value : values) {
862 qPos.add(value);
863 }
864 }
865
866 List<Role> list = q.list();
867
868 if (list.size() == 2) {
869 return list.get(1);
870 }
871 else {
872 return null;
873 }
874 }
875
876
883 public List<Role> findBySubtype(String subtype) throws SystemException {
884 return findBySubtype(subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
885 }
886
887
900 public List<Role> findBySubtype(String subtype, int start, int end)
901 throws SystemException {
902 return findBySubtype(subtype, start, end, null);
903 }
904
905
919 public List<Role> findBySubtype(String subtype, int start, int end,
920 OrderByComparator orderByComparator) throws SystemException {
921 Object[] finderArgs = new Object[] {
922 subtype,
923
924 String.valueOf(start), String.valueOf(end),
925 String.valueOf(orderByComparator)
926 };
927
928 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SUBTYPE,
929 finderArgs, this);
930
931 if (list == null) {
932 Session session = null;
933
934 try {
935 session = openSession();
936
937 StringBundler query = null;
938
939 if (orderByComparator != null) {
940 query = new StringBundler(3 +
941 (orderByComparator.getOrderByFields().length * 3));
942 }
943 else {
944 query = new StringBundler(3);
945 }
946
947 query.append(_SQL_SELECT_ROLE_WHERE);
948
949 if (subtype == null) {
950 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
951 }
952 else {
953 if (subtype.equals(StringPool.BLANK)) {
954 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
955 }
956 else {
957 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
958 }
959 }
960
961 if (orderByComparator != null) {
962 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
963 orderByComparator);
964 }
965
966 else {
967 query.append(RoleModelImpl.ORDER_BY_JPQL);
968 }
969
970 String sql = query.toString();
971
972 Query q = session.createQuery(sql);
973
974 QueryPos qPos = QueryPos.getInstance(q);
975
976 if (subtype != null) {
977 qPos.add(subtype);
978 }
979
980 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
981 }
982 catch (Exception e) {
983 throw processException(e);
984 }
985 finally {
986 if (list == null) {
987 list = new ArrayList<Role>();
988 }
989
990 cacheResult(list);
991
992 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SUBTYPE,
993 finderArgs, list);
994
995 closeSession(session);
996 }
997 }
998
999 return list;
1000 }
1001
1002
1015 public Role findBySubtype_First(String subtype,
1016 OrderByComparator orderByComparator)
1017 throws NoSuchRoleException, SystemException {
1018 List<Role> list = findBySubtype(subtype, 0, 1, orderByComparator);
1019
1020 if (list.isEmpty()) {
1021 StringBundler msg = new StringBundler(4);
1022
1023 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1024
1025 msg.append("subtype=");
1026 msg.append(subtype);
1027
1028 msg.append(StringPool.CLOSE_CURLY_BRACE);
1029
1030 throw new NoSuchRoleException(msg.toString());
1031 }
1032 else {
1033 return list.get(0);
1034 }
1035 }
1036
1037
1050 public Role findBySubtype_Last(String subtype,
1051 OrderByComparator orderByComparator)
1052 throws NoSuchRoleException, SystemException {
1053 int count = countBySubtype(subtype);
1054
1055 List<Role> list = findBySubtype(subtype, count - 1, count,
1056 orderByComparator);
1057
1058 if (list.isEmpty()) {
1059 StringBundler msg = new StringBundler(4);
1060
1061 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1062
1063 msg.append("subtype=");
1064 msg.append(subtype);
1065
1066 msg.append(StringPool.CLOSE_CURLY_BRACE);
1067
1068 throw new NoSuchRoleException(msg.toString());
1069 }
1070 else {
1071 return list.get(0);
1072 }
1073 }
1074
1075
1089 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
1090 OrderByComparator orderByComparator)
1091 throws NoSuchRoleException, SystemException {
1092 Role role = findByPrimaryKey(roleId);
1093
1094 Session session = null;
1095
1096 try {
1097 session = openSession();
1098
1099 Role[] array = new RoleImpl[3];
1100
1101 array[0] = getBySubtype_PrevAndNext(session, role, subtype,
1102 orderByComparator, true);
1103
1104 array[1] = role;
1105
1106 array[2] = getBySubtype_PrevAndNext(session, role, subtype,
1107 orderByComparator, false);
1108
1109 return array;
1110 }
1111 catch (Exception e) {
1112 throw processException(e);
1113 }
1114 finally {
1115 closeSession(session);
1116 }
1117 }
1118
1119 protected Role getBySubtype_PrevAndNext(Session session, Role role,
1120 String subtype, OrderByComparator orderByComparator, boolean previous) {
1121 StringBundler query = null;
1122
1123 if (orderByComparator != null) {
1124 query = new StringBundler(6 +
1125 (orderByComparator.getOrderByFields().length * 6));
1126 }
1127 else {
1128 query = new StringBundler(3);
1129 }
1130
1131 query.append(_SQL_SELECT_ROLE_WHERE);
1132
1133 if (subtype == null) {
1134 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
1135 }
1136 else {
1137 if (subtype.equals(StringPool.BLANK)) {
1138 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
1139 }
1140 else {
1141 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
1142 }
1143 }
1144
1145 if (orderByComparator != null) {
1146 String[] orderByFields = orderByComparator.getOrderByFields();
1147
1148 if (orderByFields.length > 0) {
1149 query.append(WHERE_AND);
1150 }
1151
1152 for (int i = 0; i < orderByFields.length; i++) {
1153 query.append(_ORDER_BY_ENTITY_ALIAS);
1154 query.append(orderByFields[i]);
1155
1156 if ((i + 1) < orderByFields.length) {
1157 if (orderByComparator.isAscending() ^ previous) {
1158 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1159 }
1160 else {
1161 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1162 }
1163 }
1164 else {
1165 if (orderByComparator.isAscending() ^ previous) {
1166 query.append(WHERE_GREATER_THAN);
1167 }
1168 else {
1169 query.append(WHERE_LESSER_THAN);
1170 }
1171 }
1172 }
1173
1174 query.append(ORDER_BY_CLAUSE);
1175
1176 for (int i = 0; i < orderByFields.length; i++) {
1177 query.append(_ORDER_BY_ENTITY_ALIAS);
1178 query.append(orderByFields[i]);
1179
1180 if ((i + 1) < orderByFields.length) {
1181 if (orderByComparator.isAscending() ^ previous) {
1182 query.append(ORDER_BY_ASC_HAS_NEXT);
1183 }
1184 else {
1185 query.append(ORDER_BY_DESC_HAS_NEXT);
1186 }
1187 }
1188 else {
1189 if (orderByComparator.isAscending() ^ previous) {
1190 query.append(ORDER_BY_ASC);
1191 }
1192 else {
1193 query.append(ORDER_BY_DESC);
1194 }
1195 }
1196 }
1197 }
1198
1199 else {
1200 query.append(RoleModelImpl.ORDER_BY_JPQL);
1201 }
1202
1203 String sql = query.toString();
1204
1205 Query q = session.createQuery(sql);
1206
1207 q.setFirstResult(0);
1208 q.setMaxResults(2);
1209
1210 QueryPos qPos = QueryPos.getInstance(q);
1211
1212 if (subtype != null) {
1213 qPos.add(subtype);
1214 }
1215
1216 if (orderByComparator != null) {
1217 Object[] values = orderByComparator.getOrderByValues(role);
1218
1219 for (Object value : values) {
1220 qPos.add(value);
1221 }
1222 }
1223
1224 List<Role> list = q.list();
1225
1226 if (list.size() == 2) {
1227 return list.get(1);
1228 }
1229 else {
1230 return null;
1231 }
1232 }
1233
1234
1243 public Role findByC_N(long companyId, String name)
1244 throws NoSuchRoleException, SystemException {
1245 Role role = fetchByC_N(companyId, name);
1246
1247 if (role == null) {
1248 StringBundler msg = new StringBundler(6);
1249
1250 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1251
1252 msg.append("companyId=");
1253 msg.append(companyId);
1254
1255 msg.append(", name=");
1256 msg.append(name);
1257
1258 msg.append(StringPool.CLOSE_CURLY_BRACE);
1259
1260 if (_log.isWarnEnabled()) {
1261 _log.warn(msg.toString());
1262 }
1263
1264 throw new NoSuchRoleException(msg.toString());
1265 }
1266
1267 return role;
1268 }
1269
1270
1278 public Role fetchByC_N(long companyId, String name)
1279 throws SystemException {
1280 return fetchByC_N(companyId, name, true);
1281 }
1282
1283
1291 public Role fetchByC_N(long companyId, String name,
1292 boolean retrieveFromCache) throws SystemException {
1293 Object[] finderArgs = new Object[] { companyId, name };
1294
1295 Object result = null;
1296
1297 if (retrieveFromCache) {
1298 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1299 finderArgs, this);
1300 }
1301
1302 if (result == null) {
1303 Session session = null;
1304
1305 try {
1306 session = openSession();
1307
1308 StringBundler query = new StringBundler(4);
1309
1310 query.append(_SQL_SELECT_ROLE_WHERE);
1311
1312 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1313
1314 if (name == null) {
1315 query.append(_FINDER_COLUMN_C_N_NAME_1);
1316 }
1317 else {
1318 if (name.equals(StringPool.BLANK)) {
1319 query.append(_FINDER_COLUMN_C_N_NAME_3);
1320 }
1321 else {
1322 query.append(_FINDER_COLUMN_C_N_NAME_2);
1323 }
1324 }
1325
1326 query.append(RoleModelImpl.ORDER_BY_JPQL);
1327
1328 String sql = query.toString();
1329
1330 Query q = session.createQuery(sql);
1331
1332 QueryPos qPos = QueryPos.getInstance(q);
1333
1334 qPos.add(companyId);
1335
1336 if (name != null) {
1337 qPos.add(name);
1338 }
1339
1340 List<Role> list = q.list();
1341
1342 result = list;
1343
1344 Role role = null;
1345
1346 if (list.isEmpty()) {
1347 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1348 finderArgs, list);
1349 }
1350 else {
1351 role = list.get(0);
1352
1353 cacheResult(role);
1354
1355 if ((role.getCompanyId() != companyId) ||
1356 (role.getName() == null) ||
1357 !role.getName().equals(name)) {
1358 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1359 finderArgs, role);
1360 }
1361 }
1362
1363 return role;
1364 }
1365 catch (Exception e) {
1366 throw processException(e);
1367 }
1368 finally {
1369 if (result == null) {
1370 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1371 finderArgs, new ArrayList<Role>());
1372 }
1373
1374 closeSession(session);
1375 }
1376 }
1377 else {
1378 if (result instanceof List<?>) {
1379 return null;
1380 }
1381 else {
1382 return (Role)result;
1383 }
1384 }
1385 }
1386
1387
1395 public List<Role> findByT_S(int type, String subtype)
1396 throws SystemException {
1397 return findByT_S(type, subtype, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1398 null);
1399 }
1400
1401
1415 public List<Role> findByT_S(int type, String subtype, int start, int end)
1416 throws SystemException {
1417 return findByT_S(type, subtype, start, end, null);
1418 }
1419
1420
1435 public List<Role> findByT_S(int type, String subtype, int start, int end,
1436 OrderByComparator orderByComparator) throws SystemException {
1437 Object[] finderArgs = new Object[] {
1438 type, subtype,
1439
1440 String.valueOf(start), String.valueOf(end),
1441 String.valueOf(orderByComparator)
1442 };
1443
1444 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_S,
1445 finderArgs, this);
1446
1447 if (list == null) {
1448 Session session = null;
1449
1450 try {
1451 session = openSession();
1452
1453 StringBundler query = null;
1454
1455 if (orderByComparator != null) {
1456 query = new StringBundler(4 +
1457 (orderByComparator.getOrderByFields().length * 3));
1458 }
1459 else {
1460 query = new StringBundler(4);
1461 }
1462
1463 query.append(_SQL_SELECT_ROLE_WHERE);
1464
1465 query.append(_FINDER_COLUMN_T_S_TYPE_2);
1466
1467 if (subtype == null) {
1468 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
1469 }
1470 else {
1471 if (subtype.equals(StringPool.BLANK)) {
1472 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
1473 }
1474 else {
1475 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
1476 }
1477 }
1478
1479 if (orderByComparator != null) {
1480 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1481 orderByComparator);
1482 }
1483
1484 else {
1485 query.append(RoleModelImpl.ORDER_BY_JPQL);
1486 }
1487
1488 String sql = query.toString();
1489
1490 Query q = session.createQuery(sql);
1491
1492 QueryPos qPos = QueryPos.getInstance(q);
1493
1494 qPos.add(type);
1495
1496 if (subtype != null) {
1497 qPos.add(subtype);
1498 }
1499
1500 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1501 }
1502 catch (Exception e) {
1503 throw processException(e);
1504 }
1505 finally {
1506 if (list == null) {
1507 list = new ArrayList<Role>();
1508 }
1509
1510 cacheResult(list);
1511
1512 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_S, finderArgs,
1513 list);
1514
1515 closeSession(session);
1516 }
1517 }
1518
1519 return list;
1520 }
1521
1522
1536 public Role findByT_S_First(int type, String subtype,
1537 OrderByComparator orderByComparator)
1538 throws NoSuchRoleException, SystemException {
1539 List<Role> list = findByT_S(type, subtype, 0, 1, orderByComparator);
1540
1541 if (list.isEmpty()) {
1542 StringBundler msg = new StringBundler(6);
1543
1544 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1545
1546 msg.append("type=");
1547 msg.append(type);
1548
1549 msg.append(", subtype=");
1550 msg.append(subtype);
1551
1552 msg.append(StringPool.CLOSE_CURLY_BRACE);
1553
1554 throw new NoSuchRoleException(msg.toString());
1555 }
1556 else {
1557 return list.get(0);
1558 }
1559 }
1560
1561
1575 public Role findByT_S_Last(int type, String subtype,
1576 OrderByComparator orderByComparator)
1577 throws NoSuchRoleException, SystemException {
1578 int count = countByT_S(type, subtype);
1579
1580 List<Role> list = findByT_S(type, subtype, count - 1, count,
1581 orderByComparator);
1582
1583 if (list.isEmpty()) {
1584 StringBundler msg = new StringBundler(6);
1585
1586 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1587
1588 msg.append("type=");
1589 msg.append(type);
1590
1591 msg.append(", subtype=");
1592 msg.append(subtype);
1593
1594 msg.append(StringPool.CLOSE_CURLY_BRACE);
1595
1596 throw new NoSuchRoleException(msg.toString());
1597 }
1598 else {
1599 return list.get(0);
1600 }
1601 }
1602
1603
1618 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
1619 OrderByComparator orderByComparator)
1620 throws NoSuchRoleException, SystemException {
1621 Role role = findByPrimaryKey(roleId);
1622
1623 Session session = null;
1624
1625 try {
1626 session = openSession();
1627
1628 Role[] array = new RoleImpl[3];
1629
1630 array[0] = getByT_S_PrevAndNext(session, role, type, subtype,
1631 orderByComparator, true);
1632
1633 array[1] = role;
1634
1635 array[2] = getByT_S_PrevAndNext(session, role, type, subtype,
1636 orderByComparator, false);
1637
1638 return array;
1639 }
1640 catch (Exception e) {
1641 throw processException(e);
1642 }
1643 finally {
1644 closeSession(session);
1645 }
1646 }
1647
1648 protected Role getByT_S_PrevAndNext(Session session, Role role, int type,
1649 String subtype, OrderByComparator orderByComparator, boolean previous) {
1650 StringBundler query = null;
1651
1652 if (orderByComparator != null) {
1653 query = new StringBundler(6 +
1654 (orderByComparator.getOrderByFields().length * 6));
1655 }
1656 else {
1657 query = new StringBundler(3);
1658 }
1659
1660 query.append(_SQL_SELECT_ROLE_WHERE);
1661
1662 query.append(_FINDER_COLUMN_T_S_TYPE_2);
1663
1664 if (subtype == null) {
1665 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
1666 }
1667 else {
1668 if (subtype.equals(StringPool.BLANK)) {
1669 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
1670 }
1671 else {
1672 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
1673 }
1674 }
1675
1676 if (orderByComparator != null) {
1677 String[] orderByFields = orderByComparator.getOrderByFields();
1678
1679 if (orderByFields.length > 0) {
1680 query.append(WHERE_AND);
1681 }
1682
1683 for (int i = 0; i < orderByFields.length; i++) {
1684 query.append(_ORDER_BY_ENTITY_ALIAS);
1685 query.append(orderByFields[i]);
1686
1687 if ((i + 1) < orderByFields.length) {
1688 if (orderByComparator.isAscending() ^ previous) {
1689 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1690 }
1691 else {
1692 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1693 }
1694 }
1695 else {
1696 if (orderByComparator.isAscending() ^ previous) {
1697 query.append(WHERE_GREATER_THAN);
1698 }
1699 else {
1700 query.append(WHERE_LESSER_THAN);
1701 }
1702 }
1703 }
1704
1705 query.append(ORDER_BY_CLAUSE);
1706
1707 for (int i = 0; i < orderByFields.length; i++) {
1708 query.append(_ORDER_BY_ENTITY_ALIAS);
1709 query.append(orderByFields[i]);
1710
1711 if ((i + 1) < orderByFields.length) {
1712 if (orderByComparator.isAscending() ^ previous) {
1713 query.append(ORDER_BY_ASC_HAS_NEXT);
1714 }
1715 else {
1716 query.append(ORDER_BY_DESC_HAS_NEXT);
1717 }
1718 }
1719 else {
1720 if (orderByComparator.isAscending() ^ previous) {
1721 query.append(ORDER_BY_ASC);
1722 }
1723 else {
1724 query.append(ORDER_BY_DESC);
1725 }
1726 }
1727 }
1728 }
1729
1730 else {
1731 query.append(RoleModelImpl.ORDER_BY_JPQL);
1732 }
1733
1734 String sql = query.toString();
1735
1736 Query q = session.createQuery(sql);
1737
1738 q.setFirstResult(0);
1739 q.setMaxResults(2);
1740
1741 QueryPos qPos = QueryPos.getInstance(q);
1742
1743 qPos.add(type);
1744
1745 if (subtype != null) {
1746 qPos.add(subtype);
1747 }
1748
1749 if (orderByComparator != null) {
1750 Object[] values = orderByComparator.getOrderByValues(role);
1751
1752 for (Object value : values) {
1753 qPos.add(value);
1754 }
1755 }
1756
1757 List<Role> list = q.list();
1758
1759 if (list.size() == 2) {
1760 return list.get(1);
1761 }
1762 else {
1763 return null;
1764 }
1765 }
1766
1767
1777 public Role findByC_C_C(long companyId, long classNameId, long classPK)
1778 throws NoSuchRoleException, SystemException {
1779 Role role = fetchByC_C_C(companyId, classNameId, classPK);
1780
1781 if (role == null) {
1782 StringBundler msg = new StringBundler(8);
1783
1784 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1785
1786 msg.append("companyId=");
1787 msg.append(companyId);
1788
1789 msg.append(", classNameId=");
1790 msg.append(classNameId);
1791
1792 msg.append(", classPK=");
1793 msg.append(classPK);
1794
1795 msg.append(StringPool.CLOSE_CURLY_BRACE);
1796
1797 if (_log.isWarnEnabled()) {
1798 _log.warn(msg.toString());
1799 }
1800
1801 throw new NoSuchRoleException(msg.toString());
1802 }
1803
1804 return role;
1805 }
1806
1807
1816 public Role fetchByC_C_C(long companyId, long classNameId, long classPK)
1817 throws SystemException {
1818 return fetchByC_C_C(companyId, classNameId, classPK, true);
1819 }
1820
1821
1830 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
1831 boolean retrieveFromCache) throws SystemException {
1832 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
1833
1834 Object result = null;
1835
1836 if (retrieveFromCache) {
1837 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
1838 finderArgs, this);
1839 }
1840
1841 if (result == null) {
1842 Session session = null;
1843
1844 try {
1845 session = openSession();
1846
1847 StringBundler query = new StringBundler(5);
1848
1849 query.append(_SQL_SELECT_ROLE_WHERE);
1850
1851 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1852
1853 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1854
1855 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1856
1857 query.append(RoleModelImpl.ORDER_BY_JPQL);
1858
1859 String sql = query.toString();
1860
1861 Query q = session.createQuery(sql);
1862
1863 QueryPos qPos = QueryPos.getInstance(q);
1864
1865 qPos.add(companyId);
1866
1867 qPos.add(classNameId);
1868
1869 qPos.add(classPK);
1870
1871 List<Role> list = q.list();
1872
1873 result = list;
1874
1875 Role role = null;
1876
1877 if (list.isEmpty()) {
1878 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1879 finderArgs, list);
1880 }
1881 else {
1882 role = list.get(0);
1883
1884 cacheResult(role);
1885
1886 if ((role.getCompanyId() != companyId) ||
1887 (role.getClassNameId() != classNameId) ||
1888 (role.getClassPK() != classPK)) {
1889 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1890 finderArgs, role);
1891 }
1892 }
1893
1894 return role;
1895 }
1896 catch (Exception e) {
1897 throw processException(e);
1898 }
1899 finally {
1900 if (result == null) {
1901 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1902 finderArgs, new ArrayList<Role>());
1903 }
1904
1905 closeSession(session);
1906 }
1907 }
1908 else {
1909 if (result instanceof List<?>) {
1910 return null;
1911 }
1912 else {
1913 return (Role)result;
1914 }
1915 }
1916 }
1917
1918
1924 public List<Role> findAll() throws SystemException {
1925 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1926 }
1927
1928
1940 public List<Role> findAll(int start, int end) throws SystemException {
1941 return findAll(start, end, null);
1942 }
1943
1944
1957 public List<Role> findAll(int start, int end,
1958 OrderByComparator orderByComparator) throws SystemException {
1959 Object[] finderArgs = new Object[] {
1960 String.valueOf(start), String.valueOf(end),
1961 String.valueOf(orderByComparator)
1962 };
1963
1964 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1965 finderArgs, this);
1966
1967 if (list == null) {
1968 Session session = null;
1969
1970 try {
1971 session = openSession();
1972
1973 StringBundler query = null;
1974 String sql = null;
1975
1976 if (orderByComparator != null) {
1977 query = new StringBundler(2 +
1978 (orderByComparator.getOrderByFields().length * 3));
1979
1980 query.append(_SQL_SELECT_ROLE);
1981
1982 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1983 orderByComparator);
1984
1985 sql = query.toString();
1986 }
1987 else {
1988 sql = _SQL_SELECT_ROLE.concat(RoleModelImpl.ORDER_BY_JPQL);
1989 }
1990
1991 Query q = session.createQuery(sql);
1992
1993 if (orderByComparator == null) {
1994 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
1995 end, false);
1996
1997 Collections.sort(list);
1998 }
1999 else {
2000 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
2001 end);
2002 }
2003 }
2004 catch (Exception e) {
2005 throw processException(e);
2006 }
2007 finally {
2008 if (list == null) {
2009 list = new ArrayList<Role>();
2010 }
2011
2012 cacheResult(list);
2013
2014 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2015
2016 closeSession(session);
2017 }
2018 }
2019
2020 return list;
2021 }
2022
2023
2029 public void removeByCompanyId(long companyId) throws SystemException {
2030 for (Role role : findByCompanyId(companyId)) {
2031 remove(role);
2032 }
2033 }
2034
2035
2041 public void removeBySubtype(String subtype) throws SystemException {
2042 for (Role role : findBySubtype(subtype)) {
2043 remove(role);
2044 }
2045 }
2046
2047
2054 public void removeByC_N(long companyId, String name)
2055 throws NoSuchRoleException, SystemException {
2056 Role role = findByC_N(companyId, name);
2057
2058 remove(role);
2059 }
2060
2061
2068 public void removeByT_S(int type, String subtype) throws SystemException {
2069 for (Role role : findByT_S(type, subtype)) {
2070 remove(role);
2071 }
2072 }
2073
2074
2082 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2083 throws NoSuchRoleException, SystemException {
2084 Role role = findByC_C_C(companyId, classNameId, classPK);
2085
2086 remove(role);
2087 }
2088
2089
2094 public void removeAll() throws SystemException {
2095 for (Role role : findAll()) {
2096 remove(role);
2097 }
2098 }
2099
2100
2107 public int countByCompanyId(long companyId) throws SystemException {
2108 Object[] finderArgs = new Object[] { companyId };
2109
2110 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2111 finderArgs, this);
2112
2113 if (count == null) {
2114 Session session = null;
2115
2116 try {
2117 session = openSession();
2118
2119 StringBundler query = new StringBundler(2);
2120
2121 query.append(_SQL_COUNT_ROLE_WHERE);
2122
2123 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2124
2125 String sql = query.toString();
2126
2127 Query q = session.createQuery(sql);
2128
2129 QueryPos qPos = QueryPos.getInstance(q);
2130
2131 qPos.add(companyId);
2132
2133 count = (Long)q.uniqueResult();
2134 }
2135 catch (Exception e) {
2136 throw processException(e);
2137 }
2138 finally {
2139 if (count == null) {
2140 count = Long.valueOf(0);
2141 }
2142
2143 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2144 finderArgs, count);
2145
2146 closeSession(session);
2147 }
2148 }
2149
2150 return count.intValue();
2151 }
2152
2153
2160 public int countBySubtype(String subtype) throws SystemException {
2161 Object[] finderArgs = new Object[] { subtype };
2162
2163 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SUBTYPE,
2164 finderArgs, this);
2165
2166 if (count == null) {
2167 Session session = null;
2168
2169 try {
2170 session = openSession();
2171
2172 StringBundler query = new StringBundler(2);
2173
2174 query.append(_SQL_COUNT_ROLE_WHERE);
2175
2176 if (subtype == null) {
2177 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
2178 }
2179 else {
2180 if (subtype.equals(StringPool.BLANK)) {
2181 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
2182 }
2183 else {
2184 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
2185 }
2186 }
2187
2188 String sql = query.toString();
2189
2190 Query q = session.createQuery(sql);
2191
2192 QueryPos qPos = QueryPos.getInstance(q);
2193
2194 if (subtype != null) {
2195 qPos.add(subtype);
2196 }
2197
2198 count = (Long)q.uniqueResult();
2199 }
2200 catch (Exception e) {
2201 throw processException(e);
2202 }
2203 finally {
2204 if (count == null) {
2205 count = Long.valueOf(0);
2206 }
2207
2208 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SUBTYPE,
2209 finderArgs, count);
2210
2211 closeSession(session);
2212 }
2213 }
2214
2215 return count.intValue();
2216 }
2217
2218
2226 public int countByC_N(long companyId, String name)
2227 throws SystemException {
2228 Object[] finderArgs = new Object[] { companyId, name };
2229
2230 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
2231 finderArgs, this);
2232
2233 if (count == null) {
2234 Session session = null;
2235
2236 try {
2237 session = openSession();
2238
2239 StringBundler query = new StringBundler(3);
2240
2241 query.append(_SQL_COUNT_ROLE_WHERE);
2242
2243 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2244
2245 if (name == null) {
2246 query.append(_FINDER_COLUMN_C_N_NAME_1);
2247 }
2248 else {
2249 if (name.equals(StringPool.BLANK)) {
2250 query.append(_FINDER_COLUMN_C_N_NAME_3);
2251 }
2252 else {
2253 query.append(_FINDER_COLUMN_C_N_NAME_2);
2254 }
2255 }
2256
2257 String sql = query.toString();
2258
2259 Query q = session.createQuery(sql);
2260
2261 QueryPos qPos = QueryPos.getInstance(q);
2262
2263 qPos.add(companyId);
2264
2265 if (name != null) {
2266 qPos.add(name);
2267 }
2268
2269 count = (Long)q.uniqueResult();
2270 }
2271 catch (Exception e) {
2272 throw processException(e);
2273 }
2274 finally {
2275 if (count == null) {
2276 count = Long.valueOf(0);
2277 }
2278
2279 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2280 count);
2281
2282 closeSession(session);
2283 }
2284 }
2285
2286 return count.intValue();
2287 }
2288
2289
2297 public int countByT_S(int type, String subtype) throws SystemException {
2298 Object[] finderArgs = new Object[] { type, subtype };
2299
2300 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
2301 finderArgs, this);
2302
2303 if (count == null) {
2304 Session session = null;
2305
2306 try {
2307 session = openSession();
2308
2309 StringBundler query = new StringBundler(3);
2310
2311 query.append(_SQL_COUNT_ROLE_WHERE);
2312
2313 query.append(_FINDER_COLUMN_T_S_TYPE_2);
2314
2315 if (subtype == null) {
2316 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
2317 }
2318 else {
2319 if (subtype.equals(StringPool.BLANK)) {
2320 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
2321 }
2322 else {
2323 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
2324 }
2325 }
2326
2327 String sql = query.toString();
2328
2329 Query q = session.createQuery(sql);
2330
2331 QueryPos qPos = QueryPos.getInstance(q);
2332
2333 qPos.add(type);
2334
2335 if (subtype != null) {
2336 qPos.add(subtype);
2337 }
2338
2339 count = (Long)q.uniqueResult();
2340 }
2341 catch (Exception e) {
2342 throw processException(e);
2343 }
2344 finally {
2345 if (count == null) {
2346 count = Long.valueOf(0);
2347 }
2348
2349 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
2350 count);
2351
2352 closeSession(session);
2353 }
2354 }
2355
2356 return count.intValue();
2357 }
2358
2359
2368 public int countByC_C_C(long companyId, long classNameId, long classPK)
2369 throws SystemException {
2370 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2371
2372 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2373 finderArgs, this);
2374
2375 if (count == null) {
2376 Session session = null;
2377
2378 try {
2379 session = openSession();
2380
2381 StringBundler query = new StringBundler(4);
2382
2383 query.append(_SQL_COUNT_ROLE_WHERE);
2384
2385 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2386
2387 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2388
2389 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2390
2391 String sql = query.toString();
2392
2393 Query q = session.createQuery(sql);
2394
2395 QueryPos qPos = QueryPos.getInstance(q);
2396
2397 qPos.add(companyId);
2398
2399 qPos.add(classNameId);
2400
2401 qPos.add(classPK);
2402
2403 count = (Long)q.uniqueResult();
2404 }
2405 catch (Exception e) {
2406 throw processException(e);
2407 }
2408 finally {
2409 if (count == null) {
2410 count = Long.valueOf(0);
2411 }
2412
2413 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2414 finderArgs, count);
2415
2416 closeSession(session);
2417 }
2418 }
2419
2420 return count.intValue();
2421 }
2422
2423
2429 public int countAll() throws SystemException {
2430 Object[] finderArgs = new Object[0];
2431
2432 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2433 finderArgs, this);
2434
2435 if (count == null) {
2436 Session session = null;
2437
2438 try {
2439 session = openSession();
2440
2441 Query q = session.createQuery(_SQL_COUNT_ROLE);
2442
2443 count = (Long)q.uniqueResult();
2444 }
2445 catch (Exception e) {
2446 throw processException(e);
2447 }
2448 finally {
2449 if (count == null) {
2450 count = Long.valueOf(0);
2451 }
2452
2453 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2454 count);
2455
2456 closeSession(session);
2457 }
2458 }
2459
2460 return count.intValue();
2461 }
2462
2463
2470 public List<com.liferay.portal.model.Group> getGroups(long pk)
2471 throws SystemException {
2472 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2473 }
2474
2475
2488 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2489 int end) throws SystemException {
2490 return getGroups(pk, start, end, null);
2491 }
2492
2493 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2494 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
2495 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroups",
2496 new String[] {
2497 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2498 "com.liferay.portal.kernel.util.OrderByComparator"
2499 });
2500
2501
2515 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2516 int end, OrderByComparator orderByComparator) throws SystemException {
2517 Object[] finderArgs = new Object[] {
2518 pk, String.valueOf(start), String.valueOf(end),
2519 String.valueOf(orderByComparator)
2520 };
2521
2522 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
2523 finderArgs, this);
2524
2525 if (list == null) {
2526 Session session = null;
2527
2528 try {
2529 session = openSession();
2530
2531 String sql = null;
2532
2533 if (orderByComparator != null) {
2534 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
2535 .concat(orderByComparator.getOrderBy());
2536 }
2537 else {
2538 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
2539 }
2540
2541 SQLQuery q = session.createSQLQuery(sql);
2542
2543 q.addEntity("Group_",
2544 com.liferay.portal.model.impl.GroupImpl.class);
2545
2546 QueryPos qPos = QueryPos.getInstance(q);
2547
2548 qPos.add(pk);
2549
2550 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
2551 getDialect(), start, end);
2552 }
2553 catch (Exception e) {
2554 throw processException(e);
2555 }
2556 finally {
2557 if (list == null) {
2558 list = new ArrayList<com.liferay.portal.model.Group>();
2559 }
2560
2561 groupPersistence.cacheResult(list);
2562
2563 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
2564 list);
2565
2566 closeSession(session);
2567 }
2568 }
2569
2570 return list;
2571 }
2572
2573 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2574 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
2575 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroupsSize",
2576 new String[] { Long.class.getName() });
2577
2578
2585 public int getGroupsSize(long pk) throws SystemException {
2586 Object[] finderArgs = new Object[] { pk };
2587
2588 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
2589 finderArgs, this);
2590
2591 if (count == null) {
2592 Session session = null;
2593
2594 try {
2595 session = openSession();
2596
2597 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2598
2599 q.addScalar(COUNT_COLUMN_NAME,
2600 com.liferay.portal.kernel.dao.orm.Type.LONG);
2601
2602 QueryPos qPos = QueryPos.getInstance(q);
2603
2604 qPos.add(pk);
2605
2606 count = (Long)q.uniqueResult();
2607 }
2608 catch (Exception e) {
2609 throw processException(e);
2610 }
2611 finally {
2612 if (count == null) {
2613 count = Long.valueOf(0);
2614 }
2615
2616 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
2617 finderArgs, count);
2618
2619 closeSession(session);
2620 }
2621 }
2622
2623 return count.intValue();
2624 }
2625
2626 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2627 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
2628 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsGroup",
2629 new String[] { Long.class.getName(), Long.class.getName() });
2630
2631
2639 public boolean containsGroup(long pk, long groupPK)
2640 throws SystemException {
2641 Object[] finderArgs = new Object[] { pk, groupPK };
2642
2643 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
2644 finderArgs, this);
2645
2646 if (value == null) {
2647 try {
2648 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
2649 }
2650 catch (Exception e) {
2651 throw processException(e);
2652 }
2653 finally {
2654 if (value == null) {
2655 value = Boolean.FALSE;
2656 }
2657
2658 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
2659 finderArgs, value);
2660 }
2661 }
2662
2663 return value.booleanValue();
2664 }
2665
2666
2673 public boolean containsGroups(long pk) throws SystemException {
2674 if (getGroupsSize(pk) > 0) {
2675 return true;
2676 }
2677 else {
2678 return false;
2679 }
2680 }
2681
2682
2689 public void addGroup(long pk, long groupPK) throws SystemException {
2690 try {
2691 addGroup.add(pk, groupPK);
2692 }
2693 catch (Exception e) {
2694 throw processException(e);
2695 }
2696 finally {
2697 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2698 }
2699 }
2700
2701
2708 public void addGroup(long pk, com.liferay.portal.model.Group group)
2709 throws SystemException {
2710 try {
2711 addGroup.add(pk, group.getPrimaryKey());
2712 }
2713 catch (Exception e) {
2714 throw processException(e);
2715 }
2716 finally {
2717 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2718 }
2719 }
2720
2721
2728 public void addGroups(long pk, long[] groupPKs) throws SystemException {
2729 try {
2730 for (long groupPK : groupPKs) {
2731 addGroup.add(pk, groupPK);
2732 }
2733 }
2734 catch (Exception e) {
2735 throw processException(e);
2736 }
2737 finally {
2738 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2739 }
2740 }
2741
2742
2749 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
2750 throws SystemException {
2751 try {
2752 for (com.liferay.portal.model.Group group : groups) {
2753 addGroup.add(pk, group.getPrimaryKey());
2754 }
2755 }
2756 catch (Exception e) {
2757 throw processException(e);
2758 }
2759 finally {
2760 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2761 }
2762 }
2763
2764
2770 public void clearGroups(long pk) throws SystemException {
2771 try {
2772 clearGroups.clear(pk);
2773 }
2774 catch (Exception e) {
2775 throw processException(e);
2776 }
2777 finally {
2778 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2779 }
2780 }
2781
2782
2789 public void removeGroup(long pk, long groupPK) throws SystemException {
2790 try {
2791 removeGroup.remove(pk, groupPK);
2792 }
2793 catch (Exception e) {
2794 throw processException(e);
2795 }
2796 finally {
2797 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2798 }
2799 }
2800
2801
2808 public void removeGroup(long pk, com.liferay.portal.model.Group group)
2809 throws SystemException {
2810 try {
2811 removeGroup.remove(pk, group.getPrimaryKey());
2812 }
2813 catch (Exception e) {
2814 throw processException(e);
2815 }
2816 finally {
2817 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2818 }
2819 }
2820
2821
2828 public void removeGroups(long pk, long[] groupPKs)
2829 throws SystemException {
2830 try {
2831 for (long groupPK : groupPKs) {
2832 removeGroup.remove(pk, groupPK);
2833 }
2834 }
2835 catch (Exception e) {
2836 throw processException(e);
2837 }
2838 finally {
2839 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2840 }
2841 }
2842
2843
2850 public void removeGroups(long pk,
2851 List<com.liferay.portal.model.Group> groups) throws SystemException {
2852 try {
2853 for (com.liferay.portal.model.Group group : groups) {
2854 removeGroup.remove(pk, group.getPrimaryKey());
2855 }
2856 }
2857 catch (Exception e) {
2858 throw processException(e);
2859 }
2860 finally {
2861 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2862 }
2863 }
2864
2865
2872 public void setGroups(long pk, long[] groupPKs) throws SystemException {
2873 try {
2874 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
2875
2876 List<com.liferay.portal.model.Group> groups = getGroups(pk);
2877
2878 for (com.liferay.portal.model.Group group : groups) {
2879 if (!groupPKSet.remove(group.getPrimaryKey())) {
2880 removeGroup.remove(pk, group.getPrimaryKey());
2881 }
2882 }
2883
2884 for (Long groupPK : groupPKSet) {
2885 addGroup.add(pk, groupPK);
2886 }
2887 }
2888 catch (Exception e) {
2889 throw processException(e);
2890 }
2891 finally {
2892 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2893 }
2894 }
2895
2896
2903 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
2904 throws SystemException {
2905 try {
2906 long[] groupPKs = new long[groups.size()];
2907
2908 for (int i = 0; i < groups.size(); i++) {
2909 com.liferay.portal.model.Group group = groups.get(i);
2910
2911 groupPKs[i] = group.getPrimaryKey();
2912 }
2913
2914 setGroups(pk, groupPKs);
2915 }
2916 catch (Exception e) {
2917 throw processException(e);
2918 }
2919 finally {
2920 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2921 }
2922 }
2923
2924
2931 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
2932 throws SystemException {
2933 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2934 }
2935
2936
2949 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2950 int start, int end) throws SystemException {
2951 return getPermissions(pk, start, end, null);
2952 }
2953
2954 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2955 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
2956 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
2957 "getPermissions",
2958 new String[] {
2959 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2960 "com.liferay.portal.kernel.util.OrderByComparator"
2961 });
2962
2963
2977 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2978 int start, int end, OrderByComparator orderByComparator)
2979 throws SystemException {
2980 Object[] finderArgs = new Object[] {
2981 pk, String.valueOf(start), String.valueOf(end),
2982 String.valueOf(orderByComparator)
2983 };
2984
2985 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
2986 finderArgs, this);
2987
2988 if (list == null) {
2989 Session session = null;
2990
2991 try {
2992 session = openSession();
2993
2994 String sql = null;
2995
2996 if (orderByComparator != null) {
2997 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
2998 .concat(orderByComparator.getOrderBy());
2999 }
3000 else {
3001 sql = _SQL_GETPERMISSIONS;
3002 }
3003
3004 SQLQuery q = session.createSQLQuery(sql);
3005
3006 q.addEntity("Permission_",
3007 com.liferay.portal.model.impl.PermissionImpl.class);
3008
3009 QueryPos qPos = QueryPos.getInstance(q);
3010
3011 qPos.add(pk);
3012
3013 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
3014 getDialect(), start, end);
3015 }
3016 catch (Exception e) {
3017 throw processException(e);
3018 }
3019 finally {
3020 if (list == null) {
3021 list = new ArrayList<com.liferay.portal.model.Permission>();
3022 }
3023
3024 permissionPersistence.cacheResult(list);
3025
3026 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
3027 finderArgs, list);
3028
3029 closeSession(session);
3030 }
3031 }
3032
3033 return list;
3034 }
3035
3036 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3037 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
3038 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
3039 "getPermissionsSize", new String[] { Long.class.getName() });
3040
3041
3048 public int getPermissionsSize(long pk) throws SystemException {
3049 Object[] finderArgs = new Object[] { pk };
3050
3051 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3052 finderArgs, this);
3053
3054 if (count == null) {
3055 Session session = null;
3056
3057 try {
3058 session = openSession();
3059
3060 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3061
3062 q.addScalar(COUNT_COLUMN_NAME,
3063 com.liferay.portal.kernel.dao.orm.Type.LONG);
3064
3065 QueryPos qPos = QueryPos.getInstance(q);
3066
3067 qPos.add(pk);
3068
3069 count = (Long)q.uniqueResult();
3070 }
3071 catch (Exception e) {
3072 throw processException(e);
3073 }
3074 finally {
3075 if (count == null) {
3076 count = Long.valueOf(0);
3077 }
3078
3079 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3080 finderArgs, count);
3081
3082 closeSession(session);
3083 }
3084 }
3085
3086 return count.intValue();
3087 }
3088
3089 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3090 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
3091 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
3092 "containsPermission",
3093 new String[] { Long.class.getName(), Long.class.getName() });
3094
3095
3103 public boolean containsPermission(long pk, long permissionPK)
3104 throws SystemException {
3105 Object[] finderArgs = new Object[] { pk, permissionPK };
3106
3107 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
3108 finderArgs, this);
3109
3110 if (value == null) {
3111 try {
3112 value = Boolean.valueOf(containsPermission.contains(pk,
3113 permissionPK));
3114 }
3115 catch (Exception e) {
3116 throw processException(e);
3117 }
3118 finally {
3119 if (value == null) {
3120 value = Boolean.FALSE;
3121 }
3122
3123 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
3124 finderArgs, value);
3125 }
3126 }
3127
3128 return value.booleanValue();
3129 }
3130
3131
3138 public boolean containsPermissions(long pk) throws SystemException {
3139 if (getPermissionsSize(pk) > 0) {
3140 return true;
3141 }
3142 else {
3143 return false;
3144 }
3145 }
3146
3147
3154 public void addPermission(long pk, long permissionPK)
3155 throws SystemException {
3156 try {
3157 addPermission.add(pk, permissionPK);
3158 }
3159 catch (Exception e) {
3160 throw processException(e);
3161 }
3162 finally {
3163 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3164 }
3165 }
3166
3167
3174 public void addPermission(long pk,
3175 com.liferay.portal.model.Permission permission)
3176 throws SystemException {
3177 try {
3178 addPermission.add(pk, permission.getPrimaryKey());
3179 }
3180 catch (Exception e) {
3181 throw processException(e);
3182 }
3183 finally {
3184 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3185 }
3186 }
3187
3188
3195 public void addPermissions(long pk, long[] permissionPKs)
3196 throws SystemException {
3197 try {
3198 for (long permissionPK : permissionPKs) {
3199 addPermission.add(pk, permissionPK);
3200 }
3201 }
3202 catch (Exception e) {
3203 throw processException(e);
3204 }
3205 finally {
3206 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3207 }
3208 }
3209
3210
3217 public void addPermissions(long pk,
3218 List<com.liferay.portal.model.Permission> permissions)
3219 throws SystemException {
3220 try {
3221 for (com.liferay.portal.model.Permission permission : permissions) {
3222 addPermission.add(pk, permission.getPrimaryKey());
3223 }
3224 }
3225 catch (Exception e) {
3226 throw processException(e);
3227 }
3228 finally {
3229 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3230 }
3231 }
3232
3233
3239 public void clearPermissions(long pk) throws SystemException {
3240 try {
3241 clearPermissions.clear(pk);
3242 }
3243 catch (Exception e) {
3244 throw processException(e);
3245 }
3246 finally {
3247 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3248 }
3249 }
3250
3251
3258 public void removePermission(long pk, long permissionPK)
3259 throws SystemException {
3260 try {
3261 removePermission.remove(pk, permissionPK);
3262 }
3263 catch (Exception e) {
3264 throw processException(e);
3265 }
3266 finally {
3267 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3268 }
3269 }
3270
3271
3278 public void removePermission(long pk,
3279 com.liferay.portal.model.Permission permission)
3280 throws SystemException {
3281 try {
3282 removePermission.remove(pk, permission.getPrimaryKey());
3283 }
3284 catch (Exception e) {
3285 throw processException(e);
3286 }
3287 finally {
3288 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3289 }
3290 }
3291
3292
3299 public void removePermissions(long pk, long[] permissionPKs)
3300 throws SystemException {
3301 try {
3302 for (long permissionPK : permissionPKs) {
3303 removePermission.remove(pk, permissionPK);
3304 }
3305 }
3306 catch (Exception e) {
3307 throw processException(e);
3308 }
3309 finally {
3310 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3311 }
3312 }
3313
3314
3321 public void removePermissions(long pk,
3322 List<com.liferay.portal.model.Permission> permissions)
3323 throws SystemException {
3324 try {
3325 for (com.liferay.portal.model.Permission permission : permissions) {
3326 removePermission.remove(pk, permission.getPrimaryKey());
3327 }
3328 }
3329 catch (Exception e) {
3330 throw processException(e);
3331 }
3332 finally {
3333 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3334 }
3335 }
3336
3337
3344 public void setPermissions(long pk, long[] permissionPKs)
3345 throws SystemException {
3346 try {
3347 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
3348
3349 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
3350
3351 for (com.liferay.portal.model.Permission permission : permissions) {
3352 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
3353 removePermission.remove(pk, permission.getPrimaryKey());
3354 }
3355 }
3356
3357 for (Long permissionPK : permissionPKSet) {
3358 addPermission.add(pk, permissionPK);
3359 }
3360 }
3361 catch (Exception e) {
3362 throw processException(e);
3363 }
3364 finally {
3365 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3366 }
3367 }
3368
3369
3376 public void setPermissions(long pk,
3377 List<com.liferay.portal.model.Permission> permissions)
3378 throws SystemException {
3379 try {
3380 long[] permissionPKs = new long[permissions.size()];
3381
3382 for (int i = 0; i < permissions.size(); i++) {
3383 com.liferay.portal.model.Permission permission = permissions.get(i);
3384
3385 permissionPKs[i] = permission.getPrimaryKey();
3386 }
3387
3388 setPermissions(pk, permissionPKs);
3389 }
3390 catch (Exception e) {
3391 throw processException(e);
3392 }
3393 finally {
3394 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
3395 }
3396 }
3397
3398
3405 public List<com.liferay.portal.model.User> getUsers(long pk)
3406 throws SystemException {
3407 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3408 }
3409
3410
3423 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3424 int end) throws SystemException {
3425 return getUsers(pk, start, end, null);
3426 }
3427
3428 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3429 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
3430 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsers",
3431 new String[] {
3432 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3433 "com.liferay.portal.kernel.util.OrderByComparator"
3434 });
3435
3436
3450 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3451 int end, OrderByComparator orderByComparator) throws SystemException {
3452 Object[] finderArgs = new Object[] {
3453 pk, String.valueOf(start), String.valueOf(end),
3454 String.valueOf(orderByComparator)
3455 };
3456
3457 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
3458 finderArgs, this);
3459
3460 if (list == null) {
3461 Session session = null;
3462
3463 try {
3464 session = openSession();
3465
3466 String sql = null;
3467
3468 if (orderByComparator != null) {
3469 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
3470 .concat(orderByComparator.getOrderBy());
3471 }
3472 else {
3473 sql = _SQL_GETUSERS;
3474 }
3475
3476 SQLQuery q = session.createSQLQuery(sql);
3477
3478 q.addEntity("User_",
3479 com.liferay.portal.model.impl.UserImpl.class);
3480
3481 QueryPos qPos = QueryPos.getInstance(q);
3482
3483 qPos.add(pk);
3484
3485 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
3486 getDialect(), start, end);
3487 }
3488 catch (Exception e) {
3489 throw processException(e);
3490 }
3491 finally {
3492 if (list == null) {
3493 list = new ArrayList<com.liferay.portal.model.User>();
3494 }
3495
3496 userPersistence.cacheResult(list);
3497
3498 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
3499 list);
3500
3501 closeSession(session);
3502 }
3503 }
3504
3505 return list;
3506 }
3507
3508 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3509 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
3510 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsersSize",
3511 new String[] { Long.class.getName() });
3512
3513
3520 public int getUsersSize(long pk) throws SystemException {
3521 Object[] finderArgs = new Object[] { pk };
3522
3523 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
3524 finderArgs, this);
3525
3526 if (count == null) {
3527 Session session = null;
3528
3529 try {
3530 session = openSession();
3531
3532 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
3533
3534 q.addScalar(COUNT_COLUMN_NAME,
3535 com.liferay.portal.kernel.dao.orm.Type.LONG);
3536
3537 QueryPos qPos = QueryPos.getInstance(q);
3538
3539 qPos.add(pk);
3540
3541 count = (Long)q.uniqueResult();
3542 }
3543 catch (Exception e) {
3544 throw processException(e);
3545 }
3546 finally {
3547 if (count == null) {
3548 count = Long.valueOf(0);
3549 }
3550
3551 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
3552 finderArgs, count);
3553
3554 closeSession(session);
3555 }
3556 }
3557
3558 return count.intValue();
3559 }
3560
3561 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3562 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
3563 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsUser",
3564 new String[] { Long.class.getName(), Long.class.getName() });
3565
3566
3574 public boolean containsUser(long pk, long userPK) throws SystemException {
3575 Object[] finderArgs = new Object[] { pk, userPK };
3576
3577 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
3578 finderArgs, this);
3579
3580 if (value == null) {
3581 try {
3582 value = Boolean.valueOf(containsUser.contains(pk, userPK));
3583 }
3584 catch (Exception e) {
3585 throw processException(e);
3586 }
3587 finally {
3588 if (value == null) {
3589 value = Boolean.FALSE;
3590 }
3591
3592 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
3593 finderArgs, value);
3594 }
3595 }
3596
3597 return value.booleanValue();
3598 }
3599
3600
3607 public boolean containsUsers(long pk) throws SystemException {
3608 if (getUsersSize(pk) > 0) {
3609 return true;
3610 }
3611 else {
3612 return false;
3613 }
3614 }
3615
3616
3623 public void addUser(long pk, long userPK) throws SystemException {
3624 try {
3625 addUser.add(pk, userPK);
3626 }
3627 catch (Exception e) {
3628 throw processException(e);
3629 }
3630 finally {
3631 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3632 }
3633 }
3634
3635
3642 public void addUser(long pk, com.liferay.portal.model.User user)
3643 throws SystemException {
3644 try {
3645 addUser.add(pk, user.getPrimaryKey());
3646 }
3647 catch (Exception e) {
3648 throw processException(e);
3649 }
3650 finally {
3651 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3652 }
3653 }
3654
3655
3662 public void addUsers(long pk, long[] userPKs) throws SystemException {
3663 try {
3664 for (long userPK : userPKs) {
3665 addUser.add(pk, userPK);
3666 }
3667 }
3668 catch (Exception e) {
3669 throw processException(e);
3670 }
3671 finally {
3672 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3673 }
3674 }
3675
3676
3683 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
3684 throws SystemException {
3685 try {
3686 for (com.liferay.portal.model.User user : users) {
3687 addUser.add(pk, user.getPrimaryKey());
3688 }
3689 }
3690 catch (Exception e) {
3691 throw processException(e);
3692 }
3693 finally {
3694 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3695 }
3696 }
3697
3698
3704 public void clearUsers(long pk) throws SystemException {
3705 try {
3706 clearUsers.clear(pk);
3707 }
3708 catch (Exception e) {
3709 throw processException(e);
3710 }
3711 finally {
3712 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3713 }
3714 }
3715
3716
3723 public void removeUser(long pk, long userPK) throws SystemException {
3724 try {
3725 removeUser.remove(pk, userPK);
3726 }
3727 catch (Exception e) {
3728 throw processException(e);
3729 }
3730 finally {
3731 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3732 }
3733 }
3734
3735
3742 public void removeUser(long pk, com.liferay.portal.model.User user)
3743 throws SystemException {
3744 try {
3745 removeUser.remove(pk, user.getPrimaryKey());
3746 }
3747 catch (Exception e) {
3748 throw processException(e);
3749 }
3750 finally {
3751 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3752 }
3753 }
3754
3755
3762 public void removeUsers(long pk, long[] userPKs) throws SystemException {
3763 try {
3764 for (long userPK : userPKs) {
3765 removeUser.remove(pk, userPK);
3766 }
3767 }
3768 catch (Exception e) {
3769 throw processException(e);
3770 }
3771 finally {
3772 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3773 }
3774 }
3775
3776
3783 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
3784 throws SystemException {
3785 try {
3786 for (com.liferay.portal.model.User user : users) {
3787 removeUser.remove(pk, user.getPrimaryKey());
3788 }
3789 }
3790 catch (Exception e) {
3791 throw processException(e);
3792 }
3793 finally {
3794 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3795 }
3796 }
3797
3798
3805 public void setUsers(long pk, long[] userPKs) throws SystemException {
3806 try {
3807 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
3808
3809 List<com.liferay.portal.model.User> users = getUsers(pk);
3810
3811 for (com.liferay.portal.model.User user : users) {
3812 if (!userPKSet.remove(user.getPrimaryKey())) {
3813 removeUser.remove(pk, user.getPrimaryKey());
3814 }
3815 }
3816
3817 for (Long userPK : userPKSet) {
3818 addUser.add(pk, userPK);
3819 }
3820 }
3821 catch (Exception e) {
3822 throw processException(e);
3823 }
3824 finally {
3825 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3826 }
3827 }
3828
3829
3836 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
3837 throws SystemException {
3838 try {
3839 long[] userPKs = new long[users.size()];
3840
3841 for (int i = 0; i < users.size(); i++) {
3842 com.liferay.portal.model.User user = users.get(i);
3843
3844 userPKs[i] = user.getPrimaryKey();
3845 }
3846
3847 setUsers(pk, userPKs);
3848 }
3849 catch (Exception e) {
3850 throw processException(e);
3851 }
3852 finally {
3853 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3854 }
3855 }
3856
3857
3860 public void afterPropertiesSet() {
3861 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3862 com.liferay.portal.util.PropsUtil.get(
3863 "value.object.listener.com.liferay.portal.model.Role")));
3864
3865 if (listenerClassNames.length > 0) {
3866 try {
3867 List<ModelListener<Role>> listenersList = new ArrayList<ModelListener<Role>>();
3868
3869 for (String listenerClassName : listenerClassNames) {
3870 listenersList.add((ModelListener<Role>)InstanceFactory.newInstance(
3871 listenerClassName));
3872 }
3873
3874 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3875 }
3876 catch (Exception e) {
3877 _log.error(e);
3878 }
3879 }
3880
3881 containsGroup = new ContainsGroup(this);
3882
3883 addGroup = new AddGroup(this);
3884 clearGroups = new ClearGroups(this);
3885 removeGroup = new RemoveGroup(this);
3886
3887 containsPermission = new ContainsPermission(this);
3888
3889 addPermission = new AddPermission(this);
3890 clearPermissions = new ClearPermissions(this);
3891 removePermission = new RemovePermission(this);
3892
3893 containsUser = new ContainsUser(this);
3894
3895 addUser = new AddUser(this);
3896 clearUsers = new ClearUsers(this);
3897 removeUser = new RemoveUser(this);
3898 }
3899
3900 @BeanReference(type = AccountPersistence.class)
3901 protected AccountPersistence accountPersistence;
3902 @BeanReference(type = AddressPersistence.class)
3903 protected AddressPersistence addressPersistence;
3904 @BeanReference(type = BrowserTrackerPersistence.class)
3905 protected BrowserTrackerPersistence browserTrackerPersistence;
3906 @BeanReference(type = ClassNamePersistence.class)
3907 protected ClassNamePersistence classNamePersistence;
3908 @BeanReference(type = ClusterGroupPersistence.class)
3909 protected ClusterGroupPersistence clusterGroupPersistence;
3910 @BeanReference(type = CompanyPersistence.class)
3911 protected CompanyPersistence companyPersistence;
3912 @BeanReference(type = ContactPersistence.class)
3913 protected ContactPersistence contactPersistence;
3914 @BeanReference(type = CountryPersistence.class)
3915 protected CountryPersistence countryPersistence;
3916 @BeanReference(type = EmailAddressPersistence.class)
3917 protected EmailAddressPersistence emailAddressPersistence;
3918 @BeanReference(type = GroupPersistence.class)
3919 protected GroupPersistence groupPersistence;
3920 @BeanReference(type = ImagePersistence.class)
3921 protected ImagePersistence imagePersistence;
3922 @BeanReference(type = LayoutPersistence.class)
3923 protected LayoutPersistence layoutPersistence;
3924 @BeanReference(type = LayoutPrototypePersistence.class)
3925 protected LayoutPrototypePersistence layoutPrototypePersistence;
3926 @BeanReference(type = LayoutSetPersistence.class)
3927 protected LayoutSetPersistence layoutSetPersistence;
3928 @BeanReference(type = LayoutSetPrototypePersistence.class)
3929 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3930 @BeanReference(type = ListTypePersistence.class)
3931 protected ListTypePersistence listTypePersistence;
3932 @BeanReference(type = LockPersistence.class)
3933 protected LockPersistence lockPersistence;
3934 @BeanReference(type = MembershipRequestPersistence.class)
3935 protected MembershipRequestPersistence membershipRequestPersistence;
3936 @BeanReference(type = OrganizationPersistence.class)
3937 protected OrganizationPersistence organizationPersistence;
3938 @BeanReference(type = OrgGroupPermissionPersistence.class)
3939 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3940 @BeanReference(type = OrgGroupRolePersistence.class)
3941 protected OrgGroupRolePersistence orgGroupRolePersistence;
3942 @BeanReference(type = OrgLaborPersistence.class)
3943 protected OrgLaborPersistence orgLaborPersistence;
3944 @BeanReference(type = PasswordPolicyPersistence.class)
3945 protected PasswordPolicyPersistence passwordPolicyPersistence;
3946 @BeanReference(type = PasswordPolicyRelPersistence.class)
3947 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3948 @BeanReference(type = PasswordTrackerPersistence.class)
3949 protected PasswordTrackerPersistence passwordTrackerPersistence;
3950 @BeanReference(type = PermissionPersistence.class)
3951 protected PermissionPersistence permissionPersistence;
3952 @BeanReference(type = PhonePersistence.class)
3953 protected PhonePersistence phonePersistence;
3954 @BeanReference(type = PluginSettingPersistence.class)
3955 protected PluginSettingPersistence pluginSettingPersistence;
3956 @BeanReference(type = PortletPersistence.class)
3957 protected PortletPersistence portletPersistence;
3958 @BeanReference(type = PortletItemPersistence.class)
3959 protected PortletItemPersistence portletItemPersistence;
3960 @BeanReference(type = PortletPreferencesPersistence.class)
3961 protected PortletPreferencesPersistence portletPreferencesPersistence;
3962 @BeanReference(type = RegionPersistence.class)
3963 protected RegionPersistence regionPersistence;
3964 @BeanReference(type = ReleasePersistence.class)
3965 protected ReleasePersistence releasePersistence;
3966 @BeanReference(type = ResourcePersistence.class)
3967 protected ResourcePersistence resourcePersistence;
3968 @BeanReference(type = ResourceActionPersistence.class)
3969 protected ResourceActionPersistence resourceActionPersistence;
3970 @BeanReference(type = ResourceCodePersistence.class)
3971 protected ResourceCodePersistence resourceCodePersistence;
3972 @BeanReference(type = ResourcePermissionPersistence.class)
3973 protected ResourcePermissionPersistence resourcePermissionPersistence;
3974 @BeanReference(type = RolePersistence.class)
3975 protected RolePersistence rolePersistence;
3976 @BeanReference(type = ServiceComponentPersistence.class)
3977 protected ServiceComponentPersistence serviceComponentPersistence;
3978 @BeanReference(type = ShardPersistence.class)
3979 protected ShardPersistence shardPersistence;
3980 @BeanReference(type = SubscriptionPersistence.class)
3981 protected SubscriptionPersistence subscriptionPersistence;
3982 @BeanReference(type = TicketPersistence.class)
3983 protected TicketPersistence ticketPersistence;
3984 @BeanReference(type = TeamPersistence.class)
3985 protected TeamPersistence teamPersistence;
3986 @BeanReference(type = UserPersistence.class)
3987 protected UserPersistence userPersistence;
3988 @BeanReference(type = UserGroupPersistence.class)
3989 protected UserGroupPersistence userGroupPersistence;
3990 @BeanReference(type = UserGroupGroupRolePersistence.class)
3991 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3992 @BeanReference(type = UserGroupRolePersistence.class)
3993 protected UserGroupRolePersistence userGroupRolePersistence;
3994 @BeanReference(type = UserIdMapperPersistence.class)
3995 protected UserIdMapperPersistence userIdMapperPersistence;
3996 @BeanReference(type = UserTrackerPersistence.class)
3997 protected UserTrackerPersistence userTrackerPersistence;
3998 @BeanReference(type = UserTrackerPathPersistence.class)
3999 protected UserTrackerPathPersistence userTrackerPathPersistence;
4000 @BeanReference(type = WebDAVPropsPersistence.class)
4001 protected WebDAVPropsPersistence webDAVPropsPersistence;
4002 @BeanReference(type = WebsitePersistence.class)
4003 protected WebsitePersistence websitePersistence;
4004 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4005 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4006 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4007 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4008 protected ContainsGroup containsGroup;
4009 protected AddGroup addGroup;
4010 protected ClearGroups clearGroups;
4011 protected RemoveGroup removeGroup;
4012 protected ContainsPermission containsPermission;
4013 protected AddPermission addPermission;
4014 protected ClearPermissions clearPermissions;
4015 protected RemovePermission removePermission;
4016 protected ContainsUser containsUser;
4017 protected AddUser addUser;
4018 protected ClearUsers clearUsers;
4019 protected RemoveUser removeUser;
4020
4021 protected class ContainsGroup {
4022 protected ContainsGroup(RolePersistenceImpl persistenceImpl) {
4023 super();
4024
4025 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4026 _SQL_CONTAINSGROUP,
4027 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4028 RowMapper.COUNT);
4029 }
4030
4031 protected boolean contains(long roleId, long groupId) {
4032 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4033 new Long(roleId), new Long(groupId)
4034 });
4035
4036 if (results.size() > 0) {
4037 Integer count = results.get(0);
4038
4039 if (count.intValue() > 0) {
4040 return true;
4041 }
4042 }
4043
4044 return false;
4045 }
4046
4047 private MappingSqlQuery<Integer> _mappingSqlQuery;
4048 }
4049
4050 protected class AddGroup {
4051 protected AddGroup(RolePersistenceImpl persistenceImpl) {
4052 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4053 "INSERT INTO Groups_Roles (roleId, groupId) VALUES (?, ?)",
4054 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4055 _persistenceImpl = persistenceImpl;
4056 }
4057
4058 protected void add(long roleId, long groupId) throws SystemException {
4059 if (!_persistenceImpl.containsGroup.contains(roleId, groupId)) {
4060 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4061
4062 for (ModelListener<Role> listener : listeners) {
4063 listener.onBeforeAddAssociation(roleId,
4064 com.liferay.portal.model.Group.class.getName(), groupId);
4065 }
4066
4067 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4068 listener.onBeforeAddAssociation(groupId,
4069 Role.class.getName(), roleId);
4070 }
4071
4072 _sqlUpdate.update(new Object[] {
4073 new Long(roleId), new Long(groupId)
4074 });
4075
4076 for (ModelListener<Role> listener : listeners) {
4077 listener.onAfterAddAssociation(roleId,
4078 com.liferay.portal.model.Group.class.getName(), groupId);
4079 }
4080
4081 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4082 listener.onAfterAddAssociation(groupId,
4083 Role.class.getName(), roleId);
4084 }
4085 }
4086 }
4087
4088 private SqlUpdate _sqlUpdate;
4089 private RolePersistenceImpl _persistenceImpl;
4090 }
4091
4092 protected class ClearGroups {
4093 protected ClearGroups(RolePersistenceImpl persistenceImpl) {
4094 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4095 "DELETE FROM Groups_Roles WHERE roleId = ?",
4096 new int[] { java.sql.Types.BIGINT });
4097 }
4098
4099 protected void clear(long roleId) throws SystemException {
4100 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4101
4102 List<com.liferay.portal.model.Group> groups = null;
4103
4104 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4105 groups = getGroups(roleId);
4106
4107 for (com.liferay.portal.model.Group group : groups) {
4108 for (ModelListener<Role> listener : listeners) {
4109 listener.onBeforeRemoveAssociation(roleId,
4110 com.liferay.portal.model.Group.class.getName(),
4111 group.getPrimaryKey());
4112 }
4113
4114 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4115 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
4116 Role.class.getName(), roleId);
4117 }
4118 }
4119 }
4120
4121 _sqlUpdate.update(new Object[] { new Long(roleId) });
4122
4123 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4124 for (com.liferay.portal.model.Group group : groups) {
4125 for (ModelListener<Role> listener : listeners) {
4126 listener.onAfterRemoveAssociation(roleId,
4127 com.liferay.portal.model.Group.class.getName(),
4128 group.getPrimaryKey());
4129 }
4130
4131 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4132 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
4133 Role.class.getName(), roleId);
4134 }
4135 }
4136 }
4137 }
4138
4139 private SqlUpdate _sqlUpdate;
4140 }
4141
4142 protected class RemoveGroup {
4143 protected RemoveGroup(RolePersistenceImpl persistenceImpl) {
4144 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4145 "DELETE FROM Groups_Roles WHERE roleId = ? AND groupId = ?",
4146 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4147 _persistenceImpl = persistenceImpl;
4148 }
4149
4150 protected void remove(long roleId, long groupId)
4151 throws SystemException {
4152 if (_persistenceImpl.containsGroup.contains(roleId, groupId)) {
4153 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4154
4155 for (ModelListener<Role> listener : listeners) {
4156 listener.onBeforeRemoveAssociation(roleId,
4157 com.liferay.portal.model.Group.class.getName(), groupId);
4158 }
4159
4160 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4161 listener.onBeforeRemoveAssociation(groupId,
4162 Role.class.getName(), roleId);
4163 }
4164
4165 _sqlUpdate.update(new Object[] {
4166 new Long(roleId), new Long(groupId)
4167 });
4168
4169 for (ModelListener<Role> listener : listeners) {
4170 listener.onAfterRemoveAssociation(roleId,
4171 com.liferay.portal.model.Group.class.getName(), groupId);
4172 }
4173
4174 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4175 listener.onAfterRemoveAssociation(groupId,
4176 Role.class.getName(), roleId);
4177 }
4178 }
4179 }
4180
4181 private SqlUpdate _sqlUpdate;
4182 private RolePersistenceImpl _persistenceImpl;
4183 }
4184
4185 protected class ContainsPermission {
4186 protected ContainsPermission(RolePersistenceImpl persistenceImpl) {
4187 super();
4188
4189 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4190 _SQL_CONTAINSPERMISSION,
4191 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4192 RowMapper.COUNT);
4193 }
4194
4195 protected boolean contains(long roleId, long permissionId) {
4196 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4197 new Long(roleId), new Long(permissionId)
4198 });
4199
4200 if (results.size() > 0) {
4201 Integer count = results.get(0);
4202
4203 if (count.intValue() > 0) {
4204 return true;
4205 }
4206 }
4207
4208 return false;
4209 }
4210
4211 private MappingSqlQuery<Integer> _mappingSqlQuery;
4212 }
4213
4214 protected class AddPermission {
4215 protected AddPermission(RolePersistenceImpl persistenceImpl) {
4216 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4217 "INSERT INTO Roles_Permissions (roleId, permissionId) VALUES (?, ?)",
4218 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4219 _persistenceImpl = persistenceImpl;
4220 }
4221
4222 protected void add(long roleId, long permissionId)
4223 throws SystemException {
4224 if (!_persistenceImpl.containsPermission.contains(roleId,
4225 permissionId)) {
4226 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
4227 permissionPersistence.getListeners();
4228
4229 for (ModelListener<Role> listener : listeners) {
4230 listener.onBeforeAddAssociation(roleId,
4231 com.liferay.portal.model.Permission.class.getName(),
4232 permissionId);
4233 }
4234
4235 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4236 listener.onBeforeAddAssociation(permissionId,
4237 Role.class.getName(), roleId);
4238 }
4239
4240 _sqlUpdate.update(new Object[] {
4241 new Long(roleId), new Long(permissionId)
4242 });
4243
4244 for (ModelListener<Role> listener : listeners) {
4245 listener.onAfterAddAssociation(roleId,
4246 com.liferay.portal.model.Permission.class.getName(),
4247 permissionId);
4248 }
4249
4250 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4251 listener.onAfterAddAssociation(permissionId,
4252 Role.class.getName(), roleId);
4253 }
4254 }
4255 }
4256
4257 private SqlUpdate _sqlUpdate;
4258 private RolePersistenceImpl _persistenceImpl;
4259 }
4260
4261 protected class ClearPermissions {
4262 protected ClearPermissions(RolePersistenceImpl persistenceImpl) {
4263 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4264 "DELETE FROM Roles_Permissions WHERE roleId = ?",
4265 new int[] { java.sql.Types.BIGINT });
4266 }
4267
4268 protected void clear(long roleId) throws SystemException {
4269 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
4270 permissionPersistence.getListeners();
4271
4272 List<com.liferay.portal.model.Permission> permissions = null;
4273
4274 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
4275 permissions = getPermissions(roleId);
4276
4277 for (com.liferay.portal.model.Permission permission : permissions) {
4278 for (ModelListener<Role> listener : listeners) {
4279 listener.onBeforeRemoveAssociation(roleId,
4280 com.liferay.portal.model.Permission.class.getName(),
4281 permission.getPrimaryKey());
4282 }
4283
4284 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4285 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
4286 Role.class.getName(), roleId);
4287 }
4288 }
4289 }
4290
4291 _sqlUpdate.update(new Object[] { new Long(roleId) });
4292
4293 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
4294 for (com.liferay.portal.model.Permission permission : permissions) {
4295 for (ModelListener<Role> listener : listeners) {
4296 listener.onAfterRemoveAssociation(roleId,
4297 com.liferay.portal.model.Permission.class.getName(),
4298 permission.getPrimaryKey());
4299 }
4300
4301 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4302 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
4303 Role.class.getName(), roleId);
4304 }
4305 }
4306 }
4307 }
4308
4309 private SqlUpdate _sqlUpdate;
4310 }
4311
4312 protected class RemovePermission {
4313 protected RemovePermission(RolePersistenceImpl persistenceImpl) {
4314 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4315 "DELETE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?",
4316 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4317 _persistenceImpl = persistenceImpl;
4318 }
4319
4320 protected void remove(long roleId, long permissionId)
4321 throws SystemException {
4322 if (_persistenceImpl.containsPermission.contains(roleId,
4323 permissionId)) {
4324 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
4325 permissionPersistence.getListeners();
4326
4327 for (ModelListener<Role> listener : listeners) {
4328 listener.onBeforeRemoveAssociation(roleId,
4329 com.liferay.portal.model.Permission.class.getName(),
4330 permissionId);
4331 }
4332
4333 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4334 listener.onBeforeRemoveAssociation(permissionId,
4335 Role.class.getName(), roleId);
4336 }
4337
4338 _sqlUpdate.update(new Object[] {
4339 new Long(roleId), new Long(permissionId)
4340 });
4341
4342 for (ModelListener<Role> listener : listeners) {
4343 listener.onAfterRemoveAssociation(roleId,
4344 com.liferay.portal.model.Permission.class.getName(),
4345 permissionId);
4346 }
4347
4348 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
4349 listener.onAfterRemoveAssociation(permissionId,
4350 Role.class.getName(), roleId);
4351 }
4352 }
4353 }
4354
4355 private SqlUpdate _sqlUpdate;
4356 private RolePersistenceImpl _persistenceImpl;
4357 }
4358
4359 protected class ContainsUser {
4360 protected ContainsUser(RolePersistenceImpl persistenceImpl) {
4361 super();
4362
4363 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4364 _SQL_CONTAINSUSER,
4365 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4366 RowMapper.COUNT);
4367 }
4368
4369 protected boolean contains(long roleId, long userId) {
4370 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4371 new Long(roleId), new Long(userId)
4372 });
4373
4374 if (results.size() > 0) {
4375 Integer count = results.get(0);
4376
4377 if (count.intValue() > 0) {
4378 return true;
4379 }
4380 }
4381
4382 return false;
4383 }
4384
4385 private MappingSqlQuery<Integer> _mappingSqlQuery;
4386 }
4387
4388 protected class AddUser {
4389 protected AddUser(RolePersistenceImpl persistenceImpl) {
4390 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4391 "INSERT INTO Users_Roles (roleId, userId) VALUES (?, ?)",
4392 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4393 _persistenceImpl = persistenceImpl;
4394 }
4395
4396 protected void add(long roleId, long userId) throws SystemException {
4397 if (!_persistenceImpl.containsUser.contains(roleId, userId)) {
4398 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4399
4400 for (ModelListener<Role> listener : listeners) {
4401 listener.onBeforeAddAssociation(roleId,
4402 com.liferay.portal.model.User.class.getName(), userId);
4403 }
4404
4405 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4406 listener.onBeforeAddAssociation(userId,
4407 Role.class.getName(), roleId);
4408 }
4409
4410 _sqlUpdate.update(new Object[] {
4411 new Long(roleId), new Long(userId)
4412 });
4413
4414 for (ModelListener<Role> listener : listeners) {
4415 listener.onAfterAddAssociation(roleId,
4416 com.liferay.portal.model.User.class.getName(), userId);
4417 }
4418
4419 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4420 listener.onAfterAddAssociation(userId,
4421 Role.class.getName(), roleId);
4422 }
4423 }
4424 }
4425
4426 private SqlUpdate _sqlUpdate;
4427 private RolePersistenceImpl _persistenceImpl;
4428 }
4429
4430 protected class ClearUsers {
4431 protected ClearUsers(RolePersistenceImpl persistenceImpl) {
4432 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4433 "DELETE FROM Users_Roles WHERE roleId = ?",
4434 new int[] { java.sql.Types.BIGINT });
4435 }
4436
4437 protected void clear(long roleId) throws SystemException {
4438 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4439
4440 List<com.liferay.portal.model.User> users = null;
4441
4442 if ((listeners.length > 0) || (userListeners.length > 0)) {
4443 users = getUsers(roleId);
4444
4445 for (com.liferay.portal.model.User user : users) {
4446 for (ModelListener<Role> listener : listeners) {
4447 listener.onBeforeRemoveAssociation(roleId,
4448 com.liferay.portal.model.User.class.getName(),
4449 user.getPrimaryKey());
4450 }
4451
4452 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4453 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
4454 Role.class.getName(), roleId);
4455 }
4456 }
4457 }
4458
4459 _sqlUpdate.update(new Object[] { new Long(roleId) });
4460
4461 if ((listeners.length > 0) || (userListeners.length > 0)) {
4462 for (com.liferay.portal.model.User user : users) {
4463 for (ModelListener<Role> listener : listeners) {
4464 listener.onAfterRemoveAssociation(roleId,
4465 com.liferay.portal.model.User.class.getName(),
4466 user.getPrimaryKey());
4467 }
4468
4469 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4470 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
4471 Role.class.getName(), roleId);
4472 }
4473 }
4474 }
4475 }
4476
4477 private SqlUpdate _sqlUpdate;
4478 }
4479
4480 protected class RemoveUser {
4481 protected RemoveUser(RolePersistenceImpl persistenceImpl) {
4482 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4483 "DELETE FROM Users_Roles WHERE roleId = ? AND userId = ?",
4484 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4485 _persistenceImpl = persistenceImpl;
4486 }
4487
4488 protected void remove(long roleId, long userId)
4489 throws SystemException {
4490 if (_persistenceImpl.containsUser.contains(roleId, userId)) {
4491 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4492
4493 for (ModelListener<Role> listener : listeners) {
4494 listener.onBeforeRemoveAssociation(roleId,
4495 com.liferay.portal.model.User.class.getName(), userId);
4496 }
4497
4498 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4499 listener.onBeforeRemoveAssociation(userId,
4500 Role.class.getName(), roleId);
4501 }
4502
4503 _sqlUpdate.update(new Object[] {
4504 new Long(roleId), new Long(userId)
4505 });
4506
4507 for (ModelListener<Role> listener : listeners) {
4508 listener.onAfterRemoveAssociation(roleId,
4509 com.liferay.portal.model.User.class.getName(), userId);
4510 }
4511
4512 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4513 listener.onAfterRemoveAssociation(userId,
4514 Role.class.getName(), roleId);
4515 }
4516 }
4517 }
4518
4519 private SqlUpdate _sqlUpdate;
4520 private RolePersistenceImpl _persistenceImpl;
4521 }
4522
4523 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
4524 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
4525 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
4526 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
4527 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Roles ON (Groups_Roles.groupId = Group_.groupId) WHERE (Groups_Roles.roleId = ?)";
4528 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ?";
4529 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ? AND groupId = ?";
4530 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Roles_Permissions ON (Roles_Permissions.permissionId = Permission_.permissionId) WHERE (Roles_Permissions.roleId = ?)";
4531 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ?";
4532 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?";
4533 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Roles ON (Users_Roles.userId = User_.userId) WHERE (Users_Roles.roleId = ?)";
4534 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ?";
4535 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ? AND userId = ?";
4536 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
4537 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
4538 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
4539 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
4540 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
4541 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
4542 private static final String _FINDER_COLUMN_C_N_NAME_2 = "role.name = ?";
4543 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR role.name = ?)";
4544 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
4545 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
4546 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
4547 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
4548 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
4549 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
4550 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
4551 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
4552 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
4553 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
4554 private static Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
4555 }