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.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.UserGroup;
047 import com.liferay.portal.model.impl.UserGroupImpl;
048 import com.liferay.portal.model.impl.UserGroupModelImpl;
049 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057 import java.util.Set;
058
059
071 public class UserGroupPersistenceImpl extends BasePersistenceImpl<UserGroup>
072 implements UserGroupPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = UserGroupImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
084 new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
085 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
087 new String[] {
088 Long.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
094 new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
095 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
097 new String[] { Long.class.getName() },
098 UserGroupModelImpl.COMPANYID_COLUMN_BITMASK);
099 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
100 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
102 new String[] { Long.class.getName() });
103 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
104 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
105 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
106 new String[] {
107 Long.class.getName(), Long.class.getName(),
108
109 "java.lang.Integer", "java.lang.Integer",
110 "com.liferay.portal.kernel.util.OrderByComparator"
111 });
112 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
113 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
115 new String[] { Long.class.getName(), Long.class.getName() },
116 UserGroupModelImpl.COMPANYID_COLUMN_BITMASK |
117 UserGroupModelImpl.PARENTUSERGROUPID_COLUMN_BITMASK);
118 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
119 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
121 new String[] { Long.class.getName(), Long.class.getName() });
122 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
123 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
124 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
125 new String[] { Long.class.getName(), String.class.getName() },
126 UserGroupModelImpl.COMPANYID_COLUMN_BITMASK |
127 UserGroupModelImpl.NAME_COLUMN_BITMASK);
128 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
129 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
131 new String[] { Long.class.getName(), String.class.getName() });
132 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
133 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
134 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
135 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
136 UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class,
137 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
138 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
139 UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
140 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
141
142
147 public void cacheResult(UserGroup userGroup) {
148 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
149 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
150
151 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
152 new Object[] {
153 Long.valueOf(userGroup.getCompanyId()),
154
155 userGroup.getName()
156 }, userGroup);
157
158 userGroup.resetOriginalValues();
159 }
160
161
166 public void cacheResult(List<UserGroup> userGroups) {
167 for (UserGroup userGroup : userGroups) {
168 if (EntityCacheUtil.getResult(
169 UserGroupModelImpl.ENTITY_CACHE_ENABLED,
170 UserGroupImpl.class, userGroup.getPrimaryKey()) == null) {
171 cacheResult(userGroup);
172 }
173 else {
174 userGroup.resetOriginalValues();
175 }
176 }
177 }
178
179
186 @Override
187 public void clearCache() {
188 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
189 CacheRegistryUtil.clear(UserGroupImpl.class.getName());
190 }
191
192 EntityCacheUtil.clearCache(UserGroupImpl.class.getName());
193
194 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
195 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
197 }
198
199
206 @Override
207 public void clearCache(UserGroup userGroup) {
208 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
209 UserGroupImpl.class, userGroup.getPrimaryKey());
210
211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
213
214 clearUniqueFindersCache(userGroup);
215 }
216
217 @Override
218 public void clearCache(List<UserGroup> userGroups) {
219 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
221
222 for (UserGroup userGroup : userGroups) {
223 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
224 UserGroupImpl.class, userGroup.getPrimaryKey());
225
226 clearUniqueFindersCache(userGroup);
227 }
228 }
229
230 protected void clearUniqueFindersCache(UserGroup userGroup) {
231 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
232 new Object[] {
233 Long.valueOf(userGroup.getCompanyId()),
234
235 userGroup.getName()
236 });
237 }
238
239
245 public UserGroup create(long userGroupId) {
246 UserGroup userGroup = new UserGroupImpl();
247
248 userGroup.setNew(true);
249 userGroup.setPrimaryKey(userGroupId);
250
251 return userGroup;
252 }
253
254
262 public UserGroup remove(long userGroupId)
263 throws NoSuchUserGroupException, SystemException {
264 return remove(Long.valueOf(userGroupId));
265 }
266
267
275 @Override
276 public UserGroup remove(Serializable primaryKey)
277 throws NoSuchUserGroupException, SystemException {
278 Session session = null;
279
280 try {
281 session = openSession();
282
283 UserGroup userGroup = (UserGroup)session.get(UserGroupImpl.class,
284 primaryKey);
285
286 if (userGroup == null) {
287 if (_log.isWarnEnabled()) {
288 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
289 }
290
291 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
292 primaryKey);
293 }
294
295 return remove(userGroup);
296 }
297 catch (NoSuchUserGroupException nsee) {
298 throw nsee;
299 }
300 catch (Exception e) {
301 throw processException(e);
302 }
303 finally {
304 closeSession(session);
305 }
306 }
307
308 @Override
309 protected UserGroup removeImpl(UserGroup userGroup)
310 throws SystemException {
311 userGroup = toUnwrappedModel(userGroup);
312
313 try {
314 clearGroups.clear(userGroup.getPrimaryKey());
315 }
316 catch (Exception e) {
317 throw processException(e);
318 }
319 finally {
320 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
321 }
322
323 try {
324 clearTeams.clear(userGroup.getPrimaryKey());
325 }
326 catch (Exception e) {
327 throw processException(e);
328 }
329 finally {
330 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
331 }
332
333 try {
334 clearUsers.clear(userGroup.getPrimaryKey());
335 }
336 catch (Exception e) {
337 throw processException(e);
338 }
339 finally {
340 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
341 }
342
343 Session session = null;
344
345 try {
346 session = openSession();
347
348 BatchSessionUtil.delete(session, userGroup);
349 }
350 catch (Exception e) {
351 throw processException(e);
352 }
353 finally {
354 closeSession(session);
355 }
356
357 clearCache(userGroup);
358
359 return userGroup;
360 }
361
362 @Override
363 public UserGroup updateImpl(com.liferay.portal.model.UserGroup userGroup,
364 boolean merge) throws SystemException {
365 userGroup = toUnwrappedModel(userGroup);
366
367 boolean isNew = userGroup.isNew();
368
369 UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup;
370
371 Session session = null;
372
373 try {
374 session = openSession();
375
376 BatchSessionUtil.update(session, userGroup, merge);
377
378 userGroup.setNew(false);
379 }
380 catch (Exception e) {
381 throw processException(e);
382 }
383 finally {
384 closeSession(session);
385 }
386
387 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
388
389 if (isNew || !UserGroupModelImpl.COLUMN_BITMASK_ENABLED) {
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
391 }
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) {
655 StringBundler query = null;
656
657 if (orderByComparator != null) {
658 query = new StringBundler(3 +
659 (orderByComparator.getOrderByFields().length * 3));
660 }
661 else {
662 query = new StringBundler(3);
663 }
664
665 query.append(_SQL_SELECT_USERGROUP_WHERE);
666
667 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
668
669 if (orderByComparator != null) {
670 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
671 orderByComparator);
672 }
673
674 else {
675 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
676 }
677
678 String sql = query.toString();
679
680 Session session = null;
681
682 try {
683 session = openSession();
684
685 Query q = session.createQuery(sql);
686
687 QueryPos qPos = QueryPos.getInstance(q);
688
689 qPos.add(companyId);
690
691 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
692 end);
693 }
694 catch (Exception e) {
695 throw processException(e);
696 }
697 finally {
698 if (list == null) {
699 FinderCacheUtil.removeResult(finderPath, finderArgs);
700 }
701 else {
702 cacheResult(list);
703
704 FinderCacheUtil.putResult(finderPath, finderArgs, list);
705 }
706
707 closeSession(session);
708 }
709 }
710
711 return list;
712 }
713
714
727 public UserGroup findByCompanyId_First(long companyId,
728 OrderByComparator orderByComparator)
729 throws NoSuchUserGroupException, SystemException {
730 List<UserGroup> list = findByCompanyId(companyId, 0, 1,
731 orderByComparator);
732
733 if (list.isEmpty()) {
734 StringBundler msg = new StringBundler(4);
735
736 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
737
738 msg.append("companyId=");
739 msg.append(companyId);
740
741 msg.append(StringPool.CLOSE_CURLY_BRACE);
742
743 throw new NoSuchUserGroupException(msg.toString());
744 }
745 else {
746 return list.get(0);
747 }
748 }
749
750
763 public UserGroup findByCompanyId_Last(long companyId,
764 OrderByComparator orderByComparator)
765 throws NoSuchUserGroupException, SystemException {
766 int count = countByCompanyId(companyId);
767
768 List<UserGroup> list = findByCompanyId(companyId, count - 1, count,
769 orderByComparator);
770
771 if (list.isEmpty()) {
772 StringBundler msg = new StringBundler(4);
773
774 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
775
776 msg.append("companyId=");
777 msg.append(companyId);
778
779 msg.append(StringPool.CLOSE_CURLY_BRACE);
780
781 throw new NoSuchUserGroupException(msg.toString());
782 }
783 else {
784 return list.get(0);
785 }
786 }
787
788
802 public UserGroup[] findByCompanyId_PrevAndNext(long userGroupId,
803 long companyId, OrderByComparator orderByComparator)
804 throws NoSuchUserGroupException, SystemException {
805 UserGroup userGroup = findByPrimaryKey(userGroupId);
806
807 Session session = null;
808
809 try {
810 session = openSession();
811
812 UserGroup[] array = new UserGroupImpl[3];
813
814 array[0] = getByCompanyId_PrevAndNext(session, userGroup,
815 companyId, orderByComparator, true);
816
817 array[1] = userGroup;
818
819 array[2] = getByCompanyId_PrevAndNext(session, userGroup,
820 companyId, orderByComparator, false);
821
822 return array;
823 }
824 catch (Exception e) {
825 throw processException(e);
826 }
827 finally {
828 closeSession(session);
829 }
830 }
831
832 protected UserGroup getByCompanyId_PrevAndNext(Session session,
833 UserGroup userGroup, long companyId,
834 OrderByComparator orderByComparator, boolean previous) {
835 StringBundler query = null;
836
837 if (orderByComparator != null) {
838 query = new StringBundler(6 +
839 (orderByComparator.getOrderByFields().length * 6));
840 }
841 else {
842 query = new StringBundler(3);
843 }
844
845 query.append(_SQL_SELECT_USERGROUP_WHERE);
846
847 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
848
849 if (orderByComparator != null) {
850 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
851
852 if (orderByConditionFields.length > 0) {
853 query.append(WHERE_AND);
854 }
855
856 for (int i = 0; i < orderByConditionFields.length; i++) {
857 query.append(_ORDER_BY_ENTITY_ALIAS);
858 query.append(orderByConditionFields[i]);
859
860 if ((i + 1) < orderByConditionFields.length) {
861 if (orderByComparator.isAscending() ^ previous) {
862 query.append(WHERE_GREATER_THAN_HAS_NEXT);
863 }
864 else {
865 query.append(WHERE_LESSER_THAN_HAS_NEXT);
866 }
867 }
868 else {
869 if (orderByComparator.isAscending() ^ previous) {
870 query.append(WHERE_GREATER_THAN);
871 }
872 else {
873 query.append(WHERE_LESSER_THAN);
874 }
875 }
876 }
877
878 query.append(ORDER_BY_CLAUSE);
879
880 String[] orderByFields = orderByComparator.getOrderByFields();
881
882 for (int i = 0; i < orderByFields.length; i++) {
883 query.append(_ORDER_BY_ENTITY_ALIAS);
884 query.append(orderByFields[i]);
885
886 if ((i + 1) < orderByFields.length) {
887 if (orderByComparator.isAscending() ^ previous) {
888 query.append(ORDER_BY_ASC_HAS_NEXT);
889 }
890 else {
891 query.append(ORDER_BY_DESC_HAS_NEXT);
892 }
893 }
894 else {
895 if (orderByComparator.isAscending() ^ previous) {
896 query.append(ORDER_BY_ASC);
897 }
898 else {
899 query.append(ORDER_BY_DESC);
900 }
901 }
902 }
903 }
904
905 else {
906 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
907 }
908
909 String sql = query.toString();
910
911 Query q = session.createQuery(sql);
912
913 q.setFirstResult(0);
914 q.setMaxResults(2);
915
916 QueryPos qPos = QueryPos.getInstance(q);
917
918 qPos.add(companyId);
919
920 if (orderByComparator != null) {
921 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
922
923 for (Object value : values) {
924 qPos.add(value);
925 }
926 }
927
928 List<UserGroup> list = q.list();
929
930 if (list.size() == 2) {
931 return list.get(1);
932 }
933 else {
934 return null;
935 }
936 }
937
938
945 public List<UserGroup> filterFindByCompanyId(long companyId)
946 throws SystemException {
947 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
948 QueryUtil.ALL_POS, null);
949 }
950
951
964 public List<UserGroup> filterFindByCompanyId(long companyId, int start,
965 int end) throws SystemException {
966 return filterFindByCompanyId(companyId, start, end, null);
967 }
968
969
983 public List<UserGroup> filterFindByCompanyId(long companyId, int start,
984 int end, OrderByComparator orderByComparator) throws SystemException {
985 if (!InlineSQLHelperUtil.isEnabled()) {
986 return findByCompanyId(companyId, start, end, orderByComparator);
987 }
988
989 StringBundler query = null;
990
991 if (orderByComparator != null) {
992 query = new StringBundler(3 +
993 (orderByComparator.getOrderByFields().length * 3));
994 }
995 else {
996 query = new StringBundler(3);
997 }
998
999 if (getDB().isSupportsInlineDistinct()) {
1000 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1001 }
1002 else {
1003 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1004 }
1005
1006 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1007
1008 if (!getDB().isSupportsInlineDistinct()) {
1009 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1010 }
1011
1012 if (orderByComparator != null) {
1013 if (getDB().isSupportsInlineDistinct()) {
1014 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1015 orderByComparator);
1016 }
1017 else {
1018 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1019 orderByComparator);
1020 }
1021 }
1022
1023 else {
1024 if (getDB().isSupportsInlineDistinct()) {
1025 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1026 }
1027 else {
1028 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1029 }
1030 }
1031
1032 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1033 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1034
1035 Session session = null;
1036
1037 try {
1038 session = openSession();
1039
1040 SQLQuery q = session.createSQLQuery(sql);
1041
1042 if (getDB().isSupportsInlineDistinct()) {
1043 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1044 }
1045 else {
1046 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1047 }
1048
1049 QueryPos qPos = QueryPos.getInstance(q);
1050
1051 qPos.add(companyId);
1052
1053 return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end);
1054 }
1055 catch (Exception e) {
1056 throw processException(e);
1057 }
1058 finally {
1059 closeSession(session);
1060 }
1061 }
1062
1063
1073 public UserGroup[] filterFindByCompanyId_PrevAndNext(long userGroupId,
1074 long companyId, OrderByComparator orderByComparator)
1075 throws NoSuchUserGroupException, SystemException {
1076 if (!InlineSQLHelperUtil.isEnabled()) {
1077 return findByCompanyId_PrevAndNext(userGroupId, companyId,
1078 orderByComparator);
1079 }
1080
1081 UserGroup userGroup = findByPrimaryKey(userGroupId);
1082
1083 Session session = null;
1084
1085 try {
1086 session = openSession();
1087
1088 UserGroup[] array = new UserGroupImpl[3];
1089
1090 array[0] = filterGetByCompanyId_PrevAndNext(session, userGroup,
1091 companyId, orderByComparator, true);
1092
1093 array[1] = userGroup;
1094
1095 array[2] = filterGetByCompanyId_PrevAndNext(session, userGroup,
1096 companyId, orderByComparator, false);
1097
1098 return array;
1099 }
1100 catch (Exception e) {
1101 throw processException(e);
1102 }
1103 finally {
1104 closeSession(session);
1105 }
1106 }
1107
1108 protected UserGroup filterGetByCompanyId_PrevAndNext(Session session,
1109 UserGroup userGroup, long companyId,
1110 OrderByComparator orderByComparator, boolean previous) {
1111 StringBundler query = null;
1112
1113 if (orderByComparator != null) {
1114 query = new StringBundler(6 +
1115 (orderByComparator.getOrderByFields().length * 6));
1116 }
1117 else {
1118 query = new StringBundler(3);
1119 }
1120
1121 if (getDB().isSupportsInlineDistinct()) {
1122 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1123 }
1124 else {
1125 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1126 }
1127
1128 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1129
1130 if (!getDB().isSupportsInlineDistinct()) {
1131 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1132 }
1133
1134 if (orderByComparator != null) {
1135 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1136
1137 if (orderByConditionFields.length > 0) {
1138 query.append(WHERE_AND);
1139 }
1140
1141 for (int i = 0; i < orderByConditionFields.length; i++) {
1142 if (getDB().isSupportsInlineDistinct()) {
1143 query.append(_ORDER_BY_ENTITY_ALIAS);
1144 }
1145 else {
1146 query.append(_ORDER_BY_ENTITY_TABLE);
1147 }
1148
1149 query.append(orderByConditionFields[i]);
1150
1151 if ((i + 1) < orderByConditionFields.length) {
1152 if (orderByComparator.isAscending() ^ previous) {
1153 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1154 }
1155 else {
1156 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1157 }
1158 }
1159 else {
1160 if (orderByComparator.isAscending() ^ previous) {
1161 query.append(WHERE_GREATER_THAN);
1162 }
1163 else {
1164 query.append(WHERE_LESSER_THAN);
1165 }
1166 }
1167 }
1168
1169 query.append(ORDER_BY_CLAUSE);
1170
1171 String[] orderByFields = orderByComparator.getOrderByFields();
1172
1173 for (int i = 0; i < orderByFields.length; i++) {
1174 if (getDB().isSupportsInlineDistinct()) {
1175 query.append(_ORDER_BY_ENTITY_ALIAS);
1176 }
1177 else {
1178 query.append(_ORDER_BY_ENTITY_TABLE);
1179 }
1180
1181 query.append(orderByFields[i]);
1182
1183 if ((i + 1) < orderByFields.length) {
1184 if (orderByComparator.isAscending() ^ previous) {
1185 query.append(ORDER_BY_ASC_HAS_NEXT);
1186 }
1187 else {
1188 query.append(ORDER_BY_DESC_HAS_NEXT);
1189 }
1190 }
1191 else {
1192 if (orderByComparator.isAscending() ^ previous) {
1193 query.append(ORDER_BY_ASC);
1194 }
1195 else {
1196 query.append(ORDER_BY_DESC);
1197 }
1198 }
1199 }
1200 }
1201
1202 else {
1203 if (getDB().isSupportsInlineDistinct()) {
1204 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1205 }
1206 else {
1207 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1208 }
1209 }
1210
1211 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1212 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1213
1214 SQLQuery q = session.createSQLQuery(sql);
1215
1216 q.setFirstResult(0);
1217 q.setMaxResults(2);
1218
1219 if (getDB().isSupportsInlineDistinct()) {
1220 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1221 }
1222 else {
1223 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1224 }
1225
1226 QueryPos qPos = QueryPos.getInstance(q);
1227
1228 qPos.add(companyId);
1229
1230 if (orderByComparator != null) {
1231 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
1232
1233 for (Object value : values) {
1234 qPos.add(value);
1235 }
1236 }
1237
1238 List<UserGroup> list = q.list();
1239
1240 if (list.size() == 2) {
1241 return list.get(1);
1242 }
1243 else {
1244 return null;
1245 }
1246 }
1247
1248
1256 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId)
1257 throws SystemException {
1258 return findByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
1259 QueryUtil.ALL_POS, null);
1260 }
1261
1262
1276 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
1277 int start, int end) throws SystemException {
1278 return findByC_P(companyId, parentUserGroupId, start, end, null);
1279 }
1280
1281
1296 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
1297 int start, int end, OrderByComparator orderByComparator)
1298 throws SystemException {
1299 FinderPath finderPath = null;
1300 Object[] finderArgs = null;
1301
1302 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1303 (orderByComparator == null)) {
1304 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
1305 finderArgs = new Object[] { companyId, parentUserGroupId };
1306 }
1307 else {
1308 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
1309 finderArgs = new Object[] {
1310 companyId, parentUserGroupId,
1311
1312 start, end, orderByComparator
1313 };
1314 }
1315
1316 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(finderPath,
1317 finderArgs, this);
1318
1319 if (list == null) {
1320 StringBundler query = null;
1321
1322 if (orderByComparator != null) {
1323 query = new StringBundler(4 +
1324 (orderByComparator.getOrderByFields().length * 3));
1325 }
1326 else {
1327 query = new StringBundler(4);
1328 }
1329
1330 query.append(_SQL_SELECT_USERGROUP_WHERE);
1331
1332 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1333
1334 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1335
1336 if (orderByComparator != null) {
1337 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1338 orderByComparator);
1339 }
1340
1341 else {
1342 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1343 }
1344
1345 String sql = query.toString();
1346
1347 Session session = null;
1348
1349 try {
1350 session = openSession();
1351
1352 Query q = session.createQuery(sql);
1353
1354 QueryPos qPos = QueryPos.getInstance(q);
1355
1356 qPos.add(companyId);
1357
1358 qPos.add(parentUserGroupId);
1359
1360 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
1361 end);
1362 }
1363 catch (Exception e) {
1364 throw processException(e);
1365 }
1366 finally {
1367 if (list == null) {
1368 FinderCacheUtil.removeResult(finderPath, finderArgs);
1369 }
1370 else {
1371 cacheResult(list);
1372
1373 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1374 }
1375
1376 closeSession(session);
1377 }
1378 }
1379
1380 return list;
1381 }
1382
1383
1397 public UserGroup findByC_P_First(long companyId, long parentUserGroupId,
1398 OrderByComparator orderByComparator)
1399 throws NoSuchUserGroupException, SystemException {
1400 List<UserGroup> list = findByC_P(companyId, parentUserGroupId, 0, 1,
1401 orderByComparator);
1402
1403 if (list.isEmpty()) {
1404 StringBundler msg = new StringBundler(6);
1405
1406 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1407
1408 msg.append("companyId=");
1409 msg.append(companyId);
1410
1411 msg.append(", parentUserGroupId=");
1412 msg.append(parentUserGroupId);
1413
1414 msg.append(StringPool.CLOSE_CURLY_BRACE);
1415
1416 throw new NoSuchUserGroupException(msg.toString());
1417 }
1418 else {
1419 return list.get(0);
1420 }
1421 }
1422
1423
1437 public UserGroup findByC_P_Last(long companyId, long parentUserGroupId,
1438 OrderByComparator orderByComparator)
1439 throws NoSuchUserGroupException, SystemException {
1440 int count = countByC_P(companyId, parentUserGroupId);
1441
1442 List<UserGroup> list = findByC_P(companyId, parentUserGroupId,
1443 count - 1, count, orderByComparator);
1444
1445 if (list.isEmpty()) {
1446 StringBundler msg = new StringBundler(6);
1447
1448 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1449
1450 msg.append("companyId=");
1451 msg.append(companyId);
1452
1453 msg.append(", parentUserGroupId=");
1454 msg.append(parentUserGroupId);
1455
1456 msg.append(StringPool.CLOSE_CURLY_BRACE);
1457
1458 throw new NoSuchUserGroupException(msg.toString());
1459 }
1460 else {
1461 return list.get(0);
1462 }
1463 }
1464
1465
1480 public UserGroup[] findByC_P_PrevAndNext(long userGroupId, long companyId,
1481 long parentUserGroupId, OrderByComparator orderByComparator)
1482 throws NoSuchUserGroupException, SystemException {
1483 UserGroup userGroup = findByPrimaryKey(userGroupId);
1484
1485 Session session = null;
1486
1487 try {
1488 session = openSession();
1489
1490 UserGroup[] array = new UserGroupImpl[3];
1491
1492 array[0] = getByC_P_PrevAndNext(session, userGroup, companyId,
1493 parentUserGroupId, orderByComparator, true);
1494
1495 array[1] = userGroup;
1496
1497 array[2] = getByC_P_PrevAndNext(session, userGroup, companyId,
1498 parentUserGroupId, orderByComparator, false);
1499
1500 return array;
1501 }
1502 catch (Exception e) {
1503 throw processException(e);
1504 }
1505 finally {
1506 closeSession(session);
1507 }
1508 }
1509
1510 protected UserGroup getByC_P_PrevAndNext(Session session,
1511 UserGroup userGroup, long companyId, long parentUserGroupId,
1512 OrderByComparator orderByComparator, boolean previous) {
1513 StringBundler query = null;
1514
1515 if (orderByComparator != null) {
1516 query = new StringBundler(6 +
1517 (orderByComparator.getOrderByFields().length * 6));
1518 }
1519 else {
1520 query = new StringBundler(3);
1521 }
1522
1523 query.append(_SQL_SELECT_USERGROUP_WHERE);
1524
1525 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1526
1527 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1528
1529 if (orderByComparator != null) {
1530 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1531
1532 if (orderByConditionFields.length > 0) {
1533 query.append(WHERE_AND);
1534 }
1535
1536 for (int i = 0; i < orderByConditionFields.length; i++) {
1537 query.append(_ORDER_BY_ENTITY_ALIAS);
1538 query.append(orderByConditionFields[i]);
1539
1540 if ((i + 1) < orderByConditionFields.length) {
1541 if (orderByComparator.isAscending() ^ previous) {
1542 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1543 }
1544 else {
1545 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1546 }
1547 }
1548 else {
1549 if (orderByComparator.isAscending() ^ previous) {
1550 query.append(WHERE_GREATER_THAN);
1551 }
1552 else {
1553 query.append(WHERE_LESSER_THAN);
1554 }
1555 }
1556 }
1557
1558 query.append(ORDER_BY_CLAUSE);
1559
1560 String[] orderByFields = orderByComparator.getOrderByFields();
1561
1562 for (int i = 0; i < orderByFields.length; i++) {
1563 query.append(_ORDER_BY_ENTITY_ALIAS);
1564 query.append(orderByFields[i]);
1565
1566 if ((i + 1) < orderByFields.length) {
1567 if (orderByComparator.isAscending() ^ previous) {
1568 query.append(ORDER_BY_ASC_HAS_NEXT);
1569 }
1570 else {
1571 query.append(ORDER_BY_DESC_HAS_NEXT);
1572 }
1573 }
1574 else {
1575 if (orderByComparator.isAscending() ^ previous) {
1576 query.append(ORDER_BY_ASC);
1577 }
1578 else {
1579 query.append(ORDER_BY_DESC);
1580 }
1581 }
1582 }
1583 }
1584
1585 else {
1586 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1587 }
1588
1589 String sql = query.toString();
1590
1591 Query q = session.createQuery(sql);
1592
1593 q.setFirstResult(0);
1594 q.setMaxResults(2);
1595
1596 QueryPos qPos = QueryPos.getInstance(q);
1597
1598 qPos.add(companyId);
1599
1600 qPos.add(parentUserGroupId);
1601
1602 if (orderByComparator != null) {
1603 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
1604
1605 for (Object value : values) {
1606 qPos.add(value);
1607 }
1608 }
1609
1610 List<UserGroup> list = q.list();
1611
1612 if (list.size() == 2) {
1613 return list.get(1);
1614 }
1615 else {
1616 return null;
1617 }
1618 }
1619
1620
1628 public List<UserGroup> filterFindByC_P(long companyId,
1629 long parentUserGroupId) throws SystemException {
1630 return filterFindByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
1631 QueryUtil.ALL_POS, null);
1632 }
1633
1634
1648 public List<UserGroup> filterFindByC_P(long companyId,
1649 long parentUserGroupId, int start, int end) throws SystemException {
1650 return filterFindByC_P(companyId, parentUserGroupId, start, end, null);
1651 }
1652
1653
1668 public List<UserGroup> filterFindByC_P(long companyId,
1669 long parentUserGroupId, int start, int end,
1670 OrderByComparator orderByComparator) throws SystemException {
1671 if (!InlineSQLHelperUtil.isEnabled()) {
1672 return findByC_P(companyId, parentUserGroupId, start, end,
1673 orderByComparator);
1674 }
1675
1676 StringBundler query = null;
1677
1678 if (orderByComparator != null) {
1679 query = new StringBundler(4 +
1680 (orderByComparator.getOrderByFields().length * 3));
1681 }
1682 else {
1683 query = new StringBundler(4);
1684 }
1685
1686 if (getDB().isSupportsInlineDistinct()) {
1687 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1688 }
1689 else {
1690 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1691 }
1692
1693 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1694
1695 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1696
1697 if (!getDB().isSupportsInlineDistinct()) {
1698 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1699 }
1700
1701 if (orderByComparator != null) {
1702 if (getDB().isSupportsInlineDistinct()) {
1703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1704 orderByComparator);
1705 }
1706 else {
1707 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1708 orderByComparator);
1709 }
1710 }
1711
1712 else {
1713 if (getDB().isSupportsInlineDistinct()) {
1714 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1715 }
1716 else {
1717 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1718 }
1719 }
1720
1721 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1722 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1723
1724 Session session = null;
1725
1726 try {
1727 session = openSession();
1728
1729 SQLQuery q = session.createSQLQuery(sql);
1730
1731 if (getDB().isSupportsInlineDistinct()) {
1732 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1733 }
1734 else {
1735 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1736 }
1737
1738 QueryPos qPos = QueryPos.getInstance(q);
1739
1740 qPos.add(companyId);
1741
1742 qPos.add(parentUserGroupId);
1743
1744 return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end);
1745 }
1746 catch (Exception e) {
1747 throw processException(e);
1748 }
1749 finally {
1750 closeSession(session);
1751 }
1752 }
1753
1754
1765 public UserGroup[] filterFindByC_P_PrevAndNext(long userGroupId,
1766 long companyId, long parentUserGroupId,
1767 OrderByComparator orderByComparator)
1768 throws NoSuchUserGroupException, SystemException {
1769 if (!InlineSQLHelperUtil.isEnabled()) {
1770 return findByC_P_PrevAndNext(userGroupId, companyId,
1771 parentUserGroupId, orderByComparator);
1772 }
1773
1774 UserGroup userGroup = findByPrimaryKey(userGroupId);
1775
1776 Session session = null;
1777
1778 try {
1779 session = openSession();
1780
1781 UserGroup[] array = new UserGroupImpl[3];
1782
1783 array[0] = filterGetByC_P_PrevAndNext(session, userGroup,
1784 companyId, parentUserGroupId, orderByComparator, true);
1785
1786 array[1] = userGroup;
1787
1788 array[2] = filterGetByC_P_PrevAndNext(session, userGroup,
1789 companyId, parentUserGroupId, orderByComparator, false);
1790
1791 return array;
1792 }
1793 catch (Exception e) {
1794 throw processException(e);
1795 }
1796 finally {
1797 closeSession(session);
1798 }
1799 }
1800
1801 protected UserGroup filterGetByC_P_PrevAndNext(Session session,
1802 UserGroup userGroup, long companyId, long parentUserGroupId,
1803 OrderByComparator orderByComparator, boolean previous) {
1804 StringBundler query = null;
1805
1806 if (orderByComparator != null) {
1807 query = new StringBundler(6 +
1808 (orderByComparator.getOrderByFields().length * 6));
1809 }
1810 else {
1811 query = new StringBundler(3);
1812 }
1813
1814 if (getDB().isSupportsInlineDistinct()) {
1815 query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE);
1816 }
1817 else {
1818 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1);
1819 }
1820
1821 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1822
1823 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1824
1825 if (!getDB().isSupportsInlineDistinct()) {
1826 query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2);
1827 }
1828
1829 if (orderByComparator != null) {
1830 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1831
1832 if (orderByConditionFields.length > 0) {
1833 query.append(WHERE_AND);
1834 }
1835
1836 for (int i = 0; i < orderByConditionFields.length; i++) {
1837 if (getDB().isSupportsInlineDistinct()) {
1838 query.append(_ORDER_BY_ENTITY_ALIAS);
1839 }
1840 else {
1841 query.append(_ORDER_BY_ENTITY_TABLE);
1842 }
1843
1844 query.append(orderByConditionFields[i]);
1845
1846 if ((i + 1) < orderByConditionFields.length) {
1847 if (orderByComparator.isAscending() ^ previous) {
1848 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1849 }
1850 else {
1851 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1852 }
1853 }
1854 else {
1855 if (orderByComparator.isAscending() ^ previous) {
1856 query.append(WHERE_GREATER_THAN);
1857 }
1858 else {
1859 query.append(WHERE_LESSER_THAN);
1860 }
1861 }
1862 }
1863
1864 query.append(ORDER_BY_CLAUSE);
1865
1866 String[] orderByFields = orderByComparator.getOrderByFields();
1867
1868 for (int i = 0; i < orderByFields.length; i++) {
1869 if (getDB().isSupportsInlineDistinct()) {
1870 query.append(_ORDER_BY_ENTITY_ALIAS);
1871 }
1872 else {
1873 query.append(_ORDER_BY_ENTITY_TABLE);
1874 }
1875
1876 query.append(orderByFields[i]);
1877
1878 if ((i + 1) < orderByFields.length) {
1879 if (orderByComparator.isAscending() ^ previous) {
1880 query.append(ORDER_BY_ASC_HAS_NEXT);
1881 }
1882 else {
1883 query.append(ORDER_BY_DESC_HAS_NEXT);
1884 }
1885 }
1886 else {
1887 if (orderByComparator.isAscending() ^ previous) {
1888 query.append(ORDER_BY_ASC);
1889 }
1890 else {
1891 query.append(ORDER_BY_DESC);
1892 }
1893 }
1894 }
1895 }
1896
1897 else {
1898 if (getDB().isSupportsInlineDistinct()) {
1899 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1900 }
1901 else {
1902 query.append(UserGroupModelImpl.ORDER_BY_SQL);
1903 }
1904 }
1905
1906 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1907 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1908
1909 SQLQuery q = session.createSQLQuery(sql);
1910
1911 q.setFirstResult(0);
1912 q.setMaxResults(2);
1913
1914 if (getDB().isSupportsInlineDistinct()) {
1915 q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class);
1916 }
1917 else {
1918 q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class);
1919 }
1920
1921 QueryPos qPos = QueryPos.getInstance(q);
1922
1923 qPos.add(companyId);
1924
1925 qPos.add(parentUserGroupId);
1926
1927 if (orderByComparator != null) {
1928 Object[] values = orderByComparator.getOrderByConditionValues(userGroup);
1929
1930 for (Object value : values) {
1931 qPos.add(value);
1932 }
1933 }
1934
1935 List<UserGroup> list = q.list();
1936
1937 if (list.size() == 2) {
1938 return list.get(1);
1939 }
1940 else {
1941 return null;
1942 }
1943 }
1944
1945
1954 public UserGroup findByC_N(long companyId, String name)
1955 throws NoSuchUserGroupException, SystemException {
1956 UserGroup userGroup = fetchByC_N(companyId, name);
1957
1958 if (userGroup == null) {
1959 StringBundler msg = new StringBundler(6);
1960
1961 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1962
1963 msg.append("companyId=");
1964 msg.append(companyId);
1965
1966 msg.append(", name=");
1967 msg.append(name);
1968
1969 msg.append(StringPool.CLOSE_CURLY_BRACE);
1970
1971 if (_log.isWarnEnabled()) {
1972 _log.warn(msg.toString());
1973 }
1974
1975 throw new NoSuchUserGroupException(msg.toString());
1976 }
1977
1978 return userGroup;
1979 }
1980
1981
1989 public UserGroup fetchByC_N(long companyId, String name)
1990 throws SystemException {
1991 return fetchByC_N(companyId, name, true);
1992 }
1993
1994
2003 public UserGroup fetchByC_N(long companyId, String name,
2004 boolean retrieveFromCache) throws SystemException {
2005 Object[] finderArgs = new Object[] { companyId, name };
2006
2007 Object result = null;
2008
2009 if (retrieveFromCache) {
2010 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2011 finderArgs, this);
2012 }
2013
2014 if (result == null) {
2015 StringBundler query = new StringBundler(4);
2016
2017 query.append(_SQL_SELECT_USERGROUP_WHERE);
2018
2019 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2020
2021 if (name == null) {
2022 query.append(_FINDER_COLUMN_C_N_NAME_1);
2023 }
2024 else {
2025 if (name.equals(StringPool.BLANK)) {
2026 query.append(_FINDER_COLUMN_C_N_NAME_3);
2027 }
2028 else {
2029 query.append(_FINDER_COLUMN_C_N_NAME_2);
2030 }
2031 }
2032
2033 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
2034
2035 String sql = query.toString();
2036
2037 Session session = null;
2038
2039 try {
2040 session = openSession();
2041
2042 Query q = session.createQuery(sql);
2043
2044 QueryPos qPos = QueryPos.getInstance(q);
2045
2046 qPos.add(companyId);
2047
2048 if (name != null) {
2049 qPos.add(name);
2050 }
2051
2052 List<UserGroup> list = q.list();
2053
2054 result = list;
2055
2056 UserGroup userGroup = null;
2057
2058 if (list.isEmpty()) {
2059 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2060 finderArgs, list);
2061 }
2062 else {
2063 userGroup = list.get(0);
2064
2065 cacheResult(userGroup);
2066
2067 if ((userGroup.getCompanyId() != companyId) ||
2068 (userGroup.getName() == null) ||
2069 !userGroup.getName().equals(name)) {
2070 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2071 finderArgs, userGroup);
2072 }
2073 }
2074
2075 return userGroup;
2076 }
2077 catch (Exception e) {
2078 throw processException(e);
2079 }
2080 finally {
2081 if (result == null) {
2082 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2083 finderArgs);
2084 }
2085
2086 closeSession(session);
2087 }
2088 }
2089 else {
2090 if (result instanceof List<?>) {
2091 return null;
2092 }
2093 else {
2094 return (UserGroup)result;
2095 }
2096 }
2097 }
2098
2099
2105 public List<UserGroup> findAll() throws SystemException {
2106 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2107 }
2108
2109
2121 public List<UserGroup> findAll(int start, int end)
2122 throws SystemException {
2123 return findAll(start, end, null);
2124 }
2125
2126
2139 public List<UserGroup> findAll(int start, int end,
2140 OrderByComparator orderByComparator) throws SystemException {
2141 FinderPath finderPath = null;
2142 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2143
2144 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2145 (orderByComparator == null)) {
2146 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2147 finderArgs = FINDER_ARGS_EMPTY;
2148 }
2149 else {
2150 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2151 finderArgs = new Object[] { start, end, orderByComparator };
2152 }
2153
2154 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(finderPath,
2155 finderArgs, this);
2156
2157 if (list == null) {
2158 StringBundler query = null;
2159 String sql = null;
2160
2161 if (orderByComparator != null) {
2162 query = new StringBundler(2 +
2163 (orderByComparator.getOrderByFields().length * 3));
2164
2165 query.append(_SQL_SELECT_USERGROUP);
2166
2167 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2168 orderByComparator);
2169
2170 sql = query.toString();
2171 }
2172 else {
2173 sql = _SQL_SELECT_USERGROUP.concat(UserGroupModelImpl.ORDER_BY_JPQL);
2174 }
2175
2176 Session session = null;
2177
2178 try {
2179 session = openSession();
2180
2181 Query q = session.createQuery(sql);
2182
2183 if (orderByComparator == null) {
2184 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
2185 start, end, false);
2186
2187 Collections.sort(list);
2188 }
2189 else {
2190 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
2191 start, end);
2192 }
2193 }
2194 catch (Exception e) {
2195 throw processException(e);
2196 }
2197 finally {
2198 if (list == null) {
2199 FinderCacheUtil.removeResult(finderPath, finderArgs);
2200 }
2201 else {
2202 cacheResult(list);
2203
2204 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2205 }
2206
2207 closeSession(session);
2208 }
2209 }
2210
2211 return list;
2212 }
2213
2214
2220 public void removeByCompanyId(long companyId) throws SystemException {
2221 for (UserGroup userGroup : findByCompanyId(companyId)) {
2222 remove(userGroup);
2223 }
2224 }
2225
2226
2233 public void removeByC_P(long companyId, long parentUserGroupId)
2234 throws SystemException {
2235 for (UserGroup userGroup : findByC_P(companyId, parentUserGroupId)) {
2236 remove(userGroup);
2237 }
2238 }
2239
2240
2247 public void removeByC_N(long companyId, String name)
2248 throws NoSuchUserGroupException, SystemException {
2249 UserGroup userGroup = findByC_N(companyId, name);
2250
2251 remove(userGroup);
2252 }
2253
2254
2259 public void removeAll() throws SystemException {
2260 for (UserGroup userGroup : findAll()) {
2261 remove(userGroup);
2262 }
2263 }
2264
2265
2272 public int countByCompanyId(long companyId) throws SystemException {
2273 Object[] finderArgs = new Object[] { companyId };
2274
2275 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2276 finderArgs, this);
2277
2278 if (count == null) {
2279 StringBundler query = new StringBundler(2);
2280
2281 query.append(_SQL_COUNT_USERGROUP_WHERE);
2282
2283 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2284
2285 String sql = query.toString();
2286
2287 Session session = null;
2288
2289 try {
2290 session = openSession();
2291
2292 Query q = session.createQuery(sql);
2293
2294 QueryPos qPos = QueryPos.getInstance(q);
2295
2296 qPos.add(companyId);
2297
2298 count = (Long)q.uniqueResult();
2299 }
2300 catch (Exception e) {
2301 throw processException(e);
2302 }
2303 finally {
2304 if (count == null) {
2305 count = Long.valueOf(0);
2306 }
2307
2308 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2309 finderArgs, count);
2310
2311 closeSession(session);
2312 }
2313 }
2314
2315 return count.intValue();
2316 }
2317
2318
2325 public int filterCountByCompanyId(long companyId) throws SystemException {
2326 if (!InlineSQLHelperUtil.isEnabled()) {
2327 return countByCompanyId(companyId);
2328 }
2329
2330 StringBundler query = new StringBundler(2);
2331
2332 query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE);
2333
2334 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2335
2336 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2337 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2338
2339 Session session = null;
2340
2341 try {
2342 session = openSession();
2343
2344 SQLQuery q = session.createSQLQuery(sql);
2345
2346 q.addScalar(COUNT_COLUMN_NAME,
2347 com.liferay.portal.kernel.dao.orm.Type.LONG);
2348
2349 QueryPos qPos = QueryPos.getInstance(q);
2350
2351 qPos.add(companyId);
2352
2353 Long count = (Long)q.uniqueResult();
2354
2355 return count.intValue();
2356 }
2357 catch (Exception e) {
2358 throw processException(e);
2359 }
2360 finally {
2361 closeSession(session);
2362 }
2363 }
2364
2365
2373 public int countByC_P(long companyId, long parentUserGroupId)
2374 throws SystemException {
2375 Object[] finderArgs = new Object[] { companyId, parentUserGroupId };
2376
2377 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
2378 finderArgs, this);
2379
2380 if (count == null) {
2381 StringBundler query = new StringBundler(3);
2382
2383 query.append(_SQL_COUNT_USERGROUP_WHERE);
2384
2385 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2386
2387 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
2388
2389 String sql = query.toString();
2390
2391 Session session = null;
2392
2393 try {
2394 session = openSession();
2395
2396 Query q = session.createQuery(sql);
2397
2398 QueryPos qPos = QueryPos.getInstance(q);
2399
2400 qPos.add(companyId);
2401
2402 qPos.add(parentUserGroupId);
2403
2404 count = (Long)q.uniqueResult();
2405 }
2406 catch (Exception e) {
2407 throw processException(e);
2408 }
2409 finally {
2410 if (count == null) {
2411 count = Long.valueOf(0);
2412 }
2413
2414 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
2415 count);
2416
2417 closeSession(session);
2418 }
2419 }
2420
2421 return count.intValue();
2422 }
2423
2424
2432 public int filterCountByC_P(long companyId, long parentUserGroupId)
2433 throws SystemException {
2434 if (!InlineSQLHelperUtil.isEnabled()) {
2435 return countByC_P(companyId, parentUserGroupId);
2436 }
2437
2438 StringBundler query = new StringBundler(3);
2439
2440 query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE);
2441
2442 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2443
2444 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
2445
2446 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2447 UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2448
2449 Session session = null;
2450
2451 try {
2452 session = openSession();
2453
2454 SQLQuery q = session.createSQLQuery(sql);
2455
2456 q.addScalar(COUNT_COLUMN_NAME,
2457 com.liferay.portal.kernel.dao.orm.Type.LONG);
2458
2459 QueryPos qPos = QueryPos.getInstance(q);
2460
2461 qPos.add(companyId);
2462
2463 qPos.add(parentUserGroupId);
2464
2465 Long count = (Long)q.uniqueResult();
2466
2467 return count.intValue();
2468 }
2469 catch (Exception e) {
2470 throw processException(e);
2471 }
2472 finally {
2473 closeSession(session);
2474 }
2475 }
2476
2477
2485 public int countByC_N(long companyId, String name)
2486 throws SystemException {
2487 Object[] finderArgs = new Object[] { companyId, name };
2488
2489 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
2490 finderArgs, this);
2491
2492 if (count == null) {
2493 StringBundler query = new StringBundler(3);
2494
2495 query.append(_SQL_COUNT_USERGROUP_WHERE);
2496
2497 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2498
2499 if (name == null) {
2500 query.append(_FINDER_COLUMN_C_N_NAME_1);
2501 }
2502 else {
2503 if (name.equals(StringPool.BLANK)) {
2504 query.append(_FINDER_COLUMN_C_N_NAME_3);
2505 }
2506 else {
2507 query.append(_FINDER_COLUMN_C_N_NAME_2);
2508 }
2509 }
2510
2511 String sql = query.toString();
2512
2513 Session session = null;
2514
2515 try {
2516 session = openSession();
2517
2518 Query q = session.createQuery(sql);
2519
2520 QueryPos qPos = QueryPos.getInstance(q);
2521
2522 qPos.add(companyId);
2523
2524 if (name != null) {
2525 qPos.add(name);
2526 }
2527
2528 count = (Long)q.uniqueResult();
2529 }
2530 catch (Exception e) {
2531 throw processException(e);
2532 }
2533 finally {
2534 if (count == null) {
2535 count = Long.valueOf(0);
2536 }
2537
2538 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2539 count);
2540
2541 closeSession(session);
2542 }
2543 }
2544
2545 return count.intValue();
2546 }
2547
2548
2554 public int countAll() throws SystemException {
2555 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2556 FINDER_ARGS_EMPTY, this);
2557
2558 if (count == null) {
2559 Session session = null;
2560
2561 try {
2562 session = openSession();
2563
2564 Query q = session.createQuery(_SQL_COUNT_USERGROUP);
2565
2566 count = (Long)q.uniqueResult();
2567 }
2568 catch (Exception e) {
2569 throw processException(e);
2570 }
2571 finally {
2572 if (count == null) {
2573 count = Long.valueOf(0);
2574 }
2575
2576 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2577 FINDER_ARGS_EMPTY, count);
2578
2579 closeSession(session);
2580 }
2581 }
2582
2583 return count.intValue();
2584 }
2585
2586
2593 public List<com.liferay.portal.model.Group> getGroups(long pk)
2594 throws SystemException {
2595 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2596 }
2597
2598
2611 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2612 int end) throws SystemException {
2613 return getGroups(pk, start, end, null);
2614 }
2615
2616 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2617 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2618 com.liferay.portal.model.impl.GroupImpl.class,
2619 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2620 "getGroups",
2621 new String[] {
2622 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2623 "com.liferay.portal.kernel.util.OrderByComparator"
2624 });
2625
2626
2640 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
2641 int end, OrderByComparator orderByComparator) throws SystemException {
2642 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2643
2644 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
2645 finderArgs, this);
2646
2647 if (list == null) {
2648 Session session = null;
2649
2650 try {
2651 session = openSession();
2652
2653 String sql = null;
2654
2655 if (orderByComparator != null) {
2656 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
2657 .concat(orderByComparator.getOrderBy());
2658 }
2659 else {
2660 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
2661 }
2662
2663 SQLQuery q = session.createSQLQuery(sql);
2664
2665 q.addEntity("Group_",
2666 com.liferay.portal.model.impl.GroupImpl.class);
2667
2668 QueryPos qPos = QueryPos.getInstance(q);
2669
2670 qPos.add(pk);
2671
2672 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
2673 getDialect(), start, end);
2674 }
2675 catch (Exception e) {
2676 throw processException(e);
2677 }
2678 finally {
2679 if (list == null) {
2680 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
2681 finderArgs);
2682 }
2683 else {
2684 groupPersistence.cacheResult(list);
2685
2686 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
2687 finderArgs, list);
2688 }
2689
2690 closeSession(session);
2691 }
2692 }
2693
2694 return list;
2695 }
2696
2697 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2698 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2699 Long.class,
2700 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2701 "getGroupsSize", new String[] { Long.class.getName() });
2702
2703
2710 public int getGroupsSize(long pk) throws SystemException {
2711 Object[] finderArgs = new Object[] { pk };
2712
2713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
2714 finderArgs, this);
2715
2716 if (count == null) {
2717 Session session = null;
2718
2719 try {
2720 session = openSession();
2721
2722 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
2723
2724 q.addScalar(COUNT_COLUMN_NAME,
2725 com.liferay.portal.kernel.dao.orm.Type.LONG);
2726
2727 QueryPos qPos = QueryPos.getInstance(q);
2728
2729 qPos.add(pk);
2730
2731 count = (Long)q.uniqueResult();
2732 }
2733 catch (Exception e) {
2734 throw processException(e);
2735 }
2736 finally {
2737 if (count == null) {
2738 count = Long.valueOf(0);
2739 }
2740
2741 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
2742 finderArgs, count);
2743
2744 closeSession(session);
2745 }
2746 }
2747
2748 return count.intValue();
2749 }
2750
2751 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
2752 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
2753 Boolean.class,
2754 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
2755 "containsGroup",
2756 new String[] { Long.class.getName(), Long.class.getName() });
2757
2758
2766 public boolean containsGroup(long pk, long groupPK)
2767 throws SystemException {
2768 Object[] finderArgs = new Object[] { pk, groupPK };
2769
2770 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
2771 finderArgs, this);
2772
2773 if (value == null) {
2774 try {
2775 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
2776 }
2777 catch (Exception e) {
2778 throw processException(e);
2779 }
2780 finally {
2781 if (value == null) {
2782 value = Boolean.FALSE;
2783 }
2784
2785 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
2786 finderArgs, value);
2787 }
2788 }
2789
2790 return value.booleanValue();
2791 }
2792
2793
2800 public boolean containsGroups(long pk) throws SystemException {
2801 if (getGroupsSize(pk) > 0) {
2802 return true;
2803 }
2804 else {
2805 return false;
2806 }
2807 }
2808
2809
2816 public void addGroup(long pk, long groupPK) throws SystemException {
2817 try {
2818 addGroup.add(pk, groupPK);
2819 }
2820 catch (Exception e) {
2821 throw processException(e);
2822 }
2823 finally {
2824 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2825 }
2826 }
2827
2828
2835 public void addGroup(long pk, com.liferay.portal.model.Group group)
2836 throws SystemException {
2837 try {
2838 addGroup.add(pk, group.getPrimaryKey());
2839 }
2840 catch (Exception e) {
2841 throw processException(e);
2842 }
2843 finally {
2844 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2845 }
2846 }
2847
2848
2855 public void addGroups(long pk, long[] groupPKs) throws SystemException {
2856 try {
2857 for (long groupPK : groupPKs) {
2858 addGroup.add(pk, groupPK);
2859 }
2860 }
2861 catch (Exception e) {
2862 throw processException(e);
2863 }
2864 finally {
2865 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2866 }
2867 }
2868
2869
2876 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
2877 throws SystemException {
2878 try {
2879 for (com.liferay.portal.model.Group group : groups) {
2880 addGroup.add(pk, group.getPrimaryKey());
2881 }
2882 }
2883 catch (Exception e) {
2884 throw processException(e);
2885 }
2886 finally {
2887 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2888 }
2889 }
2890
2891
2897 public void clearGroups(long pk) throws SystemException {
2898 try {
2899 clearGroups.clear(pk);
2900 }
2901 catch (Exception e) {
2902 throw processException(e);
2903 }
2904 finally {
2905 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2906 }
2907 }
2908
2909
2916 public void removeGroup(long pk, long groupPK) throws SystemException {
2917 try {
2918 removeGroup.remove(pk, groupPK);
2919 }
2920 catch (Exception e) {
2921 throw processException(e);
2922 }
2923 finally {
2924 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2925 }
2926 }
2927
2928
2935 public void removeGroup(long pk, com.liferay.portal.model.Group group)
2936 throws SystemException {
2937 try {
2938 removeGroup.remove(pk, group.getPrimaryKey());
2939 }
2940 catch (Exception e) {
2941 throw processException(e);
2942 }
2943 finally {
2944 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2945 }
2946 }
2947
2948
2955 public void removeGroups(long pk, long[] groupPKs)
2956 throws SystemException {
2957 try {
2958 for (long groupPK : groupPKs) {
2959 removeGroup.remove(pk, groupPK);
2960 }
2961 }
2962 catch (Exception e) {
2963 throw processException(e);
2964 }
2965 finally {
2966 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2967 }
2968 }
2969
2970
2977 public void removeGroups(long pk,
2978 List<com.liferay.portal.model.Group> groups) throws SystemException {
2979 try {
2980 for (com.liferay.portal.model.Group group : groups) {
2981 removeGroup.remove(pk, group.getPrimaryKey());
2982 }
2983 }
2984 catch (Exception e) {
2985 throw processException(e);
2986 }
2987 finally {
2988 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2989 }
2990 }
2991
2992
2999 public void setGroups(long pk, long[] groupPKs) throws SystemException {
3000 try {
3001 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
3002
3003 List<com.liferay.portal.model.Group> groups = getGroups(pk);
3004
3005 for (com.liferay.portal.model.Group group : groups) {
3006 if (!groupPKSet.remove(group.getPrimaryKey())) {
3007 removeGroup.remove(pk, group.getPrimaryKey());
3008 }
3009 }
3010
3011 for (Long groupPK : groupPKSet) {
3012 addGroup.add(pk, groupPK);
3013 }
3014 }
3015 catch (Exception e) {
3016 throw processException(e);
3017 }
3018 finally {
3019 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3020 }
3021 }
3022
3023
3030 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3031 throws SystemException {
3032 try {
3033 long[] groupPKs = new long[groups.size()];
3034
3035 for (int i = 0; i < groups.size(); i++) {
3036 com.liferay.portal.model.Group group = groups.get(i);
3037
3038 groupPKs[i] = group.getPrimaryKey();
3039 }
3040
3041 setGroups(pk, groupPKs);
3042 }
3043 catch (Exception e) {
3044 throw processException(e);
3045 }
3046 finally {
3047 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
3048 }
3049 }
3050
3051
3058 public List<com.liferay.portal.model.Team> getTeams(long pk)
3059 throws SystemException {
3060 return getTeams(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3061 }
3062
3063
3076 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
3077 int end) throws SystemException {
3078 return getTeams(pk, start, end, null);
3079 }
3080
3081 public static final FinderPath FINDER_PATH_GET_TEAMS = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
3082 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
3083 com.liferay.portal.model.impl.TeamImpl.class,
3084 UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME, "getTeams",
3085 new String[] {
3086 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3087 "com.liferay.portal.kernel.util.OrderByComparator"
3088 });
3089
3090
3104 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
3105 int end, OrderByComparator orderByComparator) throws SystemException {
3106 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3107
3108 List<com.liferay.portal.model.Team> list = (List<com.liferay.portal.model.Team>)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS,
3109 finderArgs, this);
3110
3111 if (list == null) {
3112 Session session = null;
3113
3114 try {
3115 session = openSession();
3116
3117 String sql = null;
3118
3119 if (orderByComparator != null) {
3120 sql = _SQL_GETTEAMS.concat(ORDER_BY_CLAUSE)
3121 .concat(orderByComparator.getOrderBy());
3122 }
3123 else {
3124 sql = _SQL_GETTEAMS.concat(com.liferay.portal.model.impl.TeamModelImpl.ORDER_BY_SQL);
3125 }
3126
3127 SQLQuery q = session.createSQLQuery(sql);
3128
3129 q.addEntity("Team", com.liferay.portal.model.impl.TeamImpl.class);
3130
3131 QueryPos qPos = QueryPos.getInstance(q);
3132
3133 qPos.add(pk);
3134
3135 list = (List<com.liferay.portal.model.Team>)QueryUtil.list(q,
3136 getDialect(), start, end);
3137 }
3138 catch (Exception e) {
3139 throw processException(e);
3140 }
3141 finally {
3142 if (list == null) {
3143 FinderCacheUtil.removeResult(FINDER_PATH_GET_TEAMS,
3144 finderArgs);
3145 }
3146 else {
3147 teamPersistence.cacheResult(list);
3148
3149 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS,
3150 finderArgs, list);
3151 }
3152
3153 closeSession(session);
3154 }
3155 }
3156
3157 return list;
3158 }
3159
3160 public static final FinderPath FINDER_PATH_GET_TEAMS_SIZE = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
3161 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
3162 Long.class, UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
3163 "getTeamsSize", new String[] { Long.class.getName() });
3164
3165
3172 public int getTeamsSize(long pk) throws SystemException {
3173 Object[] finderArgs = new Object[] { pk };
3174
3175 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS_SIZE,
3176 finderArgs, this);
3177
3178 if (count == null) {
3179 Session session = null;
3180
3181 try {
3182 session = openSession();
3183
3184 SQLQuery q = session.createSQLQuery(_SQL_GETTEAMSSIZE);
3185
3186 q.addScalar(COUNT_COLUMN_NAME,
3187 com.liferay.portal.kernel.dao.orm.Type.LONG);
3188
3189 QueryPos qPos = QueryPos.getInstance(q);
3190
3191 qPos.add(pk);
3192
3193 count = (Long)q.uniqueResult();
3194 }
3195 catch (Exception e) {
3196 throw processException(e);
3197 }
3198 finally {
3199 if (count == null) {
3200 count = Long.valueOf(0);
3201 }
3202
3203 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS_SIZE,
3204 finderArgs, count);
3205
3206 closeSession(session);
3207 }
3208 }
3209
3210 return count.intValue();
3211 }
3212
3213 public static final FinderPath FINDER_PATH_CONTAINS_TEAM = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
3214 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
3215 Boolean.class,
3216 UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
3217 "containsTeam",
3218 new String[] { Long.class.getName(), Long.class.getName() });
3219
3220
3228 public boolean containsTeam(long pk, long teamPK) throws SystemException {
3229 Object[] finderArgs = new Object[] { pk, teamPK };
3230
3231 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TEAM,
3232 finderArgs, this);
3233
3234 if (value == null) {
3235 try {
3236 value = Boolean.valueOf(containsTeam.contains(pk, teamPK));
3237 }
3238 catch (Exception e) {
3239 throw processException(e);
3240 }
3241 finally {
3242 if (value == null) {
3243 value = Boolean.FALSE;
3244 }
3245
3246 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TEAM,
3247 finderArgs, value);
3248 }
3249 }
3250
3251 return value.booleanValue();
3252 }
3253
3254
3261 public boolean containsTeams(long pk) throws SystemException {
3262 if (getTeamsSize(pk) > 0) {
3263 return true;
3264 }
3265 else {
3266 return false;
3267 }
3268 }
3269
3270
3277 public void addTeam(long pk, long teamPK) throws SystemException {
3278 try {
3279 addTeam.add(pk, teamPK);
3280 }
3281 catch (Exception e) {
3282 throw processException(e);
3283 }
3284 finally {
3285 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3286 }
3287 }
3288
3289
3296 public void addTeam(long pk, com.liferay.portal.model.Team team)
3297 throws SystemException {
3298 try {
3299 addTeam.add(pk, team.getPrimaryKey());
3300 }
3301 catch (Exception e) {
3302 throw processException(e);
3303 }
3304 finally {
3305 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3306 }
3307 }
3308
3309
3316 public void addTeams(long pk, long[] teamPKs) throws SystemException {
3317 try {
3318 for (long teamPK : teamPKs) {
3319 addTeam.add(pk, teamPK);
3320 }
3321 }
3322 catch (Exception e) {
3323 throw processException(e);
3324 }
3325 finally {
3326 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3327 }
3328 }
3329
3330
3337 public void addTeams(long pk, List<com.liferay.portal.model.Team> teams)
3338 throws SystemException {
3339 try {
3340 for (com.liferay.portal.model.Team team : teams) {
3341 addTeam.add(pk, team.getPrimaryKey());
3342 }
3343 }
3344 catch (Exception e) {
3345 throw processException(e);
3346 }
3347 finally {
3348 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3349 }
3350 }
3351
3352
3358 public void clearTeams(long pk) throws SystemException {
3359 try {
3360 clearTeams.clear(pk);
3361 }
3362 catch (Exception e) {
3363 throw processException(e);
3364 }
3365 finally {
3366 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3367 }
3368 }
3369
3370
3377 public void removeTeam(long pk, long teamPK) throws SystemException {
3378 try {
3379 removeTeam.remove(pk, teamPK);
3380 }
3381 catch (Exception e) {
3382 throw processException(e);
3383 }
3384 finally {
3385 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3386 }
3387 }
3388
3389
3396 public void removeTeam(long pk, com.liferay.portal.model.Team team)
3397 throws SystemException {
3398 try {
3399 removeTeam.remove(pk, team.getPrimaryKey());
3400 }
3401 catch (Exception e) {
3402 throw processException(e);
3403 }
3404 finally {
3405 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3406 }
3407 }
3408
3409
3416 public void removeTeams(long pk, long[] teamPKs) throws SystemException {
3417 try {
3418 for (long teamPK : teamPKs) {
3419 removeTeam.remove(pk, teamPK);
3420 }
3421 }
3422 catch (Exception e) {
3423 throw processException(e);
3424 }
3425 finally {
3426 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3427 }
3428 }
3429
3430
3437 public void removeTeams(long pk, List<com.liferay.portal.model.Team> teams)
3438 throws SystemException {
3439 try {
3440 for (com.liferay.portal.model.Team team : teams) {
3441 removeTeam.remove(pk, team.getPrimaryKey());
3442 }
3443 }
3444 catch (Exception e) {
3445 throw processException(e);
3446 }
3447 finally {
3448 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3449 }
3450 }
3451
3452
3459 public void setTeams(long pk, long[] teamPKs) throws SystemException {
3460 try {
3461 Set<Long> teamPKSet = SetUtil.fromArray(teamPKs);
3462
3463 List<com.liferay.portal.model.Team> teams = getTeams(pk);
3464
3465 for (com.liferay.portal.model.Team team : teams) {
3466 if (!teamPKSet.remove(team.getPrimaryKey())) {
3467 removeTeam.remove(pk, team.getPrimaryKey());
3468 }
3469 }
3470
3471 for (Long teamPK : teamPKSet) {
3472 addTeam.add(pk, teamPK);
3473 }
3474 }
3475 catch (Exception e) {
3476 throw processException(e);
3477 }
3478 finally {
3479 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3480 }
3481 }
3482
3483
3490 public void setTeams(long pk, List<com.liferay.portal.model.Team> teams)
3491 throws SystemException {
3492 try {
3493 long[] teamPKs = new long[teams.size()];
3494
3495 for (int i = 0; i < teams.size(); i++) {
3496 com.liferay.portal.model.Team team = teams.get(i);
3497
3498 teamPKs[i] = team.getPrimaryKey();
3499 }
3500
3501 setTeams(pk, teamPKs);
3502 }
3503 catch (Exception e) {
3504 throw processException(e);
3505 }
3506 finally {
3507 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
3508 }
3509 }
3510
3511
3518 public List<com.liferay.portal.model.User> getUsers(long pk)
3519 throws SystemException {
3520 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3521 }
3522
3523
3536 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3537 int end) throws SystemException {
3538 return getUsers(pk, start, end, null);
3539 }
3540
3541 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3542 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
3543 com.liferay.portal.model.impl.UserImpl.class,
3544 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUsers",
3545 new String[] {
3546 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3547 "com.liferay.portal.kernel.util.OrderByComparator"
3548 });
3549
3550
3564 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3565 int end, OrderByComparator orderByComparator) throws SystemException {
3566 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3567
3568 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
3569 finderArgs, this);
3570
3571 if (list == null) {
3572 Session session = null;
3573
3574 try {
3575 session = openSession();
3576
3577 String sql = null;
3578
3579 if (orderByComparator != null) {
3580 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
3581 .concat(orderByComparator.getOrderBy());
3582 }
3583 else {
3584 sql = _SQL_GETUSERS;
3585 }
3586
3587 SQLQuery q = session.createSQLQuery(sql);
3588
3589 q.addEntity("User_",
3590 com.liferay.portal.model.impl.UserImpl.class);
3591
3592 QueryPos qPos = QueryPos.getInstance(q);
3593
3594 qPos.add(pk);
3595
3596 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
3597 getDialect(), start, end);
3598 }
3599 catch (Exception e) {
3600 throw processException(e);
3601 }
3602 finally {
3603 if (list == null) {
3604 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
3605 finderArgs);
3606 }
3607 else {
3608 userPersistence.cacheResult(list);
3609
3610 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
3611 finderArgs, list);
3612 }
3613
3614 closeSession(session);
3615 }
3616 }
3617
3618 return list;
3619 }
3620
3621 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3622 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
3623 Long.class, UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
3624 "getUsersSize", new String[] { Long.class.getName() });
3625
3626
3633 public int getUsersSize(long pk) throws SystemException {
3634 Object[] finderArgs = new Object[] { pk };
3635
3636 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
3637 finderArgs, this);
3638
3639 if (count == null) {
3640 Session session = null;
3641
3642 try {
3643 session = openSession();
3644
3645 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
3646
3647 q.addScalar(COUNT_COLUMN_NAME,
3648 com.liferay.portal.kernel.dao.orm.Type.LONG);
3649
3650 QueryPos qPos = QueryPos.getInstance(q);
3651
3652 qPos.add(pk);
3653
3654 count = (Long)q.uniqueResult();
3655 }
3656 catch (Exception e) {
3657 throw processException(e);
3658 }
3659 finally {
3660 if (count == null) {
3661 count = Long.valueOf(0);
3662 }
3663
3664 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
3665 finderArgs, count);
3666
3667 closeSession(session);
3668 }
3669 }
3670
3671 return count.intValue();
3672 }
3673
3674 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3675 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
3676 Boolean.class,
3677 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
3678 "containsUser",
3679 new String[] { Long.class.getName(), Long.class.getName() });
3680
3681
3689 public boolean containsUser(long pk, long userPK) throws SystemException {
3690 Object[] finderArgs = new Object[] { pk, userPK };
3691
3692 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
3693 finderArgs, this);
3694
3695 if (value == null) {
3696 try {
3697 value = Boolean.valueOf(containsUser.contains(pk, userPK));
3698 }
3699 catch (Exception e) {
3700 throw processException(e);
3701 }
3702 finally {
3703 if (value == null) {
3704 value = Boolean.FALSE;
3705 }
3706
3707 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
3708 finderArgs, value);
3709 }
3710 }
3711
3712 return value.booleanValue();
3713 }
3714
3715
3722 public boolean containsUsers(long pk) throws SystemException {
3723 if (getUsersSize(pk) > 0) {
3724 return true;
3725 }
3726 else {
3727 return false;
3728 }
3729 }
3730
3731
3738 public void addUser(long pk, long userPK) throws SystemException {
3739 try {
3740 addUser.add(pk, userPK);
3741 }
3742 catch (Exception e) {
3743 throw processException(e);
3744 }
3745 finally {
3746 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3747 }
3748 }
3749
3750
3757 public void addUser(long pk, com.liferay.portal.model.User user)
3758 throws SystemException {
3759 try {
3760 addUser.add(pk, user.getPrimaryKey());
3761 }
3762 catch (Exception e) {
3763 throw processException(e);
3764 }
3765 finally {
3766 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3767 }
3768 }
3769
3770
3777 public void addUsers(long pk, long[] userPKs) throws SystemException {
3778 try {
3779 for (long userPK : userPKs) {
3780 addUser.add(pk, userPK);
3781 }
3782 }
3783 catch (Exception e) {
3784 throw processException(e);
3785 }
3786 finally {
3787 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3788 }
3789 }
3790
3791
3798 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
3799 throws SystemException {
3800 try {
3801 for (com.liferay.portal.model.User user : users) {
3802 addUser.add(pk, user.getPrimaryKey());
3803 }
3804 }
3805 catch (Exception e) {
3806 throw processException(e);
3807 }
3808 finally {
3809 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3810 }
3811 }
3812
3813
3819 public void clearUsers(long pk) throws SystemException {
3820 try {
3821 clearUsers.clear(pk);
3822 }
3823 catch (Exception e) {
3824 throw processException(e);
3825 }
3826 finally {
3827 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3828 }
3829 }
3830
3831
3838 public void removeUser(long pk, long userPK) throws SystemException {
3839 try {
3840 removeUser.remove(pk, userPK);
3841 }
3842 catch (Exception e) {
3843 throw processException(e);
3844 }
3845 finally {
3846 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3847 }
3848 }
3849
3850
3857 public void removeUser(long pk, com.liferay.portal.model.User user)
3858 throws SystemException {
3859 try {
3860 removeUser.remove(pk, user.getPrimaryKey());
3861 }
3862 catch (Exception e) {
3863 throw processException(e);
3864 }
3865 finally {
3866 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3867 }
3868 }
3869
3870
3877 public void removeUsers(long pk, long[] userPKs) throws SystemException {
3878 try {
3879 for (long userPK : userPKs) {
3880 removeUser.remove(pk, userPK);
3881 }
3882 }
3883 catch (Exception e) {
3884 throw processException(e);
3885 }
3886 finally {
3887 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3888 }
3889 }
3890
3891
3898 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
3899 throws SystemException {
3900 try {
3901 for (com.liferay.portal.model.User user : users) {
3902 removeUser.remove(pk, user.getPrimaryKey());
3903 }
3904 }
3905 catch (Exception e) {
3906 throw processException(e);
3907 }
3908 finally {
3909 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3910 }
3911 }
3912
3913
3920 public void setUsers(long pk, long[] userPKs) throws SystemException {
3921 try {
3922 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
3923
3924 List<com.liferay.portal.model.User> users = getUsers(pk);
3925
3926 for (com.liferay.portal.model.User user : users) {
3927 if (!userPKSet.remove(user.getPrimaryKey())) {
3928 removeUser.remove(pk, user.getPrimaryKey());
3929 }
3930 }
3931
3932 for (Long userPK : userPKSet) {
3933 addUser.add(pk, userPK);
3934 }
3935 }
3936 catch (Exception e) {
3937 throw processException(e);
3938 }
3939 finally {
3940 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3941 }
3942 }
3943
3944
3951 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
3952 throws SystemException {
3953 try {
3954 long[] userPKs = new long[users.size()];
3955
3956 for (int i = 0; i < users.size(); i++) {
3957 com.liferay.portal.model.User user = users.get(i);
3958
3959 userPKs[i] = user.getPrimaryKey();
3960 }
3961
3962 setUsers(pk, userPKs);
3963 }
3964 catch (Exception e) {
3965 throw processException(e);
3966 }
3967 finally {
3968 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
3969 }
3970 }
3971
3972
3975 public void afterPropertiesSet() {
3976 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3977 com.liferay.portal.util.PropsUtil.get(
3978 "value.object.listener.com.liferay.portal.model.UserGroup")));
3979
3980 if (listenerClassNames.length > 0) {
3981 try {
3982 List<ModelListener<UserGroup>> listenersList = new ArrayList<ModelListener<UserGroup>>();
3983
3984 for (String listenerClassName : listenerClassNames) {
3985 listenersList.add((ModelListener<UserGroup>)InstanceFactory.newInstance(
3986 listenerClassName));
3987 }
3988
3989 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3990 }
3991 catch (Exception e) {
3992 _log.error(e);
3993 }
3994 }
3995
3996 containsGroup = new ContainsGroup();
3997
3998 addGroup = new AddGroup();
3999 clearGroups = new ClearGroups();
4000 removeGroup = new RemoveGroup();
4001
4002 containsTeam = new ContainsTeam();
4003
4004 addTeam = new AddTeam();
4005 clearTeams = new ClearTeams();
4006 removeTeam = new RemoveTeam();
4007
4008 containsUser = new ContainsUser();
4009
4010 addUser = new AddUser();
4011 clearUsers = new ClearUsers();
4012 removeUser = new RemoveUser();
4013 }
4014
4015 public void destroy() {
4016 EntityCacheUtil.removeCache(UserGroupImpl.class.getName());
4017 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4018 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4019 }
4020
4021 @BeanReference(type = AccountPersistence.class)
4022 protected AccountPersistence accountPersistence;
4023 @BeanReference(type = AddressPersistence.class)
4024 protected AddressPersistence addressPersistence;
4025 @BeanReference(type = BrowserTrackerPersistence.class)
4026 protected BrowserTrackerPersistence browserTrackerPersistence;
4027 @BeanReference(type = ClassNamePersistence.class)
4028 protected ClassNamePersistence classNamePersistence;
4029 @BeanReference(type = ClusterGroupPersistence.class)
4030 protected ClusterGroupPersistence clusterGroupPersistence;
4031 @BeanReference(type = CompanyPersistence.class)
4032 protected CompanyPersistence companyPersistence;
4033 @BeanReference(type = ContactPersistence.class)
4034 protected ContactPersistence contactPersistence;
4035 @BeanReference(type = CountryPersistence.class)
4036 protected CountryPersistence countryPersistence;
4037 @BeanReference(type = EmailAddressPersistence.class)
4038 protected EmailAddressPersistence emailAddressPersistence;
4039 @BeanReference(type = GroupPersistence.class)
4040 protected GroupPersistence groupPersistence;
4041 @BeanReference(type = ImagePersistence.class)
4042 protected ImagePersistence imagePersistence;
4043 @BeanReference(type = LayoutPersistence.class)
4044 protected LayoutPersistence layoutPersistence;
4045 @BeanReference(type = LayoutBranchPersistence.class)
4046 protected LayoutBranchPersistence layoutBranchPersistence;
4047 @BeanReference(type = LayoutPrototypePersistence.class)
4048 protected LayoutPrototypePersistence layoutPrototypePersistence;
4049 @BeanReference(type = LayoutRevisionPersistence.class)
4050 protected LayoutRevisionPersistence layoutRevisionPersistence;
4051 @BeanReference(type = LayoutSetPersistence.class)
4052 protected LayoutSetPersistence layoutSetPersistence;
4053 @BeanReference(type = LayoutSetBranchPersistence.class)
4054 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
4055 @BeanReference(type = LayoutSetPrototypePersistence.class)
4056 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
4057 @BeanReference(type = ListTypePersistence.class)
4058 protected ListTypePersistence listTypePersistence;
4059 @BeanReference(type = LockPersistence.class)
4060 protected LockPersistence lockPersistence;
4061 @BeanReference(type = MembershipRequestPersistence.class)
4062 protected MembershipRequestPersistence membershipRequestPersistence;
4063 @BeanReference(type = OrganizationPersistence.class)
4064 protected OrganizationPersistence organizationPersistence;
4065 @BeanReference(type = OrgGroupPermissionPersistence.class)
4066 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4067 @BeanReference(type = OrgGroupRolePersistence.class)
4068 protected OrgGroupRolePersistence orgGroupRolePersistence;
4069 @BeanReference(type = OrgLaborPersistence.class)
4070 protected OrgLaborPersistence orgLaborPersistence;
4071 @BeanReference(type = PasswordPolicyPersistence.class)
4072 protected PasswordPolicyPersistence passwordPolicyPersistence;
4073 @BeanReference(type = PasswordPolicyRelPersistence.class)
4074 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4075 @BeanReference(type = PasswordTrackerPersistence.class)
4076 protected PasswordTrackerPersistence passwordTrackerPersistence;
4077 @BeanReference(type = PermissionPersistence.class)
4078 protected PermissionPersistence permissionPersistence;
4079 @BeanReference(type = PhonePersistence.class)
4080 protected PhonePersistence phonePersistence;
4081 @BeanReference(type = PluginSettingPersistence.class)
4082 protected PluginSettingPersistence pluginSettingPersistence;
4083 @BeanReference(type = PortalPreferencesPersistence.class)
4084 protected PortalPreferencesPersistence portalPreferencesPersistence;
4085 @BeanReference(type = PortletPersistence.class)
4086 protected PortletPersistence portletPersistence;
4087 @BeanReference(type = PortletItemPersistence.class)
4088 protected PortletItemPersistence portletItemPersistence;
4089 @BeanReference(type = PortletPreferencesPersistence.class)
4090 protected PortletPreferencesPersistence portletPreferencesPersistence;
4091 @BeanReference(type = RegionPersistence.class)
4092 protected RegionPersistence regionPersistence;
4093 @BeanReference(type = ReleasePersistence.class)
4094 protected ReleasePersistence releasePersistence;
4095 @BeanReference(type = RepositoryPersistence.class)
4096 protected RepositoryPersistence repositoryPersistence;
4097 @BeanReference(type = RepositoryEntryPersistence.class)
4098 protected RepositoryEntryPersistence repositoryEntryPersistence;
4099 @BeanReference(type = ResourcePersistence.class)
4100 protected ResourcePersistence resourcePersistence;
4101 @BeanReference(type = ResourceActionPersistence.class)
4102 protected ResourceActionPersistence resourceActionPersistence;
4103 @BeanReference(type = ResourceBlockPersistence.class)
4104 protected ResourceBlockPersistence resourceBlockPersistence;
4105 @BeanReference(type = ResourceBlockPermissionPersistence.class)
4106 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
4107 @BeanReference(type = ResourceCodePersistence.class)
4108 protected ResourceCodePersistence resourceCodePersistence;
4109 @BeanReference(type = ResourcePermissionPersistence.class)
4110 protected ResourcePermissionPersistence resourcePermissionPersistence;
4111 @BeanReference(type = ResourceTypePermissionPersistence.class)
4112 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
4113 @BeanReference(type = RolePersistence.class)
4114 protected RolePersistence rolePersistence;
4115 @BeanReference(type = ServiceComponentPersistence.class)
4116 protected ServiceComponentPersistence serviceComponentPersistence;
4117 @BeanReference(type = ShardPersistence.class)
4118 protected ShardPersistence shardPersistence;
4119 @BeanReference(type = SubscriptionPersistence.class)
4120 protected SubscriptionPersistence subscriptionPersistence;
4121 @BeanReference(type = TeamPersistence.class)
4122 protected TeamPersistence teamPersistence;
4123 @BeanReference(type = TicketPersistence.class)
4124 protected TicketPersistence ticketPersistence;
4125 @BeanReference(type = UserPersistence.class)
4126 protected UserPersistence userPersistence;
4127 @BeanReference(type = UserGroupPersistence.class)
4128 protected UserGroupPersistence userGroupPersistence;
4129 @BeanReference(type = UserGroupGroupRolePersistence.class)
4130 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
4131 @BeanReference(type = UserGroupRolePersistence.class)
4132 protected UserGroupRolePersistence userGroupRolePersistence;
4133 @BeanReference(type = UserIdMapperPersistence.class)
4134 protected UserIdMapperPersistence userIdMapperPersistence;
4135 @BeanReference(type = UserNotificationEventPersistence.class)
4136 protected UserNotificationEventPersistence userNotificationEventPersistence;
4137 @BeanReference(type = UserTrackerPersistence.class)
4138 protected UserTrackerPersistence userTrackerPersistence;
4139 @BeanReference(type = UserTrackerPathPersistence.class)
4140 protected UserTrackerPathPersistence userTrackerPathPersistence;
4141 @BeanReference(type = VirtualHostPersistence.class)
4142 protected VirtualHostPersistence virtualHostPersistence;
4143 @BeanReference(type = WebDAVPropsPersistence.class)
4144 protected WebDAVPropsPersistence webDAVPropsPersistence;
4145 @BeanReference(type = WebsitePersistence.class)
4146 protected WebsitePersistence websitePersistence;
4147 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4148 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4149 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4150 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4151 protected ContainsGroup containsGroup;
4152 protected AddGroup addGroup;
4153 protected ClearGroups clearGroups;
4154 protected RemoveGroup removeGroup;
4155 protected ContainsTeam containsTeam;
4156 protected AddTeam addTeam;
4157 protected ClearTeams clearTeams;
4158 protected RemoveTeam removeTeam;
4159 protected ContainsUser containsUser;
4160 protected AddUser addUser;
4161 protected ClearUsers clearUsers;
4162 protected RemoveUser removeUser;
4163
4164 protected class ContainsGroup {
4165 protected ContainsGroup() {
4166 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4167 _SQL_CONTAINSGROUP,
4168 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4169 RowMapper.COUNT);
4170 }
4171
4172 protected boolean contains(long userGroupId, long groupId) {
4173 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4174 new Long(userGroupId), new Long(groupId)
4175 });
4176
4177 if (results.size() > 0) {
4178 Integer count = results.get(0);
4179
4180 if (count.intValue() > 0) {
4181 return true;
4182 }
4183 }
4184
4185 return false;
4186 }
4187
4188 private MappingSqlQuery<Integer> _mappingSqlQuery;
4189 }
4190
4191 protected class AddGroup {
4192 protected AddGroup() {
4193 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4194 "INSERT INTO Groups_UserGroups (userGroupId, groupId) VALUES (?, ?)",
4195 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4196 }
4197
4198 protected void add(long userGroupId, long groupId)
4199 throws SystemException {
4200 if (!containsGroup.contains(userGroupId, groupId)) {
4201 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4202
4203 for (ModelListener<UserGroup> listener : listeners) {
4204 listener.onBeforeAddAssociation(userGroupId,
4205 com.liferay.portal.model.Group.class.getName(), groupId);
4206 }
4207
4208 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4209 listener.onBeforeAddAssociation(groupId,
4210 UserGroup.class.getName(), userGroupId);
4211 }
4212
4213 _sqlUpdate.update(new Object[] {
4214 new Long(userGroupId), new Long(groupId)
4215 });
4216
4217 for (ModelListener<UserGroup> listener : listeners) {
4218 listener.onAfterAddAssociation(userGroupId,
4219 com.liferay.portal.model.Group.class.getName(), groupId);
4220 }
4221
4222 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4223 listener.onAfterAddAssociation(groupId,
4224 UserGroup.class.getName(), userGroupId);
4225 }
4226 }
4227 }
4228
4229 private SqlUpdate _sqlUpdate;
4230 }
4231
4232 protected class ClearGroups {
4233 protected ClearGroups() {
4234 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4235 "DELETE FROM Groups_UserGroups WHERE userGroupId = ?",
4236 new int[] { java.sql.Types.BIGINT });
4237 }
4238
4239 protected void clear(long userGroupId) throws SystemException {
4240 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4241
4242 List<com.liferay.portal.model.Group> groups = null;
4243
4244 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4245 groups = getGroups(userGroupId);
4246
4247 for (com.liferay.portal.model.Group group : groups) {
4248 for (ModelListener<UserGroup> listener : listeners) {
4249 listener.onBeforeRemoveAssociation(userGroupId,
4250 com.liferay.portal.model.Group.class.getName(),
4251 group.getPrimaryKey());
4252 }
4253
4254 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4255 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
4256 UserGroup.class.getName(), userGroupId);
4257 }
4258 }
4259 }
4260
4261 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
4262
4263 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4264 for (com.liferay.portal.model.Group group : groups) {
4265 for (ModelListener<UserGroup> listener : listeners) {
4266 listener.onAfterRemoveAssociation(userGroupId,
4267 com.liferay.portal.model.Group.class.getName(),
4268 group.getPrimaryKey());
4269 }
4270
4271 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4272 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
4273 UserGroup.class.getName(), userGroupId);
4274 }
4275 }
4276 }
4277 }
4278
4279 private SqlUpdate _sqlUpdate;
4280 }
4281
4282 protected class RemoveGroup {
4283 protected RemoveGroup() {
4284 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4285 "DELETE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?",
4286 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4287 }
4288
4289 protected void remove(long userGroupId, long groupId)
4290 throws SystemException {
4291 if (containsGroup.contains(userGroupId, groupId)) {
4292 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4293
4294 for (ModelListener<UserGroup> listener : listeners) {
4295 listener.onBeforeRemoveAssociation(userGroupId,
4296 com.liferay.portal.model.Group.class.getName(), groupId);
4297 }
4298
4299 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4300 listener.onBeforeRemoveAssociation(groupId,
4301 UserGroup.class.getName(), userGroupId);
4302 }
4303
4304 _sqlUpdate.update(new Object[] {
4305 new Long(userGroupId), new Long(groupId)
4306 });
4307
4308 for (ModelListener<UserGroup> listener : listeners) {
4309 listener.onAfterRemoveAssociation(userGroupId,
4310 com.liferay.portal.model.Group.class.getName(), groupId);
4311 }
4312
4313 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4314 listener.onAfterRemoveAssociation(groupId,
4315 UserGroup.class.getName(), userGroupId);
4316 }
4317 }
4318 }
4319
4320 private SqlUpdate _sqlUpdate;
4321 }
4322
4323 protected class ContainsTeam {
4324 protected ContainsTeam() {
4325 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4326 _SQL_CONTAINSTEAM,
4327 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4328 RowMapper.COUNT);
4329 }
4330
4331 protected boolean contains(long userGroupId, long teamId) {
4332 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4333 new Long(userGroupId), new Long(teamId)
4334 });
4335
4336 if (results.size() > 0) {
4337 Integer count = results.get(0);
4338
4339 if (count.intValue() > 0) {
4340 return true;
4341 }
4342 }
4343
4344 return false;
4345 }
4346
4347 private MappingSqlQuery<Integer> _mappingSqlQuery;
4348 }
4349
4350 protected class AddTeam {
4351 protected AddTeam() {
4352 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4353 "INSERT INTO UserGroups_Teams (userGroupId, teamId) VALUES (?, ?)",
4354 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4355 }
4356
4357 protected void add(long userGroupId, long teamId)
4358 throws SystemException {
4359 if (!containsTeam.contains(userGroupId, teamId)) {
4360 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
4361
4362 for (ModelListener<UserGroup> listener : listeners) {
4363 listener.onBeforeAddAssociation(userGroupId,
4364 com.liferay.portal.model.Team.class.getName(), teamId);
4365 }
4366
4367 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4368 listener.onBeforeAddAssociation(teamId,
4369 UserGroup.class.getName(), userGroupId);
4370 }
4371
4372 _sqlUpdate.update(new Object[] {
4373 new Long(userGroupId), new Long(teamId)
4374 });
4375
4376 for (ModelListener<UserGroup> listener : listeners) {
4377 listener.onAfterAddAssociation(userGroupId,
4378 com.liferay.portal.model.Team.class.getName(), teamId);
4379 }
4380
4381 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4382 listener.onAfterAddAssociation(teamId,
4383 UserGroup.class.getName(), userGroupId);
4384 }
4385 }
4386 }
4387
4388 private SqlUpdate _sqlUpdate;
4389 }
4390
4391 protected class ClearTeams {
4392 protected ClearTeams() {
4393 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4394 "DELETE FROM UserGroups_Teams WHERE userGroupId = ?",
4395 new int[] { java.sql.Types.BIGINT });
4396 }
4397
4398 protected void clear(long userGroupId) throws SystemException {
4399 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
4400
4401 List<com.liferay.portal.model.Team> teams = null;
4402
4403 if ((listeners.length > 0) || (teamListeners.length > 0)) {
4404 teams = getTeams(userGroupId);
4405
4406 for (com.liferay.portal.model.Team team : teams) {
4407 for (ModelListener<UserGroup> listener : listeners) {
4408 listener.onBeforeRemoveAssociation(userGroupId,
4409 com.liferay.portal.model.Team.class.getName(),
4410 team.getPrimaryKey());
4411 }
4412
4413 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4414 listener.onBeforeRemoveAssociation(team.getPrimaryKey(),
4415 UserGroup.class.getName(), userGroupId);
4416 }
4417 }
4418 }
4419
4420 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
4421
4422 if ((listeners.length > 0) || (teamListeners.length > 0)) {
4423 for (com.liferay.portal.model.Team team : teams) {
4424 for (ModelListener<UserGroup> listener : listeners) {
4425 listener.onAfterRemoveAssociation(userGroupId,
4426 com.liferay.portal.model.Team.class.getName(),
4427 team.getPrimaryKey());
4428 }
4429
4430 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4431 listener.onAfterRemoveAssociation(team.getPrimaryKey(),
4432 UserGroup.class.getName(), userGroupId);
4433 }
4434 }
4435 }
4436 }
4437
4438 private SqlUpdate _sqlUpdate;
4439 }
4440
4441 protected class RemoveTeam {
4442 protected RemoveTeam() {
4443 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4444 "DELETE FROM UserGroups_Teams WHERE userGroupId = ? AND teamId = ?",
4445 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4446 }
4447
4448 protected void remove(long userGroupId, long teamId)
4449 throws SystemException {
4450 if (containsTeam.contains(userGroupId, teamId)) {
4451 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
4452
4453 for (ModelListener<UserGroup> listener : listeners) {
4454 listener.onBeforeRemoveAssociation(userGroupId,
4455 com.liferay.portal.model.Team.class.getName(), teamId);
4456 }
4457
4458 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4459 listener.onBeforeRemoveAssociation(teamId,
4460 UserGroup.class.getName(), userGroupId);
4461 }
4462
4463 _sqlUpdate.update(new Object[] {
4464 new Long(userGroupId), new Long(teamId)
4465 });
4466
4467 for (ModelListener<UserGroup> listener : listeners) {
4468 listener.onAfterRemoveAssociation(userGroupId,
4469 com.liferay.portal.model.Team.class.getName(), teamId);
4470 }
4471
4472 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
4473 listener.onAfterRemoveAssociation(teamId,
4474 UserGroup.class.getName(), userGroupId);
4475 }
4476 }
4477 }
4478
4479 private SqlUpdate _sqlUpdate;
4480 }
4481
4482 protected class ContainsUser {
4483 protected ContainsUser() {
4484 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4485 _SQL_CONTAINSUSER,
4486 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4487 RowMapper.COUNT);
4488 }
4489
4490 protected boolean contains(long userGroupId, long userId) {
4491 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4492 new Long(userGroupId), new Long(userId)
4493 });
4494
4495 if (results.size() > 0) {
4496 Integer count = results.get(0);
4497
4498 if (count.intValue() > 0) {
4499 return true;
4500 }
4501 }
4502
4503 return false;
4504 }
4505
4506 private MappingSqlQuery<Integer> _mappingSqlQuery;
4507 }
4508
4509 protected class AddUser {
4510 protected AddUser() {
4511 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4512 "INSERT INTO Users_UserGroups (userGroupId, userId) VALUES (?, ?)",
4513 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4514 }
4515
4516 protected void add(long userGroupId, long userId)
4517 throws SystemException {
4518 if (!containsUser.contains(userGroupId, userId)) {
4519 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4520
4521 for (ModelListener<UserGroup> listener : listeners) {
4522 listener.onBeforeAddAssociation(userGroupId,
4523 com.liferay.portal.model.User.class.getName(), userId);
4524 }
4525
4526 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4527 listener.onBeforeAddAssociation(userId,
4528 UserGroup.class.getName(), userGroupId);
4529 }
4530
4531 _sqlUpdate.update(new Object[] {
4532 new Long(userGroupId), new Long(userId)
4533 });
4534
4535 for (ModelListener<UserGroup> listener : listeners) {
4536 listener.onAfterAddAssociation(userGroupId,
4537 com.liferay.portal.model.User.class.getName(), userId);
4538 }
4539
4540 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4541 listener.onAfterAddAssociation(userId,
4542 UserGroup.class.getName(), userGroupId);
4543 }
4544 }
4545 }
4546
4547 private SqlUpdate _sqlUpdate;
4548 }
4549
4550 protected class ClearUsers {
4551 protected ClearUsers() {
4552 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4553 "DELETE FROM Users_UserGroups WHERE userGroupId = ?",
4554 new int[] { java.sql.Types.BIGINT });
4555 }
4556
4557 protected void clear(long userGroupId) throws SystemException {
4558 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4559
4560 List<com.liferay.portal.model.User> users = null;
4561
4562 if ((listeners.length > 0) || (userListeners.length > 0)) {
4563 users = getUsers(userGroupId);
4564
4565 for (com.liferay.portal.model.User user : users) {
4566 for (ModelListener<UserGroup> listener : listeners) {
4567 listener.onBeforeRemoveAssociation(userGroupId,
4568 com.liferay.portal.model.User.class.getName(),
4569 user.getPrimaryKey());
4570 }
4571
4572 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4573 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
4574 UserGroup.class.getName(), userGroupId);
4575 }
4576 }
4577 }
4578
4579 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
4580
4581 if ((listeners.length > 0) || (userListeners.length > 0)) {
4582 for (com.liferay.portal.model.User user : users) {
4583 for (ModelListener<UserGroup> listener : listeners) {
4584 listener.onAfterRemoveAssociation(userGroupId,
4585 com.liferay.portal.model.User.class.getName(),
4586 user.getPrimaryKey());
4587 }
4588
4589 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4590 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
4591 UserGroup.class.getName(), userGroupId);
4592 }
4593 }
4594 }
4595 }
4596
4597 private SqlUpdate _sqlUpdate;
4598 }
4599
4600 protected class RemoveUser {
4601 protected RemoveUser() {
4602 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4603 "DELETE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?",
4604 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4605 }
4606
4607 protected void remove(long userGroupId, long userId)
4608 throws SystemException {
4609 if (containsUser.contains(userGroupId, userId)) {
4610 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4611
4612 for (ModelListener<UserGroup> listener : listeners) {
4613 listener.onBeforeRemoveAssociation(userGroupId,
4614 com.liferay.portal.model.User.class.getName(), userId);
4615 }
4616
4617 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4618 listener.onBeforeRemoveAssociation(userId,
4619 UserGroup.class.getName(), userGroupId);
4620 }
4621
4622 _sqlUpdate.update(new Object[] {
4623 new Long(userGroupId), new Long(userId)
4624 });
4625
4626 for (ModelListener<UserGroup> listener : listeners) {
4627 listener.onAfterRemoveAssociation(userGroupId,
4628 com.liferay.portal.model.User.class.getName(), userId);
4629 }
4630
4631 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4632 listener.onAfterRemoveAssociation(userId,
4633 UserGroup.class.getName(), userGroupId);
4634 }
4635 }
4636 }
4637
4638 private SqlUpdate _sqlUpdate;
4639 }
4640
4641 private static final String _SQL_SELECT_USERGROUP = "SELECT userGroup FROM UserGroup userGroup";
4642 private static final String _SQL_SELECT_USERGROUP_WHERE = "SELECT userGroup FROM UserGroup userGroup WHERE ";
4643 private static final String _SQL_COUNT_USERGROUP = "SELECT COUNT(userGroup) FROM UserGroup userGroup";
4644 private static final String _SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(userGroup) FROM UserGroup userGroup WHERE ";
4645 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_UserGroups ON (Groups_UserGroups.groupId = Group_.groupId) WHERE (Groups_UserGroups.userGroupId = ?)";
4646 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ?";
4647 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?";
4648 private static final String _SQL_GETTEAMS = "SELECT {Team.*} FROM Team INNER JOIN UserGroups_Teams ON (UserGroups_Teams.teamId = Team.teamId) WHERE (UserGroups_Teams.userGroupId = ?)";
4649 private static final String _SQL_GETTEAMSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE userGroupId = ?";
4650 private static final String _SQL_CONTAINSTEAM = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE userGroupId = ? AND teamId = ?";
4651 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_UserGroups ON (Users_UserGroups.userId = User_.userId) WHERE (Users_UserGroups.userGroupId = ?)";
4652 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ?";
4653 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?";
4654 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userGroup.companyId = ?";
4655 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "userGroup.companyId = ? AND ";
4656 private static final String _FINDER_COLUMN_C_P_PARENTUSERGROUPID_2 = "userGroup.parentUserGroupId = ?";
4657 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "userGroup.companyId = ? AND ";
4658 private static final String _FINDER_COLUMN_C_N_NAME_1 = "userGroup.name IS NULL";
4659 private static final String _FINDER_COLUMN_C_N_NAME_2 = "userGroup.name = ?";
4660 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(userGroup.name IS NULL OR userGroup.name = ?)";
4661 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "userGroup.userGroupId";
4662 private static final String _FILTER_SQL_SELECT_USERGROUP_WHERE = "SELECT DISTINCT {userGroup.*} FROM UserGroup userGroup WHERE ";
4663 private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1 =
4664 "SELECT {UserGroup.*} FROM (SELECT DISTINCT userGroup.userGroupId FROM UserGroup userGroup WHERE ";
4665 private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2 =
4666 ") TEMP_TABLE INNER JOIN UserGroup ON TEMP_TABLE.userGroupId = UserGroup.userGroupId";
4667 private static final String _FILTER_SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(DISTINCT userGroup.userGroupId) AS COUNT_VALUE FROM UserGroup userGroup WHERE ";
4668 private static final String _FILTER_ENTITY_ALIAS = "userGroup";
4669 private static final String _FILTER_ENTITY_TABLE = "UserGroup";
4670 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroup.";
4671 private static final String _ORDER_BY_ENTITY_TABLE = "UserGroup.";
4672 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroup exists with the primary key ";
4673 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroup exists with the key {";
4674 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4675 private static Log _log = LogFactoryUtil.getLog(UserGroupPersistenceImpl.class);
4676 private static UserGroup _nullUserGroup = new UserGroupImpl() {
4677 @Override
4678 public Object clone() {
4679 return this;
4680 }
4681
4682 @Override
4683 public CacheModel<UserGroup> toCacheModel() {
4684 return _nullUserGroupCacheModel;
4685 }
4686 };
4687
4688 private static CacheModel<UserGroup> _nullUserGroupCacheModel = new CacheModel<UserGroup>() {
4689 public UserGroup toEntityModel() {
4690 return _nullUserGroup;
4691 }
4692 };
4693 }