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