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