1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchUserGroupException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
29 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
30 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
31 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
32 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
33 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
34 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
35 import com.liferay.portal.kernel.dao.orm.Query;
36 import com.liferay.portal.kernel.dao.orm.QueryPos;
37 import com.liferay.portal.kernel.dao.orm.QueryUtil;
38 import com.liferay.portal.kernel.dao.orm.SQLQuery;
39 import com.liferay.portal.kernel.dao.orm.Session;
40 import com.liferay.portal.kernel.dao.orm.Type;
41 import com.liferay.portal.kernel.log.Log;
42 import com.liferay.portal.kernel.log.LogFactoryUtil;
43 import com.liferay.portal.kernel.util.GetterUtil;
44 import com.liferay.portal.kernel.util.OrderByComparator;
45 import com.liferay.portal.kernel.util.StringPool;
46 import com.liferay.portal.kernel.util.StringUtil;
47 import com.liferay.portal.model.ModelListener;
48 import com.liferay.portal.model.UserGroup;
49 import com.liferay.portal.model.impl.UserGroupImpl;
50 import com.liferay.portal.model.impl.UserGroupModelImpl;
51 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
52
53 import java.sql.Types;
54
55 import java.util.ArrayList;
56 import java.util.Collections;
57 import java.util.Iterator;
58 import java.util.List;
59
60
66 public class UserGroupPersistenceImpl extends BasePersistenceImpl
67 implements UserGroupPersistence {
68 public UserGroup create(long userGroupId) {
69 UserGroup userGroup = new UserGroupImpl();
70
71 userGroup.setNew(true);
72 userGroup.setPrimaryKey(userGroupId);
73
74 return userGroup;
75 }
76
77 public UserGroup remove(long userGroupId)
78 throws NoSuchUserGroupException, SystemException {
79 Session session = null;
80
81 try {
82 session = openSession();
83
84 UserGroup userGroup = (UserGroup)session.get(UserGroupImpl.class,
85 new Long(userGroupId));
86
87 if (userGroup == null) {
88 if (_log.isWarnEnabled()) {
89 _log.warn("No UserGroup exists with the primary key " +
90 userGroupId);
91 }
92
93 throw new NoSuchUserGroupException(
94 "No UserGroup exists with the primary key " + userGroupId);
95 }
96
97 return remove(userGroup);
98 }
99 catch (NoSuchUserGroupException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public UserGroup remove(UserGroup userGroup) throws SystemException {
111 for (ModelListener listener : listeners) {
112 listener.onBeforeRemove(userGroup);
113 }
114
115 userGroup = removeImpl(userGroup);
116
117 for (ModelListener listener : listeners) {
118 listener.onAfterRemove(userGroup);
119 }
120
121 return userGroup;
122 }
123
124 protected UserGroup removeImpl(UserGroup userGroup)
125 throws SystemException {
126 try {
127 clearUsers.clear(userGroup.getPrimaryKey());
128 }
129 catch (Exception e) {
130 throw processException(e);
131 }
132 finally {
133 FinderCacheUtil.clearCache("Users_UserGroups");
134 }
135
136 Session session = null;
137
138 try {
139 session = openSession();
140
141 if (BatchSessionUtil.isEnabled()) {
142 Object staleObject = session.get(UserGroupImpl.class,
143 userGroup.getPrimaryKeyObj());
144
145 if (staleObject != null) {
146 session.evict(staleObject);
147 }
148 }
149
150 session.delete(userGroup);
151
152 session.flush();
153
154 return userGroup;
155 }
156 catch (Exception e) {
157 throw processException(e);
158 }
159 finally {
160 closeSession(session);
161
162 FinderCacheUtil.clearCache(UserGroup.class.getName());
163 }
164 }
165
166
169 public UserGroup update(UserGroup userGroup) throws SystemException {
170 if (_log.isWarnEnabled()) {
171 _log.warn(
172 "Using the deprecated update(UserGroup userGroup) method. Use update(UserGroup userGroup, boolean merge) instead.");
173 }
174
175 return update(userGroup, false);
176 }
177
178
191 public UserGroup update(UserGroup userGroup, boolean merge)
192 throws SystemException {
193 boolean isNew = userGroup.isNew();
194
195 for (ModelListener listener : listeners) {
196 if (isNew) {
197 listener.onBeforeCreate(userGroup);
198 }
199 else {
200 listener.onBeforeUpdate(userGroup);
201 }
202 }
203
204 userGroup = updateImpl(userGroup, merge);
205
206 for (ModelListener listener : listeners) {
207 if (isNew) {
208 listener.onAfterCreate(userGroup);
209 }
210 else {
211 listener.onAfterUpdate(userGroup);
212 }
213 }
214
215 return userGroup;
216 }
217
218 public UserGroup updateImpl(com.liferay.portal.model.UserGroup userGroup,
219 boolean merge) throws SystemException {
220 FinderCacheUtil.clearCache("Users_UserGroups");
221
222 Session session = null;
223
224 try {
225 session = openSession();
226
227 BatchSessionUtil.update(session, userGroup, merge);
228
229 userGroup.setNew(false);
230
231 return userGroup;
232 }
233 catch (Exception e) {
234 throw processException(e);
235 }
236 finally {
237 closeSession(session);
238
239 FinderCacheUtil.clearCache(UserGroup.class.getName());
240 }
241 }
242
243 public UserGroup findByPrimaryKey(long userGroupId)
244 throws NoSuchUserGroupException, SystemException {
245 UserGroup userGroup = fetchByPrimaryKey(userGroupId);
246
247 if (userGroup == null) {
248 if (_log.isWarnEnabled()) {
249 _log.warn("No UserGroup exists with the primary key " +
250 userGroupId);
251 }
252
253 throw new NoSuchUserGroupException(
254 "No UserGroup exists with the primary key " + userGroupId);
255 }
256
257 return userGroup;
258 }
259
260 public UserGroup fetchByPrimaryKey(long userGroupId)
261 throws SystemException {
262 Session session = null;
263
264 try {
265 session = openSession();
266
267 return (UserGroup)session.get(UserGroupImpl.class,
268 new Long(userGroupId));
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276 }
277
278 public List<UserGroup> findByCompanyId(long companyId)
279 throws SystemException {
280 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
281 String finderClassName = UserGroup.class.getName();
282 String finderMethodName = "findByCompanyId";
283 String[] finderParams = new String[] { Long.class.getName() };
284 Object[] finderArgs = new Object[] { new Long(companyId) };
285
286 Object result = null;
287
288 if (finderClassNameCacheEnabled) {
289 result = FinderCacheUtil.getResult(finderClassName,
290 finderMethodName, finderParams, finderArgs, this);
291 }
292
293 if (result == null) {
294 Session session = null;
295
296 try {
297 session = openSession();
298
299 StringBuilder query = new StringBuilder();
300
301 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
302
303 query.append("companyId = ?");
304
305 query.append(" ");
306
307 query.append("ORDER BY ");
308
309 query.append("name ASC");
310
311 Query q = session.createQuery(query.toString());
312
313 QueryPos qPos = QueryPos.getInstance(q);
314
315 qPos.add(companyId);
316
317 List<UserGroup> list = q.list();
318
319 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
320 finderClassName, finderMethodName, finderParams,
321 finderArgs, list);
322
323 return list;
324 }
325 catch (Exception e) {
326 throw processException(e);
327 }
328 finally {
329 closeSession(session);
330 }
331 }
332 else {
333 return (List<UserGroup>)result;
334 }
335 }
336
337 public List<UserGroup> findByCompanyId(long companyId, int start, int end)
338 throws SystemException {
339 return findByCompanyId(companyId, start, end, null);
340 }
341
342 public List<UserGroup> findByCompanyId(long companyId, int start, int end,
343 OrderByComparator obc) throws SystemException {
344 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
345 String finderClassName = UserGroup.class.getName();
346 String finderMethodName = "findByCompanyId";
347 String[] finderParams = new String[] {
348 Long.class.getName(),
349
350 "java.lang.Integer", "java.lang.Integer",
351 "com.liferay.portal.kernel.util.OrderByComparator"
352 };
353 Object[] finderArgs = new Object[] {
354 new Long(companyId),
355
356 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
357 };
358
359 Object result = null;
360
361 if (finderClassNameCacheEnabled) {
362 result = FinderCacheUtil.getResult(finderClassName,
363 finderMethodName, finderParams, finderArgs, this);
364 }
365
366 if (result == null) {
367 Session session = null;
368
369 try {
370 session = openSession();
371
372 StringBuilder query = new StringBuilder();
373
374 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
375
376 query.append("companyId = ?");
377
378 query.append(" ");
379
380 if (obc != null) {
381 query.append("ORDER BY ");
382 query.append(obc.getOrderBy());
383 }
384
385 else {
386 query.append("ORDER BY ");
387
388 query.append("name ASC");
389 }
390
391 Query q = session.createQuery(query.toString());
392
393 QueryPos qPos = QueryPos.getInstance(q);
394
395 qPos.add(companyId);
396
397 List<UserGroup> list = (List<UserGroup>)QueryUtil.list(q,
398 getDialect(), start, end);
399
400 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
401 finderClassName, finderMethodName, finderParams,
402 finderArgs, list);
403
404 return list;
405 }
406 catch (Exception e) {
407 throw processException(e);
408 }
409 finally {
410 closeSession(session);
411 }
412 }
413 else {
414 return (List<UserGroup>)result;
415 }
416 }
417
418 public UserGroup findByCompanyId_First(long companyId, OrderByComparator obc)
419 throws NoSuchUserGroupException, SystemException {
420 List<UserGroup> list = findByCompanyId(companyId, 0, 1, obc);
421
422 if (list.size() == 0) {
423 StringBuilder msg = new StringBuilder();
424
425 msg.append("No UserGroup exists with the key {");
426
427 msg.append("companyId=" + companyId);
428
429 msg.append(StringPool.CLOSE_CURLY_BRACE);
430
431 throw new NoSuchUserGroupException(msg.toString());
432 }
433 else {
434 return list.get(0);
435 }
436 }
437
438 public UserGroup findByCompanyId_Last(long companyId, OrderByComparator obc)
439 throws NoSuchUserGroupException, SystemException {
440 int count = countByCompanyId(companyId);
441
442 List<UserGroup> list = findByCompanyId(companyId, count - 1, count, obc);
443
444 if (list.size() == 0) {
445 StringBuilder msg = new StringBuilder();
446
447 msg.append("No UserGroup exists with the key {");
448
449 msg.append("companyId=" + companyId);
450
451 msg.append(StringPool.CLOSE_CURLY_BRACE);
452
453 throw new NoSuchUserGroupException(msg.toString());
454 }
455 else {
456 return list.get(0);
457 }
458 }
459
460 public UserGroup[] findByCompanyId_PrevAndNext(long userGroupId,
461 long companyId, OrderByComparator obc)
462 throws NoSuchUserGroupException, SystemException {
463 UserGroup userGroup = findByPrimaryKey(userGroupId);
464
465 int count = countByCompanyId(companyId);
466
467 Session session = null;
468
469 try {
470 session = openSession();
471
472 StringBuilder query = new StringBuilder();
473
474 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
475
476 query.append("companyId = ?");
477
478 query.append(" ");
479
480 if (obc != null) {
481 query.append("ORDER BY ");
482 query.append(obc.getOrderBy());
483 }
484
485 else {
486 query.append("ORDER BY ");
487
488 query.append("name ASC");
489 }
490
491 Query q = session.createQuery(query.toString());
492
493 QueryPos qPos = QueryPos.getInstance(q);
494
495 qPos.add(companyId);
496
497 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
498 userGroup);
499
500 UserGroup[] array = new UserGroupImpl[3];
501
502 array[0] = (UserGroup)objArray[0];
503 array[1] = (UserGroup)objArray[1];
504 array[2] = (UserGroup)objArray[2];
505
506 return array;
507 }
508 catch (Exception e) {
509 throw processException(e);
510 }
511 finally {
512 closeSession(session);
513 }
514 }
515
516 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId)
517 throws SystemException {
518 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
519 String finderClassName = UserGroup.class.getName();
520 String finderMethodName = "findByC_P";
521 String[] finderParams = new String[] {
522 Long.class.getName(), Long.class.getName()
523 };
524 Object[] finderArgs = new Object[] {
525 new Long(companyId), new Long(parentUserGroupId)
526 };
527
528 Object result = null;
529
530 if (finderClassNameCacheEnabled) {
531 result = FinderCacheUtil.getResult(finderClassName,
532 finderMethodName, finderParams, finderArgs, this);
533 }
534
535 if (result == null) {
536 Session session = null;
537
538 try {
539 session = openSession();
540
541 StringBuilder query = new StringBuilder();
542
543 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
544
545 query.append("companyId = ?");
546
547 query.append(" AND ");
548
549 query.append("parentUserGroupId = ?");
550
551 query.append(" ");
552
553 query.append("ORDER BY ");
554
555 query.append("name ASC");
556
557 Query q = session.createQuery(query.toString());
558
559 QueryPos qPos = QueryPos.getInstance(q);
560
561 qPos.add(companyId);
562
563 qPos.add(parentUserGroupId);
564
565 List<UserGroup> list = q.list();
566
567 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
568 finderClassName, finderMethodName, finderParams,
569 finderArgs, list);
570
571 return list;
572 }
573 catch (Exception e) {
574 throw processException(e);
575 }
576 finally {
577 closeSession(session);
578 }
579 }
580 else {
581 return (List<UserGroup>)result;
582 }
583 }
584
585 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
586 int start, int end) throws SystemException {
587 return findByC_P(companyId, parentUserGroupId, start, end, null);
588 }
589
590 public List<UserGroup> findByC_P(long companyId, long parentUserGroupId,
591 int start, int end, OrderByComparator obc) throws SystemException {
592 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
593 String finderClassName = UserGroup.class.getName();
594 String finderMethodName = "findByC_P";
595 String[] finderParams = new String[] {
596 Long.class.getName(), Long.class.getName(),
597
598 "java.lang.Integer", "java.lang.Integer",
599 "com.liferay.portal.kernel.util.OrderByComparator"
600 };
601 Object[] finderArgs = new Object[] {
602 new Long(companyId), new Long(parentUserGroupId),
603
604 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
605 };
606
607 Object result = null;
608
609 if (finderClassNameCacheEnabled) {
610 result = FinderCacheUtil.getResult(finderClassName,
611 finderMethodName, finderParams, finderArgs, this);
612 }
613
614 if (result == null) {
615 Session session = null;
616
617 try {
618 session = openSession();
619
620 StringBuilder query = new StringBuilder();
621
622 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
623
624 query.append("companyId = ?");
625
626 query.append(" AND ");
627
628 query.append("parentUserGroupId = ?");
629
630 query.append(" ");
631
632 if (obc != null) {
633 query.append("ORDER BY ");
634 query.append(obc.getOrderBy());
635 }
636
637 else {
638 query.append("ORDER BY ");
639
640 query.append("name ASC");
641 }
642
643 Query q = session.createQuery(query.toString());
644
645 QueryPos qPos = QueryPos.getInstance(q);
646
647 qPos.add(companyId);
648
649 qPos.add(parentUserGroupId);
650
651 List<UserGroup> list = (List<UserGroup>)QueryUtil.list(q,
652 getDialect(), start, end);
653
654 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
655 finderClassName, finderMethodName, finderParams,
656 finderArgs, list);
657
658 return list;
659 }
660 catch (Exception e) {
661 throw processException(e);
662 }
663 finally {
664 closeSession(session);
665 }
666 }
667 else {
668 return (List<UserGroup>)result;
669 }
670 }
671
672 public UserGroup findByC_P_First(long companyId, long parentUserGroupId,
673 OrderByComparator obc) throws NoSuchUserGroupException, SystemException {
674 List<UserGroup> list = findByC_P(companyId, parentUserGroupId, 0, 1, obc);
675
676 if (list.size() == 0) {
677 StringBuilder msg = new StringBuilder();
678
679 msg.append("No UserGroup exists with the key {");
680
681 msg.append("companyId=" + companyId);
682
683 msg.append(", ");
684 msg.append("parentUserGroupId=" + parentUserGroupId);
685
686 msg.append(StringPool.CLOSE_CURLY_BRACE);
687
688 throw new NoSuchUserGroupException(msg.toString());
689 }
690 else {
691 return list.get(0);
692 }
693 }
694
695 public UserGroup findByC_P_Last(long companyId, long parentUserGroupId,
696 OrderByComparator obc) throws NoSuchUserGroupException, SystemException {
697 int count = countByC_P(companyId, parentUserGroupId);
698
699 List<UserGroup> list = findByC_P(companyId, parentUserGroupId,
700 count - 1, count, obc);
701
702 if (list.size() == 0) {
703 StringBuilder msg = new StringBuilder();
704
705 msg.append("No UserGroup exists with the key {");
706
707 msg.append("companyId=" + companyId);
708
709 msg.append(", ");
710 msg.append("parentUserGroupId=" + parentUserGroupId);
711
712 msg.append(StringPool.CLOSE_CURLY_BRACE);
713
714 throw new NoSuchUserGroupException(msg.toString());
715 }
716 else {
717 return list.get(0);
718 }
719 }
720
721 public UserGroup[] findByC_P_PrevAndNext(long userGroupId, long companyId,
722 long parentUserGroupId, OrderByComparator obc)
723 throws NoSuchUserGroupException, SystemException {
724 UserGroup userGroup = findByPrimaryKey(userGroupId);
725
726 int count = countByC_P(companyId, parentUserGroupId);
727
728 Session session = null;
729
730 try {
731 session = openSession();
732
733 StringBuilder query = new StringBuilder();
734
735 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
736
737 query.append("companyId = ?");
738
739 query.append(" AND ");
740
741 query.append("parentUserGroupId = ?");
742
743 query.append(" ");
744
745 if (obc != null) {
746 query.append("ORDER BY ");
747 query.append(obc.getOrderBy());
748 }
749
750 else {
751 query.append("ORDER BY ");
752
753 query.append("name ASC");
754 }
755
756 Query q = session.createQuery(query.toString());
757
758 QueryPos qPos = QueryPos.getInstance(q);
759
760 qPos.add(companyId);
761
762 qPos.add(parentUserGroupId);
763
764 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
765 userGroup);
766
767 UserGroup[] array = new UserGroupImpl[3];
768
769 array[0] = (UserGroup)objArray[0];
770 array[1] = (UserGroup)objArray[1];
771 array[2] = (UserGroup)objArray[2];
772
773 return array;
774 }
775 catch (Exception e) {
776 throw processException(e);
777 }
778 finally {
779 closeSession(session);
780 }
781 }
782
783 public UserGroup findByC_N(long companyId, String name)
784 throws NoSuchUserGroupException, SystemException {
785 UserGroup userGroup = fetchByC_N(companyId, name);
786
787 if (userGroup == null) {
788 StringBuilder msg = new StringBuilder();
789
790 msg.append("No UserGroup exists with the key {");
791
792 msg.append("companyId=" + companyId);
793
794 msg.append(", ");
795 msg.append("name=" + name);
796
797 msg.append(StringPool.CLOSE_CURLY_BRACE);
798
799 if (_log.isWarnEnabled()) {
800 _log.warn(msg.toString());
801 }
802
803 throw new NoSuchUserGroupException(msg.toString());
804 }
805
806 return userGroup;
807 }
808
809 public UserGroup fetchByC_N(long companyId, String name)
810 throws SystemException {
811 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
812 String finderClassName = UserGroup.class.getName();
813 String finderMethodName = "fetchByC_N";
814 String[] finderParams = new String[] {
815 Long.class.getName(), String.class.getName()
816 };
817 Object[] finderArgs = new Object[] { new Long(companyId), name };
818
819 Object result = null;
820
821 if (finderClassNameCacheEnabled) {
822 result = FinderCacheUtil.getResult(finderClassName,
823 finderMethodName, finderParams, finderArgs, this);
824 }
825
826 if (result == null) {
827 Session session = null;
828
829 try {
830 session = openSession();
831
832 StringBuilder query = new StringBuilder();
833
834 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
835
836 query.append("companyId = ?");
837
838 query.append(" AND ");
839
840 if (name == null) {
841 query.append("name IS NULL");
842 }
843 else {
844 query.append("name = ?");
845 }
846
847 query.append(" ");
848
849 query.append("ORDER BY ");
850
851 query.append("name ASC");
852
853 Query q = session.createQuery(query.toString());
854
855 QueryPos qPos = QueryPos.getInstance(q);
856
857 qPos.add(companyId);
858
859 if (name != null) {
860 qPos.add(name);
861 }
862
863 List<UserGroup> list = q.list();
864
865 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
866 finderClassName, finderMethodName, finderParams,
867 finderArgs, list);
868
869 if (list.size() == 0) {
870 return null;
871 }
872 else {
873 return list.get(0);
874 }
875 }
876 catch (Exception e) {
877 throw processException(e);
878 }
879 finally {
880 closeSession(session);
881 }
882 }
883 else {
884 List<UserGroup> list = (List<UserGroup>)result;
885
886 if (list.size() == 0) {
887 return null;
888 }
889 else {
890 return list.get(0);
891 }
892 }
893 }
894
895 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
896 throws SystemException {
897 Session session = null;
898
899 try {
900 session = openSession();
901
902 dynamicQuery.compile(session);
903
904 return dynamicQuery.list();
905 }
906 catch (Exception e) {
907 throw processException(e);
908 }
909 finally {
910 closeSession(session);
911 }
912 }
913
914 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
915 int start, int end) throws SystemException {
916 Session session = null;
917
918 try {
919 session = openSession();
920
921 dynamicQuery.setLimit(start, end);
922
923 dynamicQuery.compile(session);
924
925 return dynamicQuery.list();
926 }
927 catch (Exception e) {
928 throw processException(e);
929 }
930 finally {
931 closeSession(session);
932 }
933 }
934
935 public List<UserGroup> findAll() throws SystemException {
936 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
937 }
938
939 public List<UserGroup> findAll(int start, int end)
940 throws SystemException {
941 return findAll(start, end, null);
942 }
943
944 public List<UserGroup> findAll(int start, int end, OrderByComparator obc)
945 throws SystemException {
946 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
947 String finderClassName = UserGroup.class.getName();
948 String finderMethodName = "findAll";
949 String[] finderParams = new String[] {
950 "java.lang.Integer", "java.lang.Integer",
951 "com.liferay.portal.kernel.util.OrderByComparator"
952 };
953 Object[] finderArgs = new Object[] {
954 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
955 };
956
957 Object result = null;
958
959 if (finderClassNameCacheEnabled) {
960 result = FinderCacheUtil.getResult(finderClassName,
961 finderMethodName, finderParams, finderArgs, this);
962 }
963
964 if (result == null) {
965 Session session = null;
966
967 try {
968 session = openSession();
969
970 StringBuilder query = new StringBuilder();
971
972 query.append("FROM com.liferay.portal.model.UserGroup ");
973
974 if (obc != null) {
975 query.append("ORDER BY ");
976 query.append(obc.getOrderBy());
977 }
978
979 else {
980 query.append("ORDER BY ");
981
982 query.append("name ASC");
983 }
984
985 Query q = session.createQuery(query.toString());
986
987 List<UserGroup> list = null;
988
989 if (obc == null) {
990 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
991 start, end, false);
992
993 Collections.sort(list);
994 }
995 else {
996 list = (List<UserGroup>)QueryUtil.list(q, getDialect(),
997 start, end);
998 }
999
1000 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1001 finderClassName, finderMethodName, finderParams,
1002 finderArgs, list);
1003
1004 return list;
1005 }
1006 catch (Exception e) {
1007 throw processException(e);
1008 }
1009 finally {
1010 closeSession(session);
1011 }
1012 }
1013 else {
1014 return (List<UserGroup>)result;
1015 }
1016 }
1017
1018 public void removeByCompanyId(long companyId) throws SystemException {
1019 for (UserGroup userGroup : findByCompanyId(companyId)) {
1020 remove(userGroup);
1021 }
1022 }
1023
1024 public void removeByC_P(long companyId, long parentUserGroupId)
1025 throws SystemException {
1026 for (UserGroup userGroup : findByC_P(companyId, parentUserGroupId)) {
1027 remove(userGroup);
1028 }
1029 }
1030
1031 public void removeByC_N(long companyId, String name)
1032 throws NoSuchUserGroupException, SystemException {
1033 UserGroup userGroup = findByC_N(companyId, name);
1034
1035 remove(userGroup);
1036 }
1037
1038 public void removeAll() throws SystemException {
1039 for (UserGroup userGroup : findAll()) {
1040 remove(userGroup);
1041 }
1042 }
1043
1044 public int countByCompanyId(long companyId) throws SystemException {
1045 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
1046 String finderClassName = UserGroup.class.getName();
1047 String finderMethodName = "countByCompanyId";
1048 String[] finderParams = new String[] { Long.class.getName() };
1049 Object[] finderArgs = new Object[] { new Long(companyId) };
1050
1051 Object result = null;
1052
1053 if (finderClassNameCacheEnabled) {
1054 result = FinderCacheUtil.getResult(finderClassName,
1055 finderMethodName, finderParams, finderArgs, this);
1056 }
1057
1058 if (result == null) {
1059 Session session = null;
1060
1061 try {
1062 session = openSession();
1063
1064 StringBuilder query = new StringBuilder();
1065
1066 query.append("SELECT COUNT(*) ");
1067 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
1068
1069 query.append("companyId = ?");
1070
1071 query.append(" ");
1072
1073 Query q = session.createQuery(query.toString());
1074
1075 QueryPos qPos = QueryPos.getInstance(q);
1076
1077 qPos.add(companyId);
1078
1079 Long count = null;
1080
1081 Iterator<Long> itr = q.list().iterator();
1082
1083 if (itr.hasNext()) {
1084 count = itr.next();
1085 }
1086
1087 if (count == null) {
1088 count = new Long(0);
1089 }
1090
1091 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1092 finderClassName, finderMethodName, finderParams,
1093 finderArgs, count);
1094
1095 return count.intValue();
1096 }
1097 catch (Exception e) {
1098 throw processException(e);
1099 }
1100 finally {
1101 closeSession(session);
1102 }
1103 }
1104 else {
1105 return ((Long)result).intValue();
1106 }
1107 }
1108
1109 public int countByC_P(long companyId, long parentUserGroupId)
1110 throws SystemException {
1111 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
1112 String finderClassName = UserGroup.class.getName();
1113 String finderMethodName = "countByC_P";
1114 String[] finderParams = new String[] {
1115 Long.class.getName(), Long.class.getName()
1116 };
1117 Object[] finderArgs = new Object[] {
1118 new Long(companyId), new Long(parentUserGroupId)
1119 };
1120
1121 Object result = null;
1122
1123 if (finderClassNameCacheEnabled) {
1124 result = FinderCacheUtil.getResult(finderClassName,
1125 finderMethodName, finderParams, finderArgs, this);
1126 }
1127
1128 if (result == null) {
1129 Session session = null;
1130
1131 try {
1132 session = openSession();
1133
1134 StringBuilder query = new StringBuilder();
1135
1136 query.append("SELECT COUNT(*) ");
1137 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
1138
1139 query.append("companyId = ?");
1140
1141 query.append(" AND ");
1142
1143 query.append("parentUserGroupId = ?");
1144
1145 query.append(" ");
1146
1147 Query q = session.createQuery(query.toString());
1148
1149 QueryPos qPos = QueryPos.getInstance(q);
1150
1151 qPos.add(companyId);
1152
1153 qPos.add(parentUserGroupId);
1154
1155 Long count = null;
1156
1157 Iterator<Long> itr = q.list().iterator();
1158
1159 if (itr.hasNext()) {
1160 count = itr.next();
1161 }
1162
1163 if (count == null) {
1164 count = new Long(0);
1165 }
1166
1167 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1168 finderClassName, finderMethodName, finderParams,
1169 finderArgs, count);
1170
1171 return count.intValue();
1172 }
1173 catch (Exception e) {
1174 throw processException(e);
1175 }
1176 finally {
1177 closeSession(session);
1178 }
1179 }
1180 else {
1181 return ((Long)result).intValue();
1182 }
1183 }
1184
1185 public int countByC_N(long companyId, String name)
1186 throws SystemException {
1187 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
1188 String finderClassName = UserGroup.class.getName();
1189 String finderMethodName = "countByC_N";
1190 String[] finderParams = new String[] {
1191 Long.class.getName(), String.class.getName()
1192 };
1193 Object[] finderArgs = new Object[] { new Long(companyId), name };
1194
1195 Object result = null;
1196
1197 if (finderClassNameCacheEnabled) {
1198 result = FinderCacheUtil.getResult(finderClassName,
1199 finderMethodName, finderParams, finderArgs, this);
1200 }
1201
1202 if (result == null) {
1203 Session session = null;
1204
1205 try {
1206 session = openSession();
1207
1208 StringBuilder query = new StringBuilder();
1209
1210 query.append("SELECT COUNT(*) ");
1211 query.append("FROM com.liferay.portal.model.UserGroup WHERE ");
1212
1213 query.append("companyId = ?");
1214
1215 query.append(" AND ");
1216
1217 if (name == null) {
1218 query.append("name IS NULL");
1219 }
1220 else {
1221 query.append("name = ?");
1222 }
1223
1224 query.append(" ");
1225
1226 Query q = session.createQuery(query.toString());
1227
1228 QueryPos qPos = QueryPos.getInstance(q);
1229
1230 qPos.add(companyId);
1231
1232 if (name != null) {
1233 qPos.add(name);
1234 }
1235
1236 Long count = null;
1237
1238 Iterator<Long> itr = q.list().iterator();
1239
1240 if (itr.hasNext()) {
1241 count = itr.next();
1242 }
1243
1244 if (count == null) {
1245 count = new Long(0);
1246 }
1247
1248 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1249 finderClassName, finderMethodName, finderParams,
1250 finderArgs, count);
1251
1252 return count.intValue();
1253 }
1254 catch (Exception e) {
1255 throw processException(e);
1256 }
1257 finally {
1258 closeSession(session);
1259 }
1260 }
1261 else {
1262 return ((Long)result).intValue();
1263 }
1264 }
1265
1266 public int countAll() throws SystemException {
1267 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED;
1268 String finderClassName = UserGroup.class.getName();
1269 String finderMethodName = "countAll";
1270 String[] finderParams = new String[] { };
1271 Object[] finderArgs = new Object[] { };
1272
1273 Object result = null;
1274
1275 if (finderClassNameCacheEnabled) {
1276 result = FinderCacheUtil.getResult(finderClassName,
1277 finderMethodName, finderParams, finderArgs, this);
1278 }
1279
1280 if (result == null) {
1281 Session session = null;
1282
1283 try {
1284 session = openSession();
1285
1286 Query q = session.createQuery(
1287 "SELECT COUNT(*) FROM com.liferay.portal.model.UserGroup");
1288
1289 Long count = null;
1290
1291 Iterator<Long> itr = q.list().iterator();
1292
1293 if (itr.hasNext()) {
1294 count = itr.next();
1295 }
1296
1297 if (count == null) {
1298 count = new Long(0);
1299 }
1300
1301 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1302 finderClassName, finderMethodName, finderParams,
1303 finderArgs, count);
1304
1305 return count.intValue();
1306 }
1307 catch (Exception e) {
1308 throw processException(e);
1309 }
1310 finally {
1311 closeSession(session);
1312 }
1313 }
1314 else {
1315 return ((Long)result).intValue();
1316 }
1317 }
1318
1319 public List<com.liferay.portal.model.User> getUsers(long pk)
1320 throws SystemException {
1321 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1322 }
1323
1324 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1325 int end) throws SystemException {
1326 return getUsers(pk, start, end, null);
1327 }
1328
1329 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1330 int end, OrderByComparator obc) throws SystemException {
1331 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
1332
1333 String finderClassName = "Users_UserGroups";
1334
1335 String finderMethodName = "getUsers";
1336 String[] finderParams = new String[] {
1337 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1338 "com.liferay.portal.kernel.util.OrderByComparator"
1339 };
1340 Object[] finderArgs = new Object[] {
1341 new Long(pk), String.valueOf(start), String.valueOf(end),
1342 String.valueOf(obc)
1343 };
1344
1345 Object result = null;
1346
1347 if (finderClassNameCacheEnabled) {
1348 result = FinderCacheUtil.getResult(finderClassName,
1349 finderMethodName, finderParams, finderArgs, this);
1350 }
1351
1352 if (result == null) {
1353 Session session = null;
1354
1355 try {
1356 session = openSession();
1357
1358 StringBuilder sb = new StringBuilder();
1359
1360 sb.append(_SQL_GETUSERS);
1361
1362 if (obc != null) {
1363 sb.append("ORDER BY ");
1364 sb.append(obc.getOrderBy());
1365 }
1366
1367 String sql = sb.toString();
1368
1369 SQLQuery q = session.createSQLQuery(sql);
1370
1371 q.addEntity("User_",
1372 com.liferay.portal.model.impl.UserImpl.class);
1373
1374 QueryPos qPos = QueryPos.getInstance(q);
1375
1376 qPos.add(pk);
1377
1378 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1379 getDialect(), start, end);
1380
1381 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1382 finderClassName, finderMethodName, finderParams,
1383 finderArgs, list);
1384
1385 return list;
1386 }
1387 catch (Exception e) {
1388 throw processException(e);
1389 }
1390 finally {
1391 closeSession(session);
1392 }
1393 }
1394 else {
1395 return (List<com.liferay.portal.model.User>)result;
1396 }
1397 }
1398
1399 public int getUsersSize(long pk) throws SystemException {
1400 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
1401
1402 String finderClassName = "Users_UserGroups";
1403
1404 String finderMethodName = "getUsersSize";
1405 String[] finderParams = new String[] { Long.class.getName() };
1406 Object[] finderArgs = new Object[] { new Long(pk) };
1407
1408 Object result = null;
1409
1410 if (finderClassNameCacheEnabled) {
1411 result = FinderCacheUtil.getResult(finderClassName,
1412 finderMethodName, finderParams, finderArgs, this);
1413 }
1414
1415 if (result == null) {
1416 Session session = null;
1417
1418 try {
1419 session = openSession();
1420
1421 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1422
1423 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1424
1425 QueryPos qPos = QueryPos.getInstance(q);
1426
1427 qPos.add(pk);
1428
1429 Long count = null;
1430
1431 Iterator<Long> itr = q.list().iterator();
1432
1433 if (itr.hasNext()) {
1434 count = itr.next();
1435 }
1436
1437 if (count == null) {
1438 count = new Long(0);
1439 }
1440
1441 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1442 finderClassName, finderMethodName, finderParams,
1443 finderArgs, count);
1444
1445 return count.intValue();
1446 }
1447 catch (Exception e) {
1448 throw processException(e);
1449 }
1450 finally {
1451 closeSession(session);
1452 }
1453 }
1454 else {
1455 return ((Long)result).intValue();
1456 }
1457 }
1458
1459 public boolean containsUser(long pk, long userPK) throws SystemException {
1460 boolean finderClassNameCacheEnabled = UserGroupModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
1461
1462 String finderClassName = "Users_UserGroups";
1463
1464 String finderMethodName = "containsUsers";
1465 String[] finderParams = new String[] {
1466 Long.class.getName(),
1467
1468 Long.class.getName()
1469 };
1470 Object[] finderArgs = new Object[] { new Long(pk), new Long(userPK) };
1471
1472 Object result = null;
1473
1474 if (finderClassNameCacheEnabled) {
1475 result = FinderCacheUtil.getResult(finderClassName,
1476 finderMethodName, finderParams, finderArgs, this);
1477 }
1478
1479 if (result == null) {
1480 try {
1481 Boolean value = Boolean.valueOf(containsUser.contains(pk, userPK));
1482
1483 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1484 finderClassName, finderMethodName, finderParams,
1485 finderArgs, value);
1486
1487 return value.booleanValue();
1488 }
1489 catch (Exception e) {
1490 throw processException(e);
1491 }
1492 }
1493 else {
1494 return ((Boolean)result).booleanValue();
1495 }
1496 }
1497
1498 public boolean containsUsers(long pk) throws SystemException {
1499 if (getUsersSize(pk) > 0) {
1500 return true;
1501 }
1502 else {
1503 return false;
1504 }
1505 }
1506
1507 public void addUser(long pk, long userPK) throws SystemException {
1508 try {
1509 addUser.add(pk, userPK);
1510 }
1511 catch (Exception e) {
1512 throw processException(e);
1513 }
1514 finally {
1515 FinderCacheUtil.clearCache("Users_UserGroups");
1516 }
1517 }
1518
1519 public void addUser(long pk, com.liferay.portal.model.User user)
1520 throws SystemException {
1521 try {
1522 addUser.add(pk, user.getPrimaryKey());
1523 }
1524 catch (Exception e) {
1525 throw processException(e);
1526 }
1527 finally {
1528 FinderCacheUtil.clearCache("Users_UserGroups");
1529 }
1530 }
1531
1532 public void addUsers(long pk, long[] userPKs) throws SystemException {
1533 try {
1534 for (long userPK : userPKs) {
1535 addUser.add(pk, userPK);
1536 }
1537 }
1538 catch (Exception e) {
1539 throw processException(e);
1540 }
1541 finally {
1542 FinderCacheUtil.clearCache("Users_UserGroups");
1543 }
1544 }
1545
1546 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1547 throws SystemException {
1548 try {
1549 for (com.liferay.portal.model.User user : users) {
1550 addUser.add(pk, user.getPrimaryKey());
1551 }
1552 }
1553 catch (Exception e) {
1554 throw processException(e);
1555 }
1556 finally {
1557 FinderCacheUtil.clearCache("Users_UserGroups");
1558 }
1559 }
1560
1561 public void clearUsers(long pk) throws SystemException {
1562 try {
1563 clearUsers.clear(pk);
1564 }
1565 catch (Exception e) {
1566 throw processException(e);
1567 }
1568 finally {
1569 FinderCacheUtil.clearCache("Users_UserGroups");
1570 }
1571 }
1572
1573 public void removeUser(long pk, long userPK) throws SystemException {
1574 try {
1575 removeUser.remove(pk, userPK);
1576 }
1577 catch (Exception e) {
1578 throw processException(e);
1579 }
1580 finally {
1581 FinderCacheUtil.clearCache("Users_UserGroups");
1582 }
1583 }
1584
1585 public void removeUser(long pk, com.liferay.portal.model.User user)
1586 throws SystemException {
1587 try {
1588 removeUser.remove(pk, user.getPrimaryKey());
1589 }
1590 catch (Exception e) {
1591 throw processException(e);
1592 }
1593 finally {
1594 FinderCacheUtil.clearCache("Users_UserGroups");
1595 }
1596 }
1597
1598 public void removeUsers(long pk, long[] userPKs) throws SystemException {
1599 try {
1600 for (long userPK : userPKs) {
1601 removeUser.remove(pk, userPK);
1602 }
1603 }
1604 catch (Exception e) {
1605 throw processException(e);
1606 }
1607 finally {
1608 FinderCacheUtil.clearCache("Users_UserGroups");
1609 }
1610 }
1611
1612 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
1613 throws SystemException {
1614 try {
1615 for (com.liferay.portal.model.User user : users) {
1616 removeUser.remove(pk, user.getPrimaryKey());
1617 }
1618 }
1619 catch (Exception e) {
1620 throw processException(e);
1621 }
1622 finally {
1623 FinderCacheUtil.clearCache("Users_UserGroups");
1624 }
1625 }
1626
1627 public void setUsers(long pk, long[] userPKs) throws SystemException {
1628 try {
1629 clearUsers.clear(pk);
1630
1631 for (long userPK : userPKs) {
1632 addUser.add(pk, userPK);
1633 }
1634 }
1635 catch (Exception e) {
1636 throw processException(e);
1637 }
1638 finally {
1639 FinderCacheUtil.clearCache("Users_UserGroups");
1640 }
1641 }
1642
1643 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
1644 throws SystemException {
1645 try {
1646 clearUsers.clear(pk);
1647
1648 for (com.liferay.portal.model.User user : users) {
1649 addUser.add(pk, user.getPrimaryKey());
1650 }
1651 }
1652 catch (Exception e) {
1653 throw processException(e);
1654 }
1655 finally {
1656 FinderCacheUtil.clearCache("Users_UserGroups");
1657 }
1658 }
1659
1660 public void afterPropertiesSet() {
1661 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1662 com.liferay.portal.util.PropsUtil.get(
1663 "value.object.listener.com.liferay.portal.model.UserGroup")));
1664
1665 if (listenerClassNames.length > 0) {
1666 try {
1667 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1668
1669 for (String listenerClassName : listenerClassNames) {
1670 listenersList.add((ModelListener)Class.forName(
1671 listenerClassName).newInstance());
1672 }
1673
1674 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1675 }
1676 catch (Exception e) {
1677 _log.error(e);
1678 }
1679 }
1680
1681 containsUser = new ContainsUser(this);
1682
1683 addUser = new AddUser(this);
1684 clearUsers = new ClearUsers(this);
1685 removeUser = new RemoveUser(this);
1686 }
1687
1688 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1689 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1690 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1691 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1692 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1693 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1694 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1695 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1696 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1697 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1698 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1699 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1700 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1701 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1702 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1703 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1704 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1705 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1706 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1707 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1708 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1709 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1710 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1711 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1712 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1713 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1714 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1715 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1716 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1717 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1718 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1719 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1720 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1721 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1722 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1723 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1724 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1725 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1726 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1727 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1728 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1729 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1730 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1731 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1732 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1733 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1734 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1735 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1736 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1737 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1738 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1739 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1740 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1741 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1742 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1743 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1744 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1745 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1746 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1747 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1748 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1749 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1750 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1751 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1752 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1753 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1754 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1755 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1756 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1757 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1758 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1759 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1760 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1761 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1762 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1763 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1764 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1765 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1766 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1767 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1768 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1769 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1770 protected ContainsUser containsUser;
1771 protected AddUser addUser;
1772 protected ClearUsers clearUsers;
1773 protected RemoveUser removeUser;
1774
1775 protected class ContainsUser {
1776 protected ContainsUser(UserGroupPersistenceImpl persistenceImpl) {
1777 super();
1778
1779 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
1780 _SQL_CONTAINSUSER,
1781 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
1782 }
1783
1784 protected boolean contains(long userGroupId, long userId) {
1785 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
1786 new Long(userGroupId), new Long(userId)
1787 });
1788
1789 if (results.size() > 0) {
1790 Integer count = results.get(0);
1791
1792 if (count.intValue() > 0) {
1793 return true;
1794 }
1795 }
1796
1797 return false;
1798 }
1799
1800 private MappingSqlQuery _mappingSqlQuery;
1801 }
1802
1803 protected class AddUser {
1804 protected AddUser(UserGroupPersistenceImpl persistenceImpl) {
1805 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1806 "INSERT INTO Users_UserGroups (userGroupId, userId) VALUES (?, ?)",
1807 new int[] { Types.BIGINT, Types.BIGINT });
1808 _persistenceImpl = persistenceImpl;
1809 }
1810
1811 protected void add(long userGroupId, long userId)
1812 throws SystemException {
1813 if (!_persistenceImpl.containsUser.contains(userGroupId, userId)) {
1814 ModelListener[] userListeners = userPersistence.getListeners();
1815
1816 for (ModelListener listener : listeners) {
1817 listener.onBeforeAddAssociation(userGroupId,
1818 com.liferay.portal.model.User.class.getName(), userId);
1819 }
1820
1821 for (ModelListener listener : userListeners) {
1822 listener.onBeforeAddAssociation(userId,
1823 UserGroup.class.getName(), userGroupId);
1824 }
1825
1826 _sqlUpdate.update(new Object[] {
1827 new Long(userGroupId), new Long(userId)
1828 });
1829
1830 for (ModelListener listener : listeners) {
1831 listener.onAfterAddAssociation(userGroupId,
1832 com.liferay.portal.model.User.class.getName(), userId);
1833 }
1834
1835 for (ModelListener listener : userListeners) {
1836 listener.onAfterAddAssociation(userId,
1837 UserGroup.class.getName(), userGroupId);
1838 }
1839 }
1840 }
1841
1842 private SqlUpdate _sqlUpdate;
1843 private UserGroupPersistenceImpl _persistenceImpl;
1844 }
1845
1846 protected class ClearUsers {
1847 protected ClearUsers(UserGroupPersistenceImpl persistenceImpl) {
1848 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1849 "DELETE FROM Users_UserGroups WHERE userGroupId = ?",
1850 new int[] { Types.BIGINT });
1851 }
1852
1853 protected void clear(long userGroupId) throws SystemException {
1854 ModelListener[] userListeners = userPersistence.getListeners();
1855
1856 List<com.liferay.portal.model.User> users = null;
1857
1858 if ((listeners.length > 0) || (userListeners.length > 0)) {
1859 users = getUsers(userGroupId);
1860
1861 for (com.liferay.portal.model.User user : users) {
1862 for (ModelListener listener : listeners) {
1863 listener.onBeforeRemoveAssociation(userGroupId,
1864 com.liferay.portal.model.User.class.getName(),
1865 user.getPrimaryKey());
1866 }
1867
1868 for (ModelListener listener : userListeners) {
1869 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
1870 UserGroup.class.getName(), userGroupId);
1871 }
1872 }
1873 }
1874
1875 _sqlUpdate.update(new Object[] { new Long(userGroupId) });
1876
1877 if ((listeners.length > 0) || (userListeners.length > 0)) {
1878 for (com.liferay.portal.model.User user : users) {
1879 for (ModelListener listener : listeners) {
1880 listener.onAfterRemoveAssociation(userGroupId,
1881 com.liferay.portal.model.User.class.getName(),
1882 user.getPrimaryKey());
1883 }
1884
1885 for (ModelListener listener : userListeners) {
1886 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
1887 UserGroup.class.getName(), userGroupId);
1888 }
1889 }
1890 }
1891 }
1892
1893 private SqlUpdate _sqlUpdate;
1894 }
1895
1896 protected class RemoveUser {
1897 protected RemoveUser(UserGroupPersistenceImpl persistenceImpl) {
1898 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
1899 "DELETE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?",
1900 new int[] { Types.BIGINT, Types.BIGINT });
1901 _persistenceImpl = persistenceImpl;
1902 }
1903
1904 protected void remove(long userGroupId, long userId)
1905 throws SystemException {
1906 if (_persistenceImpl.containsUser.contains(userGroupId, userId)) {
1907 ModelListener[] userListeners = userPersistence.getListeners();
1908
1909 for (ModelListener listener : listeners) {
1910 listener.onBeforeRemoveAssociation(userGroupId,
1911 com.liferay.portal.model.User.class.getName(), userId);
1912 }
1913
1914 for (ModelListener listener : userListeners) {
1915 listener.onBeforeRemoveAssociation(userId,
1916 UserGroup.class.getName(), userGroupId);
1917 }
1918
1919 _sqlUpdate.update(new Object[] {
1920 new Long(userGroupId), new Long(userId)
1921 });
1922
1923 for (ModelListener listener : listeners) {
1924 listener.onAfterRemoveAssociation(userGroupId,
1925 com.liferay.portal.model.User.class.getName(), userId);
1926 }
1927
1928 for (ModelListener listener : userListeners) {
1929 listener.onAfterRemoveAssociation(userId,
1930 UserGroup.class.getName(), userGroupId);
1931 }
1932 }
1933 }
1934
1935 private SqlUpdate _sqlUpdate;
1936 private UserGroupPersistenceImpl _persistenceImpl;
1937 }
1938
1939 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_UserGroups ON (Users_UserGroups.userId = User_.userId) WHERE (Users_UserGroups.userGroupId = ?)";
1940 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ?";
1941 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userGroupId = ? AND userId = ?";
1942 private static Log _log = LogFactoryUtil.getLog(UserGroupPersistenceImpl.class);
1943}