1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchModelException;
26 import com.liferay.portal.NoSuchRoleException;
27 import com.liferay.portal.SystemException;
28 import com.liferay.portal.kernel.annotation.BeanReference;
29 import com.liferay.portal.kernel.cache.CacheRegistry;
30 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
31 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
32 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
33 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
34 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
35 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
36 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
37 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
38 import com.liferay.portal.kernel.dao.orm.FinderPath;
39 import com.liferay.portal.kernel.dao.orm.Query;
40 import com.liferay.portal.kernel.dao.orm.QueryPos;
41 import com.liferay.portal.kernel.dao.orm.QueryUtil;
42 import com.liferay.portal.kernel.dao.orm.SQLQuery;
43 import com.liferay.portal.kernel.dao.orm.Session;
44 import com.liferay.portal.kernel.dao.orm.Type;
45 import com.liferay.portal.kernel.log.Log;
46 import com.liferay.portal.kernel.log.LogFactoryUtil;
47 import com.liferay.portal.kernel.util.GetterUtil;
48 import com.liferay.portal.kernel.util.OrderByComparator;
49 import com.liferay.portal.kernel.util.SetUtil;
50 import com.liferay.portal.kernel.util.StringBundler;
51 import com.liferay.portal.kernel.util.StringPool;
52 import com.liferay.portal.kernel.util.StringUtil;
53 import com.liferay.portal.kernel.util.Validator;
54 import com.liferay.portal.model.ModelListener;
55 import com.liferay.portal.model.Role;
56 import com.liferay.portal.model.impl.RoleImpl;
57 import com.liferay.portal.model.impl.RoleModelImpl;
58 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
59
60 import java.io.Serializable;
61
62 import java.sql.Types;
63
64 import java.util.ArrayList;
65 import java.util.Collections;
66 import java.util.List;
67 import java.util.Set;
68
69
82 public class RolePersistenceImpl extends BasePersistenceImpl<Role>
83 implements RolePersistence {
84 public static final String FINDER_CLASS_NAME_ENTITY = RoleImpl.class.getName();
85 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
86 ".List";
87 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
88 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89 "findByCompanyId", new String[] { Long.class.getName() });
90 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
91 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
92 "findByCompanyId",
93 new String[] {
94 Long.class.getName(),
95
96 "java.lang.Integer", "java.lang.Integer",
97 "com.liferay.portal.kernel.util.OrderByComparator"
98 });
99 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
100 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101 "countByCompanyId", new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FIND_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
103 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104 "findBySubtype", new String[] { String.class.getName() });
105 public static final FinderPath FINDER_PATH_FIND_BY_OBC_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
106 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
107 "findBySubtype",
108 new String[] {
109 String.class.getName(),
110
111 "java.lang.Integer", "java.lang.Integer",
112 "com.liferay.portal.kernel.util.OrderByComparator"
113 });
114 public static final FinderPath FINDER_PATH_COUNT_BY_SUBTYPE = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
115 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116 "countBySubtype", new String[] { String.class.getName() });
117 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
118 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
119 "fetchByC_N",
120 new String[] { Long.class.getName(), String.class.getName() });
121 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
122 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123 "countByC_N",
124 new String[] { Long.class.getName(), String.class.getName() });
125 public static final FinderPath FINDER_PATH_FIND_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
126 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127 "findByT_S",
128 new String[] { Integer.class.getName(), String.class.getName() });
129 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
130 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131 "findByT_S",
132 new String[] {
133 Integer.class.getName(), String.class.getName(),
134
135 "java.lang.Integer", "java.lang.Integer",
136 "com.liferay.portal.kernel.util.OrderByComparator"
137 });
138 public static final FinderPath FINDER_PATH_COUNT_BY_T_S = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
139 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
140 "countByT_S",
141 new String[] { Integer.class.getName(), String.class.getName() });
142 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
143 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
144 "fetchByC_C_C",
145 new String[] {
146 Long.class.getName(), Long.class.getName(), Long.class.getName()
147 });
148 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
149 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
150 "countByC_C_C",
151 new String[] {
152 Long.class.getName(), Long.class.getName(), Long.class.getName()
153 });
154 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
155 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156 "findAll", new String[0]);
157 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RoleModelImpl.ENTITY_CACHE_ENABLED,
158 RoleModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
159 "countAll", new String[0]);
160
161 public void cacheResult(Role role) {
162 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
163 RoleImpl.class, role.getPrimaryKey(), role);
164
165 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
166 new Object[] { new Long(role.getCompanyId()), role.getName() }, role);
167
168 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
169 new Object[] {
170 new Long(role.getCompanyId()), new Long(role.getClassNameId()),
171 new Long(role.getClassPK())
172 }, role);
173 }
174
175 public void cacheResult(List<Role> roles) {
176 for (Role role : roles) {
177 if (EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
178 RoleImpl.class, role.getPrimaryKey(), this) == null) {
179 cacheResult(role);
180 }
181 }
182 }
183
184 public void clearCache() {
185 CacheRegistry.clear(RoleImpl.class.getName());
186 EntityCacheUtil.clearCache(RoleImpl.class.getName());
187 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
189 }
190
191 public Role create(long roleId) {
192 Role role = new RoleImpl();
193
194 role.setNew(true);
195 role.setPrimaryKey(roleId);
196
197 return role;
198 }
199
200 public Role remove(Serializable primaryKey)
201 throws NoSuchModelException, SystemException {
202 return remove(((Long)primaryKey).longValue());
203 }
204
205 public Role remove(long roleId) throws NoSuchRoleException, SystemException {
206 Session session = null;
207
208 try {
209 session = openSession();
210
211 Role role = (Role)session.get(RoleImpl.class, new Long(roleId));
212
213 if (role == null) {
214 if (_log.isWarnEnabled()) {
215 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
216 }
217
218 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
219 roleId);
220 }
221
222 return remove(role);
223 }
224 catch (NoSuchRoleException nsee) {
225 throw nsee;
226 }
227 catch (Exception e) {
228 throw processException(e);
229 }
230 finally {
231 closeSession(session);
232 }
233 }
234
235 public Role remove(Role role) throws SystemException {
236 for (ModelListener<Role> listener : listeners) {
237 listener.onBeforeRemove(role);
238 }
239
240 role = removeImpl(role);
241
242 for (ModelListener<Role> listener : listeners) {
243 listener.onAfterRemove(role);
244 }
245
246 return role;
247 }
248
249 protected Role removeImpl(Role role) throws SystemException {
250 role = toUnwrappedModel(role);
251
252 try {
253 clearGroups.clear(role.getPrimaryKey());
254 }
255 catch (Exception e) {
256 throw processException(e);
257 }
258 finally {
259 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
260 }
261
262 try {
263 clearPermissions.clear(role.getPrimaryKey());
264 }
265 catch (Exception e) {
266 throw processException(e);
267 }
268 finally {
269 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
270 }
271
272 try {
273 clearUsers.clear(role.getPrimaryKey());
274 }
275 catch (Exception e) {
276 throw processException(e);
277 }
278 finally {
279 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
280 }
281
282 Session session = null;
283
284 try {
285 session = openSession();
286
287 if (role.isCachedModel() || BatchSessionUtil.isEnabled()) {
288 Object staleObject = session.get(RoleImpl.class,
289 role.getPrimaryKeyObj());
290
291 if (staleObject != null) {
292 session.evict(staleObject);
293 }
294 }
295
296 session.delete(role);
297
298 session.flush();
299 }
300 catch (Exception e) {
301 throw processException(e);
302 }
303 finally {
304 closeSession(session);
305 }
306
307 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
308
309 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
310
311 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
312 new Object[] {
313 new Long(roleModelImpl.getOriginalCompanyId()),
314
315 roleModelImpl.getOriginalName()
316 });
317
318 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
319 new Object[] {
320 new Long(roleModelImpl.getOriginalCompanyId()),
321 new Long(roleModelImpl.getOriginalClassNameId()),
322 new Long(roleModelImpl.getOriginalClassPK())
323 });
324
325 EntityCacheUtil.removeResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
326 RoleImpl.class, role.getPrimaryKey());
327
328 return role;
329 }
330
331
334 public Role update(Role role) throws SystemException {
335 if (_log.isWarnEnabled()) {
336 _log.warn(
337 "Using the deprecated update(Role role) method. Use update(Role role, boolean merge) instead.");
338 }
339
340 return update(role, false);
341 }
342
343 public Role updateImpl(com.liferay.portal.model.Role role, boolean merge)
344 throws SystemException {
345 role = toUnwrappedModel(role);
346
347 boolean isNew = role.isNew();
348
349 RoleModelImpl roleModelImpl = (RoleModelImpl)role;
350
351 Session session = null;
352
353 try {
354 session = openSession();
355
356 BatchSessionUtil.update(session, role, merge);
357
358 role.setNew(false);
359 }
360 catch (Exception e) {
361 throw processException(e);
362 }
363 finally {
364 closeSession(session);
365 }
366
367 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
368
369 EntityCacheUtil.putResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
370 RoleImpl.class, role.getPrimaryKey(), role);
371
372 if (!isNew &&
373 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
374 !Validator.equals(role.getName(),
375 roleModelImpl.getOriginalName()))) {
376 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
377 new Object[] {
378 new Long(roleModelImpl.getOriginalCompanyId()),
379
380 roleModelImpl.getOriginalName()
381 });
382 }
383
384 if (isNew ||
385 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
386 !Validator.equals(role.getName(),
387 roleModelImpl.getOriginalName()))) {
388 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
389 new Object[] { new Long(role.getCompanyId()), role.getName() },
390 role);
391 }
392
393 if (!isNew &&
394 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
395 (role.getClassNameId() != roleModelImpl.getOriginalClassNameId()) ||
396 (role.getClassPK() != roleModelImpl.getOriginalClassPK()))) {
397 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
398 new Object[] {
399 new Long(roleModelImpl.getOriginalCompanyId()),
400 new Long(roleModelImpl.getOriginalClassNameId()),
401 new Long(roleModelImpl.getOriginalClassPK())
402 });
403 }
404
405 if (isNew ||
406 ((role.getCompanyId() != roleModelImpl.getOriginalCompanyId()) ||
407 (role.getClassNameId() != roleModelImpl.getOriginalClassNameId()) ||
408 (role.getClassPK() != roleModelImpl.getOriginalClassPK()))) {
409 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
410 new Object[] {
411 new Long(role.getCompanyId()),
412 new Long(role.getClassNameId()), new Long(role.getClassPK())
413 }, role);
414 }
415
416 return role;
417 }
418
419 protected Role toUnwrappedModel(Role role) {
420 if (role instanceof RoleImpl) {
421 return role;
422 }
423
424 RoleImpl roleImpl = new RoleImpl();
425
426 roleImpl.setNew(role.isNew());
427 roleImpl.setPrimaryKey(role.getPrimaryKey());
428
429 roleImpl.setRoleId(role.getRoleId());
430 roleImpl.setCompanyId(role.getCompanyId());
431 roleImpl.setClassNameId(role.getClassNameId());
432 roleImpl.setClassPK(role.getClassPK());
433 roleImpl.setName(role.getName());
434 roleImpl.setTitle(role.getTitle());
435 roleImpl.setDescription(role.getDescription());
436 roleImpl.setType(role.getType());
437 roleImpl.setSubtype(role.getSubtype());
438
439 return roleImpl;
440 }
441
442 public Role findByPrimaryKey(Serializable primaryKey)
443 throws NoSuchModelException, SystemException {
444 return findByPrimaryKey(((Long)primaryKey).longValue());
445 }
446
447 public Role findByPrimaryKey(long roleId)
448 throws NoSuchRoleException, SystemException {
449 Role role = fetchByPrimaryKey(roleId);
450
451 if (role == null) {
452 if (_log.isWarnEnabled()) {
453 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + roleId);
454 }
455
456 throw new NoSuchRoleException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
457 roleId);
458 }
459
460 return role;
461 }
462
463 public Role fetchByPrimaryKey(Serializable primaryKey)
464 throws SystemException {
465 return fetchByPrimaryKey(((Long)primaryKey).longValue());
466 }
467
468 public Role fetchByPrimaryKey(long roleId) throws SystemException {
469 Role role = (Role)EntityCacheUtil.getResult(RoleModelImpl.ENTITY_CACHE_ENABLED,
470 RoleImpl.class, roleId, this);
471
472 if (role == null) {
473 Session session = null;
474
475 try {
476 session = openSession();
477
478 role = (Role)session.get(RoleImpl.class, new Long(roleId));
479 }
480 catch (Exception e) {
481 throw processException(e);
482 }
483 finally {
484 if (role != null) {
485 cacheResult(role);
486 }
487
488 closeSession(session);
489 }
490 }
491
492 return role;
493 }
494
495 public List<Role> findByCompanyId(long companyId) throws SystemException {
496 Object[] finderArgs = new Object[] { new Long(companyId) };
497
498 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
499 finderArgs, this);
500
501 if (list == null) {
502 Session session = null;
503
504 try {
505 session = openSession();
506
507 StringBundler query = new StringBundler(3);
508
509 query.append(_SQL_SELECT_ROLE_WHERE);
510
511 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
512
513 query.append(RoleModelImpl.ORDER_BY_JPQL);
514
515 String sql = query.toString();
516
517 Query q = session.createQuery(sql);
518
519 QueryPos qPos = QueryPos.getInstance(q);
520
521 qPos.add(companyId);
522
523 list = q.list();
524 }
525 catch (Exception e) {
526 throw processException(e);
527 }
528 finally {
529 if (list == null) {
530 list = new ArrayList<Role>();
531 }
532
533 cacheResult(list);
534
535 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
536 finderArgs, list);
537
538 closeSession(session);
539 }
540 }
541
542 return list;
543 }
544
545 public List<Role> findByCompanyId(long companyId, int start, int end)
546 throws SystemException {
547 return findByCompanyId(companyId, start, end, null);
548 }
549
550 public List<Role> findByCompanyId(long companyId, int start, int end,
551 OrderByComparator obc) throws SystemException {
552 Object[] finderArgs = new Object[] {
553 new Long(companyId),
554
555 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
556 };
557
558 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
559 finderArgs, this);
560
561 if (list == null) {
562 Session session = null;
563
564 try {
565 session = openSession();
566
567 StringBundler query = null;
568
569 if (obc != null) {
570 query = new StringBundler(3 +
571 (obc.getOrderByFields().length * 3));
572 }
573 else {
574 query = new StringBundler(3);
575 }
576
577 query.append(_SQL_SELECT_ROLE_WHERE);
578
579 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
580
581 if (obc != null) {
582 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
583 }
584
585 else {
586 query.append(RoleModelImpl.ORDER_BY_JPQL);
587 }
588
589 String sql = query.toString();
590
591 Query q = session.createQuery(sql);
592
593 QueryPos qPos = QueryPos.getInstance(q);
594
595 qPos.add(companyId);
596
597 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
598 }
599 catch (Exception e) {
600 throw processException(e);
601 }
602 finally {
603 if (list == null) {
604 list = new ArrayList<Role>();
605 }
606
607 cacheResult(list);
608
609 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
610 finderArgs, list);
611
612 closeSession(session);
613 }
614 }
615
616 return list;
617 }
618
619 public Role findByCompanyId_First(long companyId, OrderByComparator obc)
620 throws NoSuchRoleException, SystemException {
621 List<Role> list = findByCompanyId(companyId, 0, 1, obc);
622
623 if (list.isEmpty()) {
624 StringBundler msg = new StringBundler(4);
625
626 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
627
628 msg.append("companyId=");
629 msg.append(companyId);
630
631 msg.append(StringPool.CLOSE_CURLY_BRACE);
632
633 throw new NoSuchRoleException(msg.toString());
634 }
635 else {
636 return list.get(0);
637 }
638 }
639
640 public Role findByCompanyId_Last(long companyId, OrderByComparator obc)
641 throws NoSuchRoleException, SystemException {
642 int count = countByCompanyId(companyId);
643
644 List<Role> list = findByCompanyId(companyId, count - 1, count, obc);
645
646 if (list.isEmpty()) {
647 StringBundler msg = new StringBundler(4);
648
649 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
650
651 msg.append("companyId=");
652 msg.append(companyId);
653
654 msg.append(StringPool.CLOSE_CURLY_BRACE);
655
656 throw new NoSuchRoleException(msg.toString());
657 }
658 else {
659 return list.get(0);
660 }
661 }
662
663 public Role[] findByCompanyId_PrevAndNext(long roleId, long companyId,
664 OrderByComparator obc) throws NoSuchRoleException, SystemException {
665 Role role = findByPrimaryKey(roleId);
666
667 int count = countByCompanyId(companyId);
668
669 Session session = null;
670
671 try {
672 session = openSession();
673
674 StringBundler query = null;
675
676 if (obc != null) {
677 query = new StringBundler(3 +
678 (obc.getOrderByFields().length * 3));
679 }
680 else {
681 query = new StringBundler(3);
682 }
683
684 query.append(_SQL_SELECT_ROLE_WHERE);
685
686 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
687
688 if (obc != null) {
689 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
690 }
691
692 else {
693 query.append(RoleModelImpl.ORDER_BY_JPQL);
694 }
695
696 String sql = query.toString();
697
698 Query q = session.createQuery(sql);
699
700 QueryPos qPos = QueryPos.getInstance(q);
701
702 qPos.add(companyId);
703
704 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, role);
705
706 Role[] array = new RoleImpl[3];
707
708 array[0] = (Role)objArray[0];
709 array[1] = (Role)objArray[1];
710 array[2] = (Role)objArray[2];
711
712 return array;
713 }
714 catch (Exception e) {
715 throw processException(e);
716 }
717 finally {
718 closeSession(session);
719 }
720 }
721
722 public List<Role> findBySubtype(String subtype) throws SystemException {
723 Object[] finderArgs = new Object[] { subtype };
724
725 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_SUBTYPE,
726 finderArgs, this);
727
728 if (list == null) {
729 Session session = null;
730
731 try {
732 session = openSession();
733
734 StringBundler query = new StringBundler(3);
735
736 query.append(_SQL_SELECT_ROLE_WHERE);
737
738 if (subtype == null) {
739 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
740 }
741 else {
742 if (subtype.equals(StringPool.BLANK)) {
743 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
744 }
745 else {
746 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
747 }
748 }
749
750 query.append(RoleModelImpl.ORDER_BY_JPQL);
751
752 String sql = query.toString();
753
754 Query q = session.createQuery(sql);
755
756 QueryPos qPos = QueryPos.getInstance(q);
757
758 if (subtype != null) {
759 qPos.add(subtype);
760 }
761
762 list = q.list();
763 }
764 catch (Exception e) {
765 throw processException(e);
766 }
767 finally {
768 if (list == null) {
769 list = new ArrayList<Role>();
770 }
771
772 cacheResult(list);
773
774 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_SUBTYPE,
775 finderArgs, list);
776
777 closeSession(session);
778 }
779 }
780
781 return list;
782 }
783
784 public List<Role> findBySubtype(String subtype, int start, int end)
785 throws SystemException {
786 return findBySubtype(subtype, start, end, null);
787 }
788
789 public List<Role> findBySubtype(String subtype, int start, int end,
790 OrderByComparator obc) throws SystemException {
791 Object[] finderArgs = new Object[] {
792 subtype,
793
794 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
795 };
796
797 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_SUBTYPE,
798 finderArgs, this);
799
800 if (list == null) {
801 Session session = null;
802
803 try {
804 session = openSession();
805
806 StringBundler query = null;
807
808 if (obc != null) {
809 query = new StringBundler(3 +
810 (obc.getOrderByFields().length * 3));
811 }
812 else {
813 query = new StringBundler(3);
814 }
815
816 query.append(_SQL_SELECT_ROLE_WHERE);
817
818 if (subtype == null) {
819 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
820 }
821 else {
822 if (subtype.equals(StringPool.BLANK)) {
823 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
824 }
825 else {
826 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
827 }
828 }
829
830 if (obc != null) {
831 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
832 }
833
834 else {
835 query.append(RoleModelImpl.ORDER_BY_JPQL);
836 }
837
838 String sql = query.toString();
839
840 Query q = session.createQuery(sql);
841
842 QueryPos qPos = QueryPos.getInstance(q);
843
844 if (subtype != null) {
845 qPos.add(subtype);
846 }
847
848 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
849 }
850 catch (Exception e) {
851 throw processException(e);
852 }
853 finally {
854 if (list == null) {
855 list = new ArrayList<Role>();
856 }
857
858 cacheResult(list);
859
860 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_SUBTYPE,
861 finderArgs, list);
862
863 closeSession(session);
864 }
865 }
866
867 return list;
868 }
869
870 public Role findBySubtype_First(String subtype, OrderByComparator obc)
871 throws NoSuchRoleException, SystemException {
872 List<Role> list = findBySubtype(subtype, 0, 1, obc);
873
874 if (list.isEmpty()) {
875 StringBundler msg = new StringBundler(4);
876
877 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
878
879 msg.append("subtype=");
880 msg.append(subtype);
881
882 msg.append(StringPool.CLOSE_CURLY_BRACE);
883
884 throw new NoSuchRoleException(msg.toString());
885 }
886 else {
887 return list.get(0);
888 }
889 }
890
891 public Role findBySubtype_Last(String subtype, OrderByComparator obc)
892 throws NoSuchRoleException, SystemException {
893 int count = countBySubtype(subtype);
894
895 List<Role> list = findBySubtype(subtype, count - 1, count, obc);
896
897 if (list.isEmpty()) {
898 StringBundler msg = new StringBundler(4);
899
900 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
901
902 msg.append("subtype=");
903 msg.append(subtype);
904
905 msg.append(StringPool.CLOSE_CURLY_BRACE);
906
907 throw new NoSuchRoleException(msg.toString());
908 }
909 else {
910 return list.get(0);
911 }
912 }
913
914 public Role[] findBySubtype_PrevAndNext(long roleId, String subtype,
915 OrderByComparator obc) throws NoSuchRoleException, SystemException {
916 Role role = findByPrimaryKey(roleId);
917
918 int count = countBySubtype(subtype);
919
920 Session session = null;
921
922 try {
923 session = openSession();
924
925 StringBundler query = null;
926
927 if (obc != null) {
928 query = new StringBundler(3 +
929 (obc.getOrderByFields().length * 3));
930 }
931 else {
932 query = new StringBundler(3);
933 }
934
935 query.append(_SQL_SELECT_ROLE_WHERE);
936
937 if (subtype == null) {
938 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
939 }
940 else {
941 if (subtype.equals(StringPool.BLANK)) {
942 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
943 }
944 else {
945 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
946 }
947 }
948
949 if (obc != null) {
950 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
951 }
952
953 else {
954 query.append(RoleModelImpl.ORDER_BY_JPQL);
955 }
956
957 String sql = query.toString();
958
959 Query q = session.createQuery(sql);
960
961 QueryPos qPos = QueryPos.getInstance(q);
962
963 if (subtype != null) {
964 qPos.add(subtype);
965 }
966
967 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, role);
968
969 Role[] array = new RoleImpl[3];
970
971 array[0] = (Role)objArray[0];
972 array[1] = (Role)objArray[1];
973 array[2] = (Role)objArray[2];
974
975 return array;
976 }
977 catch (Exception e) {
978 throw processException(e);
979 }
980 finally {
981 closeSession(session);
982 }
983 }
984
985 public Role findByC_N(long companyId, String name)
986 throws NoSuchRoleException, SystemException {
987 Role role = fetchByC_N(companyId, name);
988
989 if (role == null) {
990 StringBundler msg = new StringBundler(6);
991
992 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
993
994 msg.append("companyId=");
995 msg.append(companyId);
996
997 msg.append(", name=");
998 msg.append(name);
999
1000 msg.append(StringPool.CLOSE_CURLY_BRACE);
1001
1002 if (_log.isWarnEnabled()) {
1003 _log.warn(msg.toString());
1004 }
1005
1006 throw new NoSuchRoleException(msg.toString());
1007 }
1008
1009 return role;
1010 }
1011
1012 public Role fetchByC_N(long companyId, String name)
1013 throws SystemException {
1014 return fetchByC_N(companyId, name, true);
1015 }
1016
1017 public Role fetchByC_N(long companyId, String name,
1018 boolean retrieveFromCache) throws SystemException {
1019 Object[] finderArgs = new Object[] { new Long(companyId), name };
1020
1021 Object result = null;
1022
1023 if (retrieveFromCache) {
1024 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1025 finderArgs, this);
1026 }
1027
1028 if (result == null) {
1029 Session session = null;
1030
1031 try {
1032 session = openSession();
1033
1034 StringBundler query = new StringBundler(4);
1035
1036 query.append(_SQL_SELECT_ROLE_WHERE);
1037
1038 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1039
1040 if (name == null) {
1041 query.append(_FINDER_COLUMN_C_N_NAME_1);
1042 }
1043 else {
1044 if (name.equals(StringPool.BLANK)) {
1045 query.append(_FINDER_COLUMN_C_N_NAME_3);
1046 }
1047 else {
1048 query.append(_FINDER_COLUMN_C_N_NAME_2);
1049 }
1050 }
1051
1052 query.append(RoleModelImpl.ORDER_BY_JPQL);
1053
1054 String sql = query.toString();
1055
1056 Query q = session.createQuery(sql);
1057
1058 QueryPos qPos = QueryPos.getInstance(q);
1059
1060 qPos.add(companyId);
1061
1062 if (name != null) {
1063 qPos.add(name);
1064 }
1065
1066 List<Role> list = q.list();
1067
1068 result = list;
1069
1070 Role role = null;
1071
1072 if (list.isEmpty()) {
1073 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1074 finderArgs, list);
1075 }
1076 else {
1077 role = list.get(0);
1078
1079 cacheResult(role);
1080
1081 if ((role.getCompanyId() != companyId) ||
1082 (role.getName() == null) ||
1083 !role.getName().equals(name)) {
1084 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1085 finderArgs, role);
1086 }
1087 }
1088
1089 return role;
1090 }
1091 catch (Exception e) {
1092 throw processException(e);
1093 }
1094 finally {
1095 if (result == null) {
1096 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1097 finderArgs, new ArrayList<Role>());
1098 }
1099
1100 closeSession(session);
1101 }
1102 }
1103 else {
1104 if (result instanceof List<?>) {
1105 return null;
1106 }
1107 else {
1108 return (Role)result;
1109 }
1110 }
1111 }
1112
1113 public List<Role> findByT_S(int type, String subtype)
1114 throws SystemException {
1115 Object[] finderArgs = new Object[] { new Integer(type), subtype };
1116
1117 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_S,
1118 finderArgs, this);
1119
1120 if (list == null) {
1121 Session session = null;
1122
1123 try {
1124 session = openSession();
1125
1126 StringBundler query = new StringBundler(4);
1127
1128 query.append(_SQL_SELECT_ROLE_WHERE);
1129
1130 query.append(_FINDER_COLUMN_T_S_TYPE_2);
1131
1132 if (subtype == null) {
1133 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
1134 }
1135 else {
1136 if (subtype.equals(StringPool.BLANK)) {
1137 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
1138 }
1139 else {
1140 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
1141 }
1142 }
1143
1144 query.append(RoleModelImpl.ORDER_BY_JPQL);
1145
1146 String sql = query.toString();
1147
1148 Query q = session.createQuery(sql);
1149
1150 QueryPos qPos = QueryPos.getInstance(q);
1151
1152 qPos.add(type);
1153
1154 if (subtype != null) {
1155 qPos.add(subtype);
1156 }
1157
1158 list = q.list();
1159 }
1160 catch (Exception e) {
1161 throw processException(e);
1162 }
1163 finally {
1164 if (list == null) {
1165 list = new ArrayList<Role>();
1166 }
1167
1168 cacheResult(list);
1169
1170 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_S, finderArgs,
1171 list);
1172
1173 closeSession(session);
1174 }
1175 }
1176
1177 return list;
1178 }
1179
1180 public List<Role> findByT_S(int type, String subtype, int start, int end)
1181 throws SystemException {
1182 return findByT_S(type, subtype, start, end, null);
1183 }
1184
1185 public List<Role> findByT_S(int type, String subtype, int start, int end,
1186 OrderByComparator obc) throws SystemException {
1187 Object[] finderArgs = new Object[] {
1188 new Integer(type),
1189
1190 subtype,
1191
1192 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1193 };
1194
1195 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_S,
1196 finderArgs, this);
1197
1198 if (list == null) {
1199 Session session = null;
1200
1201 try {
1202 session = openSession();
1203
1204 StringBundler query = null;
1205
1206 if (obc != null) {
1207 query = new StringBundler(4 +
1208 (obc.getOrderByFields().length * 3));
1209 }
1210 else {
1211 query = new StringBundler(4);
1212 }
1213
1214 query.append(_SQL_SELECT_ROLE_WHERE);
1215
1216 query.append(_FINDER_COLUMN_T_S_TYPE_2);
1217
1218 if (subtype == null) {
1219 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
1220 }
1221 else {
1222 if (subtype.equals(StringPool.BLANK)) {
1223 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
1224 }
1225 else {
1226 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
1227 }
1228 }
1229
1230 if (obc != null) {
1231 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1232 }
1233
1234 else {
1235 query.append(RoleModelImpl.ORDER_BY_JPQL);
1236 }
1237
1238 String sql = query.toString();
1239
1240 Query q = session.createQuery(sql);
1241
1242 QueryPos qPos = QueryPos.getInstance(q);
1243
1244 qPos.add(type);
1245
1246 if (subtype != null) {
1247 qPos.add(subtype);
1248 }
1249
1250 list = (List<Role>)QueryUtil.list(q, getDialect(), start, end);
1251 }
1252 catch (Exception e) {
1253 throw processException(e);
1254 }
1255 finally {
1256 if (list == null) {
1257 list = new ArrayList<Role>();
1258 }
1259
1260 cacheResult(list);
1261
1262 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_S,
1263 finderArgs, list);
1264
1265 closeSession(session);
1266 }
1267 }
1268
1269 return list;
1270 }
1271
1272 public Role findByT_S_First(int type, String subtype, OrderByComparator obc)
1273 throws NoSuchRoleException, SystemException {
1274 List<Role> list = findByT_S(type, subtype, 0, 1, obc);
1275
1276 if (list.isEmpty()) {
1277 StringBundler msg = new StringBundler(6);
1278
1279 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1280
1281 msg.append("type=");
1282 msg.append(type);
1283
1284 msg.append(", subtype=");
1285 msg.append(subtype);
1286
1287 msg.append(StringPool.CLOSE_CURLY_BRACE);
1288
1289 throw new NoSuchRoleException(msg.toString());
1290 }
1291 else {
1292 return list.get(0);
1293 }
1294 }
1295
1296 public Role findByT_S_Last(int type, String subtype, OrderByComparator obc)
1297 throws NoSuchRoleException, SystemException {
1298 int count = countByT_S(type, subtype);
1299
1300 List<Role> list = findByT_S(type, subtype, count - 1, count, obc);
1301
1302 if (list.isEmpty()) {
1303 StringBundler msg = new StringBundler(6);
1304
1305 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1306
1307 msg.append("type=");
1308 msg.append(type);
1309
1310 msg.append(", subtype=");
1311 msg.append(subtype);
1312
1313 msg.append(StringPool.CLOSE_CURLY_BRACE);
1314
1315 throw new NoSuchRoleException(msg.toString());
1316 }
1317 else {
1318 return list.get(0);
1319 }
1320 }
1321
1322 public Role[] findByT_S_PrevAndNext(long roleId, int type, String subtype,
1323 OrderByComparator obc) throws NoSuchRoleException, SystemException {
1324 Role role = findByPrimaryKey(roleId);
1325
1326 int count = countByT_S(type, subtype);
1327
1328 Session session = null;
1329
1330 try {
1331 session = openSession();
1332
1333 StringBundler query = null;
1334
1335 if (obc != null) {
1336 query = new StringBundler(4 +
1337 (obc.getOrderByFields().length * 3));
1338 }
1339 else {
1340 query = new StringBundler(4);
1341 }
1342
1343 query.append(_SQL_SELECT_ROLE_WHERE);
1344
1345 query.append(_FINDER_COLUMN_T_S_TYPE_2);
1346
1347 if (subtype == null) {
1348 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
1349 }
1350 else {
1351 if (subtype.equals(StringPool.BLANK)) {
1352 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
1353 }
1354 else {
1355 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
1356 }
1357 }
1358
1359 if (obc != null) {
1360 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1361 }
1362
1363 else {
1364 query.append(RoleModelImpl.ORDER_BY_JPQL);
1365 }
1366
1367 String sql = query.toString();
1368
1369 Query q = session.createQuery(sql);
1370
1371 QueryPos qPos = QueryPos.getInstance(q);
1372
1373 qPos.add(type);
1374
1375 if (subtype != null) {
1376 qPos.add(subtype);
1377 }
1378
1379 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, role);
1380
1381 Role[] array = new RoleImpl[3];
1382
1383 array[0] = (Role)objArray[0];
1384 array[1] = (Role)objArray[1];
1385 array[2] = (Role)objArray[2];
1386
1387 return array;
1388 }
1389 catch (Exception e) {
1390 throw processException(e);
1391 }
1392 finally {
1393 closeSession(session);
1394 }
1395 }
1396
1397 public Role findByC_C_C(long companyId, long classNameId, long classPK)
1398 throws NoSuchRoleException, SystemException {
1399 Role role = fetchByC_C_C(companyId, classNameId, classPK);
1400
1401 if (role == null) {
1402 StringBundler msg = new StringBundler(8);
1403
1404 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1405
1406 msg.append("companyId=");
1407 msg.append(companyId);
1408
1409 msg.append(", classNameId=");
1410 msg.append(classNameId);
1411
1412 msg.append(", classPK=");
1413 msg.append(classPK);
1414
1415 msg.append(StringPool.CLOSE_CURLY_BRACE);
1416
1417 if (_log.isWarnEnabled()) {
1418 _log.warn(msg.toString());
1419 }
1420
1421 throw new NoSuchRoleException(msg.toString());
1422 }
1423
1424 return role;
1425 }
1426
1427 public Role fetchByC_C_C(long companyId, long classNameId, long classPK)
1428 throws SystemException {
1429 return fetchByC_C_C(companyId, classNameId, classPK, true);
1430 }
1431
1432 public Role fetchByC_C_C(long companyId, long classNameId, long classPK,
1433 boolean retrieveFromCache) throws SystemException {
1434 Object[] finderArgs = new Object[] {
1435 new Long(companyId), new Long(classNameId), new Long(classPK)
1436 };
1437
1438 Object result = null;
1439
1440 if (retrieveFromCache) {
1441 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
1442 finderArgs, this);
1443 }
1444
1445 if (result == null) {
1446 Session session = null;
1447
1448 try {
1449 session = openSession();
1450
1451 StringBundler query = new StringBundler(5);
1452
1453 query.append(_SQL_SELECT_ROLE_WHERE);
1454
1455 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1456
1457 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1458
1459 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1460
1461 query.append(RoleModelImpl.ORDER_BY_JPQL);
1462
1463 String sql = query.toString();
1464
1465 Query q = session.createQuery(sql);
1466
1467 QueryPos qPos = QueryPos.getInstance(q);
1468
1469 qPos.add(companyId);
1470
1471 qPos.add(classNameId);
1472
1473 qPos.add(classPK);
1474
1475 List<Role> list = q.list();
1476
1477 result = list;
1478
1479 Role role = null;
1480
1481 if (list.isEmpty()) {
1482 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1483 finderArgs, list);
1484 }
1485 else {
1486 role = list.get(0);
1487
1488 cacheResult(role);
1489
1490 if ((role.getCompanyId() != companyId) ||
1491 (role.getClassNameId() != classNameId) ||
1492 (role.getClassPK() != classPK)) {
1493 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1494 finderArgs, role);
1495 }
1496 }
1497
1498 return role;
1499 }
1500 catch (Exception e) {
1501 throw processException(e);
1502 }
1503 finally {
1504 if (result == null) {
1505 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1506 finderArgs, new ArrayList<Role>());
1507 }
1508
1509 closeSession(session);
1510 }
1511 }
1512 else {
1513 if (result instanceof List<?>) {
1514 return null;
1515 }
1516 else {
1517 return (Role)result;
1518 }
1519 }
1520 }
1521
1522 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1523 throws SystemException {
1524 Session session = null;
1525
1526 try {
1527 session = openSession();
1528
1529 dynamicQuery.compile(session);
1530
1531 return dynamicQuery.list();
1532 }
1533 catch (Exception e) {
1534 throw processException(e);
1535 }
1536 finally {
1537 closeSession(session);
1538 }
1539 }
1540
1541 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1542 int start, int end) throws SystemException {
1543 Session session = null;
1544
1545 try {
1546 session = openSession();
1547
1548 dynamicQuery.setLimit(start, end);
1549
1550 dynamicQuery.compile(session);
1551
1552 return dynamicQuery.list();
1553 }
1554 catch (Exception e) {
1555 throw processException(e);
1556 }
1557 finally {
1558 closeSession(session);
1559 }
1560 }
1561
1562 public List<Role> findAll() throws SystemException {
1563 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1564 }
1565
1566 public List<Role> findAll(int start, int end) throws SystemException {
1567 return findAll(start, end, null);
1568 }
1569
1570 public List<Role> findAll(int start, int end, OrderByComparator obc)
1571 throws SystemException {
1572 Object[] finderArgs = new Object[] {
1573 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1574 };
1575
1576 List<Role> list = (List<Role>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1577 finderArgs, this);
1578
1579 if (list == null) {
1580 Session session = null;
1581
1582 try {
1583 session = openSession();
1584
1585 StringBundler query = null;
1586 String sql = null;
1587
1588 if (obc != null) {
1589 query = new StringBundler(2 +
1590 (obc.getOrderByFields().length * 3));
1591
1592 query.append(_SQL_SELECT_ROLE);
1593
1594 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1595
1596 sql = query.toString();
1597 }
1598
1599 else {
1600 sql = _SQL_SELECT_ROLE.concat(RoleModelImpl.ORDER_BY_JPQL);
1601 }
1602
1603 Query q = session.createQuery(sql);
1604
1605 if (obc == null) {
1606 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
1607 end, false);
1608
1609 Collections.sort(list);
1610 }
1611 else {
1612 list = (List<Role>)QueryUtil.list(q, getDialect(), start,
1613 end);
1614 }
1615 }
1616 catch (Exception e) {
1617 throw processException(e);
1618 }
1619 finally {
1620 if (list == null) {
1621 list = new ArrayList<Role>();
1622 }
1623
1624 cacheResult(list);
1625
1626 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1627
1628 closeSession(session);
1629 }
1630 }
1631
1632 return list;
1633 }
1634
1635 public void removeByCompanyId(long companyId) throws SystemException {
1636 for (Role role : findByCompanyId(companyId)) {
1637 remove(role);
1638 }
1639 }
1640
1641 public void removeBySubtype(String subtype) throws SystemException {
1642 for (Role role : findBySubtype(subtype)) {
1643 remove(role);
1644 }
1645 }
1646
1647 public void removeByC_N(long companyId, String name)
1648 throws NoSuchRoleException, SystemException {
1649 Role role = findByC_N(companyId, name);
1650
1651 remove(role);
1652 }
1653
1654 public void removeByT_S(int type, String subtype) throws SystemException {
1655 for (Role role : findByT_S(type, subtype)) {
1656 remove(role);
1657 }
1658 }
1659
1660 public void removeByC_C_C(long companyId, long classNameId, long classPK)
1661 throws NoSuchRoleException, SystemException {
1662 Role role = findByC_C_C(companyId, classNameId, classPK);
1663
1664 remove(role);
1665 }
1666
1667 public void removeAll() throws SystemException {
1668 for (Role role : findAll()) {
1669 remove(role);
1670 }
1671 }
1672
1673 public int countByCompanyId(long companyId) throws SystemException {
1674 Object[] finderArgs = new Object[] { new Long(companyId) };
1675
1676 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1677 finderArgs, this);
1678
1679 if (count == null) {
1680 Session session = null;
1681
1682 try {
1683 session = openSession();
1684
1685 StringBundler query = new StringBundler(2);
1686
1687 query.append(_SQL_COUNT_ROLE_WHERE);
1688
1689 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1690
1691 String sql = query.toString();
1692
1693 Query q = session.createQuery(sql);
1694
1695 QueryPos qPos = QueryPos.getInstance(q);
1696
1697 qPos.add(companyId);
1698
1699 count = (Long)q.uniqueResult();
1700 }
1701 catch (Exception e) {
1702 throw processException(e);
1703 }
1704 finally {
1705 if (count == null) {
1706 count = Long.valueOf(0);
1707 }
1708
1709 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1710 finderArgs, count);
1711
1712 closeSession(session);
1713 }
1714 }
1715
1716 return count.intValue();
1717 }
1718
1719 public int countBySubtype(String subtype) throws SystemException {
1720 Object[] finderArgs = new Object[] { subtype };
1721
1722 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SUBTYPE,
1723 finderArgs, this);
1724
1725 if (count == null) {
1726 Session session = null;
1727
1728 try {
1729 session = openSession();
1730
1731 StringBundler query = new StringBundler(2);
1732
1733 query.append(_SQL_COUNT_ROLE_WHERE);
1734
1735 if (subtype == null) {
1736 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_1);
1737 }
1738 else {
1739 if (subtype.equals(StringPool.BLANK)) {
1740 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_3);
1741 }
1742 else {
1743 query.append(_FINDER_COLUMN_SUBTYPE_SUBTYPE_2);
1744 }
1745 }
1746
1747 String sql = query.toString();
1748
1749 Query q = session.createQuery(sql);
1750
1751 QueryPos qPos = QueryPos.getInstance(q);
1752
1753 if (subtype != null) {
1754 qPos.add(subtype);
1755 }
1756
1757 count = (Long)q.uniqueResult();
1758 }
1759 catch (Exception e) {
1760 throw processException(e);
1761 }
1762 finally {
1763 if (count == null) {
1764 count = Long.valueOf(0);
1765 }
1766
1767 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SUBTYPE,
1768 finderArgs, count);
1769
1770 closeSession(session);
1771 }
1772 }
1773
1774 return count.intValue();
1775 }
1776
1777 public int countByC_N(long companyId, String name)
1778 throws SystemException {
1779 Object[] finderArgs = new Object[] { new Long(companyId), name };
1780
1781 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
1782 finderArgs, this);
1783
1784 if (count == null) {
1785 Session session = null;
1786
1787 try {
1788 session = openSession();
1789
1790 StringBundler query = new StringBundler(3);
1791
1792 query.append(_SQL_COUNT_ROLE_WHERE);
1793
1794 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1795
1796 if (name == null) {
1797 query.append(_FINDER_COLUMN_C_N_NAME_1);
1798 }
1799 else {
1800 if (name.equals(StringPool.BLANK)) {
1801 query.append(_FINDER_COLUMN_C_N_NAME_3);
1802 }
1803 else {
1804 query.append(_FINDER_COLUMN_C_N_NAME_2);
1805 }
1806 }
1807
1808 String sql = query.toString();
1809
1810 Query q = session.createQuery(sql);
1811
1812 QueryPos qPos = QueryPos.getInstance(q);
1813
1814 qPos.add(companyId);
1815
1816 if (name != null) {
1817 qPos.add(name);
1818 }
1819
1820 count = (Long)q.uniqueResult();
1821 }
1822 catch (Exception e) {
1823 throw processException(e);
1824 }
1825 finally {
1826 if (count == null) {
1827 count = Long.valueOf(0);
1828 }
1829
1830 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
1831 count);
1832
1833 closeSession(session);
1834 }
1835 }
1836
1837 return count.intValue();
1838 }
1839
1840 public int countByT_S(int type, String subtype) throws SystemException {
1841 Object[] finderArgs = new Object[] { new Integer(type), subtype };
1842
1843 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_S,
1844 finderArgs, this);
1845
1846 if (count == null) {
1847 Session session = null;
1848
1849 try {
1850 session = openSession();
1851
1852 StringBundler query = new StringBundler(3);
1853
1854 query.append(_SQL_COUNT_ROLE_WHERE);
1855
1856 query.append(_FINDER_COLUMN_T_S_TYPE_2);
1857
1858 if (subtype == null) {
1859 query.append(_FINDER_COLUMN_T_S_SUBTYPE_1);
1860 }
1861 else {
1862 if (subtype.equals(StringPool.BLANK)) {
1863 query.append(_FINDER_COLUMN_T_S_SUBTYPE_3);
1864 }
1865 else {
1866 query.append(_FINDER_COLUMN_T_S_SUBTYPE_2);
1867 }
1868 }
1869
1870 String sql = query.toString();
1871
1872 Query q = session.createQuery(sql);
1873
1874 QueryPos qPos = QueryPos.getInstance(q);
1875
1876 qPos.add(type);
1877
1878 if (subtype != null) {
1879 qPos.add(subtype);
1880 }
1881
1882 count = (Long)q.uniqueResult();
1883 }
1884 catch (Exception e) {
1885 throw processException(e);
1886 }
1887 finally {
1888 if (count == null) {
1889 count = Long.valueOf(0);
1890 }
1891
1892 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_S, finderArgs,
1893 count);
1894
1895 closeSession(session);
1896 }
1897 }
1898
1899 return count.intValue();
1900 }
1901
1902 public int countByC_C_C(long companyId, long classNameId, long classPK)
1903 throws SystemException {
1904 Object[] finderArgs = new Object[] {
1905 new Long(companyId), new Long(classNameId), new Long(classPK)
1906 };
1907
1908 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
1909 finderArgs, this);
1910
1911 if (count == null) {
1912 Session session = null;
1913
1914 try {
1915 session = openSession();
1916
1917 StringBundler query = new StringBundler(4);
1918
1919 query.append(_SQL_COUNT_ROLE_WHERE);
1920
1921 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
1922
1923 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
1924
1925 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
1926
1927 String sql = query.toString();
1928
1929 Query q = session.createQuery(sql);
1930
1931 QueryPos qPos = QueryPos.getInstance(q);
1932
1933 qPos.add(companyId);
1934
1935 qPos.add(classNameId);
1936
1937 qPos.add(classPK);
1938
1939 count = (Long)q.uniqueResult();
1940 }
1941 catch (Exception e) {
1942 throw processException(e);
1943 }
1944 finally {
1945 if (count == null) {
1946 count = Long.valueOf(0);
1947 }
1948
1949 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
1950 finderArgs, count);
1951
1952 closeSession(session);
1953 }
1954 }
1955
1956 return count.intValue();
1957 }
1958
1959 public int countAll() throws SystemException {
1960 Object[] finderArgs = new Object[0];
1961
1962 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1963 finderArgs, this);
1964
1965 if (count == null) {
1966 Session session = null;
1967
1968 try {
1969 session = openSession();
1970
1971 Query q = session.createQuery(_SQL_COUNT_ROLE);
1972
1973 count = (Long)q.uniqueResult();
1974 }
1975 catch (Exception e) {
1976 throw processException(e);
1977 }
1978 finally {
1979 if (count == null) {
1980 count = Long.valueOf(0);
1981 }
1982
1983 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1984 count);
1985
1986 closeSession(session);
1987 }
1988 }
1989
1990 return count.intValue();
1991 }
1992
1993 public List<com.liferay.portal.model.Group> getGroups(long pk)
1994 throws SystemException {
1995 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1996 }
1997
1998 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1999 int end) throws SystemException {
2000 return getGroups(pk, start, end, null);
2001 }
2002
2003 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2004 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
2005 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroups",
2006 new String[] {
2007 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2008 "com.liferay.portal.kernel.util.OrderByComparator"
2009 });
2010
2011 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2012 int end, OrderByComparator obc) throws SystemException {
2013 Object[] finderArgs = new Object[] {
2014 new Long(pk), String.valueOf(start), String.valueOf(end),
2015 String.valueOf(obc)
2016 };
2017
2018 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
2019 finderArgs, this);
2020
2021 if (list == null) {
2022 Session session = null;
2023
2024 try {
2025 session = openSession();
2026
2027 StringBundler query = null;
2028 String sql = null;
2029
2030 if (obc != null) {
2031 query = new StringBundler(3);
2032
2033 query.append(_SQL_GETGROUPS);
2034 query.append(ORDER_BY_CLAUSE);
2035 query.append(obc.getOrderBy());
2036
2037 sql = query.toString();
2038 }
2039
2040 else {
2041 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
2042 }
2043
2044 SQLQuery q = session.createSQLQuery(sql);
2045
2046 q.addEntity("Group_",
2047 com.liferay.portal.model.impl.GroupImpl.class);
2048
2049 QueryPos qPos = QueryPos.getInstance(q);
2050
2051 qPos.add(pk);
2052
2053 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
2054 getDialect(), start, end);
2055 }
2056 catch (Exception e) {
2057 throw processException(e);
2058 }
2059 finally {
2060 if (list == null) {
2061 list = new ArrayList<com.liferay.portal.model.Group>();
2062 }
2063
2064 groupPersistence.cacheResult(list);
2065
2066 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
2067 list);
2068
2069 closeSession(session);
2070 }
2071 }
2072
2073 return list;
2074 }
2075
2076 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2077 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
2078 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getGroupsSize",
2079 new String[] { Long.class.getName() });
2080
2081 public int getGroupsSize(long pk) throws SystemException {
2082 Object[] finderArgs = new Object[] { new Long(pk) };
2083
2084 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
2085 finderArgs, this);
2086
2087 if (count == null) {
2088 Session session = null;
2089
2090 try {
2091 session = openSession();
2092
2093 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2094
2095 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2096
2097 QueryPos qPos = QueryPos.getInstance(q);
2098
2099 qPos.add(pk);
2100
2101 count = (Long)q.uniqueResult();
2102 }
2103 catch (Exception e) {
2104 throw processException(e);
2105 }
2106 finally {
2107 if (count == null) {
2108 count = Long.valueOf(0);
2109 }
2110
2111 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
2112 finderArgs, count);
2113
2114 closeSession(session);
2115 }
2116 }
2117
2118 return count.intValue();
2119 }
2120
2121 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2122 RoleModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
2123 RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsGroup",
2124 new String[] { Long.class.getName(), Long.class.getName() });
2125
2126 public boolean containsGroup(long pk, long groupPK)
2127 throws SystemException {
2128 Object[] finderArgs = new Object[] { new Long(pk), new Long(groupPK) };
2129
2130 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
2131 finderArgs, this);
2132
2133 if (value == null) {
2134 try {
2135 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
2136 }
2137 catch (Exception e) {
2138 throw processException(e);
2139 }
2140 finally {
2141 if (value == null) {
2142 value = Boolean.FALSE;
2143 }
2144
2145 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
2146 finderArgs, value);
2147 }
2148 }
2149
2150 return value.booleanValue();
2151 }
2152
2153 public boolean containsGroups(long pk) throws SystemException {
2154 if (getGroupsSize(pk) > 0) {
2155 return true;
2156 }
2157 else {
2158 return false;
2159 }
2160 }
2161
2162 public void addGroup(long pk, long groupPK) throws SystemException {
2163 try {
2164 addGroup.add(pk, groupPK);
2165 }
2166 catch (Exception e) {
2167 throw processException(e);
2168 }
2169 finally {
2170 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2171 }
2172 }
2173
2174 public void addGroup(long pk, com.liferay.portal.model.Group group)
2175 throws SystemException {
2176 try {
2177 addGroup.add(pk, group.getPrimaryKey());
2178 }
2179 catch (Exception e) {
2180 throw processException(e);
2181 }
2182 finally {
2183 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2184 }
2185 }
2186
2187 public void addGroups(long pk, long[] groupPKs) throws SystemException {
2188 try {
2189 for (long groupPK : groupPKs) {
2190 addGroup.add(pk, groupPK);
2191 }
2192 }
2193 catch (Exception e) {
2194 throw processException(e);
2195 }
2196 finally {
2197 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2198 }
2199 }
2200
2201 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
2202 throws SystemException {
2203 try {
2204 for (com.liferay.portal.model.Group group : groups) {
2205 addGroup.add(pk, group.getPrimaryKey());
2206 }
2207 }
2208 catch (Exception e) {
2209 throw processException(e);
2210 }
2211 finally {
2212 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2213 }
2214 }
2215
2216 public void clearGroups(long pk) throws SystemException {
2217 try {
2218 clearGroups.clear(pk);
2219 }
2220 catch (Exception e) {
2221 throw processException(e);
2222 }
2223 finally {
2224 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2225 }
2226 }
2227
2228 public void removeGroup(long pk, long groupPK) throws SystemException {
2229 try {
2230 removeGroup.remove(pk, groupPK);
2231 }
2232 catch (Exception e) {
2233 throw processException(e);
2234 }
2235 finally {
2236 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2237 }
2238 }
2239
2240 public void removeGroup(long pk, com.liferay.portal.model.Group group)
2241 throws SystemException {
2242 try {
2243 removeGroup.remove(pk, group.getPrimaryKey());
2244 }
2245 catch (Exception e) {
2246 throw processException(e);
2247 }
2248 finally {
2249 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2250 }
2251 }
2252
2253 public void removeGroups(long pk, long[] groupPKs)
2254 throws SystemException {
2255 try {
2256 for (long groupPK : groupPKs) {
2257 removeGroup.remove(pk, groupPK);
2258 }
2259 }
2260 catch (Exception e) {
2261 throw processException(e);
2262 }
2263 finally {
2264 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2265 }
2266 }
2267
2268 public void removeGroups(long pk,
2269 List<com.liferay.portal.model.Group> groups) throws SystemException {
2270 try {
2271 for (com.liferay.portal.model.Group group : groups) {
2272 removeGroup.remove(pk, group.getPrimaryKey());
2273 }
2274 }
2275 catch (Exception e) {
2276 throw processException(e);
2277 }
2278 finally {
2279 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2280 }
2281 }
2282
2283 public void setGroups(long pk, long[] groupPKs) throws SystemException {
2284 try {
2285 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
2286
2287 List<com.liferay.portal.model.Group> groups = getGroups(pk);
2288
2289 for (com.liferay.portal.model.Group group : groups) {
2290 if (!groupPKSet.contains(group.getPrimaryKey())) {
2291 removeGroup.remove(pk, group.getPrimaryKey());
2292 }
2293 else {
2294 groupPKSet.remove(group.getPrimaryKey());
2295 }
2296 }
2297
2298 for (Long groupPK : groupPKSet) {
2299 addGroup.add(pk, groupPK);
2300 }
2301 }
2302 catch (Exception e) {
2303 throw processException(e);
2304 }
2305 finally {
2306 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2307 }
2308 }
2309
2310 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
2311 throws SystemException {
2312 try {
2313 long[] groupPKs = new long[groups.size()];
2314
2315 for (int i = 0; i < groups.size(); i++) {
2316 com.liferay.portal.model.Group group = groups.get(i);
2317
2318 groupPKs[i] = group.getPrimaryKey();
2319 }
2320
2321 setGroups(pk, groupPKs);
2322 }
2323 catch (Exception e) {
2324 throw processException(e);
2325 }
2326 finally {
2327 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
2328 }
2329 }
2330
2331 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
2332 throws SystemException {
2333 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2334 }
2335
2336 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2337 int start, int end) throws SystemException {
2338 return getPermissions(pk, start, end, null);
2339 }
2340
2341 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2342 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
2343 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
2344 "getPermissions",
2345 new String[] {
2346 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2347 "com.liferay.portal.kernel.util.OrderByComparator"
2348 });
2349
2350 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2351 int start, int end, OrderByComparator obc) throws SystemException {
2352 Object[] finderArgs = new Object[] {
2353 new Long(pk), String.valueOf(start), String.valueOf(end),
2354 String.valueOf(obc)
2355 };
2356
2357 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
2358 finderArgs, this);
2359
2360 if (list == null) {
2361 Session session = null;
2362
2363 try {
2364 session = openSession();
2365
2366 StringBundler query = null;
2367 String sql = null;
2368
2369 if (obc != null) {
2370 query = new StringBundler(3);
2371
2372 query.append(_SQL_GETPERMISSIONS);
2373 query.append(ORDER_BY_CLAUSE);
2374 query.append(obc.getOrderBy());
2375
2376 sql = query.toString();
2377 }
2378
2379 sql = _SQL_GETPERMISSIONS;
2380
2381 SQLQuery q = session.createSQLQuery(sql);
2382
2383 q.addEntity("Permission_",
2384 com.liferay.portal.model.impl.PermissionImpl.class);
2385
2386 QueryPos qPos = QueryPos.getInstance(q);
2387
2388 qPos.add(pk);
2389
2390 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
2391 getDialect(), start, end);
2392 }
2393 catch (Exception e) {
2394 throw processException(e);
2395 }
2396 finally {
2397 if (list == null) {
2398 list = new ArrayList<com.liferay.portal.model.Permission>();
2399 }
2400
2401 permissionPersistence.cacheResult(list);
2402
2403 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
2404 finderArgs, list);
2405
2406 closeSession(session);
2407 }
2408 }
2409
2410 return list;
2411 }
2412
2413 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2414 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
2415 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
2416 "getPermissionsSize", new String[] { Long.class.getName() });
2417
2418 public int getPermissionsSize(long pk) throws SystemException {
2419 Object[] finderArgs = new Object[] { new Long(pk) };
2420
2421 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
2422 finderArgs, this);
2423
2424 if (count == null) {
2425 Session session = null;
2426
2427 try {
2428 session = openSession();
2429
2430 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
2431
2432 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2433
2434 QueryPos qPos = QueryPos.getInstance(q);
2435
2436 qPos.add(pk);
2437
2438 count = (Long)q.uniqueResult();
2439 }
2440 catch (Exception e) {
2441 throw processException(e);
2442 }
2443 finally {
2444 if (count == null) {
2445 count = Long.valueOf(0);
2446 }
2447
2448 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
2449 finderArgs, count);
2450
2451 closeSession(session);
2452 }
2453 }
2454
2455 return count.intValue();
2456 }
2457
2458 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2459 RoleModelImpl.FINDER_CACHE_ENABLED_ROLES_PERMISSIONS,
2460 RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME,
2461 "containsPermission",
2462 new String[] { Long.class.getName(), Long.class.getName() });
2463
2464 public boolean containsPermission(long pk, long permissionPK)
2465 throws SystemException {
2466 Object[] finderArgs = new Object[] { new Long(pk), new Long(permissionPK) };
2467
2468 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
2469 finderArgs, this);
2470
2471 if (value == null) {
2472 try {
2473 value = Boolean.valueOf(containsPermission.contains(pk,
2474 permissionPK));
2475 }
2476 catch (Exception e) {
2477 throw processException(e);
2478 }
2479 finally {
2480 if (value == null) {
2481 value = Boolean.FALSE;
2482 }
2483
2484 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
2485 finderArgs, value);
2486 }
2487 }
2488
2489 return value.booleanValue();
2490 }
2491
2492 public boolean containsPermissions(long pk) throws SystemException {
2493 if (getPermissionsSize(pk) > 0) {
2494 return true;
2495 }
2496 else {
2497 return false;
2498 }
2499 }
2500
2501 public void addPermission(long pk, long permissionPK)
2502 throws SystemException {
2503 try {
2504 addPermission.add(pk, permissionPK);
2505 }
2506 catch (Exception e) {
2507 throw processException(e);
2508 }
2509 finally {
2510 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2511 }
2512 }
2513
2514 public void addPermission(long pk,
2515 com.liferay.portal.model.Permission permission)
2516 throws SystemException {
2517 try {
2518 addPermission.add(pk, permission.getPrimaryKey());
2519 }
2520 catch (Exception e) {
2521 throw processException(e);
2522 }
2523 finally {
2524 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2525 }
2526 }
2527
2528 public void addPermissions(long pk, long[] permissionPKs)
2529 throws SystemException {
2530 try {
2531 for (long permissionPK : permissionPKs) {
2532 addPermission.add(pk, permissionPK);
2533 }
2534 }
2535 catch (Exception e) {
2536 throw processException(e);
2537 }
2538 finally {
2539 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2540 }
2541 }
2542
2543 public void addPermissions(long pk,
2544 List<com.liferay.portal.model.Permission> permissions)
2545 throws SystemException {
2546 try {
2547 for (com.liferay.portal.model.Permission permission : permissions) {
2548 addPermission.add(pk, permission.getPrimaryKey());
2549 }
2550 }
2551 catch (Exception e) {
2552 throw processException(e);
2553 }
2554 finally {
2555 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2556 }
2557 }
2558
2559 public void clearPermissions(long pk) throws SystemException {
2560 try {
2561 clearPermissions.clear(pk);
2562 }
2563 catch (Exception e) {
2564 throw processException(e);
2565 }
2566 finally {
2567 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2568 }
2569 }
2570
2571 public void removePermission(long pk, long permissionPK)
2572 throws SystemException {
2573 try {
2574 removePermission.remove(pk, permissionPK);
2575 }
2576 catch (Exception e) {
2577 throw processException(e);
2578 }
2579 finally {
2580 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2581 }
2582 }
2583
2584 public void removePermission(long pk,
2585 com.liferay.portal.model.Permission permission)
2586 throws SystemException {
2587 try {
2588 removePermission.remove(pk, permission.getPrimaryKey());
2589 }
2590 catch (Exception e) {
2591 throw processException(e);
2592 }
2593 finally {
2594 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2595 }
2596 }
2597
2598 public void removePermissions(long pk, long[] permissionPKs)
2599 throws SystemException {
2600 try {
2601 for (long permissionPK : permissionPKs) {
2602 removePermission.remove(pk, permissionPK);
2603 }
2604 }
2605 catch (Exception e) {
2606 throw processException(e);
2607 }
2608 finally {
2609 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2610 }
2611 }
2612
2613 public void removePermissions(long pk,
2614 List<com.liferay.portal.model.Permission> permissions)
2615 throws SystemException {
2616 try {
2617 for (com.liferay.portal.model.Permission permission : permissions) {
2618 removePermission.remove(pk, permission.getPrimaryKey());
2619 }
2620 }
2621 catch (Exception e) {
2622 throw processException(e);
2623 }
2624 finally {
2625 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2626 }
2627 }
2628
2629 public void setPermissions(long pk, long[] permissionPKs)
2630 throws SystemException {
2631 try {
2632 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
2633
2634 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
2635
2636 for (com.liferay.portal.model.Permission permission : permissions) {
2637 if (!permissionPKSet.contains(permission.getPrimaryKey())) {
2638 removePermission.remove(pk, permission.getPrimaryKey());
2639 }
2640 else {
2641 permissionPKSet.remove(permission.getPrimaryKey());
2642 }
2643 }
2644
2645 for (Long permissionPK : permissionPKSet) {
2646 addPermission.add(pk, permissionPK);
2647 }
2648 }
2649 catch (Exception e) {
2650 throw processException(e);
2651 }
2652 finally {
2653 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2654 }
2655 }
2656
2657 public void setPermissions(long pk,
2658 List<com.liferay.portal.model.Permission> permissions)
2659 throws SystemException {
2660 try {
2661 long[] permissionPKs = new long[permissions.size()];
2662
2663 for (int i = 0; i < permissions.size(); i++) {
2664 com.liferay.portal.model.Permission permission = permissions.get(i);
2665
2666 permissionPKs[i] = permission.getPrimaryKey();
2667 }
2668
2669 setPermissions(pk, permissionPKs);
2670 }
2671 catch (Exception e) {
2672 throw processException(e);
2673 }
2674 finally {
2675 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_ROLES_PERMISSIONS_NAME);
2676 }
2677 }
2678
2679 public List<com.liferay.portal.model.User> getUsers(long pk)
2680 throws SystemException {
2681 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2682 }
2683
2684 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2685 int end) throws SystemException {
2686 return getUsers(pk, start, end, null);
2687 }
2688
2689 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2690 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
2691 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsers",
2692 new String[] {
2693 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2694 "com.liferay.portal.kernel.util.OrderByComparator"
2695 });
2696
2697 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2698 int end, OrderByComparator obc) throws SystemException {
2699 Object[] finderArgs = new Object[] {
2700 new Long(pk), String.valueOf(start), String.valueOf(end),
2701 String.valueOf(obc)
2702 };
2703
2704 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
2705 finderArgs, this);
2706
2707 if (list == null) {
2708 Session session = null;
2709
2710 try {
2711 session = openSession();
2712
2713 StringBundler query = null;
2714 String sql = null;
2715
2716 if (obc != null) {
2717 query = new StringBundler(3);
2718
2719 query.append(_SQL_GETUSERS);
2720 query.append(ORDER_BY_CLAUSE);
2721 query.append(obc.getOrderBy());
2722
2723 sql = query.toString();
2724 }
2725
2726 sql = _SQL_GETUSERS;
2727
2728 SQLQuery q = session.createSQLQuery(sql);
2729
2730 q.addEntity("User_",
2731 com.liferay.portal.model.impl.UserImpl.class);
2732
2733 QueryPos qPos = QueryPos.getInstance(q);
2734
2735 qPos.add(pk);
2736
2737 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
2738 getDialect(), start, end);
2739 }
2740 catch (Exception e) {
2741 throw processException(e);
2742 }
2743 finally {
2744 if (list == null) {
2745 list = new ArrayList<com.liferay.portal.model.User>();
2746 }
2747
2748 userPersistence.cacheResult(list);
2749
2750 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
2751 list);
2752
2753 closeSession(session);
2754 }
2755 }
2756
2757 return list;
2758 }
2759
2760 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2761 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
2762 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getUsersSize",
2763 new String[] { Long.class.getName() });
2764
2765 public int getUsersSize(long pk) throws SystemException {
2766 Object[] finderArgs = new Object[] { new Long(pk) };
2767
2768 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
2769 finderArgs, this);
2770
2771 if (count == null) {
2772 Session session = null;
2773
2774 try {
2775 session = openSession();
2776
2777 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
2778
2779 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2780
2781 QueryPos qPos = QueryPos.getInstance(q);
2782
2783 qPos.add(pk);
2784
2785 count = (Long)q.uniqueResult();
2786 }
2787 catch (Exception e) {
2788 throw processException(e);
2789 }
2790 finally {
2791 if (count == null) {
2792 count = Long.valueOf(0);
2793 }
2794
2795 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
2796 finderArgs, count);
2797
2798 closeSession(session);
2799 }
2800 }
2801
2802 return count.intValue();
2803 }
2804
2805 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2806 RoleModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
2807 RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsUser",
2808 new String[] { Long.class.getName(), Long.class.getName() });
2809
2810 public boolean containsUser(long pk, long userPK) throws SystemException {
2811 Object[] finderArgs = new Object[] { new Long(pk), new Long(userPK) };
2812
2813 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
2814 finderArgs, this);
2815
2816 if (value == null) {
2817 try {
2818 value = Boolean.valueOf(containsUser.contains(pk, userPK));
2819 }
2820 catch (Exception e) {
2821 throw processException(e);
2822 }
2823 finally {
2824 if (value == null) {
2825 value = Boolean.FALSE;
2826 }
2827
2828 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
2829 finderArgs, value);
2830 }
2831 }
2832
2833 return value.booleanValue();
2834 }
2835
2836 public boolean containsUsers(long pk) throws SystemException {
2837 if (getUsersSize(pk) > 0) {
2838 return true;
2839 }
2840 else {
2841 return false;
2842 }
2843 }
2844
2845 public void addUser(long pk, long userPK) throws SystemException {
2846 try {
2847 addUser.add(pk, userPK);
2848 }
2849 catch (Exception e) {
2850 throw processException(e);
2851 }
2852 finally {
2853 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2854 }
2855 }
2856
2857 public void addUser(long pk, com.liferay.portal.model.User user)
2858 throws SystemException {
2859 try {
2860 addUser.add(pk, user.getPrimaryKey());
2861 }
2862 catch (Exception e) {
2863 throw processException(e);
2864 }
2865 finally {
2866 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2867 }
2868 }
2869
2870 public void addUsers(long pk, long[] userPKs) throws SystemException {
2871 try {
2872 for (long userPK : userPKs) {
2873 addUser.add(pk, userPK);
2874 }
2875 }
2876 catch (Exception e) {
2877 throw processException(e);
2878 }
2879 finally {
2880 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2881 }
2882 }
2883
2884 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2885 throws SystemException {
2886 try {
2887 for (com.liferay.portal.model.User user : users) {
2888 addUser.add(pk, user.getPrimaryKey());
2889 }
2890 }
2891 catch (Exception e) {
2892 throw processException(e);
2893 }
2894 finally {
2895 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2896 }
2897 }
2898
2899 public void clearUsers(long pk) throws SystemException {
2900 try {
2901 clearUsers.clear(pk);
2902 }
2903 catch (Exception e) {
2904 throw processException(e);
2905 }
2906 finally {
2907 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2908 }
2909 }
2910
2911 public void removeUser(long pk, long userPK) throws SystemException {
2912 try {
2913 removeUser.remove(pk, userPK);
2914 }
2915 catch (Exception e) {
2916 throw processException(e);
2917 }
2918 finally {
2919 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2920 }
2921 }
2922
2923 public void removeUser(long pk, com.liferay.portal.model.User user)
2924 throws SystemException {
2925 try {
2926 removeUser.remove(pk, user.getPrimaryKey());
2927 }
2928 catch (Exception e) {
2929 throw processException(e);
2930 }
2931 finally {
2932 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2933 }
2934 }
2935
2936 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2937 try {
2938 for (long userPK : userPKs) {
2939 removeUser.remove(pk, userPK);
2940 }
2941 }
2942 catch (Exception e) {
2943 throw processException(e);
2944 }
2945 finally {
2946 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2947 }
2948 }
2949
2950 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2951 throws SystemException {
2952 try {
2953 for (com.liferay.portal.model.User user : users) {
2954 removeUser.remove(pk, user.getPrimaryKey());
2955 }
2956 }
2957 catch (Exception e) {
2958 throw processException(e);
2959 }
2960 finally {
2961 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2962 }
2963 }
2964
2965 public void setUsers(long pk, long[] userPKs) throws SystemException {
2966 try {
2967 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2968
2969 List<com.liferay.portal.model.User> users = getUsers(pk);
2970
2971 for (com.liferay.portal.model.User user : users) {
2972 if (!userPKSet.contains(user.getPrimaryKey())) {
2973 removeUser.remove(pk, user.getPrimaryKey());
2974 }
2975 else {
2976 userPKSet.remove(user.getPrimaryKey());
2977 }
2978 }
2979
2980 for (Long userPK : userPKSet) {
2981 addUser.add(pk, userPK);
2982 }
2983 }
2984 catch (Exception e) {
2985 throw processException(e);
2986 }
2987 finally {
2988 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
2989 }
2990 }
2991
2992 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2993 throws SystemException {
2994 try {
2995 long[] userPKs = new long[users.size()];
2996
2997 for (int i = 0; i < users.size(); i++) {
2998 com.liferay.portal.model.User user = users.get(i);
2999
3000 userPKs[i] = user.getPrimaryKey();
3001 }
3002
3003 setUsers(pk, userPKs);
3004 }
3005 catch (Exception e) {
3006 throw processException(e);
3007 }
3008 finally {
3009 FinderCacheUtil.clearCache(RoleModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
3010 }
3011 }
3012
3013 public void afterPropertiesSet() {
3014 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3015 com.liferay.portal.util.PropsUtil.get(
3016 "value.object.listener.com.liferay.portal.model.Role")));
3017
3018 if (listenerClassNames.length > 0) {
3019 try {
3020 List<ModelListener<Role>> listenersList = new ArrayList<ModelListener<Role>>();
3021
3022 for (String listenerClassName : listenerClassNames) {
3023 listenersList.add((ModelListener<Role>)Class.forName(
3024 listenerClassName).newInstance());
3025 }
3026
3027 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3028 }
3029 catch (Exception e) {
3030 _log.error(e);
3031 }
3032 }
3033
3034 containsGroup = new ContainsGroup(this);
3035
3036 addGroup = new AddGroup(this);
3037 clearGroups = new ClearGroups(this);
3038 removeGroup = new RemoveGroup(this);
3039
3040 containsPermission = new ContainsPermission(this);
3041
3042 addPermission = new AddPermission(this);
3043 clearPermissions = new ClearPermissions(this);
3044 removePermission = new RemovePermission(this);
3045
3046 containsUser = new ContainsUser(this);
3047
3048 addUser = new AddUser(this);
3049 clearUsers = new ClearUsers(this);
3050 removeUser = new RemoveUser(this);
3051 }
3052
3053 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence")
3054 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
3055 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence")
3056 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
3057 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence")
3058 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
3059 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence")
3060 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
3061 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
3062 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
3063 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence")
3064 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
3065 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence")
3066 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
3067 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence")
3068 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
3069 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
3070 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
3071 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
3072 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
3073 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence")
3074 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
3075 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence")
3076 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
3077 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence")
3078 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
3079 @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence")
3080 protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
3081 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence")
3082 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
3083 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence")
3084 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
3085 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence")
3086 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3087 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence")
3088 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
3089 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence")
3090 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
3091 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence")
3092 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
3093 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence")
3094 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3095 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence")
3096 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
3097 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence")
3098 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
3099 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence")
3100 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
3101 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence")
3102 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
3103 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence")
3104 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
3105 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence")
3106 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
3107 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
3108 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
3109 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence")
3110 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
3111 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence")
3112 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
3113 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
3114 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
3115 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence")
3116 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
3117 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence")
3118 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
3119 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence")
3120 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
3121 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence")
3122 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
3123 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence")
3124 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
3125 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence")
3126 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
3127 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
3128 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
3129 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
3130 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
3131 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence")
3132 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
3133 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupGroupRolePersistence")
3134 protected com.liferay.portal.service.persistence.UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3135 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence")
3136 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
3137 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence")
3138 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
3139 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence")
3140 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
3141 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence")
3142 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
3143 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence")
3144 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
3145 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence")
3146 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
3147 protected ContainsGroup containsGroup;
3148 protected AddGroup addGroup;
3149 protected ClearGroups clearGroups;
3150 protected RemoveGroup removeGroup;
3151 protected ContainsPermission containsPermission;
3152 protected AddPermission addPermission;
3153 protected ClearPermissions clearPermissions;
3154 protected RemovePermission removePermission;
3155 protected ContainsUser containsUser;
3156 protected AddUser addUser;
3157 protected ClearUsers clearUsers;
3158 protected RemoveUser removeUser;
3159
3160 protected class ContainsGroup {
3161 protected ContainsGroup(RolePersistenceImpl persistenceImpl) {
3162 super();
3163
3164 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3165 _SQL_CONTAINSGROUP,
3166 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
3167 }
3168
3169 protected boolean contains(long roleId, long groupId) {
3170 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3171 new Long(roleId), new Long(groupId)
3172 });
3173
3174 if (results.size() > 0) {
3175 Integer count = results.get(0);
3176
3177 if (count.intValue() > 0) {
3178 return true;
3179 }
3180 }
3181
3182 return false;
3183 }
3184
3185 private MappingSqlQuery _mappingSqlQuery;
3186 }
3187
3188 protected class AddGroup {
3189 protected AddGroup(RolePersistenceImpl persistenceImpl) {
3190 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3191 "INSERT INTO Groups_Roles (roleId, groupId) VALUES (?, ?)",
3192 new int[] { Types.BIGINT, Types.BIGINT });
3193 _persistenceImpl = persistenceImpl;
3194 }
3195
3196 protected void add(long roleId, long groupId) throws SystemException {
3197 if (!_persistenceImpl.containsGroup.contains(roleId, groupId)) {
3198 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3199
3200 for (ModelListener<Role> listener : listeners) {
3201 listener.onBeforeAddAssociation(roleId,
3202 com.liferay.portal.model.Group.class.getName(), groupId);
3203 }
3204
3205 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3206 listener.onBeforeAddAssociation(groupId,
3207 Role.class.getName(), roleId);
3208 }
3209
3210 _sqlUpdate.update(new Object[] {
3211 new Long(roleId), new Long(groupId)
3212 });
3213
3214 for (ModelListener<Role> listener : listeners) {
3215 listener.onAfterAddAssociation(roleId,
3216 com.liferay.portal.model.Group.class.getName(), groupId);
3217 }
3218
3219 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3220 listener.onAfterAddAssociation(groupId,
3221 Role.class.getName(), roleId);
3222 }
3223 }
3224 }
3225
3226 private SqlUpdate _sqlUpdate;
3227 private RolePersistenceImpl _persistenceImpl;
3228 }
3229
3230 protected class ClearGroups {
3231 protected ClearGroups(RolePersistenceImpl persistenceImpl) {
3232 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3233 "DELETE FROM Groups_Roles WHERE roleId = ?",
3234 new int[] { Types.BIGINT });
3235 }
3236
3237 protected void clear(long roleId) throws SystemException {
3238 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3239
3240 List<com.liferay.portal.model.Group> groups = null;
3241
3242 if ((listeners.length > 0) || (groupListeners.length > 0)) {
3243 groups = getGroups(roleId);
3244
3245 for (com.liferay.portal.model.Group group : groups) {
3246 for (ModelListener<Role> listener : listeners) {
3247 listener.onBeforeRemoveAssociation(roleId,
3248 com.liferay.portal.model.Group.class.getName(),
3249 group.getPrimaryKey());
3250 }
3251
3252 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3253 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
3254 Role.class.getName(), roleId);
3255 }
3256 }
3257 }
3258
3259 _sqlUpdate.update(new Object[] { new Long(roleId) });
3260
3261 if ((listeners.length > 0) || (groupListeners.length > 0)) {
3262 for (com.liferay.portal.model.Group group : groups) {
3263 for (ModelListener<Role> listener : listeners) {
3264 listener.onAfterRemoveAssociation(roleId,
3265 com.liferay.portal.model.Group.class.getName(),
3266 group.getPrimaryKey());
3267 }
3268
3269 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3270 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
3271 Role.class.getName(), roleId);
3272 }
3273 }
3274 }
3275 }
3276
3277 private SqlUpdate _sqlUpdate;
3278 }
3279
3280 protected class RemoveGroup {
3281 protected RemoveGroup(RolePersistenceImpl persistenceImpl) {
3282 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3283 "DELETE FROM Groups_Roles WHERE roleId = ? AND groupId = ?",
3284 new int[] { Types.BIGINT, Types.BIGINT });
3285 _persistenceImpl = persistenceImpl;
3286 }
3287
3288 protected void remove(long roleId, long groupId)
3289 throws SystemException {
3290 if (_persistenceImpl.containsGroup.contains(roleId, groupId)) {
3291 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
3292
3293 for (ModelListener<Role> listener : listeners) {
3294 listener.onBeforeRemoveAssociation(roleId,
3295 com.liferay.portal.model.Group.class.getName(), groupId);
3296 }
3297
3298 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3299 listener.onBeforeRemoveAssociation(groupId,
3300 Role.class.getName(), roleId);
3301 }
3302
3303 _sqlUpdate.update(new Object[] {
3304 new Long(roleId), new Long(groupId)
3305 });
3306
3307 for (ModelListener<Role> listener : listeners) {
3308 listener.onAfterRemoveAssociation(roleId,
3309 com.liferay.portal.model.Group.class.getName(), groupId);
3310 }
3311
3312 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
3313 listener.onAfterRemoveAssociation(groupId,
3314 Role.class.getName(), roleId);
3315 }
3316 }
3317 }
3318
3319 private SqlUpdate _sqlUpdate;
3320 private RolePersistenceImpl _persistenceImpl;
3321 }
3322
3323 protected class ContainsPermission {
3324 protected ContainsPermission(RolePersistenceImpl persistenceImpl) {
3325 super();
3326
3327 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3328 _SQL_CONTAINSPERMISSION,
3329 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
3330 }
3331
3332 protected boolean contains(long roleId, long permissionId) {
3333 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3334 new Long(roleId), new Long(permissionId)
3335 });
3336
3337 if (results.size() > 0) {
3338 Integer count = results.get(0);
3339
3340 if (count.intValue() > 0) {
3341 return true;
3342 }
3343 }
3344
3345 return false;
3346 }
3347
3348 private MappingSqlQuery _mappingSqlQuery;
3349 }
3350
3351 protected class AddPermission {
3352 protected AddPermission(RolePersistenceImpl persistenceImpl) {
3353 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3354 "INSERT INTO Roles_Permissions (roleId, permissionId) VALUES (?, ?)",
3355 new int[] { Types.BIGINT, Types.BIGINT });
3356 _persistenceImpl = persistenceImpl;
3357 }
3358
3359 protected void add(long roleId, long permissionId)
3360 throws SystemException {
3361 if (!_persistenceImpl.containsPermission.contains(roleId,
3362 permissionId)) {
3363 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
3364 permissionPersistence.getListeners();
3365
3366 for (ModelListener<Role> listener : listeners) {
3367 listener.onBeforeAddAssociation(roleId,
3368 com.liferay.portal.model.Permission.class.getName(),
3369 permissionId);
3370 }
3371
3372 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
3373 listener.onBeforeAddAssociation(permissionId,
3374 Role.class.getName(), roleId);
3375 }
3376
3377 _sqlUpdate.update(new Object[] {
3378 new Long(roleId), new Long(permissionId)
3379 });
3380
3381 for (ModelListener<Role> listener : listeners) {
3382 listener.onAfterAddAssociation(roleId,
3383 com.liferay.portal.model.Permission.class.getName(),
3384 permissionId);
3385 }
3386
3387 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
3388 listener.onAfterAddAssociation(permissionId,
3389 Role.class.getName(), roleId);
3390 }
3391 }
3392 }
3393
3394 private SqlUpdate _sqlUpdate;
3395 private RolePersistenceImpl _persistenceImpl;
3396 }
3397
3398 protected class ClearPermissions {
3399 protected ClearPermissions(RolePersistenceImpl persistenceImpl) {
3400 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3401 "DELETE FROM Roles_Permissions WHERE roleId = ?",
3402 new int[] { Types.BIGINT });
3403 }
3404
3405 protected void clear(long roleId) throws SystemException {
3406 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
3407 permissionPersistence.getListeners();
3408
3409 List<com.liferay.portal.model.Permission> permissions = null;
3410
3411 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
3412 permissions = getPermissions(roleId);
3413
3414 for (com.liferay.portal.model.Permission permission : permissions) {
3415 for (ModelListener<Role> listener : listeners) {
3416 listener.onBeforeRemoveAssociation(roleId,
3417 com.liferay.portal.model.Permission.class.getName(),
3418 permission.getPrimaryKey());
3419 }
3420
3421 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
3422 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
3423 Role.class.getName(), roleId);
3424 }
3425 }
3426 }
3427
3428 _sqlUpdate.update(new Object[] { new Long(roleId) });
3429
3430 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
3431 for (com.liferay.portal.model.Permission permission : permissions) {
3432 for (ModelListener<Role> listener : listeners) {
3433 listener.onAfterRemoveAssociation(roleId,
3434 com.liferay.portal.model.Permission.class.getName(),
3435 permission.getPrimaryKey());
3436 }
3437
3438 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
3439 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
3440 Role.class.getName(), roleId);
3441 }
3442 }
3443 }
3444 }
3445
3446 private SqlUpdate _sqlUpdate;
3447 }
3448
3449 protected class RemovePermission {
3450 protected RemovePermission(RolePersistenceImpl persistenceImpl) {
3451 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3452 "DELETE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?",
3453 new int[] { Types.BIGINT, Types.BIGINT });
3454 _persistenceImpl = persistenceImpl;
3455 }
3456
3457 protected void remove(long roleId, long permissionId)
3458 throws SystemException {
3459 if (_persistenceImpl.containsPermission.contains(roleId,
3460 permissionId)) {
3461 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
3462 permissionPersistence.getListeners();
3463
3464 for (ModelListener<Role> listener : listeners) {
3465 listener.onBeforeRemoveAssociation(roleId,
3466 com.liferay.portal.model.Permission.class.getName(),
3467 permissionId);
3468 }
3469
3470 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
3471 listener.onBeforeRemoveAssociation(permissionId,
3472 Role.class.getName(), roleId);
3473 }
3474
3475 _sqlUpdate.update(new Object[] {
3476 new Long(roleId), new Long(permissionId)
3477 });
3478
3479 for (ModelListener<Role> listener : listeners) {
3480 listener.onAfterRemoveAssociation(roleId,
3481 com.liferay.portal.model.Permission.class.getName(),
3482 permissionId);
3483 }
3484
3485 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
3486 listener.onAfterRemoveAssociation(permissionId,
3487 Role.class.getName(), roleId);
3488 }
3489 }
3490 }
3491
3492 private SqlUpdate _sqlUpdate;
3493 private RolePersistenceImpl _persistenceImpl;
3494 }
3495
3496 protected class ContainsUser {
3497 protected ContainsUser(RolePersistenceImpl persistenceImpl) {
3498 super();
3499
3500 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3501 _SQL_CONTAINSUSER,
3502 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
3503 }
3504
3505 protected boolean contains(long roleId, long userId) {
3506 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3507 new Long(roleId), new Long(userId)
3508 });
3509
3510 if (results.size() > 0) {
3511 Integer count = results.get(0);
3512
3513 if (count.intValue() > 0) {
3514 return true;
3515 }
3516 }
3517
3518 return false;
3519 }
3520
3521 private MappingSqlQuery _mappingSqlQuery;
3522 }
3523
3524 protected class AddUser {
3525 protected AddUser(RolePersistenceImpl persistenceImpl) {
3526 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3527 "INSERT INTO Users_Roles (roleId, userId) VALUES (?, ?)",
3528 new int[] { Types.BIGINT, Types.BIGINT });
3529 _persistenceImpl = persistenceImpl;
3530 }
3531
3532 protected void add(long roleId, long userId) throws SystemException {
3533 if (!_persistenceImpl.containsUser.contains(roleId, userId)) {
3534 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3535
3536 for (ModelListener<Role> listener : listeners) {
3537 listener.onBeforeAddAssociation(roleId,
3538 com.liferay.portal.model.User.class.getName(), userId);
3539 }
3540
3541 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3542 listener.onBeforeAddAssociation(userId,
3543 Role.class.getName(), roleId);
3544 }
3545
3546 _sqlUpdate.update(new Object[] {
3547 new Long(roleId), new Long(userId)
3548 });
3549
3550 for (ModelListener<Role> listener : listeners) {
3551 listener.onAfterAddAssociation(roleId,
3552 com.liferay.portal.model.User.class.getName(), userId);
3553 }
3554
3555 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3556 listener.onAfterAddAssociation(userId,
3557 Role.class.getName(), roleId);
3558 }
3559 }
3560 }
3561
3562 private SqlUpdate _sqlUpdate;
3563 private RolePersistenceImpl _persistenceImpl;
3564 }
3565
3566 protected class ClearUsers {
3567 protected ClearUsers(RolePersistenceImpl persistenceImpl) {
3568 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3569 "DELETE FROM Users_Roles WHERE roleId = ?",
3570 new int[] { Types.BIGINT });
3571 }
3572
3573 protected void clear(long roleId) throws SystemException {
3574 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3575
3576 List<com.liferay.portal.model.User> users = null;
3577
3578 if ((listeners.length > 0) || (userListeners.length > 0)) {
3579 users = getUsers(roleId);
3580
3581 for (com.liferay.portal.model.User user : users) {
3582 for (ModelListener<Role> listener : listeners) {
3583 listener.onBeforeRemoveAssociation(roleId,
3584 com.liferay.portal.model.User.class.getName(),
3585 user.getPrimaryKey());
3586 }
3587
3588 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3589 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
3590 Role.class.getName(), roleId);
3591 }
3592 }
3593 }
3594
3595 _sqlUpdate.update(new Object[] { new Long(roleId) });
3596
3597 if ((listeners.length > 0) || (userListeners.length > 0)) {
3598 for (com.liferay.portal.model.User user : users) {
3599 for (ModelListener<Role> listener : listeners) {
3600 listener.onAfterRemoveAssociation(roleId,
3601 com.liferay.portal.model.User.class.getName(),
3602 user.getPrimaryKey());
3603 }
3604
3605 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3606 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
3607 Role.class.getName(), roleId);
3608 }
3609 }
3610 }
3611 }
3612
3613 private SqlUpdate _sqlUpdate;
3614 }
3615
3616 protected class RemoveUser {
3617 protected RemoveUser(RolePersistenceImpl persistenceImpl) {
3618 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3619 "DELETE FROM Users_Roles WHERE roleId = ? AND userId = ?",
3620 new int[] { Types.BIGINT, Types.BIGINT });
3621 _persistenceImpl = persistenceImpl;
3622 }
3623
3624 protected void remove(long roleId, long userId)
3625 throws SystemException {
3626 if (_persistenceImpl.containsUser.contains(roleId, userId)) {
3627 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3628
3629 for (ModelListener<Role> listener : listeners) {
3630 listener.onBeforeRemoveAssociation(roleId,
3631 com.liferay.portal.model.User.class.getName(), userId);
3632 }
3633
3634 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3635 listener.onBeforeRemoveAssociation(userId,
3636 Role.class.getName(), roleId);
3637 }
3638
3639 _sqlUpdate.update(new Object[] {
3640 new Long(roleId), new Long(userId)
3641 });
3642
3643 for (ModelListener<Role> listener : listeners) {
3644 listener.onAfterRemoveAssociation(roleId,
3645 com.liferay.portal.model.User.class.getName(), userId);
3646 }
3647
3648 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3649 listener.onAfterRemoveAssociation(userId,
3650 Role.class.getName(), roleId);
3651 }
3652 }
3653 }
3654
3655 private SqlUpdate _sqlUpdate;
3656 private RolePersistenceImpl _persistenceImpl;
3657 }
3658
3659 private static final String _SQL_SELECT_ROLE = "SELECT role FROM Role role";
3660 private static final String _SQL_SELECT_ROLE_WHERE = "SELECT role FROM Role role WHERE ";
3661 private static final String _SQL_COUNT_ROLE = "SELECT COUNT(role) FROM Role role";
3662 private static final String _SQL_COUNT_ROLE_WHERE = "SELECT COUNT(role) FROM Role role WHERE ";
3663 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Roles ON (Groups_Roles.groupId = Group_.groupId) WHERE (Groups_Roles.roleId = ?)";
3664 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ?";
3665 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE roleId = ? AND groupId = ?";
3666 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Roles_Permissions ON (Roles_Permissions.permissionId = Permission_.permissionId) WHERE (Roles_Permissions.roleId = ?)";
3667 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ?";
3668 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Roles_Permissions WHERE roleId = ? AND permissionId = ?";
3669 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Roles ON (Users_Roles.userId = User_.userId) WHERE (Users_Roles.roleId = ?)";
3670 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ?";
3671 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE roleId = ? AND userId = ?";
3672 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "role.companyId = ?";
3673 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_1 = "role.subtype IS NULL";
3674 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_2 = "role.subtype = ?";
3675 private static final String _FINDER_COLUMN_SUBTYPE_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
3676 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "role.companyId = ? AND ";
3677 private static final String _FINDER_COLUMN_C_N_NAME_1 = "role.name IS NULL";
3678 private static final String _FINDER_COLUMN_C_N_NAME_2 = "role.name = ?";
3679 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(role.name IS NULL OR role.name = ?)";
3680 private static final String _FINDER_COLUMN_T_S_TYPE_2 = "role.type = ? AND ";
3681 private static final String _FINDER_COLUMN_T_S_SUBTYPE_1 = "role.subtype IS NULL";
3682 private static final String _FINDER_COLUMN_T_S_SUBTYPE_2 = "role.subtype = ?";
3683 private static final String _FINDER_COLUMN_T_S_SUBTYPE_3 = "(role.subtype IS NULL OR role.subtype = ?)";
3684 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "role.companyId = ? AND ";
3685 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "role.classNameId = ? AND ";
3686 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "role.classPK = ?";
3687 private static final String _ORDER_BY_ENTITY_ALIAS = "role.";
3688 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Role exists with the primary key ";
3689 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Role exists with the key {";
3690 private static Log _log = LogFactoryUtil.getLog(RolePersistenceImpl.class);
3691}