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.annotation.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.UserGroup;
047 import com.liferay.portal.model.impl.UserGroupImpl;
048 import com.liferay.portal.model.impl.UserGroupModelImpl;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056 import java.util.Set;
057
058
074 public class UserGroupPersistenceImpl extends BasePersistenceImpl<UserGroup>
075 implements UserGroupPersistence {
076 public static final String FINDER_CLASS_NAME_ENTITY = UserGroupImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
078 ".List";
079 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
080 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
081 "findByCompanyId",
082 new String[] {
083 Long.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
089 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
090 "countByCompanyId", new String[] { Long.class.getName() });
091 public static final FinderPath FINDER_PATH_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
092 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
093 "findByC_P",
094 new String[] {
095 Long.class.getName(), Long.class.getName(),
096
097 "java.lang.Integer", "java.lang.Integer",
098 "com.liferay.portal.kernel.util.OrderByComparator"
099 });
100 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
101 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
102 "countByC_P",
103 new String[] { Long.class.getName(), Long.class.getName() });
104 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
105 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
106 "fetchByC_N",
107 new String[] { Long.class.getName(), String.class.getName() });
108 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
109 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110 "countByC_N",
111 new String[] { Long.class.getName(), String.class.getName() });
112 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
113 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114 "findAll", new String[0]);
115 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
116 UserGroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117 "countAll", new String[0]);
118
119
124 public void cacheResult(UserGroup userGroup) {
125 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
126 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
127
128 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
129 new Object[] { new Long(userGroup.getCompanyId()), userGroup.getName() },
130 userGroup);
131 }
132
133
138 public void cacheResult(List<UserGroup> userGroups) {
139 for (UserGroup userGroup : userGroups) {
140 if (EntityCacheUtil.getResult(
141 UserGroupModelImpl.ENTITY_CACHE_ENABLED,
142 UserGroupImpl.class, userGroup.getPrimaryKey(), this) == null) {
143 cacheResult(userGroup);
144 }
145 }
146 }
147
148
155 public void clearCache() {
156 CacheRegistryUtil.clear(UserGroupImpl.class.getName());
157 EntityCacheUtil.clearCache(UserGroupImpl.class.getName());
158 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
159 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
160 }
161
162
169 public void clearCache(UserGroup userGroup) {
170 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
171 UserGroupImpl.class, userGroup.getPrimaryKey());
172
173 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
174 new Object[] { new Long(userGroup.getCompanyId()), userGroup.getName() });
175 }
176
177
183 public UserGroup create(long userGroupId) {
184 UserGroup userGroup = new UserGroupImpl();
185
186 userGroup.setNew(true);
187 userGroup.setPrimaryKey(userGroupId);
188
189 return userGroup;
190 }
191
192
200 public UserGroup remove(Serializable primaryKey)
201 throws NoSuchModelException, SystemException {
202 return remove(((Long)primaryKey).longValue());
203 }
204
205
213 public UserGroup remove(long userGroupId)
214 throws NoSuchUserGroupException, SystemException {
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 UserGroup userGroup = (UserGroup)session.get(UserGroupImpl.class,
221 new Long(userGroupId));
222
223 if (userGroup == null) {
224 if (_log.isWarnEnabled()) {
225 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupId);
226 }
227
228 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
229 userGroupId);
230 }
231
232 return remove(userGroup);
233 }
234 catch (NoSuchUserGroupException nsee) {
235 throw nsee;
236 }
237 catch (Exception e) {
238 throw processException(e);
239 }
240 finally {
241 closeSession(session);
242 }
243 }
244
245 protected UserGroup removeImpl(UserGroup userGroup)
246 throws SystemException {
247 userGroup = toUnwrappedModel(userGroup);
248
249 try {
250 clearGroups.clear(userGroup.getPrimaryKey());
251 }
252 catch (Exception e) {
253 throw processException(e);
254 }
255 finally {
256 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
257 }
258
259 try {
260 clearUsers.clear(userGroup.getPrimaryKey());
261 }
262 catch (Exception e) {
263 throw processException(e);
264 }
265 finally {
266 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
267 }
268
269 Session session = null;
270
271 try {
272 session = openSession();
273
274 if (userGroup.isCachedModel() || BatchSessionUtil.isEnabled()) {
275 Object staleObject = session.get(UserGroupImpl.class,
276 userGroup.getPrimaryKeyObj());
277
278 if (staleObject != null) {
279 session.evict(staleObject);
280 }
281 }
282
283 session.delete(userGroup);
284
285 session.flush();
286 }
287 catch (Exception e) {
288 throw processException(e);
289 }
290 finally {
291 closeSession(session);
292 }
293
294 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
295
296 UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup;
297
298 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
299 new Object[] {
300 new Long(userGroupModelImpl.getOriginalCompanyId()),
301
302 userGroupModelImpl.getOriginalName()
303 });
304
305 EntityCacheUtil.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
306 UserGroupImpl.class, userGroup.getPrimaryKey());
307
308 return userGroup;
309 }
310
311 public UserGroup updateImpl(com.liferay.portal.model.UserGroup userGroup,
312 boolean merge) throws SystemException {
313 userGroup = toUnwrappedModel(userGroup);
314
315 boolean isNew = userGroup.isNew();
316
317 UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup;
318
319 Session session = null;
320
321 try {
322 session = openSession();
323
324 BatchSessionUtil.update(session, userGroup, merge);
325
326 userGroup.setNew(false);
327 }
328 catch (Exception e) {
329 throw processException(e);
330 }
331 finally {
332 closeSession(session);
333 }
334
335 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
336
337 EntityCacheUtil.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
338 UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup);
339
340 if (!isNew &&
341 ((userGroup.getCompanyId() != userGroupModelImpl.getOriginalCompanyId()) ||
342 !Validator.equals(userGroup.getName(),
343 userGroupModelImpl.getOriginalName()))) {
344 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
345 new Object[] {
346 new Long(userGroupModelImpl.getOriginalCompanyId()),
347
348 userGroupModelImpl.getOriginalName()
349 });
350 }
351
352 if (isNew ||
353 ((userGroup.getCompanyId() != userGroupModelImpl.getOriginalCompanyId()) ||
354 !Validator.equals(userGroup.getName(),
355 userGroupModelImpl.getOriginalName()))) {
356 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
357 new Object[] {
358 new Long(userGroup.getCompanyId()),
359
360 userGroup.getName()
361 }, userGroup);
362 }
363
364 return userGroup;
365 }
366
367 protected UserGroup toUnwrappedModel(UserGroup userGroup) {
368 if (userGroup instanceof UserGroupImpl) {
369 return userGroup;
370 }
371
372 UserGroupImpl userGroupImpl = new UserGroupImpl();
373
374 userGroupImpl.setNew(userGroup.isNew());
375 userGroupImpl.setPrimaryKey(userGroup.getPrimaryKey());
376
377 userGroupImpl.setUserGroupId(userGroup.getUserGroupId());
378 userGroupImpl.setCompanyId(userGroup.getCompanyId());
379 userGroupImpl.setParentUserGroupId(userGroup.getParentUserGroupId());
380 userGroupImpl.setName(userGroup.getName());
381 userGroupImpl.setDescription(userGroup.getDescription());
382
383 return userGroupImpl;
384 }
385
386
394 public UserGroup findByPrimaryKey(Serializable primaryKey)
395 throws NoSuchModelException, SystemException {
396 return findByPrimaryKey(((Long)primaryKey).longValue());
397 }
398
399
407 public UserGroup findByPrimaryKey(long userGroupId)
408 throws NoSuchUserGroupException, SystemException {
409 UserGroup userGroup = fetchByPrimaryKey(userGroupId);
410
411 if (userGroup == null) {
412 if (_log.isWarnEnabled()) {
413 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userGroupId);
414 }
415
416 throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
417 userGroupId);
418 }
419
420 return userGroup;
421 }
422
423
430 public UserGroup fetchByPrimaryKey(Serializable primaryKey)
431 throws SystemException {
432 return fetchByPrimaryKey(((Long)primaryKey).longValue());
433 }
434
435
442 public UserGroup fetchByPrimaryKey(long userGroupId)
443 throws SystemException {
444 UserGroup userGroup = (UserGroup)EntityCacheUtil.getResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED,
445 UserGroupImpl.class, userGroupId, this);
446
447 if (userGroup == null) {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 userGroup = (UserGroup)session.get(UserGroupImpl.class,
454 new Long(userGroupId));
455 }
456 catch (Exception e) {
457 throw processException(e);
458 }
459 finally {
460 if (userGroup != null) {
461 cacheResult(userGroup);
462 }
463
464 closeSession(session);
465 }
466 }
467
468 return userGroup;
469 }
470
471
478 public List<UserGroup> findByCompanyId(long companyId)
479 throws SystemException {
480 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
481 null);
482 }
483
484
497 public List<UserGroup> findByCompanyId(long companyId, int start, int end)
498 throws SystemException {
499 return findByCompanyId(companyId, start, end, null);
500 }
501
502
516 public List<UserGroup> findByCompanyId(long companyId, int start, int end,
517 OrderByComparator orderByComparator) throws SystemException {
518 Object[] finderArgs = new Object[] {
519 companyId,
520
521 String.valueOf(start), String.valueOf(end),
522 String.valueOf(orderByComparator)
523 };
524
525 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
526 finderArgs, this);
527
528 if (list == null) {
529 Session session = null;
530
531 try {
532 session = openSession();
533
534 StringBundler query = null;
535
536 if (orderByComparator != null) {
537 query = new StringBundler(3 +
538 (orderByComparator.getOrderByFields().length * 3));
539 }
540 else {
541 query = new StringBundler(3);
542 }
543
544 query.append(_SQL_SELECT_USERGROUP_WHERE);
545
546 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
547
548 if (orderByComparator != null) {
549 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
550 orderByComparator);
551 }
552
553 else {
554 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
555 }
556
557 String sql = query.toString();
558
559 Query q = session.createQuery(sql);
560
561 QueryPos qPos = QueryPos.getInstance(q);
562
563 qPos.add(companyId);
564
565 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
566 end);
567 }
568 catch (Exception e) {
569 throw processException(e);
570 }
571 finally {
572 if (list == null) {
573 list = new ArrayList<UserGroup>();
574 }
575
576 cacheResult(list);
577
578 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
579 finderArgs, list);
580
581 closeSession(session);
582 }
583 }
584
585 return list;
586 }
587
588
601 public UserGroup findByCompanyId_First(long companyId,
602 OrderByComparator orderByComparator)
603 throws NoSuchUserGroupException, SystemException {
604 List<UserGroup> list = findByCompanyId(companyId, 0, 1,
605 orderByComparator);
606
607 if (list.isEmpty()) {
608 StringBundler msg = new StringBundler(4);
609
610 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
611
612 msg.append("companyId=");
613 msg.append(companyId);
614
615 msg.append(StringPool.CLOSE_CURLY_BRACE);
616
617 throw new NoSuchUserGroupException(msg.toString());
618 }
619 else {
620 return list.get(0);
621 }
622 }
623
624
637 public UserGroup findByCompanyId_Last(long companyId,
638 OrderByComparator orderByComparator)
639 throws NoSuchUserGroupException, SystemException {
640 int count = countByCompanyId(companyId);
641
642 List<UserGroup> list = findByCompanyId(companyId, count - 1, count,
643 orderByComparator);
644
645 if (list.isEmpty()) {
646 StringBundler msg = new StringBundler(4);
647
648 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649
650 msg.append("companyId=");
651 msg.append(companyId);
652
653 msg.append(StringPool.CLOSE_CURLY_BRACE);
654
655 throw new NoSuchUserGroupException(msg.toString());
656 }
657 else {
658 return list.get(0);
659 }
660 }
661
662
676 public UserGroup[] findByCompanyId_PrevAndNext(long userGroupId,
677 long companyId, OrderByComparator orderByComparator)
678 throws NoSuchUserGroupException, SystemException {
679 UserGroup userGroup = findByPrimaryKey(userGroupId);
680
681 Session session = null;
682
683 try {
684 session = openSession();
685
686 UserGroup[] array = new UserGroupImpl[3];
687
688 array[0] = getByCompanyId_PrevAndNext(session, userGroup,
689 companyId, orderByComparator, true);
690
691 array[1] = userGroup;
692
693 array[2] = getByCompanyId_PrevAndNext(session, userGroup,
694 companyId, orderByComparator, false);
695
696 return array;
697 }
698 catch (Exception e) {
699 throw processException(e);
700 }
701 finally {
702 closeSession(session);
703 }
704 }
705
706 protected UserGroup getByCompanyId_PrevAndNext(Session session,
707 UserGroup userGroup, long companyId,
708 OrderByComparator orderByComparator, boolean previous) {
709 StringBundler query = null;
710
711 if (orderByComparator != null) {
712 query = new StringBundler(6 +
713 (orderByComparator.getOrderByFields().length * 6));
714 }
715 else {
716 query = new StringBundler(3);
717 }
718
719 query.append(_SQL_SELECT_USERGROUP_WHERE);
720
721 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
722
723 if (orderByComparator != null) {
724 String[] orderByFields = orderByComparator.getOrderByFields();
725
726 if (orderByFields.length > 0) {
727 query.append(WHERE_AND);
728 }
729
730 for (int i = 0; i < orderByFields.length; i++) {
731 query.append(_ORDER_BY_ENTITY_ALIAS);
732 query.append(orderByFields[i]);
733
734 if ((i + 1) < orderByFields.length) {
735 if (orderByComparator.isAscending() ^ previous) {
736 query.append(WHERE_GREATER_THAN_HAS_NEXT);
737 }
738 else {
739 query.append(WHERE_LESSER_THAN_HAS_NEXT);
740 }
741 }
742 else {
743 if (orderByComparator.isAscending() ^ previous) {
744 query.append(WHERE_GREATER_THAN);
745 }
746 else {
747 query.append(WHERE_LESSER_THAN);
748 }
749 }
750 }
751
752 query.append(ORDER_BY_CLAUSE);
753
754 for (int i = 0; i < orderByFields.length; i++) {
755 query.append(_ORDER_BY_ENTITY_ALIAS);
756 query.append(orderByFields[i]);
757
758 if ((i + 1) < orderByFields.length) {
759 if (orderByComparator.isAscending() ^ previous) {
760 query.append(ORDER_BY_ASC_HAS_NEXT);
761 }
762 else {
763 query.append(ORDER_BY_DESC_HAS_NEXT);
764 }
765 }
766 else {
767 if (orderByComparator.isAscending() ^ previous) {
768 query.append(ORDER_BY_ASC);
769 }
770 else {
771 query.append(ORDER_BY_DESC);
772 }
773 }
774 }
775 }
776
777 else {
778 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
779 }
780
781 String sql = query.toString();
782
783 Query q = session.createQuery(sql);
784
785 q.setFirstResult(0);
786 q.setMaxResults(2);
787
788 QueryPos qPos = QueryPos.getInstance(q);
789
790 qPos.add(companyId);
791
792 if (orderByComparator != null) {
793 Object[] values = orderByComparator.getOrderByValues(userGroup);
794
795 for (Object value : values) {
796 qPos.add(value);
797 }
798 }
799
800 List<UserGroup> list = q.list();
801
802 if (list.size() == 2) {
803 return list.get(1);
804 }
805 else {
806 return null;
807 }
808 }
809
810
818 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId)
819 throws SystemException {
820 return findByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS,
821 QueryUtil.ALL_POS, null);
822 }
823
824
838 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
839 int start, int end) throws SystemException {
840 return findByC_P(companyId, parentUserGroupId, start, end, null);
841 }
842
843
858 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
859 int start, int end, OrderByComparator orderByComparator)
860 throws SystemException {
861 Object[] finderArgs = new Object[] {
862 companyId, parentUserGroupId,
863
864 String.valueOf(start), String.valueOf(end),
865 String.valueOf(orderByComparator)
866 };
867
868 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_P,
869 finderArgs, this);
870
871 if (list == null) {
872 Session session = null;
873
874 try {
875 session = openSession();
876
877 StringBundler query = null;
878
879 if (orderByComparator != null) {
880 query = new StringBundler(4 +
881 (orderByComparator.getOrderByFields().length * 3));
882 }
883 else {
884 query = new StringBundler(4);
885 }
886
887 query.append(_SQL_SELECT_USERGROUP_WHERE);
888
889 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
890
891 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
892
893 if (orderByComparator != null) {
894 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
895 orderByComparator);
896 }
897
898 else {
899 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
900 }
901
902 String sql = query.toString();
903
904 Query q = session.createQuery(sql);
905
906 QueryPos qPos = QueryPos.getInstance(q);
907
908 qPos.add(companyId);
909
910 qPos.add(parentUserGroupId);
911
912 list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start,
913 end);
914 }
915 catch (Exception e) {
916 throw processException(e);
917 }
918 finally {
919 if (list == null) {
920 list = new ArrayList<UserGroup>();
921 }
922
923 cacheResult(list);
924
925 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_P, finderArgs,
926 list);
927
928 closeSession(session);
929 }
930 }
931
932 return list;
933 }
934
935
949 public UserGroup findByC_P_First(long companyId, long parentUserGroupId,
950 OrderByComparator orderByComparator)
951 throws NoSuchUserGroupException, SystemException {
952 List<UserGroup> list = findByC_P(companyId, parentUserGroupId, 0, 1,
953 orderByComparator);
954
955 if (list.isEmpty()) {
956 StringBundler msg = new StringBundler(6);
957
958 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
959
960 msg.append("companyId=");
961 msg.append(companyId);
962
963 msg.append(", parentUserGroupId=");
964 msg.append(parentUserGroupId);
965
966 msg.append(StringPool.CLOSE_CURLY_BRACE);
967
968 throw new NoSuchUserGroupException(msg.toString());
969 }
970 else {
971 return list.get(0);
972 }
973 }
974
975
989 public UserGroup findByC_P_Last(long companyId, long parentUserGroupId,
990 OrderByComparator orderByComparator)
991 throws NoSuchUserGroupException, SystemException {
992 int count = countByC_P(companyId, parentUserGroupId);
993
994 List<UserGroup> list = findByC_P(companyId, parentUserGroupId,
995 count - 1, count, orderByComparator);
996
997 if (list.isEmpty()) {
998 StringBundler msg = new StringBundler(6);
999
1000 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1001
1002 msg.append("companyId=");
1003 msg.append(companyId);
1004
1005 msg.append(", parentUserGroupId=");
1006 msg.append(parentUserGroupId);
1007
1008 msg.append(StringPool.CLOSE_CURLY_BRACE);
1009
1010 throw new NoSuchUserGroupException(msg.toString());
1011 }
1012 else {
1013 return list.get(0);
1014 }
1015 }
1016
1017
1032 public UserGroup[] findByC_P_PrevAndNext(long userGroupId, long companyId,
1033 long parentUserGroupId, OrderByComparator orderByComparator)
1034 throws NoSuchUserGroupException, SystemException {
1035 UserGroup userGroup = findByPrimaryKey(userGroupId);
1036
1037 Session session = null;
1038
1039 try {
1040 session = openSession();
1041
1042 UserGroup[] array = new UserGroupImpl[3];
1043
1044 array[0] = getByC_P_PrevAndNext(session, userGroup, companyId,
1045 parentUserGroupId, orderByComparator, true);
1046
1047 array[1] = userGroup;
1048
1049 array[2] = getByC_P_PrevAndNext(session, userGroup, companyId,
1050 parentUserGroupId, orderByComparator, false);
1051
1052 return array;
1053 }
1054 catch (Exception e) {
1055 throw processException(e);
1056 }
1057 finally {
1058 closeSession(session);
1059 }
1060 }
1061
1062 protected UserGroup getByC_P_PrevAndNext(Session session,
1063 UserGroup userGroup, long companyId, long parentUserGroupId,
1064 OrderByComparator orderByComparator, boolean previous) {
1065 StringBundler query = null;
1066
1067 if (orderByComparator != null) {
1068 query = new StringBundler(6 +
1069 (orderByComparator.getOrderByFields().length * 6));
1070 }
1071 else {
1072 query = new StringBundler(3);
1073 }
1074
1075 query.append(_SQL_SELECT_USERGROUP_WHERE);
1076
1077 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1078
1079 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1080
1081 if (orderByComparator != null) {
1082 String[] orderByFields = orderByComparator.getOrderByFields();
1083
1084 if (orderByFields.length > 0) {
1085 query.append(WHERE_AND);
1086 }
1087
1088 for (int i = 0; i < orderByFields.length; i++) {
1089 query.append(_ORDER_BY_ENTITY_ALIAS);
1090 query.append(orderByFields[i]);
1091
1092 if ((i + 1) < orderByFields.length) {
1093 if (orderByComparator.isAscending() ^ previous) {
1094 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1095 }
1096 else {
1097 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1098 }
1099 }
1100 else {
1101 if (orderByComparator.isAscending() ^ previous) {
1102 query.append(WHERE_GREATER_THAN);
1103 }
1104 else {
1105 query.append(WHERE_LESSER_THAN);
1106 }
1107 }
1108 }
1109
1110 query.append(ORDER_BY_CLAUSE);
1111
1112 for (int i = 0; i < orderByFields.length; i++) {
1113 query.append(_ORDER_BY_ENTITY_ALIAS);
1114 query.append(orderByFields[i]);
1115
1116 if ((i + 1) < orderByFields.length) {
1117 if (orderByComparator.isAscending() ^ previous) {
1118 query.append(ORDER_BY_ASC_HAS_NEXT);
1119 }
1120 else {
1121 query.append(ORDER_BY_DESC_HAS_NEXT);
1122 }
1123 }
1124 else {
1125 if (orderByComparator.isAscending() ^ previous) {
1126 query.append(ORDER_BY_ASC);
1127 }
1128 else {
1129 query.append(ORDER_BY_DESC);
1130 }
1131 }
1132 }
1133 }
1134
1135 else {
1136 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1137 }
1138
1139 String sql = query.toString();
1140
1141 Query q = session.createQuery(sql);
1142
1143 q.setFirstResult(0);
1144 q.setMaxResults(2);
1145
1146 QueryPos qPos = QueryPos.getInstance(q);
1147
1148 qPos.add(companyId);
1149
1150 qPos.add(parentUserGroupId);
1151
1152 if (orderByComparator != null) {
1153 Object[] values = orderByComparator.getOrderByValues(userGroup);
1154
1155 for (Object value : values) {
1156 qPos.add(value);
1157 }
1158 }
1159
1160 List<UserGroup> list = q.list();
1161
1162 if (list.size() == 2) {
1163 return list.get(1);
1164 }
1165 else {
1166 return null;
1167 }
1168 }
1169
1170
1179 public UserGroup findByC_N(long companyId, String name)
1180 throws NoSuchUserGroupException, SystemException {
1181 UserGroup userGroup = fetchByC_N(companyId, name);
1182
1183 if (userGroup == null) {
1184 StringBundler msg = new StringBundler(6);
1185
1186 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1187
1188 msg.append("companyId=");
1189 msg.append(companyId);
1190
1191 msg.append(", name=");
1192 msg.append(name);
1193
1194 msg.append(StringPool.CLOSE_CURLY_BRACE);
1195
1196 if (_log.isWarnEnabled()) {
1197 _log.warn(msg.toString());
1198 }
1199
1200 throw new NoSuchUserGroupException(msg.toString());
1201 }
1202
1203 return userGroup;
1204 }
1205
1206
1214 public UserGroup fetchByC_N(long companyId, String name)
1215 throws SystemException {
1216 return fetchByC_N(companyId, name, true);
1217 }
1218
1219
1227 public UserGroup fetchByC_N(long companyId, String name,
1228 boolean retrieveFromCache) throws SystemException {
1229 Object[] finderArgs = new Object[] { companyId, name };
1230
1231 Object result = null;
1232
1233 if (retrieveFromCache) {
1234 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1235 finderArgs, this);
1236 }
1237
1238 if (result == null) {
1239 Session session = null;
1240
1241 try {
1242 session = openSession();
1243
1244 StringBundler query = new StringBundler(4);
1245
1246 query.append(_SQL_SELECT_USERGROUP_WHERE);
1247
1248 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1249
1250 if (name == null) {
1251 query.append(_FINDER_COLUMN_C_N_NAME_1);
1252 }
1253 else {
1254 if (name.equals(StringPool.BLANK)) {
1255 query.append(_FINDER_COLUMN_C_N_NAME_3);
1256 }
1257 else {
1258 query.append(_FINDER_COLUMN_C_N_NAME_2);
1259 }
1260 }
1261
1262 query.append(UserGroupModelImpl.ORDER_BY_JPQL);
1263
1264 String sql = query.toString();
1265
1266 Query q = session.createQuery(sql);
1267
1268 QueryPos qPos = QueryPos.getInstance(q);
1269
1270 qPos.add(companyId);
1271
1272 if (name != null) {
1273 qPos.add(name);
1274 }
1275
1276 List<UserGroup> list = q.list();
1277
1278 result = list;
1279
1280 UserGroup userGroup = null;
1281
1282 if (list.isEmpty()) {
1283 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1284 finderArgs, list);
1285 }
1286 else {
1287 userGroup = list.get(0);
1288
1289 cacheResult(userGroup);
1290
1291 if ((userGroup.getCompanyId() != companyId) ||
1292 (userGroup.getName() == null) ||
1293 !userGroup.getName().equals(name)) {
1294 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1295 finderArgs, userGroup);
1296 }
1297 }
1298
1299 return userGroup;
1300 }
1301 catch (Exception e) {
1302 throw processException(e);
1303 }
1304 finally {
1305 if (result == null) {
1306 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1307 finderArgs, new ArrayList<UserGroup>());
1308 }
1309
1310 closeSession(session);
1311 }
1312 }
1313 else {
1314 if (result instanceof List<?>) {
1315 return null;
1316 }
1317 else {
1318 return (UserGroup)result;
1319 }
1320 }
1321 }
1322
1323
1329 public List<UserGroup> findAll() throws SystemException {
1330 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1331 }
1332
1333
1345 public List<UserGroup> findAll(int start, int end)
1346 throws SystemException {
1347 return findAll(start, end, null);
1348 }
1349
1350
1363 public List<UserGroup> findAll(int start, int end,
1364 OrderByComparator orderByComparator) throws SystemException {
1365 Object[] finderArgs = new Object[] {
1366 String.valueOf(start), String.valueOf(end),
1367 String.valueOf(orderByComparator)
1368 };
1369
1370 List<UserGroup> list = (List<UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1371 finderArgs, this);
1372
1373 if (list == null) {
1374 Session session = null;
1375
1376 try {
1377 session = openSession();
1378
1379 StringBundler query = null;
1380 String sql = null;
1381
1382 if (orderByComparator != null) {
1383 query = new StringBundler(2 +
1384 (orderByComparator.getOrderByFields().length * 3));
1385
1386 query.append(_SQL_SELECT_USERGROUP);
1387
1388 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1389 orderByComparator);
1390
1391 sql = query.toString();
1392 }
1393 else {
1394 sql = _SQL_SELECT_USERGROUP.concat(UserGroupModelImpl.ORDER_BY_JPQL);
1395 }
1396
1397 Query q = session.createQuery(sql);
1398
1399 if (orderByComparator == null) {
1400 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
1401 start, end, false);
1402
1403 Collections.sort(list);
1404 }
1405 else {
1406 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
1407 start, end);
1408 }
1409 }
1410 catch (Exception e) {
1411 throw processException(e);
1412 }
1413 finally {
1414 if (list == null) {
1415 list = new ArrayList<UserGroup>();
1416 }
1417
1418 cacheResult(list);
1419
1420 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1421
1422 closeSession(session);
1423 }
1424 }
1425
1426 return list;
1427 }
1428
1429
1435 public void removeByCompanyId(long companyId) throws SystemException {
1436 for (UserGroup userGroup : findByCompanyId(companyId)) {
1437 remove(userGroup);
1438 }
1439 }
1440
1441
1448 public void removeByC_P(long companyId, long parentUserGroupId)
1449 throws SystemException {
1450 for (UserGroup userGroup : findByC_P(companyId, parentUserGroupId)) {
1451 remove(userGroup);
1452 }
1453 }
1454
1455
1462 public void removeByC_N(long companyId, String name)
1463 throws NoSuchUserGroupException, SystemException {
1464 UserGroup userGroup = findByC_N(companyId, name);
1465
1466 remove(userGroup);
1467 }
1468
1469
1474 public void removeAll() throws SystemException {
1475 for (UserGroup userGroup : findAll()) {
1476 remove(userGroup);
1477 }
1478 }
1479
1480
1487 public int countByCompanyId(long companyId) throws SystemException {
1488 Object[] finderArgs = new Object[] { companyId };
1489
1490 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1491 finderArgs, this);
1492
1493 if (count == null) {
1494 Session session = null;
1495
1496 try {
1497 session = openSession();
1498
1499 StringBundler query = new StringBundler(2);
1500
1501 query.append(_SQL_COUNT_USERGROUP_WHERE);
1502
1503 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1504
1505 String sql = query.toString();
1506
1507 Query q = session.createQuery(sql);
1508
1509 QueryPos qPos = QueryPos.getInstance(q);
1510
1511 qPos.add(companyId);
1512
1513 count = (Long)q.uniqueResult();
1514 }
1515 catch (Exception e) {
1516 throw processException(e);
1517 }
1518 finally {
1519 if (count == null) {
1520 count = Long.valueOf(0);
1521 }
1522
1523 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1524 finderArgs, count);
1525
1526 closeSession(session);
1527 }
1528 }
1529
1530 return count.intValue();
1531 }
1532
1533
1541 public int countByC_P(long companyId, long parentUserGroupId)
1542 throws SystemException {
1543 Object[] finderArgs = new Object[] { companyId, parentUserGroupId };
1544
1545 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
1546 finderArgs, this);
1547
1548 if (count == null) {
1549 Session session = null;
1550
1551 try {
1552 session = openSession();
1553
1554 StringBundler query = new StringBundler(3);
1555
1556 query.append(_SQL_COUNT_USERGROUP_WHERE);
1557
1558 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1559
1560 query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2);
1561
1562 String sql = query.toString();
1563
1564 Query q = session.createQuery(sql);
1565
1566 QueryPos qPos = QueryPos.getInstance(q);
1567
1568 qPos.add(companyId);
1569
1570 qPos.add(parentUserGroupId);
1571
1572 count = (Long)q.uniqueResult();
1573 }
1574 catch (Exception e) {
1575 throw processException(e);
1576 }
1577 finally {
1578 if (count == null) {
1579 count = Long.valueOf(0);
1580 }
1581
1582 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
1583 count);
1584
1585 closeSession(session);
1586 }
1587 }
1588
1589 return count.intValue();
1590 }
1591
1592
1600 public int countByC_N(long companyId, String name)
1601 throws SystemException {
1602 Object[] finderArgs = new Object[] { companyId, name };
1603
1604 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
1605 finderArgs, this);
1606
1607 if (count == null) {
1608 Session session = null;
1609
1610 try {
1611 session = openSession();
1612
1613 StringBundler query = new StringBundler(3);
1614
1615 query.append(_SQL_COUNT_USERGROUP_WHERE);
1616
1617 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1618
1619 if (name == null) {
1620 query.append(_FINDER_COLUMN_C_N_NAME_1);
1621 }
1622 else {
1623 if (name.equals(StringPool.BLANK)) {
1624 query.append(_FINDER_COLUMN_C_N_NAME_3);
1625 }
1626 else {
1627 query.append(_FINDER_COLUMN_C_N_NAME_2);
1628 }
1629 }
1630
1631 String sql = query.toString();
1632
1633 Query q = session.createQuery(sql);
1634
1635 QueryPos qPos = QueryPos.getInstance(q);
1636
1637 qPos.add(companyId);
1638
1639 if (name != null) {
1640 qPos.add(name);
1641 }
1642
1643 count = (Long)q.uniqueResult();
1644 }
1645 catch (Exception e) {
1646 throw processException(e);
1647 }
1648 finally {
1649 if (count == null) {
1650 count = Long.valueOf(0);
1651 }
1652
1653 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
1654 count);
1655
1656 closeSession(session);
1657 }
1658 }
1659
1660 return count.intValue();
1661 }
1662
1663
1669 public int countAll() throws SystemException {
1670 Object[] finderArgs = new Object[0];
1671
1672 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1673 finderArgs, this);
1674
1675 if (count == null) {
1676 Session session = null;
1677
1678 try {
1679 session = openSession();
1680
1681 Query q = session.createQuery(_SQL_COUNT_USERGROUP);
1682
1683 count = (Long)q.uniqueResult();
1684 }
1685 catch (Exception e) {
1686 throw processException(e);
1687 }
1688 finally {
1689 if (count == null) {
1690 count = Long.valueOf(0);
1691 }
1692
1693 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1694 count);
1695
1696 closeSession(session);
1697 }
1698 }
1699
1700 return count.intValue();
1701 }
1702
1703
1710 public List<com.liferay.portal.model.Group> getGroups(long pk)
1711 throws SystemException {
1712 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1713 }
1714
1715
1728 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1729 int end) throws SystemException {
1730 return getGroups(pk, start, end, null);
1731 }
1732
1733 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1734 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
1735 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
1736 "getGroups",
1737 new String[] {
1738 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1739 "com.liferay.portal.kernel.util.OrderByComparator"
1740 });
1741
1742
1756 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
1757 int end, OrderByComparator orderByComparator) throws SystemException {
1758 Object[] finderArgs = new Object[] {
1759 pk, String.valueOf(start), String.valueOf(end),
1760 String.valueOf(orderByComparator)
1761 };
1762
1763 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
1764 finderArgs, this);
1765
1766 if (list == null) {
1767 Session session = null;
1768
1769 try {
1770 session = openSession();
1771
1772 String sql = null;
1773
1774 if (orderByComparator != null) {
1775 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
1776 .concat(orderByComparator.getOrderBy());
1777 }
1778 else {
1779 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
1780 }
1781
1782 SQLQuery q = session.createSQLQuery(sql);
1783
1784 q.addEntity("Group_",
1785 com.liferay.portal.model.impl.GroupImpl.class);
1786
1787 QueryPos qPos = QueryPos.getInstance(q);
1788
1789 qPos.add(pk);
1790
1791 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
1792 getDialect(), start, end);
1793 }
1794 catch (Exception e) {
1795 throw processException(e);
1796 }
1797 finally {
1798 if (list == null) {
1799 list = new ArrayList<com.liferay.portal.model.Group>();
1800 }
1801
1802 groupPersistence.cacheResult(list);
1803
1804 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
1805 list);
1806
1807 closeSession(session);
1808 }
1809 }
1810
1811 return list;
1812 }
1813
1814 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1815 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
1816 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
1817 "getGroupsSize", new String[] { Long.class.getName() });
1818
1819
1826 public int getGroupsSize(long pk) throws SystemException {
1827 Object[] finderArgs = new Object[] { pk };
1828
1829 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
1830 finderArgs, this);
1831
1832 if (count == null) {
1833 Session session = null;
1834
1835 try {
1836 session = openSession();
1837
1838 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
1839
1840 q.addScalar(COUNT_COLUMN_NAME,
1841 com.liferay.portal.kernel.dao.orm.Type.LONG);
1842
1843 QueryPos qPos = QueryPos.getInstance(q);
1844
1845 qPos.add(pk);
1846
1847 count = (Long)q.uniqueResult();
1848 }
1849 catch (Exception e) {
1850 throw processException(e);
1851 }
1852 finally {
1853 if (count == null) {
1854 count = Long.valueOf(0);
1855 }
1856
1857 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
1858 finderArgs, count);
1859
1860 closeSession(session);
1861 }
1862 }
1863
1864 return count.intValue();
1865 }
1866
1867 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
1868 UserGroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
1869 UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
1870 "containsGroup",
1871 new String[] { Long.class.getName(), Long.class.getName() });
1872
1873
1881 public boolean containsGroup(long pk, long groupPK)
1882 throws SystemException {
1883 Object[] finderArgs = new Object[] { pk, groupPK };
1884
1885 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
1886 finderArgs, this);
1887
1888 if (value == null) {
1889 try {
1890 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
1891 }
1892 catch (Exception e) {
1893 throw processException(e);
1894 }
1895 finally {
1896 if (value == null) {
1897 value = Boolean.FALSE;
1898 }
1899
1900 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
1901 finderArgs, value);
1902 }
1903 }
1904
1905 return value.booleanValue();
1906 }
1907
1908
1915 public boolean containsGroups(long pk) throws SystemException {
1916 if (getGroupsSize(pk) > 0) {
1917 return true;
1918 }
1919 else {
1920 return false;
1921 }
1922 }
1923
1924
1931 public void addGroup(long pk, long groupPK) throws SystemException {
1932 try {
1933 addGroup.add(pk, groupPK);
1934 }
1935 catch (Exception e) {
1936 throw processException(e);
1937 }
1938 finally {
1939 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
1940 }
1941 }
1942
1943
1950 public void addGroup(long pk, com.liferay.portal.model.Group group)
1951 throws SystemException {
1952 try {
1953 addGroup.add(pk, group.getPrimaryKey());
1954 }
1955 catch (Exception e) {
1956 throw processException(e);
1957 }
1958 finally {
1959 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
1960 }
1961 }
1962
1963
1970 public void addGroups(long pk, long[] groupPKs) throws SystemException {
1971 try {
1972 for (long groupPK : groupPKs) {
1973 addGroup.add(pk, groupPK);
1974 }
1975 }
1976 catch (Exception e) {
1977 throw processException(e);
1978 }
1979 finally {
1980 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
1981 }
1982 }
1983
1984
1991 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
1992 throws SystemException {
1993 try {
1994 for (com.liferay.portal.model.Group group : groups) {
1995 addGroup.add(pk, group.getPrimaryKey());
1996 }
1997 }
1998 catch (Exception e) {
1999 throw processException(e);
2000 }
2001 finally {
2002 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2003 }
2004 }
2005
2006
2012 public void clearGroups(long pk) throws SystemException {
2013 try {
2014 clearGroups.clear(pk);
2015 }
2016 catch (Exception e) {
2017 throw processException(e);
2018 }
2019 finally {
2020 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2021 }
2022 }
2023
2024
2031 public void removeGroup(long pk, long groupPK) throws SystemException {
2032 try {
2033 removeGroup.remove(pk, groupPK);
2034 }
2035 catch (Exception e) {
2036 throw processException(e);
2037 }
2038 finally {
2039 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2040 }
2041 }
2042
2043
2050 public void removeGroup(long pk, com.liferay.portal.model.Group group)
2051 throws SystemException {
2052 try {
2053 removeGroup.remove(pk, group.getPrimaryKey());
2054 }
2055 catch (Exception e) {
2056 throw processException(e);
2057 }
2058 finally {
2059 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2060 }
2061 }
2062
2063
2070 public void removeGroups(long pk, long[] groupPKs)
2071 throws SystemException {
2072 try {
2073 for (long groupPK : groupPKs) {
2074 removeGroup.remove(pk, groupPK);
2075 }
2076 }
2077 catch (Exception e) {
2078 throw processException(e);
2079 }
2080 finally {
2081 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2082 }
2083 }
2084
2085
2092 public void removeGroups(long pk,
2093 List<com.liferay.portal.model.Group> groups) throws SystemException {
2094 try {
2095 for (com.liferay.portal.model.Group group : groups) {
2096 removeGroup.remove(pk, group.getPrimaryKey());
2097 }
2098 }
2099 catch (Exception e) {
2100 throw processException(e);
2101 }
2102 finally {
2103 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2104 }
2105 }
2106
2107
2114 public void setGroups(long pk, long[] groupPKs) throws SystemException {
2115 try {
2116 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
2117
2118 List<com.liferay.portal.model.Group> groups = getGroups(pk);
2119
2120 for (com.liferay.portal.model.Group group : groups) {
2121 if (!groupPKSet.remove(group.getPrimaryKey())) {
2122 removeGroup.remove(pk, group.getPrimaryKey());
2123 }
2124 }
2125
2126 for (Long groupPK : groupPKSet) {
2127 addGroup.add(pk, groupPK);
2128 }
2129 }
2130 catch (Exception e) {
2131 throw processException(e);
2132 }
2133 finally {
2134 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2135 }
2136 }
2137
2138
2145 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
2146 throws SystemException {
2147 try {
2148 long[] groupPKs = new long[groups.size()];
2149
2150 for (int i = 0; i < groups.size(); i++) {
2151 com.liferay.portal.model.Group group = groups.get(i);
2152
2153 groupPKs[i] = group.getPrimaryKey();
2154 }
2155
2156 setGroups(pk, groupPKs);
2157 }
2158 catch (Exception e) {
2159 throw processException(e);
2160 }
2161 finally {
2162 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
2163 }
2164 }
2165
2166
2173 public List<com.liferay.portal.model.User> getUsers(long pk)
2174 throws SystemException {
2175 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2176 }
2177
2178
2191 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2192 int end) throws SystemException {
2193 return getUsers(pk, start, end, null);
2194 }
2195
2196 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2197 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
2198 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUsers",
2199 new String[] {
2200 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2201 "com.liferay.portal.kernel.util.OrderByComparator"
2202 });
2203
2204
2218 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
2219 int end, OrderByComparator orderByComparator) throws SystemException {
2220 Object[] finderArgs = new Object[] {
2221 pk, String.valueOf(start), String.valueOf(end),
2222 String.valueOf(orderByComparator)
2223 };
2224
2225 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
2226 finderArgs, this);
2227
2228 if (list == null) {
2229 Session session = null;
2230
2231 try {
2232 session = openSession();
2233
2234 String sql = null;
2235
2236 if (orderByComparator != null) {
2237 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
2238 .concat(orderByComparator.getOrderBy());
2239 }
2240 else {
2241 sql = _SQL_GETUSERS;
2242 }
2243
2244 SQLQuery q = session.createSQLQuery(sql);
2245
2246 q.addEntity("User_",
2247 com.liferay.portal.model.impl.UserImpl.class);
2248
2249 QueryPos qPos = QueryPos.getInstance(q);
2250
2251 qPos.add(pk);
2252
2253 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
2254 getDialect(), start, end);
2255 }
2256 catch (Exception e) {
2257 throw processException(e);
2258 }
2259 finally {
2260 if (list == null) {
2261 list = new ArrayList<com.liferay.portal.model.User>();
2262 }
2263
2264 userPersistence.cacheResult(list);
2265
2266 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
2267 list);
2268
2269 closeSession(session);
2270 }
2271 }
2272
2273 return list;
2274 }
2275
2276 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2277 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
2278 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
2279 "getUsersSize", new String[] { Long.class.getName() });
2280
2281
2288 public int getUsersSize(long pk) throws SystemException {
2289 Object[] finderArgs = new Object[] { pk };
2290
2291 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
2292 finderArgs, this);
2293
2294 if (count == null) {
2295 Session session = null;
2296
2297 try {
2298 session = openSession();
2299
2300 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
2301
2302 q.addScalar(COUNT_COLUMN_NAME,
2303 com.liferay.portal.kernel.dao.orm.Type.LONG);
2304
2305 QueryPos qPos = QueryPos.getInstance(q);
2306
2307 qPos.add(pk);
2308
2309 count = (Long)q.uniqueResult();
2310 }
2311 catch (Exception e) {
2312 throw processException(e);
2313 }
2314 finally {
2315 if (count == null) {
2316 count = Long.valueOf(0);
2317 }
2318
2319 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
2320 finderArgs, count);
2321
2322 closeSession(session);
2323 }
2324 }
2325
2326 return count.intValue();
2327 }
2328
2329 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
2330 UserGroupModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
2331 UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
2332 "containsUser",
2333 new String[] { Long.class.getName(), Long.class.getName() });
2334
2335
2343 public boolean containsUser(long pk, long userPK) throws SystemException {
2344 Object[] finderArgs = new Object[] { pk, userPK };
2345
2346 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
2347 finderArgs, this);
2348
2349 if (value == null) {
2350 try {
2351 value = Boolean.valueOf(containsUser.contains(pk, userPK));
2352 }
2353 catch (Exception e) {
2354 throw processException(e);
2355 }
2356 finally {
2357 if (value == null) {
2358 value = Boolean.FALSE;
2359 }
2360
2361 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
2362 finderArgs, value);
2363 }
2364 }
2365
2366 return value.booleanValue();
2367 }
2368
2369
2376 public boolean containsUsers(long pk) throws SystemException {
2377 if (getUsersSize(pk) > 0) {
2378 return true;
2379 }
2380 else {
2381 return false;
2382 }
2383 }
2384
2385
2392 public void addUser(long pk, long userPK) throws SystemException {
2393 try {
2394 addUser.add(pk, userPK);
2395 }
2396 catch (Exception e) {
2397 throw processException(e);
2398 }
2399 finally {
2400 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2401 }
2402 }
2403
2404
2411 public void addUser(long pk, com.liferay.portal.model.User user)
2412 throws SystemException {
2413 try {
2414 addUser.add(pk, user.getPrimaryKey());
2415 }
2416 catch (Exception e) {
2417 throw processException(e);
2418 }
2419 finally {
2420 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2421 }
2422 }
2423
2424
2431 public void addUsers(long pk, long[] userPKs) throws SystemException {
2432 try {
2433 for (long userPK : userPKs) {
2434 addUser.add(pk, userPK);
2435 }
2436 }
2437 catch (Exception e) {
2438 throw processException(e);
2439 }
2440 finally {
2441 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2442 }
2443 }
2444
2445
2452 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2453 throws SystemException {
2454 try {
2455 for (com.liferay.portal.model.User user : users) {
2456 addUser.add(pk, user.getPrimaryKey());
2457 }
2458 }
2459 catch (Exception e) {
2460 throw processException(e);
2461 }
2462 finally {
2463 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2464 }
2465 }
2466
2467
2473 public void clearUsers(long pk) throws SystemException {
2474 try {
2475 clearUsers.clear(pk);
2476 }
2477 catch (Exception e) {
2478 throw processException(e);
2479 }
2480 finally {
2481 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2482 }
2483 }
2484
2485
2492 public void removeUser(long pk, long userPK) throws SystemException {
2493 try {
2494 removeUser.remove(pk, userPK);
2495 }
2496 catch (Exception e) {
2497 throw processException(e);
2498 }
2499 finally {
2500 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2501 }
2502 }
2503
2504
2511 public void removeUser(long pk, com.liferay.portal.model.User user)
2512 throws SystemException {
2513 try {
2514 removeUser.remove(pk, user.getPrimaryKey());
2515 }
2516 catch (Exception e) {
2517 throw processException(e);
2518 }
2519 finally {
2520 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2521 }
2522 }
2523
2524
2531 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2532 try {
2533 for (long userPK : userPKs) {
2534 removeUser.remove(pk, userPK);
2535 }
2536 }
2537 catch (Exception e) {
2538 throw processException(e);
2539 }
2540 finally {
2541 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2542 }
2543 }
2544
2545
2552 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2553 throws SystemException {
2554 try {
2555 for (com.liferay.portal.model.User user : users) {
2556 removeUser.remove(pk, user.getPrimaryKey());
2557 }
2558 }
2559 catch (Exception e) {
2560 throw processException(e);
2561 }
2562 finally {
2563 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2564 }
2565 }
2566
2567
2574 public void setUsers(long pk, long[] userPKs) throws SystemException {
2575 try {
2576 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2577
2578 List<com.liferay.portal.model.User> users = getUsers(pk);
2579
2580 for (com.liferay.portal.model.User user : users) {
2581 if (!userPKSet.remove(user.getPrimaryKey())) {
2582 removeUser.remove(pk, user.getPrimaryKey());
2583 }
2584 }
2585
2586 for (Long userPK : userPKSet) {
2587 addUser.add(pk, userPK);
2588 }
2589 }
2590 catch (Exception e) {
2591 throw processException(e);
2592 }
2593 finally {
2594 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2595 }
2596 }
2597
2598
2605 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2606 throws SystemException {
2607 try {
2608 long[] userPKs = new long[users.size()];
2609
2610 for (int i = 0; i < users.size(); i++) {
2611 com.liferay.portal.model.User user = users.get(i);
2612
2613 userPKs[i] = user.getPrimaryKey();
2614 }
2615
2616 setUsers(pk, userPKs);
2617 }
2618 catch (Exception e) {
2619 throw processException(e);
2620 }
2621 finally {
2622 FinderCacheUtil.clearCache(UserGroupModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
2623 }
2624 }
2625
2626
2629 public void afterPropertiesSet() {
2630 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2631 com.liferay.portal.util.PropsUtil.get(
2632 "value.object.listener.com.liferay.portal.model.UserGroup")));
2633
2634 if (listenerClassNames.length > 0) {
2635 try {
2636 List<ModelListener<UserGroup>> listenersList = new ArrayList<ModelListener<UserGroup>>();
2637
2638 for (String listenerClassName : listenerClassNames) {
2639 listenersList.add((ModelListener<UserGroup>)InstanceFactory.newInstance(
2640 listenerClassName));
2641 }
2642
2643 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2644 }
2645 catch (Exception e) {
2646 _log.error(e);
2647 }
2648 }
2649
2650 containsGroup = new ContainsGroup(this);
2651
2652 addGroup = new AddGroup(this);
2653 clearGroups = new ClearGroups(this);
2654 removeGroup = new RemoveGroup(this);
2655
2656 containsUser = new ContainsUser(this);
2657
2658 addUser = new AddUser(this);
2659 clearUsers = new ClearUsers(this);
2660 removeUser = new RemoveUser(this);
2661 }
2662
2663 @BeanReference(type = AccountPersistence.class)
2664 protected AccountPersistence accountPersistence;
2665 @BeanReference(type = AddressPersistence.class)
2666 protected AddressPersistence addressPersistence;
2667 @BeanReference(type = BrowserTrackerPersistence.class)
2668 protected BrowserTrackerPersistence browserTrackerPersistence;
2669 @BeanReference(type = ClassNamePersistence.class)
2670 protected ClassNamePersistence classNamePersistence;
2671 @BeanReference(type = ClusterGroupPersistence.class)
2672 protected ClusterGroupPersistence clusterGroupPersistence;
2673 @BeanReference(type = CompanyPersistence.class)
2674 protected CompanyPersistence companyPersistence;
2675 @BeanReference(type = ContactPersistence.class)
2676 protected ContactPersistence contactPersistence;
2677 @BeanReference(type = CountryPersistence.class)
2678 protected CountryPersistence countryPersistence;
2679 @BeanReference(type = EmailAddressPersistence.class)
2680 protected EmailAddressPersistence emailAddressPersistence;
2681 @BeanReference(type = GroupPersistence.class)
2682 protected GroupPersistence groupPersistence;
2683 @BeanReference(type = ImagePersistence.class)
2684 protected ImagePersistence imagePersistence;
2685 @BeanReference(type = LayoutPersistence.class)
2686 protected LayoutPersistence layoutPersistence;
2687 @BeanReference(type = LayoutPrototypePersistence.class)
2688 protected LayoutPrototypePersistence layoutPrototypePersistence;
2689 @BeanReference(type = LayoutSetPersistence.class)
2690 protected LayoutSetPersistence layoutSetPersistence;
2691 @BeanReference(type = LayoutSetPrototypePersistence.class)
2692 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2693 @BeanReference(type = ListTypePersistence.class)
2694 protected ListTypePersistence listTypePersistence;
2695 @BeanReference(type = LockPersistence.class)
2696 protected LockPersistence lockPersistence;
2697 @BeanReference(type = MembershipRequestPersistence.class)
2698 protected MembershipRequestPersistence membershipRequestPersistence;
2699 @BeanReference(type = OrganizationPersistence.class)
2700 protected OrganizationPersistence organizationPersistence;
2701 @BeanReference(type = OrgGroupPermissionPersistence.class)
2702 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2703 @BeanReference(type = OrgGroupRolePersistence.class)
2704 protected OrgGroupRolePersistence orgGroupRolePersistence;
2705 @BeanReference(type = OrgLaborPersistence.class)
2706 protected OrgLaborPersistence orgLaborPersistence;
2707 @BeanReference(type = PasswordPolicyPersistence.class)
2708 protected PasswordPolicyPersistence passwordPolicyPersistence;
2709 @BeanReference(type = PasswordPolicyRelPersistence.class)
2710 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2711 @BeanReference(type = PasswordTrackerPersistence.class)
2712 protected PasswordTrackerPersistence passwordTrackerPersistence;
2713 @BeanReference(type = PermissionPersistence.class)
2714 protected PermissionPersistence permissionPersistence;
2715 @BeanReference(type = PhonePersistence.class)
2716 protected PhonePersistence phonePersistence;
2717 @BeanReference(type = PluginSettingPersistence.class)
2718 protected PluginSettingPersistence pluginSettingPersistence;
2719 @BeanReference(type = PortletPersistence.class)
2720 protected PortletPersistence portletPersistence;
2721 @BeanReference(type = PortletItemPersistence.class)
2722 protected PortletItemPersistence portletItemPersistence;
2723 @BeanReference(type = PortletPreferencesPersistence.class)
2724 protected PortletPreferencesPersistence portletPreferencesPersistence;
2725 @BeanReference(type = RegionPersistence.class)
2726 protected RegionPersistence regionPersistence;
2727 @BeanReference(type = ReleasePersistence.class)
2728 protected ReleasePersistence releasePersistence;
2729 @BeanReference(type = ResourcePersistence.class)
2730 protected ResourcePersistence resourcePersistence;
2731 @BeanReference(type = ResourceActionPersistence.class)
2732 protected ResourceActionPersistence resourceActionPersistence;
2733 @BeanReference(type = ResourceCodePersistence.class)
2734 protected ResourceCodePersistence resourceCodePersistence;
2735 @BeanReference(type = ResourcePermissionPersistence.class)
2736 protected ResourcePermissionPersistence resourcePermissionPersistence;
2737 @BeanReference(type = RolePersistence.class)
2738 protected RolePersistence rolePersistence;
2739 @BeanReference(type = ServiceComponentPersistence.class)
2740 protected ServiceComponentPersistence serviceComponentPersistence;
2741 @BeanReference(type = ShardPersistence.class)
2742 protected ShardPersistence shardPersistence;
2743 @BeanReference(type = SubscriptionPersistence.class)
2744 protected SubscriptionPersistence subscriptionPersistence;
2745 @BeanReference(type = TicketPersistence.class)
2746 protected TicketPersistence ticketPersistence;
2747 @BeanReference(type = TeamPersistence.class)
2748 protected TeamPersistence teamPersistence;
2749 @BeanReference(type = UserPersistence.class)
2750 protected UserPersistence userPersistence;
2751 @BeanReference(type = UserGroupPersistence.class)
2752 protected UserGroupPersistence userGroupPersistence;
2753 @BeanReference(type = UserGroupGroupRolePersistence.class)
2754 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2755 @BeanReference(type = UserGroupRolePersistence.class)
2756 protected UserGroupRolePersistence userGroupRolePersistence;
2757 @BeanReference(type = UserIdMapperPersistence.class)
2758 protected UserIdMapperPersistence userIdMapperPersistence;
2759 @BeanReference(type = UserTrackerPersistence.class)
2760 protected UserTrackerPersistence userTrackerPersistence;
2761 @BeanReference(type = UserTrackerPathPersistence.class)
2762 protected UserTrackerPathPersistence userTrackerPathPersistence;
2763 @BeanReference(type = WebDAVPropsPersistence.class)
2764 protected WebDAVPropsPersistence webDAVPropsPersistence;
2765 @BeanReference(type = WebsitePersistence.class)
2766 protected WebsitePersistence websitePersistence;
2767 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2768 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2769 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2770 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2771 protected ContainsGroup containsGroup;
2772 protected AddGroup addGroup;
2773 protected ClearGroups clearGroups;
2774 protected RemoveGroup removeGroup;
2775 protected ContainsUser containsUser;
2776 protected AddUser addUser;
2777 protected ClearUsers clearUsers;
2778 protected RemoveUser removeUser;
2779
2780 protected class ContainsGroup {
2781 protected ContainsGroup(UserGroupPersistenceImpl persistenceImpl) {
2782 super();
2783
2784 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2785 _SQL_CONTAINSGROUP,
2786 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2787 RowMapper.COUNT);
2788 }
2789
2790 protected boolean contains(long userGroupId, long groupId) {
2791 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2792 new Long(userGroupId), new Long(groupId)
2793 });
2794
2795 if (results.size() > 0) {
2796 Integer count = results.get(0);
2797
2798 if (count.intValue() > 0) {
2799 return true;
2800 }
2801 }
2802
2803 return false;
2804 }
2805
2806 private MappingSqlQuery<Integer> _mappingSqlQuery;
2807 }
2808
2809 protected class AddGroup {
2810 protected AddGroup(UserGroupPersistenceImpl persistenceImpl) {
2811 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2812 "INSERT INTO Groups_UserGroups (userGroupId, groupId) VALUES (?, ?)",
2813 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2814 _persistenceImpl = persistenceImpl;
2815 }
2816
2817 protected void add(long userGroupId, long groupId)
2818 throws SystemException {
2819 if (!_persistenceImpl.containsGroup.contains(userGroupId, groupId)) {
2820 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2821
2822 for (ModelListener<UserGroup> listener : listeners) {
2823 listener.onBeforeAddAssociation(userGroupId,
2824 com.liferay.portal.model.Group.class.getName(), groupId);
2825 }
2826
2827 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2828 listener.onBeforeAddAssociation(groupId,
2829 UserGroup.class.getName(), userGroupId);
2830 }
2831
2832 _sqlUpdate.update(new Object[] {
2833 new Long(userGroupId), new Long(groupId)
2834 });
2835
2836 for (ModelListener<UserGroup> listener : listeners) {
2837 listener.onAfterAddAssociation(userGroupId,
2838 com.liferay.portal.model.Group.class.getName(), groupId);
2839 }
2840
2841 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2842 listener.onAfterAddAssociation(groupId,
2843 UserGroup.class.getName(), userGroupId);
2844 }
2845 }
2846 }
2847
2848 private SqlUpdate _sqlUpdate;
2849 private UserGroupPersistenceImpl _persistenceImpl;
2850 }
2851
2852 protected class ClearGroups {
2853 protected ClearGroups(UserGroupPersistenceImpl persistenceImpl) {
2854 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2855 "DELETE FROM Groups_UserGroups WHERE userGroupId = ?",
2856 new int[] { java.sql.Types.BIGINT });
2857 }
2858
2859 protected void clear(long userGroupId) throws SystemException {
2860 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2861
2862 List<com.liferay.portal.model.Group> groups = null;
2863
2864 if ((listeners.length > 0) || (groupListeners.length > 0)) {
2865 groups = getGroups(userGroupId);
2866
2867 for (com.liferay.portal.model.Group group : groups) {
2868 for (ModelListener<UserGroup> listener : listeners) {
2869 listener.onBeforeRemoveAssociation(userGroupId,
2870 com.liferay.portal.model.Group.class.getName(),
2871 group.getPrimaryKey());
2872 }
2873
2874 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2875 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
2876 UserGroup.class.getName(), userGroupId);
2877 }
2878 }
2879 }
2880
2881 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
2882
2883 if ((listeners.length > 0) || (groupListeners.length > 0)) {
2884 for (com.liferay.portal.model.Group group : groups) {
2885 for (ModelListener<UserGroup> listener : listeners) {
2886 listener.onAfterRemoveAssociation(userGroupId,
2887 com.liferay.portal.model.Group.class.getName(),
2888 group.getPrimaryKey());
2889 }
2890
2891 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2892 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
2893 UserGroup.class.getName(), userGroupId);
2894 }
2895 }
2896 }
2897 }
2898
2899 private SqlUpdate _sqlUpdate;
2900 }
2901
2902 protected class RemoveGroup {
2903 protected RemoveGroup(UserGroupPersistenceImpl persistenceImpl) {
2904 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2905 "DELETE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?",
2906 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2907 _persistenceImpl = persistenceImpl;
2908 }
2909
2910 protected void remove(long userGroupId, long groupId)
2911 throws SystemException {
2912 if (_persistenceImpl.containsGroup.contains(userGroupId, groupId)) {
2913 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
2914
2915 for (ModelListener<UserGroup> listener : listeners) {
2916 listener.onBeforeRemoveAssociation(userGroupId,
2917 com.liferay.portal.model.Group.class.getName(), groupId);
2918 }
2919
2920 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2921 listener.onBeforeRemoveAssociation(groupId,
2922 UserGroup.class.getName(), userGroupId);
2923 }
2924
2925 _sqlUpdate.update(new Object[] {
2926 new Long(userGroupId), new Long(groupId)
2927 });
2928
2929 for (ModelListener<UserGroup> listener : listeners) {
2930 listener.onAfterRemoveAssociation(userGroupId,
2931 com.liferay.portal.model.Group.class.getName(), groupId);
2932 }
2933
2934 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
2935 listener.onAfterRemoveAssociation(groupId,
2936 UserGroup.class.getName(), userGroupId);
2937 }
2938 }
2939 }
2940
2941 private SqlUpdate _sqlUpdate;
2942 private UserGroupPersistenceImpl _persistenceImpl;
2943 }
2944
2945 protected class ContainsUser {
2946 protected ContainsUser(UserGroupPersistenceImpl persistenceImpl) {
2947 super();
2948
2949 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2950 _SQL_CONTAINSUSER,
2951 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2952 RowMapper.COUNT);
2953 }
2954
2955 protected boolean contains(long userGroupId, long userId) {
2956 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2957 new Long(userGroupId), new Long(userId)
2958 });
2959
2960 if (results.size() > 0) {
2961 Integer count = results.get(0);
2962
2963 if (count.intValue() > 0) {
2964 return true;
2965 }
2966 }
2967
2968 return false;
2969 }
2970
2971 private MappingSqlQuery<Integer> _mappingSqlQuery;
2972 }
2973
2974 protected class AddUser {
2975 protected AddUser(UserGroupPersistenceImpl persistenceImpl) {
2976 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2977 "INSERT INTO Users_UserGroups (userGroupId, userId) VALUES (?, ?)",
2978 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2979 _persistenceImpl = persistenceImpl;
2980 }
2981
2982 protected void add(long userGroupId, long userId)
2983 throws SystemException {
2984 if (!_persistenceImpl.containsUser.contains(userGroupId, userId)) {
2985 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2986
2987 for (ModelListener<UserGroup> listener : listeners) {
2988 listener.onBeforeAddAssociation(userGroupId,
2989 com.liferay.portal.model.User.class.getName(), userId);
2990 }
2991
2992 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2993 listener.onBeforeAddAssociation(userId,
2994 UserGroup.class.getName(), userGroupId);
2995 }
2996
2997 _sqlUpdate.update(new Object[] {
2998 new Long(userGroupId), new Long(userId)
2999 });
3000
3001 for (ModelListener<UserGroup> listener : listeners) {
3002 listener.onAfterAddAssociation(userGroupId,
3003 com.liferay.portal.model.User.class.getName(), userId);
3004 }
3005
3006 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3007 listener.onAfterAddAssociation(userId,
3008 UserGroup.class.getName(), userGroupId);
3009 }
3010 }
3011 }
3012
3013 private SqlUpdate _sqlUpdate;
3014 private UserGroupPersistenceImpl _persistenceImpl;
3015 }
3016
3017 protected class ClearUsers {
3018 protected ClearUsers(UserGroupPersistenceImpl persistenceImpl) {
3019 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3020 "DELETE FROM Users_UserGroups WHERE userGroupId = ?",
3021 new int[] { java.sql.Types.BIGINT });
3022 }
3023
3024 protected void clear(long userGroupId) throws SystemException {
3025 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3026
3027 List<com.liferay.portal.model.User> users = null;
3028
3029 if ((listeners.length > 0) || (userListeners.length > 0)) {
3030 users = getUsers(userGroupId);
3031
3032 for (com.liferay.portal.model.User user : users) {
3033 for (ModelListener<UserGroup> listener : listeners) {
3034 listener.onBeforeRemoveAssociation(userGroupId,
3035 com.liferay.portal.model.User.class.getName(),
3036 user.getPrimaryKey());
3037 }
3038
3039 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3040 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
3041 UserGroup.class.getName(), userGroupId);
3042 }
3043 }
3044 }
3045
3046 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
3047
3048 if ((listeners.length > 0) || (userListeners.length > 0)) {
3049 for (com.liferay.portal.model.User user : users) {
3050 for (ModelListener<UserGroup> listener : listeners) {
3051 listener.onAfterRemoveAssociation(userGroupId,
3052 com.liferay.portal.model.User.class.getName(),
3053 user.getPrimaryKey());
3054 }
3055
3056 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3057 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
3058 UserGroup.class.getName(), userGroupId);
3059 }
3060 }
3061 }
3062 }
3063
3064 private SqlUpdate _sqlUpdate;
3065 }
3066
3067 protected class RemoveUser {
3068 protected RemoveUser(UserGroupPersistenceImpl persistenceImpl) {
3069 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3070 "DELETE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?",
3071 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3072 _persistenceImpl = persistenceImpl;
3073 }
3074
3075 protected void remove(long userGroupId, long userId)
3076 throws SystemException {
3077 if (_persistenceImpl.containsUser.contains(userGroupId, userId)) {
3078 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
3079
3080 for (ModelListener<UserGroup> listener : listeners) {
3081 listener.onBeforeRemoveAssociation(userGroupId,
3082 com.liferay.portal.model.User.class.getName(), userId);
3083 }
3084
3085 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3086 listener.onBeforeRemoveAssociation(userId,
3087 UserGroup.class.getName(), userGroupId);
3088 }
3089
3090 _sqlUpdate.update(new Object[] {
3091 new Long(userGroupId), new Long(userId)
3092 });
3093
3094 for (ModelListener<UserGroup> listener : listeners) {
3095 listener.onAfterRemoveAssociation(userGroupId,
3096 com.liferay.portal.model.User.class.getName(), userId);
3097 }
3098
3099 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3100 listener.onAfterRemoveAssociation(userId,
3101 UserGroup.class.getName(), userGroupId);
3102 }
3103 }
3104 }
3105
3106 private SqlUpdate _sqlUpdate;
3107 private UserGroupPersistenceImpl _persistenceImpl;
3108 }
3109
3110 private static final String _SQL_SELECT_USERGROUP = "SELECT userGroup FROM UserGroup userGroup";
3111 private static final String _SQL_SELECT_USERGROUP_WHERE = "SELECT userGroup FROM UserGroup userGroup WHERE ";
3112 private static final String _SQL_COUNT_USERGROUP = "SELECT COUNT(userGroup) FROM UserGroup userGroup";
3113 private static final String _SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(userGroup) FROM UserGroup userGroup WHERE ";
3114 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_UserGroups ON (Groups_UserGroups.groupId = Group_.groupId) WHERE (Groups_UserGroups.userGroupId = ?)";
3115 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ?";
3116 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE userGroupId = ? AND groupId = ?";
3117 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_UserGroups ON (Users_UserGroups.userId = User_.userId) WHERE (Users_UserGroups.userGroupId = ?)";
3118 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ?";
3119 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?";
3120 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userGroup.companyId = ?";
3121 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "userGroup.companyId = ? AND ";
3122 private static final String _FINDER_COLUMN_C_P_PARENTUSERGROUPID_2 = "userGroup.parentUserGroupId = ?";
3123 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "userGroup.companyId = ? AND ";
3124 private static final String _FINDER_COLUMN_C_N_NAME_1 = "userGroup.name IS NULL";
3125 private static final String _FINDER_COLUMN_C_N_NAME_2 = "userGroup.name = ?";
3126 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(userGroup.name IS NULL OR userGroup.name = ?)";
3127 private static final String _ORDER_BY_ENTITY_ALIAS = "userGroup.";
3128 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroup exists with the primary key ";
3129 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroup exists with the key {";
3130 private static Log _log = LogFactoryUtil.getLog(UserGroupPersistenceImpl.class);
3131 }