001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserGroupException;
019 import com.liferay.portal.kernel.bean.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.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.model.UserGroup;
048 import com.liferay.portal.model.impl.UserGroupImpl;
049 import com.liferay.portal.model.impl.UserGroupModelImpl;
050 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.List;
058 import java.util.Set;
059
060
072 public class UserGroupPersistenceImpl extends BasePersistenceImpl<UserGroup>
073 implements UserGroupPersistence {
074
079 public static final String FINDER_CLASS_NAME_ENTITY = UserGroupImpl.class.getName();
080 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List1";
082 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List2";
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
085 new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
086 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
087 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
088 new String[] {
089 Long.class.getName(),
090
091 "java.lang.Integer", "java.lang.Integer",
092 "com.liferay.portal.kernel.util.OrderByComparator"
093 });
094 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
095 new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
096 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
097 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
098 new String[] { Long.class.getName() },
099 UserGroupModelImpl.COMPANYID_COLUMN_BITMASK);
100 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
101 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
103 new String[] { Long.class.getName() });
104 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
105 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
106 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
107 new String[] {
108 Long.class.getName(), Long.class.getName(),
109
110 "java.lang.Integer", "java.lang.Integer",
111 "com.liferay.portal.kernel.util.OrderByComparator"
112 });
113 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
114 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
116 new String[] { Long.class.getName(), Long.class.getName() },
117 UserGroupModelImpl.COMPANYID_COLUMN_BITMASK |
118 UserGroupModelImpl.PARENTUSERGROUPID_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
120 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
122 new String[] { Long.class.getName(), Long.class.getName() });
123 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
124 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
125 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
126 new String[] { Long.class.getName(), String.class.getName() },
127 UserGroupModelImpl.COMPANYID_COLUMN_BITMASK |
128 UserGroupModelImpl.NAME_COLUMN_BITMASK);
129 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
130 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
132 new String[] { Long.class.getName(), String.class.getName() });
133 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
134 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
135 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
136 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
137 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
140 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
142
143
148 public void cacheResult(UserGroup userGroup) {
149 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
150 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
153 new Object[] {
154 Long.valueOf(userGroup.getCompanyId()),
155
156 userGroup.getName()
157 }, userGroup);
158
159 userGroup.resetOriginalValues();
160 }
161
162
167 public void cacheResult(List<UserGroup> userGroups) {
168 for (UserGroup userGroup : userGroups) {
169 if (EntityCacheUtil.getResult(
170 UserGroupModelImpl.ENTITY_CACHE_ENABLED,
171 UserGroupImpl.class, userGroup.getPrimaryKey()) == null) {
172 cacheResult(userGroup);
173 }
174 else {
175 userGroup.resetOriginalValues();
176 }
177 }
178 }
179
180
187 @Override
188 public void clearCache() {
189 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
190 CacheRegistryUtil.clear(UserGroupImpl.class.getName());
191 }
192
193 EntityCacheUtil.clearCache(UserGroupImpl.class.getName());
194
195 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
197 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
198 }
199
200
207 @Override
208 public void clearCache(UserGroup userGroup) {
209 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
210 UserGroupImpl.class, userGroup.getPrimaryKey());
211
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
214
215 clearUniqueFindersCache(userGroup);
216 }
217
218 @Override
219 public void clearCache(List<UserGroup> userGroups) {
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
222
223 for (UserGroup userGroup : userGroups) {
224 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
225 UserGroupImpl.class, userGroup.getPrimaryKey());
226
227 clearUniqueFindersCache(userGroup);
228 }
229 }
230
231 protected void clearUniqueFindersCache(UserGroup userGroup) {
232 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
233 new Object[] {
234 Long.valueOf(userGroup.getCompanyId()),
235
236 userGroup.getName()
237 });
238 }
239
240
246 public UserGroup create(long userGroupId) {
247 UserGroup userGroup = new UserGroupImpl();
248
249 userGroup.setNew(true);
250 userGroup.setPrimaryKey(userGroupId);
251
252 return userGroup;
253 }
254
255
263 public UserGroup remove(long userGroupId)
264 throws NoSuchUserGroupException, SystemException {
265 return remove(Long.valueOf(userGroupId));
266 }
267
268
276 @Override
277 public UserGroup remove(Serializable primaryKey)
278 throws NoSuchUserGroupException, SystemException {
279 Session session = null;
280
281 try {
282 session = openSession();
283
284 UserGroup userGroup = (UserGroup)session.get(UserGroupImpl.class,
285 primaryKey);
286
287 if (userGroup == null) {
288 if (_log.isWarnEnabled()) {
289 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
290 }
291
292 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
293 primaryKey);
294 }
295
296 return remove(userGroup);
297 }
298 catch (NoSuchUserGroupException nsee) {
299 throw nsee;
300 }
301 catch (Exception e) {
302 throw processException(e);
303 }
304 finally {
305 closeSession(session);
306 }
307 }
308
309 @Override
310 protected UserGroup removeImpl(UserGroup userGroup)
311 throws SystemException {
312 userGroup = toUnwrappedModel(userGroup);
313
314 try {
315 clearGroups.clear(userGroup.getPrimaryKey());
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
322 }
323
324 try {
325 clearTeams.clear(userGroup.getPrimaryKey());
326 }
327 catch (Exception e) {
328 throw processException(e);
329 }
330 finally {
331 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
332 }
333
334 try {
335 clearUsers.clear(userGroup.getPrimaryKey());
336 }
337 catch (Exception e) {
338 throw processException(e);
339 }
340 finally {
341 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
342 }
343
344 Session session = null;
345
346 try {
347 session = openSession();
348
349 BatchSessionUtil.delete(session, userGroup);
350 }
351 catch (Exception e) {
352 throw processException(e);
353 }
354 finally {
355 closeSession(session);
356 }
357
358 clearCache(userGroup);
359
360 return userGroup;
361 }
362
363 @Override
364 public UserGroup updateImpl(com.liferay.portal.model.UserGroup userGroup,
365 boolean merge) throws SystemException {
366 userGroup = toUnwrappedModel(userGroup);
367
368 boolean isNew = userGroup.isNew();
369
370 UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup;
371
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 BatchSessionUtil.update(session, userGroup, merge);
378
379 userGroup.setNew(false);
380 }
381 catch (Exception e) {
382 throw processException(e);
383 }
384 finally {
385 closeSession(session);
386 }
387
388 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
389
390 if (isNew || !UserGroupModelImpl.COLUMN_BITMASK_ENABLED) {
391 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
392 }
393 else {
394 if ((userGroupModelImpl.getColumnBitmask() &
395 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
396 Object[] args = new Object[] {
397 Long.valueOf(userGroupModelImpl.getOriginalCompanyId())
398 };
399
400 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
401 args);
402 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
403 args);
404
405 args = new Object[] {
406 Long.valueOf(userGroupModelImpl.getCompanyId())
407 };
408
409 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
410 args);
411 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
412 args);
413 }
414
415 if ((userGroupModelImpl.getColumnBitmask() &
416 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
417 Object[] args = new Object[] {
418 Long.valueOf(userGroupModelImpl.getOriginalCompanyId()),
419 Long.valueOf(userGroupModelImpl.getOriginalParentUserGroupId())
420 };
421
422 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
423 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
424 args);
425
426 args = new Object[] {
427 Long.valueOf(userGroupModelImpl.getCompanyId()),
428 Long.valueOf(userGroupModelImpl.getParentUserGroupId())
429 };
430
431 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
433 args);
434 }
435 }
436
437 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
438 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
439
440 if (isNew) {
441 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
442 new Object[] {
443 Long.valueOf(userGroup.getCompanyId()),
444
445 userGroup.getName()
446 }, userGroup);
447 }
448 else {
449 if ((userGroupModelImpl.getColumnBitmask() &
450 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
451 Object[] args = new Object[] {
452 Long.valueOf(userGroupModelImpl.getOriginalCompanyId()),
453
454 userGroupModelImpl.getOriginalName()
455 };
456
457 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
458 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
459
460 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
461 new Object[] {
462 Long.valueOf(userGroup.getCompanyId()),
463
464 userGroup.getName()
465 }, userGroup);
466 }
467 }
468
469 return userGroup;
470 }
471
472 protected UserGroup toUnwrappedModel(UserGroup userGroup) {
473 if (userGroup instanceof UserGroupImpl) {
474 return userGroup;
475 }
476
477 UserGroupImpl userGroupImpl = new UserGroupImpl();
478
479 userGroupImpl.setNew(userGroup.isNew());
480 userGroupImpl.setPrimaryKey(userGroup.getPrimaryKey());
481
482 userGroupImpl.setUserGroupId(userGroup.getUserGroupId());
483 userGroupImpl.setCompanyId(userGroup.getCompanyId());
484 userGroupImpl.setParentUserGroupId(userGroup.getParentUserGroupId());
485 userGroupImpl.setName(userGroup.getName());
486 userGroupImpl.setDescription(userGroup.getDescription());
487 userGroupImpl.setAddedByLDAPImport(userGroup.isAddedByLDAPImport());
488
489 return userGroupImpl;
490 }
491
492
500 @Override
501 public UserGroup findByPrimaryKey(Serializable primaryKey)
502 throws NoSuchModelException, SystemException {
503 return findByPrimaryKey(((Long)primaryKey).longValue());
504 }
505
506
514 public UserGroup findByPrimaryKey(long userGroupId)
515 throws NoSuchUserGroupException, SystemException {
516 UserGroup userGroup = fetchByPrimaryKey(userGroupId);
517
518 if (userGroup == null) {
519 if (_log.isWarnEnabled()) {
520 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupId);
521 }
522
523 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
524 userGroupId);
525 }
526
527 return userGroup;
528 }
529
530
537 @Override
538 public UserGroup fetchByPrimaryKey(Serializable primaryKey)
539 throws SystemException {
540 return fetchByPrimaryKey(((Long)primaryKey).longValue());
541 }
542
543
550 public UserGroup fetchByPrimaryKey(long userGroupId)
551 throws SystemException {
552 UserGroup userGroup = (UserGroup)EntityCacheUtil.getResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
553 UserGroupImpl.class, userGroupId);
554
555 if (userGroup == _nullUserGroup) {
556 return null;
557 }
558
559 if (userGroup == null) {
560 Session session = null;
561
562 boolean hasException = false;
563
564 try {
565 session = openSession();
566
567 userGroup = (UserGroup)session.get(UserGroupImpl.class,
568 Long.valueOf(userGroupId));
569 }
570 catch (Exception e) {
571 hasException = true;
572
573 throw processException(e);
574 }
575 finally {
576 if (userGroup != null) {
577 cacheResult(userGroup);
578 }
579 else if (!hasException) {
580 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
581 UserGroupImpl.class, userGroupId, _nullUserGroup);
582 }
583
584 closeSession(session);
585 }
586 }
587
588 return userGroup;
589 }
590
591
598 public List<UserGroup> findByCompanyId(long companyId)
599 throws SystemException {
600 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
601 null);
602 }
603
604
617 public List<UserGroup> findByCompanyId(long companyId, int start, int end)
618 throws SystemException {
619 return findByCompanyId(companyId, start, end, null);
620 }
621
622
636 public List<UserGroup> findByCompanyId(long companyId, int start, int end,
637 OrderByComparator orderByComparator) throws SystemException {
638 FinderPath finderPath = null;
639 Object[] finderArgs = null;
640
641 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
642 (orderByComparator == null)) {
643 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
644 finderArgs = new Object[] { companyId };
645 }
646 else {
647 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
648 finderArgs = new Object[] { companyId, start, end, orderByComparator };
649 }
650
651 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(finderPath,
652 finderArgs, this);
653
654 if ((list != null) && !list.isEmpty()) {
655 for (UserGroup userGroup : list) {
656 if ((companyId != userGroup.getCompanyId())) {
657 list = null;
658
659 break;
660 }
661 }
662 }
663
664 if (list == null) {
665 StringBundler query = null;
666
667 if (orderByComparator != null) {
668 query = new StringBundler(3 +
669 (orderByComparator.getOrderByFields().length * 3));
670 }
671 else {
672 query = new StringBundler(3);
673 }
674
675 query.append(_SQL_SELECT_USERGROUP_WHERE);
676
677 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
678
679 if (orderByComparator != null) {
680 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
681 orderByComparator);
682 }
683
684 else {
685 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
686 }
687
688 String sql = query.toString();
689
690 Session session = null;
691
692 try {
693 session = openSession();
694
695 Query q = session.createQuery(sql);
696
697 QueryPos qPos = QueryPos.getInstance(q);
698
699 qPos.add(companyId);
700
701 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
702 end);
703 }
704 catch (Exception e) {
705 throw processException(e);
706 }
707 finally {
708 if (list == null) {
709 FinderCacheUtil.removeResult(finderPath, finderArgs);
710 }
711 else {
712 cacheResult(list);
713
714 FinderCacheUtil.putResult(finderPath, finderArgs, list);
715 }
716
717 closeSession(session);
718 }
719 }
720
721 return list;
722 }
723
724
737 public UserGroup findByCompanyId_First(long companyId,
738 OrderByComparator orderByComparator)
739 throws NoSuchUserGroupException, SystemException {
740 List<UserGroup> list = findByCompanyId(companyId, 0, 1,
741 orderByComparator);
742
743 if (list.isEmpty()) {
744 StringBundler msg = new StringBundler(4);
745
746 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
747
748 msg.append("companyId=");
749 msg.append(companyId);
750
751 msg.append(StringPool.CLOSE_CURLY_BRACE);
752
753 throw new NoSuchUserGroupException(msg.toString());
754 }
755 else {
756 return list.get(0);
757 }
758 }
759
760
773 public UserGroup findByCompanyId_Last(long companyId,
774 OrderByComparator orderByComparator)
775 throws NoSuchUserGroupException, SystemException {
776 int count = countByCompanyId(companyId);
777
778 List<UserGroup> list = findByCompanyId(companyId, count - 1, count,
779 orderByComparator);
780
781 if (list.isEmpty()) {
782 StringBundler msg = new StringBundler(4);
783
784 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
785
786 msg.append("companyId=");
787 msg.append(companyId);
788
789 msg.append(StringPool.CLOSE_CURLY_BRACE);
790
791 throw new NoSuchUserGroupException(msg.toString());
792 }
793 else {
794 return list.get(0);
795 }
796 }
797
798
812 public UserGroup[] findByCompanyId_PrevAndNext(long userGroupId,
813 long companyId, OrderByComparator orderByComparator)
814 throws NoSuchUserGroupException, SystemException {
815 UserGroup userGroup = findByPrimaryKey(userGroupId);
816
817 Session session = null;
818
819 try {
820 session = openSession();
821
822 UserGroup[] array = new UserGroupImpl[3];
823
824 array[0] = getByCompanyId_PrevAndNext(session, userGroup,
825 companyId, orderByComparator, true);
826
827 array[1] = userGroup;
828
829 array[2] = getByCompanyId_PrevAndNext(session, userGroup,
830 companyId, orderByComparator, false);
831
832 return array;
833 }
834 catch (Exception e) {
835 throw processException(e);
836 }
837 finally {
838 closeSession(session);
839 }
840 }
841
842 protected UserGroup getByCompanyId_PrevAndNext(Session session,
843 UserGroup userGroup, long companyId,
844 OrderByComparator orderByComparator, boolean previous) {
845 StringBundler query = null;
846
847 if (orderByComparator != null) {
848 query = new StringBundler(6 +
849 (orderByComparator.getOrderByFields().length * 6));
850 }
851 else {
852 query = new StringBundler(3);
853 }
854
855 query.append(_SQL_SELECT_USERGROUP_WHERE);
856
857 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
858
859 if (orderByComparator != null) {
860 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
861
862 if (orderByConditionFields.length > 0) {
863 query.append(WHERE_AND);
864 }
865
866 for (int i = 0; i < orderByConditionFields.length; i++) {
867 query.append(_ORDER_BY_ENTITY_ALIAS);
868 query.append(orderByConditionFields[i]);
869
870 if ((i + 1) < orderByConditionFields.length) {
871 if (orderByComparator.isAscending() ^ previous) {
872 query.append(WHERE_GREATER_THAN_HAS_NEXT);
873 }
874 else {
875 query.append(WHERE_LESSER_THAN_HAS_NEXT);
876 }
877 }
878 else {
879 if (orderByComparator.isAscending() ^ previous) {
880 query.append(WHERE_GREATER_THAN);
881 }
882 else {
883 query.append(WHERE_LESSER_THAN);
884 }
885 }
886 }
887
888 query.append(ORDER_BY_CLAUSE);
889
890 String[] orderByFields = orderByComparator.getOrderByFields();
891
892 for (int i = 0; i < orderByFields.length; i++) {
893 query.append(_ORDER_BY_ENTITY_ALIAS);
894 query.append(orderByFields[i]);
895
896 if ((i + 1) < orderByFields.length) {
897 if (orderByComparator.isAscending() ^ previous) {
898 query.append(ORDER_BY_ASC_HAS_NEXT);
899 }
900 else {
901 query.append(ORDER_BY_DESC_HAS_NEXT);
902 }
903 }
904 else {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(ORDER_BY_ASC);
907 }
908 else {
909 query.append(ORDER_BY_DESC);
910 }
911 }
912 }
913 }
914
915 else {
916 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
917 }
918
919 String sql = query.toString();
920
921 Query q = session.createQuery(sql);
922
923 q.setFirstResult(0);
924 q.setMaxResults(2);
925
926 QueryPos qPos = QueryPos.getInstance(q);
927
928 qPos.add(companyId);
929
930 if (orderByComparator != null) {
931 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
932
933 for (Object value : values) {
934 qPos.add(value);
935 }
936 }
937
938 List<UserGroup> list = q.list();
939
940 if (list.size() == 2) {
941 return list.get(1);
942 }
943 else {
944 return null;
945 }
946 }
947
948
955 public List<UserGroup> filterFindByCompanyId(long companyId)
956 throws SystemException {
957 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
958 QueryUtil.ALL_POS, null);
959 }
960
961
974 public List<UserGroup> filterFindByCompanyId(long companyId, int start,
975 int end) throws SystemException {
976 return filterFindByCompanyId(companyId, start, end, null);
977 }
978
979
993 public List<UserGroup> filterFindByCompanyId(long companyId, int start,
994 int end, OrderByComparator orderByComparator) throws SystemException {
995 if (!InlineSQLHelperUtil.isEnabled()) {
996 return findByCompanyId(companyId, start, end, orderByComparator);
997 }
998
999 StringBundler query = null;
1000
1001 if (orderByComparator != null) {
1002 query = new StringBundler(3 +
1003 (orderByComparator.getOrderByFields().length * 3));
1004 }
1005 else {
1006 query = new StringBundler(3);
1007 }
1008
1009 if (getDB().isSupportsInlineDistinct()) {
1010 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1011 }
1012 else {
1013 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1014 }
1015
1016 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1017
1018 if (!getDB().isSupportsInlineDistinct()) {
1019 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1020 }
1021
1022 if (orderByComparator != null) {
1023 if (getDB().isSupportsInlineDistinct()) {
1024 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1025 orderByComparator);
1026 }
1027 else {
1028 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1029 orderByComparator);
1030 }
1031 }
1032
1033 else {
1034 if (getDB().isSupportsInlineDistinct()) {
1035 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1036 }
1037 else {
1038 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1039 }
1040 }
1041
1042 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1043 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1044
1045 Session session = null;
1046
1047 try {
1048 session = openSession();
1049
1050 SQLQuery q = session.createSQLQuery(sql);
1051
1052 if (getDB().isSupportsInlineDistinct()) {
1053 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1054 }
1055 else {
1056 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1057 }
1058
1059 QueryPos qPos = QueryPos.getInstance(q);
1060
1061 qPos.add(companyId);
1062
1063 return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end);
1064 }
1065 catch (Exception e) {
1066 throw processException(e);
1067 }
1068 finally {
1069 closeSession(session);
1070 }
1071 }
1072
1073
1083 public UserGroup[] filterFindByCompanyId_PrevAndNext(long userGroupId,
1084 long companyId, OrderByComparator orderByComparator)
1085 throws NoSuchUserGroupException, SystemException {
1086 if (!InlineSQLHelperUtil.isEnabled()) {
1087 return findByCompanyId_PrevAndNext(userGroupId, companyId,
1088 orderByComparator);
1089 }
1090
1091 UserGroup userGroup = findByPrimaryKey(userGroupId);
1092
1093 Session session = null;
1094
1095 try {
1096 session = openSession();
1097
1098 UserGroup[] array = new UserGroupImpl[3];
1099
1100 array[0] = filterGetByCompanyId_PrevAndNext(session, userGroup,
1101 companyId, orderByComparator, true);
1102
1103 array[1] = userGroup;
1104
1105 array[2] = filterGetByCompanyId_PrevAndNext(session, userGroup,
1106 companyId, orderByComparator, false);
1107
1108 return array;
1109 }
1110 catch (Exception e) {
1111 throw processException(e);
1112 }
1113 finally {
1114 closeSession(session);
1115 }
1116 }
1117
1118 protected UserGroup filterGetByCompanyId_PrevAndNext(Session session,
1119 UserGroup userGroup, long companyId,
1120 OrderByComparator orderByComparator, boolean previous) {
1121 StringBundler query = null;
1122
1123 if (orderByComparator != null) {
1124 query = new StringBundler(6 +
1125 (orderByComparator.getOrderByFields().length * 6));
1126 }
1127 else {
1128 query = new StringBundler(3);
1129 }
1130
1131 if (getDB().isSupportsInlineDistinct()) {
1132 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1133 }
1134 else {
1135 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1136 }
1137
1138 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1139
1140 if (!getDB().isSupportsInlineDistinct()) {
1141 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1142 }
1143
1144 if (orderByComparator != null) {
1145 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1146
1147 if (orderByConditionFields.length > 0) {
1148 query.append(WHERE_AND);
1149 }
1150
1151 for (int i = 0; i < orderByConditionFields.length; i++) {
1152 if (getDB().isSupportsInlineDistinct()) {
1153 query.append(_ORDER_BY_ENTITY_ALIAS);
1154 }
1155 else {
1156 query.append(_ORDER_BY_ENTITY_TABLE);
1157 }
1158
1159 query.append(orderByConditionFields[i]);
1160
1161 if ((i + 1) < orderByConditionFields.length) {
1162 if (orderByComparator.isAscending() ^ previous) {
1163 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1164 }
1165 else {
1166 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1167 }
1168 }
1169 else {
1170 if (orderByComparator.isAscending() ^ previous) {
1171 query.append(WHERE_GREATER_THAN);
1172 }
1173 else {
1174 query.append(WHERE_LESSER_THAN);
1175 }
1176 }
1177 }
1178
1179 query.append(ORDER_BY_CLAUSE);
1180
1181 String[] orderByFields = orderByComparator.getOrderByFields();
1182
1183 for (int i = 0; i < orderByFields.length; i++) {
1184 if (getDB().isSupportsInlineDistinct()) {
1185 query.append(_ORDER_BY_ENTITY_ALIAS);
1186 }
1187 else {
1188 query.append(_ORDER_BY_ENTITY_TABLE);
1189 }
1190
1191 query.append(orderByFields[i]);
1192
1193 if ((i + 1) < orderByFields.length) {
1194 if (orderByComparator.isAscending() ^ previous) {
1195 query.append(ORDER_BY_ASC_HAS_NEXT);
1196 }
1197 else {
1198 query.append(ORDER_BY_DESC_HAS_NEXT);
1199 }
1200 }
1201 else {
1202 if (orderByComparator.isAscending() ^ previous) {
1203 query.append(ORDER_BY_ASC);
1204 }
1205 else {
1206 query.append(ORDER_BY_DESC);
1207 }
1208 }
1209 }
1210 }
1211
1212 else {
1213 if (getDB().isSupportsInlineDistinct()) {
1214 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1215 }
1216 else {
1217 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1218 }
1219 }
1220
1221 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1222 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1223
1224 SQLQuery q = session.createSQLQuery(sql);
1225
1226 q.setFirstResult(0);
1227 q.setMaxResults(2);
1228
1229 if (getDB().isSupportsInlineDistinct()) {
1230 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1231 }
1232 else {
1233 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1234 }
1235
1236 QueryPos qPos = QueryPos.getInstance(q);
1237
1238 qPos.add(companyId);
1239
1240 if (orderByComparator != null) {
1241 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
1242
1243 for (Object value : values) {
1244 qPos.add(value);
1245 }
1246 }
1247
1248 List<UserGroup> list = q.list();
1249
1250 if (list.size() == 2) {
1251 return list.get(1);
1252 }
1253 else {
1254 return null;
1255 }
1256 }
1257
1258
1266 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId)
1267 throws SystemException {
1268 return findByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
1269 QueryUtil.ALL_POS, null);
1270 }
1271
1272
1286 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
1287 int start, int end) throws SystemException {
1288 return findByC_P(companyId, parentUserGroupId, start, end, null);
1289 }
1290
1291
1306 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
1307 int start, int end, OrderByComparator orderByComparator)
1308 throws SystemException {
1309 FinderPath finderPath = null;
1310 Object[] finderArgs = null;
1311
1312 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1313 (orderByComparator == null)) {
1314 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
1315 finderArgs = new Object[] { companyId, parentUserGroupId };
1316 }
1317 else {
1318 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
1319 finderArgs = new Object[] {
1320 companyId, parentUserGroupId,
1321
1322 start, end, orderByComparator
1323 };
1324 }
1325
1326 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(finderPath,
1327 finderArgs, this);
1328
1329 if ((list != null) && !list.isEmpty()) {
1330 for (UserGroup userGroup : list) {
1331 if ((companyId != userGroup.getCompanyId()) ||
1332 (parentUserGroupId != userGroup.getParentUserGroupId())) {
1333 list = null;
1334
1335 break;
1336 }
1337 }
1338 }
1339
1340 if (list == null) {
1341 StringBundler query = null;
1342
1343 if (orderByComparator != null) {
1344 query = new StringBundler(4 +
1345 (orderByComparator.getOrderByFields().length * 3));
1346 }
1347 else {
1348 query = new StringBundler(4);
1349 }
1350
1351 query.append(_SQL_SELECT_USERGROUP_WHERE);
1352
1353 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1354
1355 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1356
1357 if (orderByComparator != null) {
1358 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1359 orderByComparator);
1360 }
1361
1362 else {
1363 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1364 }
1365
1366 String sql = query.toString();
1367
1368 Session session = null;
1369
1370 try {
1371 session = openSession();
1372
1373 Query q = session.createQuery(sql);
1374
1375 QueryPos qPos = QueryPos.getInstance(q);
1376
1377 qPos.add(companyId);
1378
1379 qPos.add(parentUserGroupId);
1380
1381 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
1382 end);
1383 }
1384 catch (Exception e) {
1385 throw processException(e);
1386 }
1387 finally {
1388 if (list == null) {
1389 FinderCacheUtil.removeResult(finderPath, finderArgs);
1390 }
1391 else {
1392 cacheResult(list);
1393
1394 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1395 }
1396
1397 closeSession(session);
1398 }
1399 }
1400
1401 return list;
1402 }
1403
1404
1418 public UserGroup findByC_P_First(long companyId, long parentUserGroupId,
1419 OrderByComparator orderByComparator)
1420 throws NoSuchUserGroupException, SystemException {
1421 List<UserGroup> list = findByC_P(companyId, parentUserGroupId, 0, 1,
1422 orderByComparator);
1423
1424 if (list.isEmpty()) {
1425 StringBundler msg = new StringBundler(6);
1426
1427 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1428
1429 msg.append("companyId=");
1430 msg.append(companyId);
1431
1432 msg.append(", parentUserGroupId=");
1433 msg.append(parentUserGroupId);
1434
1435 msg.append(StringPool.CLOSE_CURLY_BRACE);
1436
1437 throw new NoSuchUserGroupException(msg.toString());
1438 }
1439 else {
1440 return list.get(0);
1441 }
1442 }
1443
1444
1458 public UserGroup findByC_P_Last(long companyId, long parentUserGroupId,
1459 OrderByComparator orderByComparator)
1460 throws NoSuchUserGroupException, SystemException {
1461 int count = countByC_P(companyId, parentUserGroupId);
1462
1463 List<UserGroup> list = findByC_P(companyId, parentUserGroupId,
1464 count - 1, count, orderByComparator);
1465
1466 if (list.isEmpty()) {
1467 StringBundler msg = new StringBundler(6);
1468
1469 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1470
1471 msg.append("companyId=");
1472 msg.append(companyId);
1473
1474 msg.append(", parentUserGroupId=");
1475 msg.append(parentUserGroupId);
1476
1477 msg.append(StringPool.CLOSE_CURLY_BRACE);
1478
1479 throw new NoSuchUserGroupException(msg.toString());
1480 }
1481 else {
1482 return list.get(0);
1483 }
1484 }
1485
1486
1501 public UserGroup[] findByC_P_PrevAndNext(long userGroupId, long companyId,
1502 long parentUserGroupId, OrderByComparator orderByComparator)
1503 throws NoSuchUserGroupException, SystemException {
1504 UserGroup userGroup = findByPrimaryKey(userGroupId);
1505
1506 Session session = null;
1507
1508 try {
1509 session = openSession();
1510
1511 UserGroup[] array = new UserGroupImpl[3];
1512
1513 array[0] = getByC_P_PrevAndNext(session, userGroup, companyId,
1514 parentUserGroupId, orderByComparator, true);
1515
1516 array[1] = userGroup;
1517
1518 array[2] = getByC_P_PrevAndNext(session, userGroup, companyId,
1519 parentUserGroupId, orderByComparator, false);
1520
1521 return array;
1522 }
1523 catch (Exception e) {
1524 throw processException(e);
1525 }
1526 finally {
1527 closeSession(session);
1528 }
1529 }
1530
1531 protected UserGroup getByC_P_PrevAndNext(Session session,
1532 UserGroup userGroup, long companyId, long parentUserGroupId,
1533 OrderByComparator orderByComparator, boolean previous) {
1534 StringBundler query = null;
1535
1536 if (orderByComparator != null) {
1537 query = new StringBundler(6 +
1538 (orderByComparator.getOrderByFields().length * 6));
1539 }
1540 else {
1541 query = new StringBundler(3);
1542 }
1543
1544 query.append(_SQL_SELECT_USERGROUP_WHERE);
1545
1546 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1547
1548 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1549
1550 if (orderByComparator != null) {
1551 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1552
1553 if (orderByConditionFields.length > 0) {
1554 query.append(WHERE_AND);
1555 }
1556
1557 for (int i = 0; i < orderByConditionFields.length; i++) {
1558 query.append(_ORDER_BY_ENTITY_ALIAS);
1559 query.append(orderByConditionFields[i]);
1560
1561 if ((i + 1) < orderByConditionFields.length) {
1562 if (orderByComparator.isAscending() ^ previous) {
1563 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1564 }
1565 else {
1566 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1567 }
1568 }
1569 else {
1570 if (orderByComparator.isAscending() ^ previous) {
1571 query.append(WHERE_GREATER_THAN);
1572 }
1573 else {
1574 query.append(WHERE_LESSER_THAN);
1575 }
1576 }
1577 }
1578
1579 query.append(ORDER_BY_CLAUSE);
1580
1581 String[] orderByFields = orderByComparator.getOrderByFields();
1582
1583 for (int i = 0; i < orderByFields.length; i++) {
1584 query.append(_ORDER_BY_ENTITY_ALIAS);
1585 query.append(orderByFields[i]);
1586
1587 if ((i + 1) < orderByFields.length) {
1588 if (orderByComparator.isAscending() ^ previous) {
1589 query.append(ORDER_BY_ASC_HAS_NEXT);
1590 }
1591 else {
1592 query.append(ORDER_BY_DESC_HAS_NEXT);
1593 }
1594 }
1595 else {
1596 if (orderByComparator.isAscending() ^ previous) {
1597 query.append(ORDER_BY_ASC);
1598 }
1599 else {
1600 query.append(ORDER_BY_DESC);
1601 }
1602 }
1603 }
1604 }
1605
1606 else {
1607 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1608 }
1609
1610 String sql = query.toString();
1611
1612 Query q = session.createQuery(sql);
1613
1614 q.setFirstResult(0);
1615 q.setMaxResults(2);
1616
1617 QueryPos qPos = QueryPos.getInstance(q);
1618
1619 qPos.add(companyId);
1620
1621 qPos.add(parentUserGroupId);
1622
1623 if (orderByComparator != null) {
1624 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
1625
1626 for (Object value : values) {
1627 qPos.add(value);
1628 }
1629 }
1630
1631 List<UserGroup> list = q.list();
1632
1633 if (list.size() == 2) {
1634 return list.get(1);
1635 }
1636 else {
1637 return null;
1638 }
1639 }
1640
1641
1649 public List<UserGroup> filterFindByC_P(long companyId,
1650 long parentUserGroupId) throws SystemException {
1651 return filterFindByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
1652 QueryUtil.ALL_POS, null);
1653 }
1654
1655
1669 public List<UserGroup> filterFindByC_P(long companyId,
1670 long parentUserGroupId, int start, int end) throws SystemException {
1671 return filterFindByC_P(companyId, parentUserGroupId, start, end, null);
1672 }
1673
1674
1689 public List<UserGroup> filterFindByC_P(long companyId,
1690 long parentUserGroupId, int start, int end,
1691 OrderByComparator orderByComparator) throws SystemException {
1692 if (!InlineSQLHelperUtil.isEnabled()) {
1693 return findByC_P(companyId, parentUserGroupId, start, end,
1694 orderByComparator);
1695 }
1696
1697 StringBundler query = null;
1698
1699 if (orderByComparator != null) {
1700 query = new StringBundler(4 +
1701 (orderByComparator.getOrderByFields().length * 3));
1702 }
1703 else {
1704 query = new StringBundler(4);
1705 }
1706
1707 if (getDB().isSupportsInlineDistinct()) {
1708 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1709 }
1710 else {
1711 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1712 }
1713
1714 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1715
1716 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1717
1718 if (!getDB().isSupportsInlineDistinct()) {
1719 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1720 }
1721
1722 if (orderByComparator != null) {
1723 if (getDB().isSupportsInlineDistinct()) {
1724 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1725 orderByComparator);
1726 }
1727 else {
1728 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1729 orderByComparator);
1730 }
1731 }
1732
1733 else {
1734 if (getDB().isSupportsInlineDistinct()) {
1735 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1736 }
1737 else {
1738 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1739 }
1740 }
1741
1742 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1743 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1744
1745 Session session = null;
1746
1747 try {
1748 session = openSession();
1749
1750 SQLQuery q = session.createSQLQuery(sql);
1751
1752 if (getDB().isSupportsInlineDistinct()) {
1753 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1754 }
1755 else {
1756 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1757 }
1758
1759 QueryPos qPos = QueryPos.getInstance(q);
1760
1761 qPos.add(companyId);
1762
1763 qPos.add(parentUserGroupId);
1764
1765 return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end);
1766 }
1767 catch (Exception e) {
1768 throw processException(e);
1769 }
1770 finally {
1771 closeSession(session);
1772 }
1773 }
1774
1775
1786 public UserGroup[] filterFindByC_P_PrevAndNext(long userGroupId,
1787 long companyId, long parentUserGroupId,
1788 OrderByComparator orderByComparator)
1789 throws NoSuchUserGroupException, SystemException {
1790 if (!InlineSQLHelperUtil.isEnabled()) {
1791 return findByC_P_PrevAndNext(userGroupId, companyId,
1792 parentUserGroupId, orderByComparator);
1793 }
1794
1795 UserGroup userGroup = findByPrimaryKey(userGroupId);
1796
1797 Session session = null;
1798
1799 try {
1800 session = openSession();
1801
1802 UserGroup[] array = new UserGroupImpl[3];
1803
1804 array[0] = filterGetByC_P_PrevAndNext(session, userGroup,
1805 companyId, parentUserGroupId, orderByComparator, true);
1806
1807 array[1] = userGroup;
1808
1809 array[2] = filterGetByC_P_PrevAndNext(session, userGroup,
1810 companyId, parentUserGroupId, orderByComparator, false);
1811
1812 return array;
1813 }
1814 catch (Exception e) {
1815 throw processException(e);
1816 }
1817 finally {
1818 closeSession(session);
1819 }
1820 }
1821
1822 protected UserGroup filterGetByC_P_PrevAndNext(Session session,
1823 UserGroup userGroup, long companyId, long parentUserGroupId,
1824 OrderByComparator orderByComparator, boolean previous) {
1825 StringBundler query = null;
1826
1827 if (orderByComparator != null) {
1828 query = new StringBundler(6 +
1829 (orderByComparator.getOrderByFields().length * 6));
1830 }
1831 else {
1832 query = new StringBundler(3);
1833 }
1834
1835 if (getDB().isSupportsInlineDistinct()) {
1836 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1837 }
1838 else {
1839 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1840 }
1841
1842 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1843
1844 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1845
1846 if (!getDB().isSupportsInlineDistinct()) {
1847 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1848 }
1849
1850 if (orderByComparator != null) {
1851 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1852
1853 if (orderByConditionFields.length > 0) {
1854 query.append(WHERE_AND);
1855 }
1856
1857 for (int i = 0; i < orderByConditionFields.length; i++) {
1858 if (getDB().isSupportsInlineDistinct()) {
1859 query.append(_ORDER_BY_ENTITY_ALIAS);
1860 }
1861 else {
1862 query.append(_ORDER_BY_ENTITY_TABLE);
1863 }
1864
1865 query.append(orderByConditionFields[i]);
1866
1867 if ((i + 1) < orderByConditionFields.length) {
1868 if (orderByComparator.isAscending() ^ previous) {
1869 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1870 }
1871 else {
1872 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1873 }
1874 }
1875 else {
1876 if (orderByComparator.isAscending() ^ previous) {
1877 query.append(WHERE_GREATER_THAN);
1878 }
1879 else {
1880 query.append(WHERE_LESSER_THAN);
1881 }
1882 }
1883 }
1884
1885 query.append(ORDER_BY_CLAUSE);
1886
1887 String[] orderByFields = orderByComparator.getOrderByFields();
1888
1889 for (int i = 0; i < orderByFields.length; i++) {
1890 if (getDB().isSupportsInlineDistinct()) {
1891 query.append(_ORDER_BY_ENTITY_ALIAS);
1892 }
1893 else {
1894 query.append(_ORDER_BY_ENTITY_TABLE);
1895 }
1896
1897 query.append(orderByFields[i]);
1898
1899 if ((i + 1) < orderByFields.length) {
1900 if (orderByComparator.isAscending() ^ previous) {
1901 query.append(ORDER_BY_ASC_HAS_NEXT);
1902 }
1903 else {
1904 query.append(ORDER_BY_DESC_HAS_NEXT);
1905 }
1906 }
1907 else {
1908 if (orderByComparator.isAscending() ^ previous) {
1909 query.append(ORDER_BY_ASC);
1910 }
1911 else {
1912 query.append(ORDER_BY_DESC);
1913 }
1914 }
1915 }
1916 }
1917
1918 else {
1919 if (getDB().isSupportsInlineDistinct()) {
1920 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1921 }
1922 else {
1923 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1924 }
1925 }
1926
1927 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1928 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1929
1930 SQLQuery q = session.createSQLQuery(sql);
1931
1932 q.setFirstResult(0);
1933 q.setMaxResults(2);
1934
1935 if (getDB().isSupportsInlineDistinct()) {
1936 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1937 }
1938 else {
1939 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1940 }
1941
1942 QueryPos qPos = QueryPos.getInstance(q);
1943
1944 qPos.add(companyId);
1945
1946 qPos.add(parentUserGroupId);
1947
1948 if (orderByComparator != null) {
1949 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
1950
1951 for (Object value : values) {
1952 qPos.add(value);
1953 }
1954 }
1955
1956 List<UserGroup> list = q.list();
1957
1958 if (list.size() == 2) {
1959 return list.get(1);
1960 }
1961 else {
1962 return null;
1963 }
1964 }
1965
1966
1975 public UserGroup findByC_N(long companyId, String name)
1976 throws NoSuchUserGroupException, SystemException {
1977 UserGroup userGroup = fetchByC_N(companyId, name);
1978
1979 if (userGroup == null) {
1980 StringBundler msg = new StringBundler(6);
1981
1982 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1983
1984 msg.append("companyId=");
1985 msg.append(companyId);
1986
1987 msg.append(", name=");
1988 msg.append(name);
1989
1990 msg.append(StringPool.CLOSE_CURLY_BRACE);
1991
1992 if (_log.isWarnEnabled()) {
1993 _log.warn(msg.toString());
1994 }
1995
1996 throw new NoSuchUserGroupException(msg.toString());
1997 }
1998
1999 return userGroup;
2000 }
2001
2002
2010 public UserGroup fetchByC_N(long companyId, String name)
2011 throws SystemException {
2012 return fetchByC_N(companyId, name, true);
2013 }
2014
2015
2024 public UserGroup fetchByC_N(long companyId, String name,
2025 boolean retrieveFromCache) throws SystemException {
2026 Object[] finderArgs = new Object[] { companyId, name };
2027
2028 Object result = null;
2029
2030 if (retrieveFromCache) {
2031 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2032 finderArgs, this);
2033 }
2034
2035 if (result instanceof UserGroup) {
2036 UserGroup userGroup = (UserGroup)result;
2037
2038 if ((companyId != userGroup.getCompanyId()) ||
2039 !Validator.equals(name, userGroup.getName())) {
2040 result = null;
2041 }
2042 }
2043
2044 if (result == null) {
2045 StringBundler query = new StringBundler(4);
2046
2047 query.append(_SQL_SELECT_USERGROUP_WHERE);
2048
2049 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2050
2051 if (name == null) {
2052 query.append(_FINDER_COLUMN_C_N_NAME_1);
2053 }
2054 else {
2055 if (name.equals(StringPool.BLANK)) {
2056 query.append(_FINDER_COLUMN_C_N_NAME_3);
2057 }
2058 else {
2059 query.append(_FINDER_COLUMN_C_N_NAME_2);
2060 }
2061 }
2062
2063 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
2064
2065 String sql = query.toString();
2066
2067 Session session = null;
2068
2069 try {
2070 session = openSession();
2071
2072 Query q = session.createQuery(sql);
2073
2074 QueryPos qPos = QueryPos.getInstance(q);
2075
2076 qPos.add(companyId);
2077
2078 if (name != null) {
2079 qPos.add(name);
2080 }
2081
2082 List<UserGroup> list = q.list();
2083
2084 result = list;
2085
2086 UserGroup userGroup = null;
2087
2088 if (list.isEmpty()) {
2089 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2090 finderArgs, list);
2091 }
2092 else {
2093 userGroup = list.get(0);
2094
2095 cacheResult(userGroup);
2096
2097 if ((userGroup.getCompanyId() != companyId) ||
2098 (userGroup.getName() == null) ||
2099 !userGroup.getName().equals(name)) {
2100 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2101 finderArgs, userGroup);
2102 }
2103 }
2104
2105 return userGroup;
2106 }
2107 catch (Exception e) {
2108 throw processException(e);
2109 }
2110 finally {
2111 if (result == null) {
2112 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2113 finderArgs);
2114 }
2115
2116 closeSession(session);
2117 }
2118 }
2119 else {
2120 if (result instanceof List<?>) {
2121 return null;
2122 }
2123 else {
2124 return (UserGroup)result;
2125 }
2126 }
2127 }
2128
2129
2135 public List<UserGroup> findAll() throws SystemException {
2136 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2137 }
2138
2139
2151 public List<UserGroup> findAll(int start, int end)
2152 throws SystemException {
2153 return findAll(start, end, null);
2154 }
2155
2156
2169 public List<UserGroup> findAll(int start, int end,
2170 OrderByComparator orderByComparator) throws SystemException {
2171 FinderPath finderPath = null;
2172 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2173
2174 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2175 (orderByComparator == null)) {
2176 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2177 finderArgs = FINDER_ARGS_EMPTY;
2178 }
2179 else {
2180 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2181 finderArgs = new Object[] { start, end, orderByComparator };
2182 }
2183
2184 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(finderPath,
2185 finderArgs, this);
2186
2187 if (list == null) {
2188 StringBundler query = null;
2189 String sql = null;
2190
2191 if (orderByComparator != null) {
2192 query = new StringBundler(2 +
2193 (orderByComparator.getOrderByFields().length * 3));
2194
2195 query.append(_SQL_SELECT_USERGROUP);
2196
2197 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2198 orderByComparator);
2199
2200 sql = query.toString();
2201 }
2202 else {
2203 sql = _SQL_SELECT_USERGROUP.concat(UserGroupModelImpl.ORDER_BY_JPQL);
2204 }
2205
2206 Session session = null;
2207
2208 try {
2209 session = openSession();
2210
2211 Query q = session.createQuery(sql);
2212
2213 if (orderByComparator == null) {
2214 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
2215 start, end, false);
2216
2217 Collections.sort(list);
2218 }
2219 else {
2220 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
2221 start, end);
2222 }
2223 }
2224 catch (Exception e) {
2225 throw processException(e);
2226 }
2227 finally {
2228 if (list == null) {
2229 FinderCacheUtil.removeResult(finderPath, finderArgs);
2230 }
2231 else {
2232 cacheResult(list);
2233
2234 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2235 }
2236
2237 closeSession(session);
2238 }
2239 }
2240
2241 return list;
2242 }
2243
2244
2250 public void removeByCompanyId(long companyId) throws SystemException {
2251 for (UserGroup userGroup : findByCompanyId(companyId)) {
2252 remove(userGroup);
2253 }
2254 }
2255
2256
2263 public void removeByC_P(long companyId, long parentUserGroupId)
2264 throws SystemException {
2265 for (UserGroup userGroup : findByC_P(companyId, parentUserGroupId)) {
2266 remove(userGroup);
2267 }
2268 }
2269
2270
2277 public void removeByC_N(long companyId, String name)
2278 throws NoSuchUserGroupException, SystemException {
2279 UserGroup userGroup = findByC_N(companyId, name);
2280
2281 remove(userGroup);
2282 }
2283
2284
2289 public void removeAll() throws SystemException {
2290 for (UserGroup userGroup : findAll()) {
2291 remove(userGroup);
2292 }
2293 }
2294
2295
2302 public int countByCompanyId(long companyId) throws SystemException {
2303 Object[] finderArgs = new Object[] { companyId };
2304
2305 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2306 finderArgs, this);
2307
2308 if (count == null) {
2309 StringBundler query = new StringBundler(2);
2310
2311 query.append(_SQL_COUNT_USERGROUP_WHERE);
2312
2313 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2314
2315 String sql = query.toString();
2316
2317 Session session = null;
2318
2319 try {
2320 session = openSession();
2321
2322 Query q = session.createQuery(sql);
2323
2324 QueryPos qPos = QueryPos.getInstance(q);
2325
2326 qPos.add(companyId);
2327
2328 count = (Long)q.uniqueResult();
2329 }
2330 catch (Exception e) {
2331 throw processException(e);
2332 }
2333 finally {
2334 if (count == null) {
2335 count = Long.valueOf(0);
2336 }
2337
2338 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2339 finderArgs, count);
2340
2341 closeSession(session);
2342 }
2343 }
2344
2345 return count.intValue();
2346 }
2347
2348
2355 public int filterCountByCompanyId(long companyId) throws SystemException {
2356 if (!InlineSQLHelperUtil.isEnabled()) {
2357 return countByCompanyId(companyId);
2358 }
2359
2360 StringBundler query = new StringBundler(2);
2361
2362 query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE);
2363
2364 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2365
2366 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2367 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2368
2369 Session session = null;
2370
2371 try {
2372 session = openSession();
2373
2374 SQLQuery q = session.createSQLQuery(sql);
2375
2376 q.addScalar(COUNT_COLUMN_NAME,
2377 com.liferay.portal.kernel.dao.orm.Type.LONG);
2378
2379 QueryPos qPos = QueryPos.getInstance(q);
2380
2381 qPos.add(companyId);
2382
2383 Long count = (Long)q.uniqueResult();
2384
2385 return count.intValue();
2386 }
2387 catch (Exception e) {
2388 throw processException(e);
2389 }
2390 finally {
2391 closeSession(session);
2392 }
2393 }
2394
2395
2403 public int countByC_P(long companyId, long parentUserGroupId)
2404 throws SystemException {
2405 Object[] finderArgs = new Object[] { companyId, parentUserGroupId };
2406
2407 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
2408 finderArgs, this);
2409
2410 if (count == null) {
2411 StringBundler query = new StringBundler(3);
2412
2413 query.append(_SQL_COUNT_USERGROUP_WHERE);
2414
2415 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2416
2417 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
2418
2419 String sql = query.toString();
2420
2421 Session session = null;
2422
2423 try {
2424 session = openSession();
2425
2426 Query q = session.createQuery(sql);
2427
2428 QueryPos qPos = QueryPos.getInstance(q);
2429
2430 qPos.add(companyId);
2431
2432 qPos.add(parentUserGroupId);
2433
2434 count = (Long)q.uniqueResult();
2435 }
2436 catch (Exception e) {
2437 throw processException(e);
2438 }
2439 finally {
2440 if (count == null) {
2441 count = Long.valueOf(0);
2442 }
2443
2444 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
2445 count);
2446
2447 closeSession(session);
2448 }
2449 }
2450
2451 return count.intValue();
2452 }
2453
2454
2462 public int filterCountByC_P(long companyId, long parentUserGroupId)
2463 throws SystemException {
2464 if (!InlineSQLHelperUtil.isEnabled()) {
2465 return countByC_P(companyId, parentUserGroupId);
2466 }
2467
2468 StringBundler query = new StringBundler(3);
2469
2470 query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE);
2471
2472 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2473
2474 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
2475
2476 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2477 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2478
2479 Session session = null;
2480
2481 try {
2482 session = openSession();
2483
2484 SQLQuery q = session.createSQLQuery(sql);
2485
2486 q.addScalar(COUNT_COLUMN_NAME,
2487 com.liferay.portal.kernel.dao.orm.Type.LONG);
2488
2489 QueryPos qPos = QueryPos.getInstance(q);
2490
2491 qPos.add(companyId);
2492
2493 qPos.add(parentUserGroupId);
2494
2495 Long count = (Long)q.uniqueResult();
2496
2497 return count.intValue();
2498 }
2499 catch (Exception e) {
2500 throw processException(e);
2501 }
2502 finally {
2503 closeSession(session);
2504 }
2505 }
2506
2507
2515 public int countByC_N(long companyId, String name)
2516 throws SystemException {
2517 Object[] finderArgs = new Object[] { companyId, name };
2518
2519 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
2520 finderArgs, this);
2521
2522 if (count == null) {
2523 StringBundler query = new StringBundler(3);
2524
2525 query.append(_SQL_COUNT_USERGROUP_WHERE);
2526
2527 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2528
2529 if (name == null) {
2530 query.append(_FINDER_COLUMN_C_N_NAME_1);
2531 }
2532 else {
2533 if (name.equals(StringPool.BLANK)) {
2534 query.append(_FINDER_COLUMN_C_N_NAME_3);
2535 }
2536 else {
2537 query.append(_FINDER_COLUMN_C_N_NAME_2);
2538 }
2539 }
2540
2541 String sql = query.toString();
2542
2543 Session session = null;
2544
2545 try {
2546 session = openSession();
2547
2548 Query q = session.createQuery(sql);
2549
2550 QueryPos qPos = QueryPos.getInstance(q);
2551
2552 qPos.add(companyId);
2553
2554 if (name != null) {
2555 qPos.add(name);
2556 }
2557
2558 count = (Long)q.uniqueResult();
2559 }
2560 catch (Exception e) {
2561 throw processException(e);
2562 }
2563 finally {
2564 if (count == null) {
2565 count = Long.valueOf(0);
2566 }
2567
2568 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2569 count);
2570
2571 closeSession(session);
2572 }
2573 }
2574
2575 return count.intValue();
2576 }
2577
2578
2584 public int countAll() throws SystemException {
2585 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2586 FINDER_ARGS_EMPTY, this);
2587
2588 if (count == null) {
2589 Session session = null;
2590
2591 try {
2592 session = openSession();
2593
2594 Query q = session.createQuery(_SQL_COUNT_USERGROUP);
2595
2596 count = (Long)q.uniqueResult();
2597 }
2598 catch (Exception e) {
2599 throw processException(e);
2600 }
2601 finally {
2602 if (count == null) {
2603 count = Long.valueOf(0);
2604 }
2605
2606 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2607 FINDER_ARGS_EMPTY, count);
2608
2609 closeSession(session);
2610 }
2611 }
2612
2613 return count.intValue();
2614 }
2615
2616
2623 public List<com.liferay.portal.model.Group> getGroups(long pk)
2624 throws SystemException {
2625 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2626 }
2627
2628
2641 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2642 int end) throws SystemException {
2643 return getGroups(pk, start, end, null);
2644 }
2645
2646 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2647 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2648 com.liferay.portal.model.impl.GroupImpl.class,
2649 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2650 "getGroups",
2651 new String[] {
2652 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2653 "com.liferay.portal.kernel.util.OrderByComparator"
2654 });
2655
2656 static {
2657 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
2658 }
2659
2660
2674 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2675 int end, OrderByComparator orderByComparator) throws SystemException {
2676 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2677
2678 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
2679 finderArgs, this);
2680
2681 if (list == null) {
2682 Session session = null;
2683
2684 try {
2685 session = openSession();
2686
2687 String sql = null;
2688
2689 if (orderByComparator != null) {
2690 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
2691 .concat(orderByComparator.getOrderBy());
2692 }
2693 else {
2694 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
2695 }
2696
2697 SQLQuery q = session.createSQLQuery(sql);
2698
2699 q.addEntity("Group_",
2700 com.liferay.portal.model.impl.GroupImpl.class);
2701
2702 QueryPos qPos = QueryPos.getInstance(q);
2703
2704 qPos.add(pk);
2705
2706 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
2707 getDialect(), start, end);
2708 }
2709 catch (Exception e) {
2710 throw processException(e);
2711 }
2712 finally {
2713 if (list == null) {
2714 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
2715 finderArgs);
2716 }
2717 else {
2718 groupPersistence.cacheResult(list);
2719
2720 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
2721 finderArgs, list);
2722 }
2723
2724 closeSession(session);
2725 }
2726 }
2727
2728 return list;
2729 }
2730
2731 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2732 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2733 Long.class,
2734 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2735 "getGroupsSize", new String[] { Long.class.getName() });
2736
2737 static {
2738 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
2739 }
2740
2741
2748 public int getGroupsSize(long pk) throws SystemException {
2749 Object[] finderArgs = new Object[] { pk };
2750
2751 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
2752 finderArgs, this);
2753
2754 if (count == null) {
2755 Session session = null;
2756
2757 try {
2758 session = openSession();
2759
2760 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2761
2762 q.addScalar(COUNT_COLUMN_NAME,
2763 com.liferay.portal.kernel.dao.orm.Type.LONG);
2764
2765 QueryPos qPos = QueryPos.getInstance(q);
2766
2767 qPos.add(pk);
2768
2769 count = (Long)q.uniqueResult();
2770 }
2771 catch (Exception e) {
2772 throw processException(e);
2773 }
2774 finally {
2775 if (count == null) {
2776 count = Long.valueOf(0);
2777 }
2778
2779 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
2780 finderArgs, count);
2781
2782 closeSession(session);
2783 }
2784 }
2785
2786 return count.intValue();
2787 }
2788
2789 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2790 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2791 Boolean.class,
2792 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2793 "containsGroup",
2794 new String[] { Long.class.getName(), Long.class.getName() });
2795
2796
2804 public boolean containsGroup(long pk, long groupPK)
2805 throws SystemException {
2806 Object[] finderArgs = new Object[] { pk, groupPK };
2807
2808 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
2809 finderArgs, this);
2810
2811 if (value == null) {
2812 try {
2813 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
2814 }
2815 catch (Exception e) {
2816 throw processException(e);
2817 }
2818 finally {
2819 if (value == null) {
2820 value = Boolean.FALSE;
2821 }
2822
2823 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
2824 finderArgs, value);
2825 }
2826 }
2827
2828 return value.booleanValue();
2829 }
2830
2831
2838 public boolean containsGroups(long pk) throws SystemException {
2839 if (getGroupsSize(pk) > 0) {
2840 return true;
2841 }
2842 else {
2843 return false;
2844 }
2845 }
2846
2847
2854 public void addGroup(long pk, long groupPK) throws SystemException {
2855 try {
2856 addGroup.add(pk, groupPK);
2857 }
2858 catch (Exception e) {
2859 throw processException(e);
2860 }
2861 finally {
2862 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2863 }
2864 }
2865
2866
2873 public void addGroup(long pk, com.liferay.portal.model.Group group)
2874 throws SystemException {
2875 try {
2876 addGroup.add(pk, group.getPrimaryKey());
2877 }
2878 catch (Exception e) {
2879 throw processException(e);
2880 }
2881 finally {
2882 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2883 }
2884 }
2885
2886
2893 public void addGroups(long pk, long[] groupPKs) throws SystemException {
2894 try {
2895 for (long groupPK : groupPKs) {
2896 addGroup.add(pk, groupPK);
2897 }
2898 }
2899 catch (Exception e) {
2900 throw processException(e);
2901 }
2902 finally {
2903 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2904 }
2905 }
2906
2907
2914 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
2915 throws SystemException {
2916 try {
2917 for (com.liferay.portal.model.Group group : groups) {
2918 addGroup.add(pk, group.getPrimaryKey());
2919 }
2920 }
2921 catch (Exception e) {
2922 throw processException(e);
2923 }
2924 finally {
2925 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2926 }
2927 }
2928
2929
2935 public void clearGroups(long pk) throws SystemException {
2936 try {
2937 clearGroups.clear(pk);
2938 }
2939 catch (Exception e) {
2940 throw processException(e);
2941 }
2942 finally {
2943 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2944 }
2945 }
2946
2947
2954 public void removeGroup(long pk, long groupPK) throws SystemException {
2955 try {
2956 removeGroup.remove(pk, groupPK);
2957 }
2958 catch (Exception e) {
2959 throw processException(e);
2960 }
2961 finally {
2962 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2963 }
2964 }
2965
2966
2973 public void removeGroup(long pk, com.liferay.portal.model.Group group)
2974 throws SystemException {
2975 try {
2976 removeGroup.remove(pk, group.getPrimaryKey());
2977 }
2978 catch (Exception e) {
2979 throw processException(e);
2980 }
2981 finally {
2982 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2983 }
2984 }
2985
2986
2993 public void removeGroups(long pk, long[] groupPKs)
2994 throws SystemException {
2995 try {
2996 for (long groupPK : groupPKs) {
2997 removeGroup.remove(pk, groupPK);
2998 }
2999 }
3000 catch (Exception e) {
3001 throw processException(e);
3002 }
3003 finally {
3004 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3005 }
3006 }
3007
3008
3015 public void removeGroups(long pk,
3016 List<com.liferay.portal.model.Group> groups) throws SystemException {
3017 try {
3018 for (com.liferay.portal.model.Group group : groups) {
3019 removeGroup.remove(pk, group.getPrimaryKey());
3020 }
3021 }
3022 catch (Exception e) {
3023 throw processException(e);
3024 }
3025 finally {
3026 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3027 }
3028 }
3029
3030
3037 public void setGroups(long pk, long[] groupPKs) throws SystemException {
3038 try {
3039 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
3040
3041 List<com.liferay.portal.model.Group> groups = getGroups(pk);
3042
3043 for (com.liferay.portal.model.Group group : groups) {
3044 if (!groupPKSet.remove(group.getPrimaryKey())) {
3045 removeGroup.remove(pk, group.getPrimaryKey());
3046 }
3047 }
3048
3049 for (Long groupPK : groupPKSet) {
3050 addGroup.add(pk, groupPK);
3051 }
3052 }
3053 catch (Exception e) {
3054 throw processException(e);
3055 }
3056 finally {
3057 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3058 }
3059 }
3060
3061
3068 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3069 throws SystemException {
3070 try {
3071 long[] groupPKs = new long[groups.size()];
3072
3073 for (int i = 0; i < groups.size(); i++) {
3074 com.liferay.portal.model.Group group = groups.get(i);
3075
3076 groupPKs[i] = group.getPrimaryKey();
3077 }
3078
3079 setGroups(pk, groupPKs);
3080 }
3081 catch (Exception e) {
3082 throw processException(e);
3083 }
3084 finally {
3085 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3086 }
3087 }
3088
3089
3096 public List<com.liferay.portal.model.Team> getTeams(long pk)
3097 throws SystemException {
3098 return getTeams(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3099 }
3100
3101
3114 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
3115 int end) throws SystemException {
3116 return getTeams(pk, start, end, null);
3117 }
3118
3119 public static final FinderPath FINDER_PATH_GET_TEAMS = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
3120 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
3121 com.liferay.portal.model.impl.TeamImpl.class,
3122 UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME, "getTeams",
3123 new String[] {
3124 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3125 "com.liferay.portal.kernel.util.OrderByComparator"
3126 });
3127
3128 static {
3129 FINDER_PATH_GET_TEAMS.setCacheKeyGeneratorCacheName(null);
3130 }
3131
3132
3146 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
3147 int end, OrderByComparator orderByComparator) throws SystemException {
3148 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3149
3150 List<com.liferay.portal.model.Team> list = (List<com.liferay.portal.model.Team>)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS,
3151 finderArgs, this);
3152
3153 if (list == null) {
3154 Session session = null;
3155
3156 try {
3157 session = openSession();
3158
3159 String sql = null;
3160
3161 if (orderByComparator != null) {
3162 sql = _SQL_GETTEAMS.concat(ORDER_BY_CLAUSE)
3163 .concat(orderByComparator.getOrderBy());
3164 }
3165 else {
3166 sql = _SQL_GETTEAMS.concat(com.liferay.portal.model.impl.TeamModelImpl.ORDER_BY_SQL);
3167 }
3168
3169 SQLQuery q = session.createSQLQuery(sql);
3170
3171 q.addEntity("Team", com.liferay.portal.model.impl.TeamImpl.class);
3172
3173 QueryPos qPos = QueryPos.getInstance(q);
3174
3175 qPos.add(pk);
3176
3177 list = (List<com.liferay.portal.model.Team>)QueryUtil.list(q,
3178 getDialect(), start, end);
3179 }
3180 catch (Exception e) {
3181 throw processException(e);
3182 }
3183 finally {
3184 if (list == null) {
3185 FinderCacheUtil.removeResult(FINDER_PATH_GET_TEAMS,
3186 finderArgs);
3187 }
3188 else {
3189 teamPersistence.cacheResult(list);
3190
3191 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS,
3192 finderArgs, list);
3193 }
3194
3195 closeSession(session);
3196 }
3197 }
3198
3199 return list;
3200 }
3201
3202 public static final FinderPath FINDER_PATH_GET_TEAMS_SIZE = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
3203 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
3204 Long.class, UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
3205 "getTeamsSize", new String[] { Long.class.getName() });
3206
3207 static {
3208 FINDER_PATH_GET_TEAMS_SIZE.setCacheKeyGeneratorCacheName(null);
3209 }
3210
3211
3218 public int getTeamsSize(long pk) throws SystemException {
3219 Object[] finderArgs = new Object[] { pk };
3220
3221 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS_SIZE,
3222 finderArgs, this);
3223
3224 if (count == null) {
3225 Session session = null;
3226
3227 try {
3228 session = openSession();
3229
3230 SQLQuery q = session.createSQLQuery(_SQL_GETTEAMSSIZE);
3231
3232 q.addScalar(COUNT_COLUMN_NAME,
3233 com.liferay.portal.kernel.dao.orm.Type.LONG);
3234
3235 QueryPos qPos = QueryPos.getInstance(q);
3236
3237 qPos.add(pk);
3238
3239 count = (Long)q.uniqueResult();
3240 }
3241 catch (Exception e) {
3242 throw processException(e);
3243 }
3244 finally {
3245 if (count == null) {
3246 count = Long.valueOf(0);
3247 }
3248
3249 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS_SIZE,
3250 finderArgs, count);
3251
3252 closeSession(session);
3253 }
3254 }
3255
3256 return count.intValue();
3257 }
3258
3259 public static final FinderPath FINDER_PATH_CONTAINS_TEAM = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
3260 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
3261 Boolean.class,
3262 UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
3263 "containsTeam",
3264 new String[] { Long.class.getName(), Long.class.getName() });
3265
3266
3274 public boolean containsTeam(long pk, long teamPK) throws SystemException {
3275 Object[] finderArgs = new Object[] { pk, teamPK };
3276
3277 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TEAM,
3278 finderArgs, this);
3279
3280 if (value == null) {
3281 try {
3282 value = Boolean.valueOf(containsTeam.contains(pk, teamPK));
3283 }
3284 catch (Exception e) {
3285 throw processException(e);
3286 }
3287 finally {
3288 if (value == null) {
3289 value = Boolean.FALSE;
3290 }
3291
3292 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TEAM,
3293 finderArgs, value);
3294 }
3295 }
3296
3297 return value.booleanValue();
3298 }
3299
3300
3307 public boolean containsTeams(long pk) throws SystemException {
3308 if (getTeamsSize(pk) > 0) {
3309 return true;
3310 }
3311 else {
3312 return false;
3313 }
3314 }
3315
3316
3323 public void addTeam(long pk, long teamPK) throws SystemException {
3324 try {
3325 addTeam.add(pk, teamPK);
3326 }
3327 catch (Exception e) {
3328 throw processException(e);
3329 }
3330 finally {
3331 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3332 }
3333 }
3334
3335
3342 public void addTeam(long pk, com.liferay.portal.model.Team team)
3343 throws SystemException {
3344 try {
3345 addTeam.add(pk, team.getPrimaryKey());
3346 }
3347 catch (Exception e) {
3348 throw processException(e);
3349 }
3350 finally {
3351 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3352 }
3353 }
3354
3355
3362 public void addTeams(long pk, long[] teamPKs) throws SystemException {
3363 try {
3364 for (long teamPK : teamPKs) {
3365 addTeam.add(pk, teamPK);
3366 }
3367 }
3368 catch (Exception e) {
3369 throw processException(e);
3370 }
3371 finally {
3372 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3373 }
3374 }
3375
3376
3383 public void addTeams(long pk, List<com.liferay.portal.model.Team> teams)
3384 throws SystemException {
3385 try {
3386 for (com.liferay.portal.model.Team team : teams) {
3387 addTeam.add(pk, team.getPrimaryKey());
3388 }
3389 }
3390 catch (Exception e) {
3391 throw processException(e);
3392 }
3393 finally {
3394 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3395 }
3396 }
3397
3398
3404 public void clearTeams(long pk) throws SystemException {
3405 try {
3406 clearTeams.clear(pk);
3407 }
3408 catch (Exception e) {
3409 throw processException(e);
3410 }
3411 finally {
3412 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3413 }
3414 }
3415
3416
3423 public void removeTeam(long pk, long teamPK) throws SystemException {
3424 try {
3425 removeTeam.remove(pk, teamPK);
3426 }
3427 catch (Exception e) {
3428 throw processException(e);
3429 }
3430 finally {
3431 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3432 }
3433 }
3434
3435
3442 public void removeTeam(long pk, com.liferay.portal.model.Team team)
3443 throws SystemException {
3444 try {
3445 removeTeam.remove(pk, team.getPrimaryKey());
3446 }
3447 catch (Exception e) {
3448 throw processException(e);
3449 }
3450 finally {
3451 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3452 }
3453 }
3454
3455
3462 public void removeTeams(long pk, long[] teamPKs) throws SystemException {
3463 try {
3464 for (long teamPK : teamPKs) {
3465 removeTeam.remove(pk, teamPK);
3466 }
3467 }
3468 catch (Exception e) {
3469 throw processException(e);
3470 }
3471 finally {
3472 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3473 }
3474 }
3475
3476
3483 public void removeTeams(long pk, List<com.liferay.portal.model.Team> teams)
3484 throws SystemException {
3485 try {
3486 for (com.liferay.portal.model.Team team : teams) {
3487 removeTeam.remove(pk, team.getPrimaryKey());
3488 }
3489 }
3490 catch (Exception e) {
3491 throw processException(e);
3492 }
3493 finally {
3494 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3495 }
3496 }
3497
3498
3505 public void setTeams(long pk, long[] teamPKs) throws SystemException {
3506 try {
3507 Set<Long> teamPKSet = SetUtil.fromArray(teamPKs);
3508
3509 List<com.liferay.portal.model.Team> teams = getTeams(pk);
3510
3511 for (com.liferay.portal.model.Team team : teams) {
3512 if (!teamPKSet.remove(team.getPrimaryKey())) {
3513 removeTeam.remove(pk, team.getPrimaryKey());
3514 }
3515 }
3516
3517 for (Long teamPK : teamPKSet) {
3518 addTeam.add(pk, teamPK);
3519 }
3520 }
3521 catch (Exception e) {
3522 throw processException(e);
3523 }
3524 finally {
3525 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3526 }
3527 }
3528
3529
3536 public void setTeams(long pk, List<com.liferay.portal.model.Team> teams)
3537 throws SystemException {
3538 try {
3539 long[] teamPKs = new long[teams.size()];
3540
3541 for (int i = 0; i < teams.size(); i++) {
3542 com.liferay.portal.model.Team team = teams.get(i);
3543
3544 teamPKs[i] = team.getPrimaryKey();
3545 }
3546
3547 setTeams(pk, teamPKs);
3548 }
3549 catch (Exception e) {
3550 throw processException(e);
3551 }
3552 finally {
3553 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3554 }
3555 }
3556
3557
3564 public List<com.liferay.portal.model.User> getUsers(long pk)
3565 throws SystemException {
3566 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3567 }
3568
3569
3582 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3583 int end) throws SystemException {
3584 return getUsers(pk, start, end, null);
3585 }
3586
3587 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3588 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
3589 com.liferay.portal.model.impl.UserImpl.class,
3590 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUsers",
3591 new String[] {
3592 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3593 "com.liferay.portal.kernel.util.OrderByComparator"
3594 });
3595
3596 static {
3597 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
3598 }
3599
3600
3614 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3615 int end, OrderByComparator orderByComparator) throws SystemException {
3616 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3617
3618 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
3619 finderArgs, this);
3620
3621 if (list == null) {
3622 Session session = null;
3623
3624 try {
3625 session = openSession();
3626
3627 String sql = null;
3628
3629 if (orderByComparator != null) {
3630 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
3631 .concat(orderByComparator.getOrderBy());
3632 }
3633 else {
3634 sql = _SQL_GETUSERS;
3635 }
3636
3637 SQLQuery q = session.createSQLQuery(sql);
3638
3639 q.addEntity("User_",
3640 com.liferay.portal.model.impl.UserImpl.class);
3641
3642 QueryPos qPos = QueryPos.getInstance(q);
3643
3644 qPos.add(pk);
3645
3646 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
3647 getDialect(), start, end);
3648 }
3649 catch (Exception e) {
3650 throw processException(e);
3651 }
3652 finally {
3653 if (list == null) {
3654 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
3655 finderArgs);
3656 }
3657 else {
3658 userPersistence.cacheResult(list);
3659
3660 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
3661 finderArgs, list);
3662 }
3663
3664 closeSession(session);
3665 }
3666 }
3667
3668 return list;
3669 }
3670
3671 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3672 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
3673 Long.class, UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
3674 "getUsersSize", new String[] { Long.class.getName() });
3675
3676 static {
3677 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
3678 }
3679
3680
3687 public int getUsersSize(long pk) throws SystemException {
3688 Object[] finderArgs = new Object[] { pk };
3689
3690 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
3691 finderArgs, this);
3692
3693 if (count == null) {
3694 Session session = null;
3695
3696 try {
3697 session = openSession();
3698
3699 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
3700
3701 q.addScalar(COUNT_COLUMN_NAME,
3702 com.liferay.portal.kernel.dao.orm.Type.LONG);
3703
3704 QueryPos qPos = QueryPos.getInstance(q);
3705
3706 qPos.add(pk);
3707
3708 count = (Long)q.uniqueResult();
3709 }
3710 catch (Exception e) {
3711 throw processException(e);
3712 }
3713 finally {
3714 if (count == null) {
3715 count = Long.valueOf(0);
3716 }
3717
3718 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
3719 finderArgs, count);
3720
3721 closeSession(session);
3722 }
3723 }
3724
3725 return count.intValue();
3726 }
3727
3728 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3729 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
3730 Boolean.class,
3731 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
3732 "containsUser",
3733 new String[] { Long.class.getName(), Long.class.getName() });
3734
3735
3743 public boolean containsUser(long pk, long userPK) throws SystemException {
3744 Object[] finderArgs = new Object[] { pk, userPK };
3745
3746 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
3747 finderArgs, this);
3748
3749 if (value == null) {
3750 try {
3751 value = Boolean.valueOf(containsUser.contains(pk, userPK));
3752 }
3753 catch (Exception e) {
3754 throw processException(e);
3755 }
3756 finally {
3757 if (value == null) {
3758 value = Boolean.FALSE;
3759 }
3760
3761 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
3762 finderArgs, value);
3763 }
3764 }
3765
3766 return value.booleanValue();
3767 }
3768
3769
3776 public boolean containsUsers(long pk) throws SystemException {
3777 if (getUsersSize(pk) > 0) {
3778 return true;
3779 }
3780 else {
3781 return false;
3782 }
3783 }
3784
3785
3792 public void addUser(long pk, long userPK) throws SystemException {
3793 try {
3794 addUser.add(pk, userPK);
3795 }
3796 catch (Exception e) {
3797 throw processException(e);
3798 }
3799 finally {
3800 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3801 }
3802 }
3803
3804
3811 public void addUser(long pk, com.liferay.portal.model.User user)
3812 throws SystemException {
3813 try {
3814 addUser.add(pk, user.getPrimaryKey());
3815 }
3816 catch (Exception e) {
3817 throw processException(e);
3818 }
3819 finally {
3820 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3821 }
3822 }
3823
3824
3831 public void addUsers(long pk, long[] userPKs) throws SystemException {
3832 try {
3833 for (long userPK : userPKs) {
3834 addUser.add(pk, userPK);
3835 }
3836 }
3837 catch (Exception e) {
3838 throw processException(e);
3839 }
3840 finally {
3841 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3842 }
3843 }
3844
3845
3852 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
3853 throws SystemException {
3854 try {
3855 for (com.liferay.portal.model.User user : users) {
3856 addUser.add(pk, user.getPrimaryKey());
3857 }
3858 }
3859 catch (Exception e) {
3860 throw processException(e);
3861 }
3862 finally {
3863 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3864 }
3865 }
3866
3867
3873 public void clearUsers(long pk) throws SystemException {
3874 try {
3875 clearUsers.clear(pk);
3876 }
3877 catch (Exception e) {
3878 throw processException(e);
3879 }
3880 finally {
3881 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3882 }
3883 }
3884
3885
3892 public void removeUser(long pk, long userPK) throws SystemException {
3893 try {
3894 removeUser.remove(pk, userPK);
3895 }
3896 catch (Exception e) {
3897 throw processException(e);
3898 }
3899 finally {
3900 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3901 }
3902 }
3903
3904
3911 public void removeUser(long pk, com.liferay.portal.model.User user)
3912 throws SystemException {
3913 try {
3914 removeUser.remove(pk, user.getPrimaryKey());
3915 }
3916 catch (Exception e) {
3917 throw processException(e);
3918 }
3919 finally {
3920 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3921 }
3922 }
3923
3924
3931 public void removeUsers(long pk, long[] userPKs) throws SystemException {
3932 try {
3933 for (long userPK : userPKs) {
3934 removeUser.remove(pk, userPK);
3935 }
3936 }
3937 catch (Exception e) {
3938 throw processException(e);
3939 }
3940 finally {
3941 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3942 }
3943 }
3944
3945
3952 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
3953 throws SystemException {
3954 try {
3955 for (com.liferay.portal.model.User user : users) {
3956 removeUser.remove(pk, user.getPrimaryKey());
3957 }
3958 }
3959 catch (Exception e) {
3960 throw processException(e);
3961 }
3962 finally {
3963 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3964 }
3965 }
3966
3967
3974 public void setUsers(long pk, long[] userPKs) throws SystemException {
3975 try {
3976 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
3977
3978 List<com.liferay.portal.model.User> users = getUsers(pk);
3979
3980 for (com.liferay.portal.model.User user : users) {
3981 if (!userPKSet.remove(user.getPrimaryKey())) {
3982 removeUser.remove(pk, user.getPrimaryKey());
3983 }
3984 }
3985
3986 for (Long userPK : userPKSet) {
3987 addUser.add(pk, userPK);
3988 }
3989 }
3990 catch (Exception e) {
3991 throw processException(e);
3992 }
3993 finally {
3994 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3995 }
3996 }
3997
3998
4005 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
4006 throws SystemException {
4007 try {
4008 long[] userPKs = new long[users.size()];
4009
4010 for (int i = 0; i < users.size(); i++) {
4011 com.liferay.portal.model.User user = users.get(i);
4012
4013 userPKs[i] = user.getPrimaryKey();
4014 }
4015
4016 setUsers(pk, userPKs);
4017 }
4018 catch (Exception e) {
4019 throw processException(e);
4020 }
4021 finally {
4022 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4023 }
4024 }
4025
4026
4029 public void afterPropertiesSet() {
4030 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4031 com.liferay.portal.util.PropsUtil.get(
4032 "value.object.listener.com.liferay.portal.model.UserGroup")));
4033
4034 if (listenerClassNames.length > 0) {
4035 try {
4036 List<ModelListener<UserGroup>> listenersList = new ArrayList<ModelListener<UserGroup>>();
4037
4038 for (String listenerClassName : listenerClassNames) {
4039 listenersList.add((ModelListener<UserGroup>)InstanceFactory.newInstance(
4040 listenerClassName));
4041 }
4042
4043 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4044 }
4045 catch (Exception e) {
4046 _log.error(e);
4047 }
4048 }
4049
4050 containsGroup = new ContainsGroup();
4051
4052 addGroup = new AddGroup();
4053 clearGroups = new ClearGroups();
4054 removeGroup = new RemoveGroup();
4055
4056 containsTeam = new ContainsTeam();
4057
4058 addTeam = new AddTeam();
4059 clearTeams = new ClearTeams();
4060 removeTeam = new RemoveTeam();
4061
4062 containsUser = new ContainsUser();
4063
4064 addUser = new AddUser();
4065 clearUsers = new ClearUsers();
4066 removeUser = new RemoveUser();
4067 }
4068
4069 public void destroy() {
4070 EntityCacheUtil.removeCache(UserGroupImpl.class.getName());
4071 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4072 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4073 }
4074
4075 @BeanReference(type = AccountPersistence.class)
4076 protected AccountPersistence accountPersistence;
4077 @BeanReference(type = AddressPersistence.class)
4078 protected AddressPersistence addressPersistence;
4079 @BeanReference(type = BrowserTrackerPersistence.class)
4080 protected BrowserTrackerPersistence browserTrackerPersistence;
4081 @BeanReference(type = ClassNamePersistence.class)
4082 protected ClassNamePersistence classNamePersistence;
4083 @BeanReference(type = ClusterGroupPersistence.class)
4084 protected ClusterGroupPersistence clusterGroupPersistence;
4085 @BeanReference(type = CompanyPersistence.class)
4086 protected CompanyPersistence companyPersistence;
4087 @BeanReference(type = ContactPersistence.class)
4088 protected ContactPersistence contactPersistence;
4089 @BeanReference(type = CountryPersistence.class)
4090 protected CountryPersistence countryPersistence;
4091 @BeanReference(type = EmailAddressPersistence.class)
4092 protected EmailAddressPersistence emailAddressPersistence;
4093 @BeanReference(type = GroupPersistence.class)
4094 protected GroupPersistence groupPersistence;
4095 @BeanReference(type = ImagePersistence.class)
4096 protected ImagePersistence imagePersistence;
4097 @BeanReference(type = LayoutPersistence.class)
4098 protected LayoutPersistence layoutPersistence;
4099 @BeanReference(type = LayoutBranchPersistence.class)
4100 protected LayoutBranchPersistence layoutBranchPersistence;
4101 @BeanReference(type = LayoutPrototypePersistence.class)
4102 protected LayoutPrototypePersistence layoutPrototypePersistence;
4103 @BeanReference(type = LayoutRevisionPersistence.class)
4104 protected LayoutRevisionPersistence layoutRevisionPersistence;
4105 @BeanReference(type = LayoutSetPersistence.class)
4106 protected LayoutSetPersistence layoutSetPersistence;
4107 @BeanReference(type = LayoutSetBranchPersistence.class)
4108 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
4109 @BeanReference(type = LayoutSetPrototypePersistence.class)
4110 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
4111 @BeanReference(type = ListTypePersistence.class)
4112 protected ListTypePersistence listTypePersistence;
4113 @BeanReference(type = LockPersistence.class)
4114 protected LockPersistence lockPersistence;
4115 @BeanReference(type = MembershipRequestPersistence.class)
4116 protected MembershipRequestPersistence membershipRequestPersistence;
4117 @BeanReference(type = OrganizationPersistence.class)
4118 protected OrganizationPersistence organizationPersistence;
4119 @BeanReference(type = OrgGroupPermissionPersistence.class)
4120 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4121 @BeanReference(type = OrgGroupRolePersistence.class)
4122 protected OrgGroupRolePersistence orgGroupRolePersistence;
4123 @BeanReference(type = OrgLaborPersistence.class)
4124 protected OrgLaborPersistence orgLaborPersistence;
4125 @BeanReference(type = PasswordPolicyPersistence.class)
4126 protected PasswordPolicyPersistence passwordPolicyPersistence;
4127 @BeanReference(type = PasswordPolicyRelPersistence.class)
4128 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4129 @BeanReference(type = PasswordTrackerPersistence.class)
4130 protected PasswordTrackerPersistence passwordTrackerPersistence;
4131 @BeanReference(type = PermissionPersistence.class)
4132 protected PermissionPersistence permissionPersistence;
4133 @BeanReference(type = PhonePersistence.class)
4134 protected PhonePersistence phonePersistence;
4135 @BeanReference(type = PluginSettingPersistence.class)
4136 protected PluginSettingPersistence pluginSettingPersistence;
4137 @BeanReference(type = PortalPreferencesPersistence.class)
4138 protected PortalPreferencesPersistence portalPreferencesPersistence;
4139 @BeanReference(type = PortletPersistence.class)
4140 protected PortletPersistence portletPersistence;
4141 @BeanReference(type = PortletItemPersistence.class)
4142 protected PortletItemPersistence portletItemPersistence;
4143 @BeanReference(type = PortletPreferencesPersistence.class)
4144 protected PortletPreferencesPersistence portletPreferencesPersistence;
4145 @BeanReference(type = RegionPersistence.class)
4146 protected RegionPersistence regionPersistence;
4147 @BeanReference(type = ReleasePersistence.class)
4148 protected ReleasePersistence releasePersistence;
4149 @BeanReference(type = RepositoryPersistence.class)
4150 protected RepositoryPersistence repositoryPersistence;
4151 @BeanReference(type = RepositoryEntryPersistence.class)
4152 protected RepositoryEntryPersistence repositoryEntryPersistence;
4153 @BeanReference(type = ResourcePersistence.class)
4154 protected ResourcePersistence resourcePersistence;
4155 @BeanReference(type = ResourceActionPersistence.class)
4156 protected ResourceActionPersistence resourceActionPersistence;
4157 @BeanReference(type = ResourceBlockPersistence.class)
4158 protected ResourceBlockPersistence resourceBlockPersistence;
4159 @BeanReference(type = ResourceBlockPermissionPersistence.class)
4160 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
4161 @BeanReference(type = ResourceCodePersistence.class)
4162 protected ResourceCodePersistence resourceCodePersistence;
4163 @BeanReference(type = ResourcePermissionPersistence.class)
4164 protected ResourcePermissionPersistence resourcePermissionPersistence;
4165 @BeanReference(type = ResourceTypePermissionPersistence.class)
4166 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
4167 @BeanReference(type = RolePersistence.class)
4168 protected RolePersistence rolePersistence;
4169 @BeanReference(type = ServiceComponentPersistence.class)
4170 protected ServiceComponentPersistence serviceComponentPersistence;
4171 @BeanReference(type = ShardPersistence.class)
4172 protected ShardPersistence shardPersistence;
4173 @BeanReference(type = SubscriptionPersistence.class)
4174 protected SubscriptionPersistence subscriptionPersistence;
4175 @BeanReference(type = TeamPersistence.class)
4176 protected TeamPersistence teamPersistence;
4177 @BeanReference(type = TicketPersistence.class)
4178 protected TicketPersistence ticketPersistence;
4179 @BeanReference(type = UserPersistence.class)
4180 protected UserPersistence userPersistence;
4181 @BeanReference(type = UserGroupPersistence.class)
4182 protected UserGroupPersistence userGroupPersistence;
4183 @BeanReference(type = UserGroupGroupRolePersistence.class)
4184 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
4185 @BeanReference(type = UserGroupRolePersistence.class)
4186 protected UserGroupRolePersistence userGroupRolePersistence;
4187 @BeanReference(type = UserIdMapperPersistence.class)
4188 protected UserIdMapperPersistence userIdMapperPersistence;
4189 @BeanReference(type = UserNotificationEventPersistence.class)
4190 protected UserNotificationEventPersistence userNotificationEventPersistence;
4191 @BeanReference(type = UserTrackerPersistence.class)
4192 protected UserTrackerPersistence userTrackerPersistence;
4193 @BeanReference(type = UserTrackerPathPersistence.class)
4194 protected UserTrackerPathPersistence userTrackerPathPersistence;
4195 @BeanReference(type = VirtualHostPersistence.class)
4196 protected VirtualHostPersistence virtualHostPersistence;
4197 @BeanReference(type = WebDAVPropsPersistence.class)
4198 protected WebDAVPropsPersistence webDAVPropsPersistence;
4199 @BeanReference(type = WebsitePersistence.class)
4200 protected WebsitePersistence websitePersistence;
4201 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4202 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4203 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4204 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4205 protected ContainsGroup containsGroup;
4206 protected AddGroup addGroup;
4207 protected ClearGroups clearGroups;
4208 protected RemoveGroup removeGroup;
4209 protected ContainsTeam containsTeam;
4210 protected AddTeam addTeam;
4211 protected ClearTeams clearTeams;
4212 protected RemoveTeam removeTeam;
4213 protected ContainsUser containsUser;
4214 protected AddUser addUser;
4215 protected ClearUsers clearUsers;
4216 protected RemoveUser removeUser;
4217
4218 protected class ContainsGroup {
4219 protected ContainsGroup() {
4220 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4221 _SQL_CONTAINSGROUP,
4222 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4223 RowMapper.COUNT);
4224 }
4225
4226 protected boolean contains(long userGroupId, long groupId) {
4227 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4228 new Long(userGroupId), new Long(groupId)
4229 });
4230
4231 if (results.size() > 0) {
4232 Integer count = results.get(0);
4233
4234 if (count.intValue() > 0) {
4235 return true;
4236 }
4237 }
4238
4239 return false;
4240 }
4241
4242 private MappingSqlQuery<Integer> _mappingSqlQuery;
4243 }
4244
4245 protected class AddGroup {
4246 protected AddGroup() {
4247 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4248 "INSERT INTO Groups_UserGroups (userGroupId, groupId) VALUES (?, ?)",
4249 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4250 }
4251
4252 protected void add(long userGroupId, long groupId)
4253 throws SystemException {
4254 if (!containsGroup.contains(userGroupId, groupId)) {
4255 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4256
4257 for (ModelListener<UserGroup> listener : listeners) {
4258 listener.onBeforeAddAssociation(userGroupId,
4259 com.liferay.portal.model.Group.class.getName(), groupId);
4260 }
4261
4262 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4263 listener.onBeforeAddAssociation(groupId,
4264 UserGroup.class.getName(), userGroupId);
4265 }
4266
4267 _sqlUpdate.update(new Object[] {
4268 new Long(userGroupId), new Long(groupId)
4269 });
4270
4271 for (ModelListener<UserGroup> listener : listeners) {
4272 listener.onAfterAddAssociation(userGroupId,
4273 com.liferay.portal.model.Group.class.getName(), groupId);
4274 }
4275
4276 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4277 listener.onAfterAddAssociation(groupId,
4278 UserGroup.class.getName(), userGroupId);
4279 }
4280 }
4281 }
4282
4283 private SqlUpdate _sqlUpdate;
4284 }
4285
4286 protected class ClearGroups {
4287 protected ClearGroups() {
4288 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4289 "DELETE FROM Groups_UserGroups WHERE userGroupId = ?",
4290 new int[] { java.sql.Types.BIGINT });
4291 }
4292
4293 protected void clear(long userGroupId) throws SystemException {
4294 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4295
4296 List<com.liferay.portal.model.Group> groups = null;
4297
4298 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4299 groups = getGroups(userGroupId);
4300
4301 for (com.liferay.portal.model.Group group : groups) {
4302 for (ModelListener<UserGroup> listener : listeners) {
4303 listener.onBeforeRemoveAssociation(userGroupId,
4304 com.liferay.portal.model.Group.class.getName(),
4305 group.getPrimaryKey());
4306 }
4307
4308 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4309 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
4310 UserGroup.class.getName(), userGroupId);
4311 }
4312 }
4313 }
4314
4315 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
4316
4317 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4318 for (com.liferay.portal.model.Group group : groups) {
4319 for (ModelListener<UserGroup> listener : listeners) {
4320 listener.onAfterRemoveAssociation(userGroupId,
4321 com.liferay.portal.model.Group.class.getName(),
4322 group.getPrimaryKey());
4323 }
4324
4325 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4326 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
4327 UserGroup.class.getName(), userGroupId);
4328 }
4329 }
4330 }
4331 }
4332
4333 private SqlUpdate _sqlUpdate;
4334 }
4335
4336 protected class RemoveGroup {
4337 protected RemoveGroup() {
4338 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4339 "DELETE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?",
4340 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4341 }
4342
4343 protected void remove(long userGroupId, long groupId)
4344 throws SystemException {
4345 if (containsGroup.contains(userGroupId, groupId)) {
4346 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4347
4348 for (ModelListener<UserGroup> listener : listeners) {
4349 listener.onBeforeRemoveAssociation(userGroupId,
4350 com.liferay.portal.model.Group.class.getName(), groupId);
4351 }
4352
4353 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4354 listener.onBeforeRemoveAssociation(groupId,
4355 UserGroup.class.getName(), userGroupId);
4356 }
4357
4358 _sqlUpdate.update(new Object[] {
4359 new Long(userGroupId), new Long(groupId)
4360 });
4361
4362 for (ModelListener<UserGroup> listener : listeners) {
4363 listener.onAfterRemoveAssociation(userGroupId,
4364 com.liferay.portal.model.Group.class.getName(), groupId);
4365 }
4366
4367 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4368 listener.onAfterRemoveAssociation(groupId,
4369 UserGroup.class.getName(), userGroupId);
4370 }
4371 }
4372 }
4373
4374 private SqlUpdate _sqlUpdate;
4375 }
4376
4377 protected class ContainsTeam {
4378 protected ContainsTeam() {
4379 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4380 _SQL_CONTAINSTEAM,
4381 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4382 RowMapper.COUNT);
4383 }
4384
4385 protected boolean contains(long userGroupId, long teamId) {
4386 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4387 new Long(userGroupId), new Long(teamId)
4388 });
4389
4390 if (results.size() > 0) {
4391 Integer count = results.get(0);
4392
4393 if (count.intValue() > 0) {
4394 return true;
4395 }
4396 }
4397
4398 return false;
4399 }
4400
4401 private MappingSqlQuery<Integer> _mappingSqlQuery;
4402 }
4403
4404 protected class AddTeam {
4405 protected AddTeam() {
4406 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4407 "INSERT INTO UserGroups_Teams (userGroupId, teamId) VALUES (?, ?)",
4408 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4409 }
4410
4411 protected void add(long userGroupId, long teamId)
4412 throws SystemException {
4413 if (!containsTeam.contains(userGroupId, teamId)) {
4414 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
4415
4416 for (ModelListener<UserGroup> listener : listeners) {
4417 listener.onBeforeAddAssociation(userGroupId,
4418 com.liferay.portal.model.Team.class.getName(), teamId);
4419 }
4420
4421 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4422 listener.onBeforeAddAssociation(teamId,
4423 UserGroup.class.getName(), userGroupId);
4424 }
4425
4426 _sqlUpdate.update(new Object[] {
4427 new Long(userGroupId), new Long(teamId)
4428 });
4429
4430 for (ModelListener<UserGroup> listener : listeners) {
4431 listener.onAfterAddAssociation(userGroupId,
4432 com.liferay.portal.model.Team.class.getName(), teamId);
4433 }
4434
4435 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4436 listener.onAfterAddAssociation(teamId,
4437 UserGroup.class.getName(), userGroupId);
4438 }
4439 }
4440 }
4441
4442 private SqlUpdate _sqlUpdate;
4443 }
4444
4445 protected class ClearTeams {
4446 protected ClearTeams() {
4447 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4448 "DELETE FROM UserGroups_Teams WHERE userGroupId = ?",
4449 new int[] { java.sql.Types.BIGINT });
4450 }
4451
4452 protected void clear(long userGroupId) throws SystemException {
4453 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
4454
4455 List<com.liferay.portal.model.Team> teams = null;
4456
4457 if ((listeners.length > 0) || (teamListeners.length > 0)) {
4458 teams = getTeams(userGroupId);
4459
4460 for (com.liferay.portal.model.Team team : teams) {
4461 for (ModelListener<UserGroup> listener : listeners) {
4462 listener.onBeforeRemoveAssociation(userGroupId,
4463 com.liferay.portal.model.Team.class.getName(),
4464 team.getPrimaryKey());
4465 }
4466
4467 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4468 listener.onBeforeRemoveAssociation(team.getPrimaryKey(),
4469 UserGroup.class.getName(), userGroupId);
4470 }
4471 }
4472 }
4473
4474 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
4475
4476 if ((listeners.length > 0) || (teamListeners.length > 0)) {
4477 for (com.liferay.portal.model.Team team : teams) {
4478 for (ModelListener<UserGroup> listener : listeners) {
4479 listener.onAfterRemoveAssociation(userGroupId,
4480 com.liferay.portal.model.Team.class.getName(),
4481 team.getPrimaryKey());
4482 }
4483
4484 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4485 listener.onAfterRemoveAssociation(team.getPrimaryKey(),
4486 UserGroup.class.getName(), userGroupId);
4487 }
4488 }
4489 }
4490 }
4491
4492 private SqlUpdate _sqlUpdate;
4493 }
4494
4495 protected class RemoveTeam {
4496 protected RemoveTeam() {
4497 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4498 "DELETE FROM UserGroups_Teams WHERE userGroupId = ? AND teamId = ?",
4499 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4500 }
4501
4502 protected void remove(long userGroupId, long teamId)
4503 throws SystemException {
4504 if (containsTeam.contains(userGroupId, teamId)) {
4505 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
4506
4507 for (ModelListener<UserGroup> listener : listeners) {
4508 listener.onBeforeRemoveAssociation(userGroupId,
4509 com.liferay.portal.model.Team.class.getName(), teamId);
4510 }
4511
4512 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4513 listener.onBeforeRemoveAssociation(teamId,
4514 UserGroup.class.getName(), userGroupId);
4515 }
4516
4517 _sqlUpdate.update(new Object[] {
4518 new Long(userGroupId), new Long(teamId)
4519 });
4520
4521 for (ModelListener<UserGroup> listener : listeners) {
4522 listener.onAfterRemoveAssociation(userGroupId,
4523 com.liferay.portal.model.Team.class.getName(), teamId);
4524 }
4525
4526 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4527 listener.onAfterRemoveAssociation(teamId,
4528 UserGroup.class.getName(), userGroupId);
4529 }
4530 }
4531 }
4532
4533 private SqlUpdate _sqlUpdate;
4534 }
4535
4536 protected class ContainsUser {
4537 protected ContainsUser() {
4538 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4539 _SQL_CONTAINSUSER,
4540 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4541 RowMapper.COUNT);
4542 }
4543
4544 protected boolean contains(long userGroupId, long userId) {
4545 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4546 new Long(userGroupId), new Long(userId)
4547 });
4548
4549 if (results.size() > 0) {
4550 Integer count = results.get(0);
4551
4552 if (count.intValue() > 0) {
4553 return true;
4554 }
4555 }
4556
4557 return false;
4558 }
4559
4560 private MappingSqlQuery<Integer> _mappingSqlQuery;
4561 }
4562
4563 protected class AddUser {
4564 protected AddUser() {
4565 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4566 "INSERT INTO Users_UserGroups (userGroupId, userId) VALUES (?, ?)",
4567 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4568 }
4569
4570 protected void add(long userGroupId, long userId)
4571 throws SystemException {
4572 if (!containsUser.contains(userGroupId, userId)) {
4573 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4574
4575 for (ModelListener<UserGroup> listener : listeners) {
4576 listener.onBeforeAddAssociation(userGroupId,
4577 com.liferay.portal.model.User.class.getName(), userId);
4578 }
4579
4580 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4581 listener.onBeforeAddAssociation(userId,
4582 UserGroup.class.getName(), userGroupId);
4583 }
4584
4585 _sqlUpdate.update(new Object[] {
4586 new Long(userGroupId), new Long(userId)
4587 });
4588
4589 for (ModelListener<UserGroup> listener : listeners) {
4590 listener.onAfterAddAssociation(userGroupId,
4591 com.liferay.portal.model.User.class.getName(), userId);
4592 }
4593
4594 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4595 listener.onAfterAddAssociation(userId,
4596 UserGroup.class.getName(), userGroupId);
4597 }
4598 }
4599 }
4600
4601 private SqlUpdate _sqlUpdate;
4602 }
4603
4604 protected class ClearUsers {
4605 protected ClearUsers() {
4606 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4607 "DELETE FROM Users_UserGroups WHERE userGroupId = ?",
4608 new int[] { java.sql.Types.BIGINT });
4609 }
4610
4611 protected void clear(long userGroupId) throws SystemException {
4612 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4613
4614 List<com.liferay.portal.model.User> users = null;
4615
4616 if ((listeners.length > 0) || (userListeners.length > 0)) {
4617 users = getUsers(userGroupId);
4618
4619 for (com.liferay.portal.model.User user : users) {
4620 for (ModelListener<UserGroup> listener : listeners) {
4621 listener.onBeforeRemoveAssociation(userGroupId,
4622 com.liferay.portal.model.User.class.getName(),
4623 user.getPrimaryKey());
4624 }
4625
4626 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4627 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
4628 UserGroup.class.getName(), userGroupId);
4629 }
4630 }
4631 }
4632
4633 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
4634
4635 if ((listeners.length > 0) || (userListeners.length > 0)) {
4636 for (com.liferay.portal.model.User user : users) {
4637 for (ModelListener<UserGroup> listener : listeners) {
4638 listener.onAfterRemoveAssociation(userGroupId,
4639 com.liferay.portal.model.User.class.getName(),
4640 user.getPrimaryKey());
4641 }
4642
4643 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4644 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
4645 UserGroup.class.getName(), userGroupId);
4646 }
4647 }
4648 }
4649 }
4650
4651 private SqlUpdate _sqlUpdate;
4652 }
4653
4654 protected class RemoveUser {
4655 protected RemoveUser() {
4656 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4657 "DELETE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?",
4658 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4659 }
4660
4661 protected void remove(long userGroupId, long userId)
4662 throws SystemException {
4663 if (containsUser.contains(userGroupId, userId)) {
4664 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4665
4666 for (ModelListener<UserGroup> listener : listeners) {
4667 listener.onBeforeRemoveAssociation(userGroupId,
4668 com.liferay.portal.model.User.class.getName(), userId);
4669 }
4670
4671 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4672 listener.onBeforeRemoveAssociation(userId,
4673 UserGroup.class.getName(), userGroupId);
4674 }
4675
4676 _sqlUpdate.update(new Object[] {
4677 new Long(userGroupId), new Long(userId)
4678 });
4679
4680 for (ModelListener<UserGroup> listener : listeners) {
4681 listener.onAfterRemoveAssociation(userGroupId,
4682 com.liferay.portal.model.User.class.getName(), userId);
4683 }
4684
4685 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4686 listener.onAfterRemoveAssociation(userId,
4687 UserGroup.class.getName(), userGroupId);
4688 }
4689 }
4690 }
4691
4692 private SqlUpdate _sqlUpdate;
4693 }
4694
4695 private static final String _SQL_SELECT_USERGROUP = "SELECT userGroup FROM UserGroup userGroup";
4696 private static final String _SQL_SELECT_USERGROUP_WHERE = "SELECT userGroup FROM UserGroup userGroup WHERE ";
4697 private static final String _SQL_COUNT_USERGROUP = "SELECT COUNT(userGroup) FROM UserGroup userGroup";
4698 private static final String _SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(userGroup) FROM UserGroup userGroup WHERE ";
4699 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_UserGroups ON (Groups_UserGroups.groupId = Group_.groupId) WHERE (Groups_UserGroups.userGroupId = ?)";
4700 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ?";
4701 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?";
4702 private static final String _SQL_GETTEAMS = "SELECT {Team.*} FROM Team INNER JOIN UserGroups_Teams ON (UserGroups_Teams.teamId = Team.teamId) WHERE (UserGroups_Teams.userGroupId = ?)";
4703 private static final String _SQL_GETTEAMSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE userGroupId = ?";
4704 private static final String _SQL_CONTAINSTEAM = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE userGroupId = ? AND teamId = ?";
4705 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_UserGroups ON (Users_UserGroups.userId = User_.userId) WHERE (Users_UserGroups.userGroupId = ?)";
4706 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ?";
4707 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?";
4708 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userGroup.companyId = ?";
4709 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "userGroup.companyId = ? AND ";
4710 private static final String _FINDER_COLUMN_C_P_PARENTUSERGROUPID_2 = "userGroup.parentUserGroupId = ?";
4711 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "userGroup.companyId = ? AND ";
4712 private static final String _FINDER_COLUMN_C_N_NAME_1 = "userGroup.name IS NULL";
4713 private static final String _FINDER_COLUMN_C_N_NAME_2 = "userGroup.name = ?";
4714 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(userGroup.name IS NULL OR userGroup.name = ?)";
4715 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "userGroup.userGroupId";
4716 private static final String _FILTER_SQL_SELECT_USERGROUP_WHERE = "SELECT DISTINCT {userGroup.*} FROM UserGroup userGroup WHERE ";
4717 private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1 =
4718 "SELECT {UserGroup.*} FROM (SELECT DISTINCT userGroup.userGroupId FROM UserGroup userGroup WHERE ";
4719 private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2 =
4720 ") TEMP_TABLE INNER JOIN UserGroup ON TEMP_TABLE.userGroupId = UserGroup.userGroupId";
4721 private static final String _FILTER_SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(DISTINCT userGroup.userGroupId) AS COUNT_VALUE FROM UserGroup userGroup WHERE ";
4722 private static final String _FILTER_ENTITY_ALIAS = "userGroup";
4723 private static final String _FILTER_ENTITY_TABLE = "UserGroup";
4724 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroup.";
4725 private static final String _ORDER_BY_ENTITY_TABLE = "UserGroup.";
4726 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroup exists with the primary key ";
4727 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroup exists with the key {";
4728 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4729 private static Log _log = LogFactoryUtil.getLog(UserGroupPersistenceImpl.class);
4730 private static UserGroup _nullUserGroup = new UserGroupImpl() {
4731 @Override
4732 public Object clone() {
4733 return this;
4734 }
4735
4736 @Override
4737 public CacheModel<UserGroup> toCacheModel() {
4738 return _nullUserGroupCacheModel;
4739 }
4740 };
4741
4742 private static CacheModel<UserGroup> _nullUserGroupCacheModel = new CacheModel<UserGroup>() {
4743 public UserGroup toEntityModel() {
4744 return _nullUserGroup;
4745 }
4746 };
4747 }