1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchGroupException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
30 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
31 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
32 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
33 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
34 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
35 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
36 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
37 import com.liferay.portal.kernel.dao.orm.FinderPath;
38 import com.liferay.portal.kernel.dao.orm.Query;
39 import com.liferay.portal.kernel.dao.orm.QueryPos;
40 import com.liferay.portal.kernel.dao.orm.QueryUtil;
41 import com.liferay.portal.kernel.dao.orm.SQLQuery;
42 import com.liferay.portal.kernel.dao.orm.Session;
43 import com.liferay.portal.kernel.dao.orm.Type;
44 import com.liferay.portal.kernel.log.Log;
45 import com.liferay.portal.kernel.log.LogFactoryUtil;
46 import com.liferay.portal.kernel.util.GetterUtil;
47 import com.liferay.portal.kernel.util.OrderByComparator;
48 import com.liferay.portal.kernel.util.StringPool;
49 import com.liferay.portal.kernel.util.StringUtil;
50 import com.liferay.portal.kernel.util.Validator;
51 import com.liferay.portal.model.Group;
52 import com.liferay.portal.model.ModelListener;
53 import com.liferay.portal.model.impl.GroupImpl;
54 import com.liferay.portal.model.impl.GroupModelImpl;
55 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
56
57 import java.sql.Types;
58
59 import java.util.ArrayList;
60 import java.util.Collections;
61 import java.util.List;
62
63
69 public class GroupPersistenceImpl extends BasePersistenceImpl
70 implements GroupPersistence {
71 public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
72 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
73 ".List";
74 public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
75 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
76 "fetchByLiveGroupId", new String[] { Long.class.getName() });
77 public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
78 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
79 "countByLiveGroupId", new String[] { Long.class.getName() });
80 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
81 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
82 "fetchByC_N",
83 new String[] { Long.class.getName(), String.class.getName() });
84 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
85 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
86 "countByC_N",
87 new String[] { Long.class.getName(), String.class.getName() });
88 public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
89 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
90 "fetchByC_F",
91 new String[] { Long.class.getName(), String.class.getName() });
92 public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
93 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
94 "countByC_F",
95 new String[] { Long.class.getName(), String.class.getName() });
96 public static final FinderPath FINDER_PATH_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
97 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
98 "findByT_A",
99 new String[] { Integer.class.getName(), Boolean.class.getName() });
100 public static final FinderPath FINDER_PATH_FIND_BY_OBC_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
101 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
102 "findByT_A",
103 new String[] {
104 Integer.class.getName(), Boolean.class.getName(),
105
106 "java.lang.Integer", "java.lang.Integer",
107 "com.liferay.portal.kernel.util.OrderByComparator"
108 });
109 public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
110 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "countByT_A",
112 new String[] { Integer.class.getName(), Boolean.class.getName() });
113 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
114 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
115 "fetchByC_C_C",
116 new String[] {
117 Long.class.getName(), Long.class.getName(), Long.class.getName()
118 });
119 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
120 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
121 "countByC_C_C",
122 new String[] {
123 Long.class.getName(), Long.class.getName(), Long.class.getName()
124 });
125 public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
126 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
127 "fetchByC_L_N",
128 new String[] {
129 Long.class.getName(), Long.class.getName(),
130 String.class.getName()
131 });
132 public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
133 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "countByC_L_N",
135 new String[] {
136 Long.class.getName(), Long.class.getName(),
137 String.class.getName()
138 });
139 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
140 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
141 "fetchByC_C_L_N",
142 new String[] {
143 Long.class.getName(), Long.class.getName(), Long.class.getName(),
144 String.class.getName()
145 });
146 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
147 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
148 "countByC_C_L_N",
149 new String[] {
150 Long.class.getName(), Long.class.getName(), Long.class.getName(),
151 String.class.getName()
152 });
153 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
154 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
155 "findAll", new String[0]);
156 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
157 GroupModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
158 "countAll", new String[0]);
159
160 public void cacheResult(Group group) {
161 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
162 GroupImpl.class, group.getPrimaryKey(), group);
163
164 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
165 new Object[] { new Long(group.getLiveGroupId()) }, group);
166
167 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
168 new Object[] { new Long(group.getCompanyId()), group.getName() },
169 group);
170
171 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
172 new Object[] { new Long(group.getCompanyId()), group.getFriendlyURL() },
173 group);
174
175 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
176 new Object[] {
177 new Long(group.getCompanyId()), new Long(group.getClassNameId()),
178 new Long(group.getClassPK())
179 }, group);
180
181 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
182 new Object[] {
183 new Long(group.getCompanyId()), new Long(group.getLiveGroupId()),
184
185 group.getName()
186 }, group);
187
188 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
189 new Object[] {
190 new Long(group.getCompanyId()), new Long(group.getClassNameId()),
191 new Long(group.getLiveGroupId()),
192
193 group.getName()
194 }, group);
195 }
196
197 public void cacheResult(List<Group> groups) {
198 for (Group group : groups) {
199 if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
200 GroupImpl.class, group.getPrimaryKey(), this) == null) {
201 cacheResult(group);
202 }
203 }
204 }
205
206 public void clearCache() {
207 CacheRegistry.clear(GroupImpl.class.getName());
208 EntityCacheUtil.clearCache(GroupImpl.class.getName());
209 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
211 }
212
213 public Group create(long groupId) {
214 Group group = new GroupImpl();
215
216 group.setNew(true);
217 group.setPrimaryKey(groupId);
218
219 return group;
220 }
221
222 public Group remove(long groupId)
223 throws NoSuchGroupException, SystemException {
224 Session session = null;
225
226 try {
227 session = openSession();
228
229 Group group = (Group)session.get(GroupImpl.class, new Long(groupId));
230
231 if (group == null) {
232 if (_log.isWarnEnabled()) {
233 _log.warn("No Group exists with the primary key " +
234 groupId);
235 }
236
237 throw new NoSuchGroupException(
238 "No Group exists with the primary key " + groupId);
239 }
240
241 return remove(group);
242 }
243 catch (NoSuchGroupException nsee) {
244 throw nsee;
245 }
246 catch (Exception e) {
247 throw processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252 }
253
254 public Group remove(Group group) throws SystemException {
255 for (ModelListener<Group> listener : listeners) {
256 listener.onBeforeRemove(group);
257 }
258
259 group = removeImpl(group);
260
261 for (ModelListener<Group> listener : listeners) {
262 listener.onAfterRemove(group);
263 }
264
265 return group;
266 }
267
268 protected Group removeImpl(Group group) throws SystemException {
269 try {
270 clearOrganizations.clear(group.getPrimaryKey());
271 }
272 catch (Exception e) {
273 throw processException(e);
274 }
275 finally {
276 FinderCacheUtil.clearCache("Groups_Orgs");
277 }
278
279 try {
280 clearPermissions.clear(group.getPrimaryKey());
281 }
282 catch (Exception e) {
283 throw processException(e);
284 }
285 finally {
286 FinderCacheUtil.clearCache("Groups_Permissions");
287 }
288
289 try {
290 clearRoles.clear(group.getPrimaryKey());
291 }
292 catch (Exception e) {
293 throw processException(e);
294 }
295 finally {
296 FinderCacheUtil.clearCache("Groups_Roles");
297 }
298
299 try {
300 clearUserGroups.clear(group.getPrimaryKey());
301 }
302 catch (Exception e) {
303 throw processException(e);
304 }
305 finally {
306 FinderCacheUtil.clearCache("Groups_UserGroups");
307 }
308
309 try {
310 clearUsers.clear(group.getPrimaryKey());
311 }
312 catch (Exception e) {
313 throw processException(e);
314 }
315 finally {
316 FinderCacheUtil.clearCache("Users_Groups");
317 }
318
319 Session session = null;
320
321 try {
322 session = openSession();
323
324 if (group.isCachedModel() || BatchSessionUtil.isEnabled()) {
325 Object staleObject = session.get(GroupImpl.class,
326 group.getPrimaryKeyObj());
327
328 if (staleObject != null) {
329 session.evict(staleObject);
330 }
331 }
332
333 session.delete(group);
334
335 session.flush();
336 }
337 catch (Exception e) {
338 throw processException(e);
339 }
340 finally {
341 closeSession(session);
342 }
343
344 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
345
346 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
347
348 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
349 new Object[] { new Long(groupModelImpl.getOriginalLiveGroupId()) });
350
351 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
352 new Object[] {
353 new Long(groupModelImpl.getOriginalCompanyId()),
354
355 groupModelImpl.getOriginalName()
356 });
357
358 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
359 new Object[] {
360 new Long(groupModelImpl.getOriginalCompanyId()),
361
362 groupModelImpl.getOriginalFriendlyURL()
363 });
364
365 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
366 new Object[] {
367 new Long(groupModelImpl.getOriginalCompanyId()),
368 new Long(groupModelImpl.getOriginalClassNameId()),
369 new Long(groupModelImpl.getOriginalClassPK())
370 });
371
372 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
373 new Object[] {
374 new Long(groupModelImpl.getOriginalCompanyId()),
375 new Long(groupModelImpl.getOriginalLiveGroupId()),
376
377 groupModelImpl.getOriginalName()
378 });
379
380 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
381 new Object[] {
382 new Long(groupModelImpl.getOriginalCompanyId()),
383 new Long(groupModelImpl.getOriginalClassNameId()),
384 new Long(groupModelImpl.getOriginalLiveGroupId()),
385
386 groupModelImpl.getOriginalName()
387 });
388
389 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
390 GroupImpl.class, group.getPrimaryKey());
391
392 return group;
393 }
394
395
398 public Group update(Group group) throws SystemException {
399 if (_log.isWarnEnabled()) {
400 _log.warn(
401 "Using the deprecated update(Group group) method. Use update(Group group, boolean merge) instead.");
402 }
403
404 return update(group, false);
405 }
406
407
420 public Group update(Group group, boolean merge) throws SystemException {
421 boolean isNew = group.isNew();
422
423 for (ModelListener<Group> listener : listeners) {
424 if (isNew) {
425 listener.onBeforeCreate(group);
426 }
427 else {
428 listener.onBeforeUpdate(group);
429 }
430 }
431
432 group = updateImpl(group, merge);
433
434 for (ModelListener<Group> listener : listeners) {
435 if (isNew) {
436 listener.onAfterCreate(group);
437 }
438 else {
439 listener.onAfterUpdate(group);
440 }
441 }
442
443 return group;
444 }
445
446 public Group updateImpl(com.liferay.portal.model.Group group, boolean merge)
447 throws SystemException {
448 boolean isNew = group.isNew();
449
450 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
451
452 Session session = null;
453
454 try {
455 session = openSession();
456
457 BatchSessionUtil.update(session, group, merge);
458
459 group.setNew(false);
460 }
461 catch (Exception e) {
462 throw processException(e);
463 }
464 finally {
465 closeSession(session);
466 }
467
468 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
469
470 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
471 GroupImpl.class, group.getPrimaryKey(), group);
472
473 if (!isNew &&
474 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId())) {
475 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
476 new Object[] { new Long(groupModelImpl.getOriginalLiveGroupId()) });
477 }
478
479 if (isNew ||
480 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId())) {
481 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
482 new Object[] { new Long(group.getLiveGroupId()) }, group);
483 }
484
485 if (!isNew &&
486 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
487 !Validator.equals(group.getName(),
488 groupModelImpl.getOriginalName()))) {
489 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
490 new Object[] {
491 new Long(groupModelImpl.getOriginalCompanyId()),
492
493 groupModelImpl.getOriginalName()
494 });
495 }
496
497 if (isNew ||
498 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
499 !Validator.equals(group.getName(),
500 groupModelImpl.getOriginalName()))) {
501 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
502 new Object[] { new Long(group.getCompanyId()), group.getName() },
503 group);
504 }
505
506 if (!isNew &&
507 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
508 !Validator.equals(group.getFriendlyURL(),
509 groupModelImpl.getOriginalFriendlyURL()))) {
510 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
511 new Object[] {
512 new Long(groupModelImpl.getOriginalCompanyId()),
513
514 groupModelImpl.getOriginalFriendlyURL()
515 });
516 }
517
518 if (isNew ||
519 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
520 !Validator.equals(group.getFriendlyURL(),
521 groupModelImpl.getOriginalFriendlyURL()))) {
522 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
523 new Object[] {
524 new Long(group.getCompanyId()),
525
526 group.getFriendlyURL()
527 }, group);
528 }
529
530 if (!isNew &&
531 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
532 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
533 (group.getClassPK() != groupModelImpl.getOriginalClassPK()))) {
534 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
535 new Object[] {
536 new Long(groupModelImpl.getOriginalCompanyId()),
537 new Long(groupModelImpl.getOriginalClassNameId()),
538 new Long(groupModelImpl.getOriginalClassPK())
539 });
540 }
541
542 if (isNew ||
543 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
544 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
545 (group.getClassPK() != groupModelImpl.getOriginalClassPK()))) {
546 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
547 new Object[] {
548 new Long(group.getCompanyId()),
549 new Long(group.getClassNameId()),
550 new Long(group.getClassPK())
551 }, group);
552 }
553
554 if (!isNew &&
555 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
556 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
557 !Validator.equals(group.getName(),
558 groupModelImpl.getOriginalName()))) {
559 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
560 new Object[] {
561 new Long(groupModelImpl.getOriginalCompanyId()),
562 new Long(groupModelImpl.getOriginalLiveGroupId()),
563
564 groupModelImpl.getOriginalName()
565 });
566 }
567
568 if (isNew ||
569 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
570 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
571 !Validator.equals(group.getName(),
572 groupModelImpl.getOriginalName()))) {
573 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
574 new Object[] {
575 new Long(group.getCompanyId()),
576 new Long(group.getLiveGroupId()),
577
578 group.getName()
579 }, group);
580 }
581
582 if (!isNew &&
583 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
584 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
585 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
586 !Validator.equals(group.getName(),
587 groupModelImpl.getOriginalName()))) {
588 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
589 new Object[] {
590 new Long(groupModelImpl.getOriginalCompanyId()),
591 new Long(groupModelImpl.getOriginalClassNameId()),
592 new Long(groupModelImpl.getOriginalLiveGroupId()),
593
594 groupModelImpl.getOriginalName()
595 });
596 }
597
598 if (isNew ||
599 ((group.getCompanyId() != groupModelImpl.getOriginalCompanyId()) ||
600 (group.getClassNameId() != groupModelImpl.getOriginalClassNameId()) ||
601 (group.getLiveGroupId() != groupModelImpl.getOriginalLiveGroupId()) ||
602 !Validator.equals(group.getName(),
603 groupModelImpl.getOriginalName()))) {
604 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
605 new Object[] {
606 new Long(group.getCompanyId()),
607 new Long(group.getClassNameId()),
608 new Long(group.getLiveGroupId()),
609
610 group.getName()
611 }, group);
612 }
613
614 return group;
615 }
616
617 public Group findByPrimaryKey(long groupId)
618 throws NoSuchGroupException, SystemException {
619 Group group = fetchByPrimaryKey(groupId);
620
621 if (group == null) {
622 if (_log.isWarnEnabled()) {
623 _log.warn("No Group exists with the primary key " + groupId);
624 }
625
626 throw new NoSuchGroupException(
627 "No Group exists with the primary key " + groupId);
628 }
629
630 return group;
631 }
632
633 public Group fetchByPrimaryKey(long groupId) throws SystemException {
634 Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
635 GroupImpl.class, groupId, this);
636
637 if (group == null) {
638 Session session = null;
639
640 try {
641 session = openSession();
642
643 group = (Group)session.get(GroupImpl.class, new Long(groupId));
644 }
645 catch (Exception e) {
646 throw processException(e);
647 }
648 finally {
649 if (group != null) {
650 cacheResult(group);
651 }
652
653 closeSession(session);
654 }
655 }
656
657 return group;
658 }
659
660 public Group findByLiveGroupId(long liveGroupId)
661 throws NoSuchGroupException, SystemException {
662 Group group = fetchByLiveGroupId(liveGroupId);
663
664 if (group == null) {
665 StringBuilder msg = new StringBuilder();
666
667 msg.append("No Group exists with the key {");
668
669 msg.append("liveGroupId=" + liveGroupId);
670
671 msg.append(StringPool.CLOSE_CURLY_BRACE);
672
673 if (_log.isWarnEnabled()) {
674 _log.warn(msg.toString());
675 }
676
677 throw new NoSuchGroupException(msg.toString());
678 }
679
680 return group;
681 }
682
683 public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
684 return fetchByLiveGroupId(liveGroupId, true);
685 }
686
687 public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
688 throws SystemException {
689 Object[] finderArgs = new Object[] { new Long(liveGroupId) };
690
691 Object result = null;
692
693 if (retrieveFromCache) {
694 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
695 finderArgs, this);
696 }
697
698 if (result == null) {
699 Session session = null;
700
701 try {
702 session = openSession();
703
704 StringBuilder query = new StringBuilder();
705
706 query.append("SELECT group_ FROM Group group_ WHERE ");
707
708 query.append("group_.liveGroupId = ?");
709
710 query.append(" ");
711
712 query.append("ORDER BY ");
713
714 query.append("group_.name ASC");
715
716 Query q = session.createQuery(query.toString());
717
718 QueryPos qPos = QueryPos.getInstance(q);
719
720 qPos.add(liveGroupId);
721
722 List<Group> list = q.list();
723
724 result = list;
725
726 Group group = null;
727
728 if (list.isEmpty()) {
729 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
730 finderArgs, list);
731 }
732 else {
733 group = list.get(0);
734
735 cacheResult(group);
736
737 if ((group.getLiveGroupId() != liveGroupId)) {
738 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
739 finderArgs, group);
740 }
741 }
742
743 return group;
744 }
745 catch (Exception e) {
746 throw processException(e);
747 }
748 finally {
749 if (result == null) {
750 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
751 finderArgs, new ArrayList<Group>());
752 }
753
754 closeSession(session);
755 }
756 }
757 else {
758 if (result instanceof List) {
759 return null;
760 }
761 else {
762 return (Group)result;
763 }
764 }
765 }
766
767 public Group findByC_N(long companyId, String name)
768 throws NoSuchGroupException, SystemException {
769 Group group = fetchByC_N(companyId, name);
770
771 if (group == null) {
772 StringBuilder msg = new StringBuilder();
773
774 msg.append("No Group exists with the key {");
775
776 msg.append("companyId=" + companyId);
777
778 msg.append(", ");
779 msg.append("name=" + name);
780
781 msg.append(StringPool.CLOSE_CURLY_BRACE);
782
783 if (_log.isWarnEnabled()) {
784 _log.warn(msg.toString());
785 }
786
787 throw new NoSuchGroupException(msg.toString());
788 }
789
790 return group;
791 }
792
793 public Group fetchByC_N(long companyId, String name)
794 throws SystemException {
795 return fetchByC_N(companyId, name, true);
796 }
797
798 public Group fetchByC_N(long companyId, String name,
799 boolean retrieveFromCache) throws SystemException {
800 Object[] finderArgs = new Object[] { new Long(companyId), name };
801
802 Object result = null;
803
804 if (retrieveFromCache) {
805 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
806 finderArgs, this);
807 }
808
809 if (result == null) {
810 Session session = null;
811
812 try {
813 session = openSession();
814
815 StringBuilder query = new StringBuilder();
816
817 query.append("SELECT group_ FROM Group group_ WHERE ");
818
819 query.append("group_.companyId = ?");
820
821 query.append(" AND ");
822
823 if (name == null) {
824 query.append("group_.name IS NULL");
825 }
826 else {
827 query.append("group_.name = ?");
828 }
829
830 query.append(" ");
831
832 query.append("ORDER BY ");
833
834 query.append("group_.name ASC");
835
836 Query q = session.createQuery(query.toString());
837
838 QueryPos qPos = QueryPos.getInstance(q);
839
840 qPos.add(companyId);
841
842 if (name != null) {
843 qPos.add(name);
844 }
845
846 List<Group> list = q.list();
847
848 result = list;
849
850 Group group = null;
851
852 if (list.isEmpty()) {
853 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
854 finderArgs, list);
855 }
856 else {
857 group = list.get(0);
858
859 cacheResult(group);
860
861 if ((group.getCompanyId() != companyId) ||
862 (group.getName() == null) ||
863 !group.getName().equals(name)) {
864 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
865 finderArgs, group);
866 }
867 }
868
869 return group;
870 }
871 catch (Exception e) {
872 throw processException(e);
873 }
874 finally {
875 if (result == null) {
876 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
877 finderArgs, new ArrayList<Group>());
878 }
879
880 closeSession(session);
881 }
882 }
883 else {
884 if (result instanceof List) {
885 return null;
886 }
887 else {
888 return (Group)result;
889 }
890 }
891 }
892
893 public Group findByC_F(long companyId, String friendlyURL)
894 throws NoSuchGroupException, SystemException {
895 Group group = fetchByC_F(companyId, friendlyURL);
896
897 if (group == null) {
898 StringBuilder msg = new StringBuilder();
899
900 msg.append("No Group exists with the key {");
901
902 msg.append("companyId=" + companyId);
903
904 msg.append(", ");
905 msg.append("friendlyURL=" + friendlyURL);
906
907 msg.append(StringPool.CLOSE_CURLY_BRACE);
908
909 if (_log.isWarnEnabled()) {
910 _log.warn(msg.toString());
911 }
912
913 throw new NoSuchGroupException(msg.toString());
914 }
915
916 return group;
917 }
918
919 public Group fetchByC_F(long companyId, String friendlyURL)
920 throws SystemException {
921 return fetchByC_F(companyId, friendlyURL, true);
922 }
923
924 public Group fetchByC_F(long companyId, String friendlyURL,
925 boolean retrieveFromCache) throws SystemException {
926 Object[] finderArgs = new Object[] { new Long(companyId), friendlyURL };
927
928 Object result = null;
929
930 if (retrieveFromCache) {
931 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
932 finderArgs, this);
933 }
934
935 if (result == null) {
936 Session session = null;
937
938 try {
939 session = openSession();
940
941 StringBuilder query = new StringBuilder();
942
943 query.append("SELECT group_ FROM Group group_ WHERE ");
944
945 query.append("group_.companyId = ?");
946
947 query.append(" AND ");
948
949 if (friendlyURL == null) {
950 query.append("group_.friendlyURL IS NULL");
951 }
952 else {
953 query.append("group_.friendlyURL = ?");
954 }
955
956 query.append(" ");
957
958 query.append("ORDER BY ");
959
960 query.append("group_.name ASC");
961
962 Query q = session.createQuery(query.toString());
963
964 QueryPos qPos = QueryPos.getInstance(q);
965
966 qPos.add(companyId);
967
968 if (friendlyURL != null) {
969 qPos.add(friendlyURL);
970 }
971
972 List<Group> list = q.list();
973
974 result = list;
975
976 Group group = null;
977
978 if (list.isEmpty()) {
979 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
980 finderArgs, list);
981 }
982 else {
983 group = list.get(0);
984
985 cacheResult(group);
986
987 if ((group.getCompanyId() != companyId) ||
988 (group.getFriendlyURL() == null) ||
989 !group.getFriendlyURL().equals(friendlyURL)) {
990 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
991 finderArgs, group);
992 }
993 }
994
995 return group;
996 }
997 catch (Exception e) {
998 throw processException(e);
999 }
1000 finally {
1001 if (result == null) {
1002 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1003 finderArgs, new ArrayList<Group>());
1004 }
1005
1006 closeSession(session);
1007 }
1008 }
1009 else {
1010 if (result instanceof List) {
1011 return null;
1012 }
1013 else {
1014 return (Group)result;
1015 }
1016 }
1017 }
1018
1019 public List<Group> findByT_A(int type, boolean active)
1020 throws SystemException {
1021 Object[] finderArgs = new Object[] {
1022 new Integer(type), Boolean.valueOf(active)
1023 };
1024
1025 List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_T_A,
1026 finderArgs, this);
1027
1028 if (list == null) {
1029 Session session = null;
1030
1031 try {
1032 session = openSession();
1033
1034 StringBuilder query = new StringBuilder();
1035
1036 query.append("SELECT group_ FROM Group group_ WHERE ");
1037
1038 query.append("group_.type = ?");
1039
1040 query.append(" AND ");
1041
1042 query.append("group_.active = ?");
1043
1044 query.append(" ");
1045
1046 query.append("ORDER BY ");
1047
1048 query.append("group_.name ASC");
1049
1050 Query q = session.createQuery(query.toString());
1051
1052 QueryPos qPos = QueryPos.getInstance(q);
1053
1054 qPos.add(type);
1055
1056 qPos.add(active);
1057
1058 list = q.list();
1059 }
1060 catch (Exception e) {
1061 throw processException(e);
1062 }
1063 finally {
1064 if (list == null) {
1065 list = new ArrayList<Group>();
1066 }
1067
1068 cacheResult(list);
1069
1070 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_T_A, finderArgs,
1071 list);
1072
1073 closeSession(session);
1074 }
1075 }
1076
1077 return list;
1078 }
1079
1080 public List<Group> findByT_A(int type, boolean active, int start, int end)
1081 throws SystemException {
1082 return findByT_A(type, active, start, end, null);
1083 }
1084
1085 public List<Group> findByT_A(int type, boolean active, int start, int end,
1086 OrderByComparator obc) throws SystemException {
1087 Object[] finderArgs = new Object[] {
1088 new Integer(type), Boolean.valueOf(active),
1089
1090 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1091 };
1092
1093 List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_T_A,
1094 finderArgs, this);
1095
1096 if (list == null) {
1097 Session session = null;
1098
1099 try {
1100 session = openSession();
1101
1102 StringBuilder query = new StringBuilder();
1103
1104 query.append("SELECT group_ FROM Group group_ WHERE ");
1105
1106 query.append("group_.type = ?");
1107
1108 query.append(" AND ");
1109
1110 query.append("group_.active = ?");
1111
1112 query.append(" ");
1113
1114 if (obc != null) {
1115 query.append("ORDER BY ");
1116
1117 String[] orderByFields = obc.getOrderByFields();
1118
1119 for (int i = 0; i < orderByFields.length; i++) {
1120 query.append("group_.");
1121 query.append(orderByFields[i]);
1122
1123 if (obc.isAscending()) {
1124 query.append(" ASC");
1125 }
1126 else {
1127 query.append(" DESC");
1128 }
1129
1130 if ((i + 1) < orderByFields.length) {
1131 query.append(", ");
1132 }
1133 }
1134 }
1135
1136 else {
1137 query.append("ORDER BY ");
1138
1139 query.append("group_.name ASC");
1140 }
1141
1142 Query q = session.createQuery(query.toString());
1143
1144 QueryPos qPos = QueryPos.getInstance(q);
1145
1146 qPos.add(type);
1147
1148 qPos.add(active);
1149
1150 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1151 }
1152 catch (Exception e) {
1153 throw processException(e);
1154 }
1155 finally {
1156 if (list == null) {
1157 list = new ArrayList<Group>();
1158 }
1159
1160 cacheResult(list);
1161
1162 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_T_A,
1163 finderArgs, list);
1164
1165 closeSession(session);
1166 }
1167 }
1168
1169 return list;
1170 }
1171
1172 public Group findByT_A_First(int type, boolean active, OrderByComparator obc)
1173 throws NoSuchGroupException, SystemException {
1174 List<Group> list = findByT_A(type, active, 0, 1, obc);
1175
1176 if (list.isEmpty()) {
1177 StringBuilder msg = new StringBuilder();
1178
1179 msg.append("No Group exists with the key {");
1180
1181 msg.append("type=" + type);
1182
1183 msg.append(", ");
1184 msg.append("active=" + active);
1185
1186 msg.append(StringPool.CLOSE_CURLY_BRACE);
1187
1188 throw new NoSuchGroupException(msg.toString());
1189 }
1190 else {
1191 return list.get(0);
1192 }
1193 }
1194
1195 public Group findByT_A_Last(int type, boolean active, OrderByComparator obc)
1196 throws NoSuchGroupException, SystemException {
1197 int count = countByT_A(type, active);
1198
1199 List<Group> list = findByT_A(type, active, count - 1, count, obc);
1200
1201 if (list.isEmpty()) {
1202 StringBuilder msg = new StringBuilder();
1203
1204 msg.append("No Group exists with the key {");
1205
1206 msg.append("type=" + type);
1207
1208 msg.append(", ");
1209 msg.append("active=" + active);
1210
1211 msg.append(StringPool.CLOSE_CURLY_BRACE);
1212
1213 throw new NoSuchGroupException(msg.toString());
1214 }
1215 else {
1216 return list.get(0);
1217 }
1218 }
1219
1220 public Group[] findByT_A_PrevAndNext(long groupId, int type,
1221 boolean active, OrderByComparator obc)
1222 throws NoSuchGroupException, SystemException {
1223 Group group = findByPrimaryKey(groupId);
1224
1225 int count = countByT_A(type, active);
1226
1227 Session session = null;
1228
1229 try {
1230 session = openSession();
1231
1232 StringBuilder query = new StringBuilder();
1233
1234 query.append("SELECT group_ FROM Group group_ WHERE ");
1235
1236 query.append("group_.type = ?");
1237
1238 query.append(" AND ");
1239
1240 query.append("group_.active = ?");
1241
1242 query.append(" ");
1243
1244 if (obc != null) {
1245 query.append("ORDER BY ");
1246
1247 String[] orderByFields = obc.getOrderByFields();
1248
1249 for (int i = 0; i < orderByFields.length; i++) {
1250 query.append("group_.");
1251 query.append(orderByFields[i]);
1252
1253 if (obc.isAscending()) {
1254 query.append(" ASC");
1255 }
1256 else {
1257 query.append(" DESC");
1258 }
1259
1260 if ((i + 1) < orderByFields.length) {
1261 query.append(", ");
1262 }
1263 }
1264 }
1265
1266 else {
1267 query.append("ORDER BY ");
1268
1269 query.append("group_.name ASC");
1270 }
1271
1272 Query q = session.createQuery(query.toString());
1273
1274 QueryPos qPos = QueryPos.getInstance(q);
1275
1276 qPos.add(type);
1277
1278 qPos.add(active);
1279
1280 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, group);
1281
1282 Group[] array = new GroupImpl[3];
1283
1284 array[0] = (Group)objArray[0];
1285 array[1] = (Group)objArray[1];
1286 array[2] = (Group)objArray[2];
1287
1288 return array;
1289 }
1290 catch (Exception e) {
1291 throw processException(e);
1292 }
1293 finally {
1294 closeSession(session);
1295 }
1296 }
1297
1298 public Group findByC_C_C(long companyId, long classNameId, long classPK)
1299 throws NoSuchGroupException, SystemException {
1300 Group group = fetchByC_C_C(companyId, classNameId, classPK);
1301
1302 if (group == null) {
1303 StringBuilder msg = new StringBuilder();
1304
1305 msg.append("No Group exists with the key {");
1306
1307 msg.append("companyId=" + companyId);
1308
1309 msg.append(", ");
1310 msg.append("classNameId=" + classNameId);
1311
1312 msg.append(", ");
1313 msg.append("classPK=" + classPK);
1314
1315 msg.append(StringPool.CLOSE_CURLY_BRACE);
1316
1317 if (_log.isWarnEnabled()) {
1318 _log.warn(msg.toString());
1319 }
1320
1321 throw new NoSuchGroupException(msg.toString());
1322 }
1323
1324 return group;
1325 }
1326
1327 public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
1328 throws SystemException {
1329 return fetchByC_C_C(companyId, classNameId, classPK, true);
1330 }
1331
1332 public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
1333 boolean retrieveFromCache) throws SystemException {
1334 Object[] finderArgs = new Object[] {
1335 new Long(companyId), new Long(classNameId), new Long(classPK)
1336 };
1337
1338 Object result = null;
1339
1340 if (retrieveFromCache) {
1341 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
1342 finderArgs, this);
1343 }
1344
1345 if (result == null) {
1346 Session session = null;
1347
1348 try {
1349 session = openSession();
1350
1351 StringBuilder query = new StringBuilder();
1352
1353 query.append("SELECT group_ FROM Group group_ WHERE ");
1354
1355 query.append("group_.companyId = ?");
1356
1357 query.append(" AND ");
1358
1359 query.append("group_.classNameId = ?");
1360
1361 query.append(" AND ");
1362
1363 query.append("group_.classPK = ?");
1364
1365 query.append(" ");
1366
1367 query.append("ORDER BY ");
1368
1369 query.append("group_.name ASC");
1370
1371 Query q = session.createQuery(query.toString());
1372
1373 QueryPos qPos = QueryPos.getInstance(q);
1374
1375 qPos.add(companyId);
1376
1377 qPos.add(classNameId);
1378
1379 qPos.add(classPK);
1380
1381 List<Group> list = q.list();
1382
1383 result = list;
1384
1385 Group group = null;
1386
1387 if (list.isEmpty()) {
1388 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1389 finderArgs, list);
1390 }
1391 else {
1392 group = list.get(0);
1393
1394 cacheResult(group);
1395
1396 if ((group.getCompanyId() != companyId) ||
1397 (group.getClassNameId() != classNameId) ||
1398 (group.getClassPK() != classPK)) {
1399 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1400 finderArgs, group);
1401 }
1402 }
1403
1404 return group;
1405 }
1406 catch (Exception e) {
1407 throw processException(e);
1408 }
1409 finally {
1410 if (result == null) {
1411 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
1412 finderArgs, new ArrayList<Group>());
1413 }
1414
1415 closeSession(session);
1416 }
1417 }
1418 else {
1419 if (result instanceof List) {
1420 return null;
1421 }
1422 else {
1423 return (Group)result;
1424 }
1425 }
1426 }
1427
1428 public Group findByC_L_N(long companyId, long liveGroupId, String name)
1429 throws NoSuchGroupException, SystemException {
1430 Group group = fetchByC_L_N(companyId, liveGroupId, name);
1431
1432 if (group == null) {
1433 StringBuilder msg = new StringBuilder();
1434
1435 msg.append("No Group exists with the key {");
1436
1437 msg.append("companyId=" + companyId);
1438
1439 msg.append(", ");
1440 msg.append("liveGroupId=" + liveGroupId);
1441
1442 msg.append(", ");
1443 msg.append("name=" + name);
1444
1445 msg.append(StringPool.CLOSE_CURLY_BRACE);
1446
1447 if (_log.isWarnEnabled()) {
1448 _log.warn(msg.toString());
1449 }
1450
1451 throw new NoSuchGroupException(msg.toString());
1452 }
1453
1454 return group;
1455 }
1456
1457 public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
1458 throws SystemException {
1459 return fetchByC_L_N(companyId, liveGroupId, name, true);
1460 }
1461
1462 public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
1463 boolean retrieveFromCache) throws SystemException {
1464 Object[] finderArgs = new Object[] {
1465 new Long(companyId), new Long(liveGroupId),
1466
1467 name
1468 };
1469
1470 Object result = null;
1471
1472 if (retrieveFromCache) {
1473 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
1474 finderArgs, this);
1475 }
1476
1477 if (result == null) {
1478 Session session = null;
1479
1480 try {
1481 session = openSession();
1482
1483 StringBuilder query = new StringBuilder();
1484
1485 query.append("SELECT group_ FROM Group group_ WHERE ");
1486
1487 query.append("group_.companyId = ?");
1488
1489 query.append(" AND ");
1490
1491 query.append("group_.liveGroupId = ?");
1492
1493 query.append(" AND ");
1494
1495 if (name == null) {
1496 query.append("group_.name IS NULL");
1497 }
1498 else {
1499 query.append("group_.name = ?");
1500 }
1501
1502 query.append(" ");
1503
1504 query.append("ORDER BY ");
1505
1506 query.append("group_.name ASC");
1507
1508 Query q = session.createQuery(query.toString());
1509
1510 QueryPos qPos = QueryPos.getInstance(q);
1511
1512 qPos.add(companyId);
1513
1514 qPos.add(liveGroupId);
1515
1516 if (name != null) {
1517 qPos.add(name);
1518 }
1519
1520 List<Group> list = q.list();
1521
1522 result = list;
1523
1524 Group group = null;
1525
1526 if (list.isEmpty()) {
1527 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
1528 finderArgs, list);
1529 }
1530 else {
1531 group = list.get(0);
1532
1533 cacheResult(group);
1534
1535 if ((group.getCompanyId() != companyId) ||
1536 (group.getLiveGroupId() != liveGroupId) ||
1537 (group.getName() == null) ||
1538 !group.getName().equals(name)) {
1539 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
1540 finderArgs, group);
1541 }
1542 }
1543
1544 return group;
1545 }
1546 catch (Exception e) {
1547 throw processException(e);
1548 }
1549 finally {
1550 if (result == null) {
1551 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
1552 finderArgs, new ArrayList<Group>());
1553 }
1554
1555 closeSession(session);
1556 }
1557 }
1558 else {
1559 if (result instanceof List) {
1560 return null;
1561 }
1562 else {
1563 return (Group)result;
1564 }
1565 }
1566 }
1567
1568 public Group findByC_C_L_N(long companyId, long classNameId,
1569 long liveGroupId, String name)
1570 throws NoSuchGroupException, SystemException {
1571 Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
1572
1573 if (group == null) {
1574 StringBuilder msg = new StringBuilder();
1575
1576 msg.append("No Group exists with the key {");
1577
1578 msg.append("companyId=" + companyId);
1579
1580 msg.append(", ");
1581 msg.append("classNameId=" + classNameId);
1582
1583 msg.append(", ");
1584 msg.append("liveGroupId=" + liveGroupId);
1585
1586 msg.append(", ");
1587 msg.append("name=" + name);
1588
1589 msg.append(StringPool.CLOSE_CURLY_BRACE);
1590
1591 if (_log.isWarnEnabled()) {
1592 _log.warn(msg.toString());
1593 }
1594
1595 throw new NoSuchGroupException(msg.toString());
1596 }
1597
1598 return group;
1599 }
1600
1601 public Group fetchByC_C_L_N(long companyId, long classNameId,
1602 long liveGroupId, String name) throws SystemException {
1603 return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
1604 }
1605
1606 public Group fetchByC_C_L_N(long companyId, long classNameId,
1607 long liveGroupId, String name, boolean retrieveFromCache)
1608 throws SystemException {
1609 Object[] finderArgs = new Object[] {
1610 new Long(companyId), new Long(classNameId),
1611 new Long(liveGroupId),
1612
1613 name
1614 };
1615
1616 Object result = null;
1617
1618 if (retrieveFromCache) {
1619 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1620 finderArgs, this);
1621 }
1622
1623 if (result == null) {
1624 Session session = null;
1625
1626 try {
1627 session = openSession();
1628
1629 StringBuilder query = new StringBuilder();
1630
1631 query.append("SELECT group_ FROM Group group_ WHERE ");
1632
1633 query.append("group_.companyId = ?");
1634
1635 query.append(" AND ");
1636
1637 query.append("group_.classNameId = ?");
1638
1639 query.append(" AND ");
1640
1641 query.append("group_.liveGroupId = ?");
1642
1643 query.append(" AND ");
1644
1645 if (name == null) {
1646 query.append("group_.name IS NULL");
1647 }
1648 else {
1649 query.append("group_.name = ?");
1650 }
1651
1652 query.append(" ");
1653
1654 query.append("ORDER BY ");
1655
1656 query.append("group_.name ASC");
1657
1658 Query q = session.createQuery(query.toString());
1659
1660 QueryPos qPos = QueryPos.getInstance(q);
1661
1662 qPos.add(companyId);
1663
1664 qPos.add(classNameId);
1665
1666 qPos.add(liveGroupId);
1667
1668 if (name != null) {
1669 qPos.add(name);
1670 }
1671
1672 List<Group> list = q.list();
1673
1674 result = list;
1675
1676 Group group = null;
1677
1678 if (list.isEmpty()) {
1679 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1680 finderArgs, list);
1681 }
1682 else {
1683 group = list.get(0);
1684
1685 cacheResult(group);
1686
1687 if ((group.getCompanyId() != companyId) ||
1688 (group.getClassNameId() != classNameId) ||
1689 (group.getLiveGroupId() != liveGroupId) ||
1690 (group.getName() == null) ||
1691 !group.getName().equals(name)) {
1692 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1693 finderArgs, group);
1694 }
1695 }
1696
1697 return group;
1698 }
1699 catch (Exception e) {
1700 throw processException(e);
1701 }
1702 finally {
1703 if (result == null) {
1704 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
1705 finderArgs, new ArrayList<Group>());
1706 }
1707
1708 closeSession(session);
1709 }
1710 }
1711 else {
1712 if (result instanceof List) {
1713 return null;
1714 }
1715 else {
1716 return (Group)result;
1717 }
1718 }
1719 }
1720
1721 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1722 throws SystemException {
1723 Session session = null;
1724
1725 try {
1726 session = openSession();
1727
1728 dynamicQuery.compile(session);
1729
1730 return dynamicQuery.list();
1731 }
1732 catch (Exception e) {
1733 throw processException(e);
1734 }
1735 finally {
1736 closeSession(session);
1737 }
1738 }
1739
1740 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1741 int start, int end) throws SystemException {
1742 Session session = null;
1743
1744 try {
1745 session = openSession();
1746
1747 dynamicQuery.setLimit(start, end);
1748
1749 dynamicQuery.compile(session);
1750
1751 return dynamicQuery.list();
1752 }
1753 catch (Exception e) {
1754 throw processException(e);
1755 }
1756 finally {
1757 closeSession(session);
1758 }
1759 }
1760
1761 public List<Group> findAll() throws SystemException {
1762 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1763 }
1764
1765 public List<Group> findAll(int start, int end) throws SystemException {
1766 return findAll(start, end, null);
1767 }
1768
1769 public List<Group> findAll(int start, int end, OrderByComparator obc)
1770 throws SystemException {
1771 Object[] finderArgs = new Object[] {
1772 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1773 };
1774
1775 List<Group> list = (List<Group>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1776 finderArgs, this);
1777
1778 if (list == null) {
1779 Session session = null;
1780
1781 try {
1782 session = openSession();
1783
1784 StringBuilder query = new StringBuilder();
1785
1786 query.append("SELECT group_ FROM Group group_ ");
1787
1788 if (obc != null) {
1789 query.append("ORDER BY ");
1790
1791 String[] orderByFields = obc.getOrderByFields();
1792
1793 for (int i = 0; i < orderByFields.length; i++) {
1794 query.append("group_.");
1795 query.append(orderByFields[i]);
1796
1797 if (obc.isAscending()) {
1798 query.append(" ASC");
1799 }
1800 else {
1801 query.append(" DESC");
1802 }
1803
1804 if ((i + 1) < orderByFields.length) {
1805 query.append(", ");
1806 }
1807 }
1808 }
1809
1810 else {
1811 query.append("ORDER BY ");
1812
1813 query.append("group_.name ASC");
1814 }
1815
1816 Query q = session.createQuery(query.toString());
1817
1818 if (obc == null) {
1819 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1820 end, false);
1821
1822 Collections.sort(list);
1823 }
1824 else {
1825 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
1826 end);
1827 }
1828 }
1829 catch (Exception e) {
1830 throw processException(e);
1831 }
1832 finally {
1833 if (list == null) {
1834 list = new ArrayList<Group>();
1835 }
1836
1837 cacheResult(list);
1838
1839 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1840
1841 closeSession(session);
1842 }
1843 }
1844
1845 return list;
1846 }
1847
1848 public void removeByLiveGroupId(long liveGroupId)
1849 throws NoSuchGroupException, SystemException {
1850 Group group = findByLiveGroupId(liveGroupId);
1851
1852 remove(group);
1853 }
1854
1855 public void removeByC_N(long companyId, String name)
1856 throws NoSuchGroupException, SystemException {
1857 Group group = findByC_N(companyId, name);
1858
1859 remove(group);
1860 }
1861
1862 public void removeByC_F(long companyId, String friendlyURL)
1863 throws NoSuchGroupException, SystemException {
1864 Group group = findByC_F(companyId, friendlyURL);
1865
1866 remove(group);
1867 }
1868
1869 public void removeByT_A(int type, boolean active) throws SystemException {
1870 for (Group group : findByT_A(type, active)) {
1871 remove(group);
1872 }
1873 }
1874
1875 public void removeByC_C_C(long companyId, long classNameId, long classPK)
1876 throws NoSuchGroupException, SystemException {
1877 Group group = findByC_C_C(companyId, classNameId, classPK);
1878
1879 remove(group);
1880 }
1881
1882 public void removeByC_L_N(long companyId, long liveGroupId, String name)
1883 throws NoSuchGroupException, SystemException {
1884 Group group = findByC_L_N(companyId, liveGroupId, name);
1885
1886 remove(group);
1887 }
1888
1889 public void removeByC_C_L_N(long companyId, long classNameId,
1890 long liveGroupId, String name)
1891 throws NoSuchGroupException, SystemException {
1892 Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
1893
1894 remove(group);
1895 }
1896
1897 public void removeAll() throws SystemException {
1898 for (Group group : findAll()) {
1899 remove(group);
1900 }
1901 }
1902
1903 public int countByLiveGroupId(long liveGroupId) throws SystemException {
1904 Object[] finderArgs = new Object[] { new Long(liveGroupId) };
1905
1906 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
1907 finderArgs, this);
1908
1909 if (count == null) {
1910 Session session = null;
1911
1912 try {
1913 session = openSession();
1914
1915 StringBuilder query = new StringBuilder();
1916
1917 query.append("SELECT COUNT(group_) ");
1918 query.append("FROM Group group_ WHERE ");
1919
1920 query.append("group_.liveGroupId = ?");
1921
1922 query.append(" ");
1923
1924 Query q = session.createQuery(query.toString());
1925
1926 QueryPos qPos = QueryPos.getInstance(q);
1927
1928 qPos.add(liveGroupId);
1929
1930 count = (Long)q.uniqueResult();
1931 }
1932 catch (Exception e) {
1933 throw processException(e);
1934 }
1935 finally {
1936 if (count == null) {
1937 count = Long.valueOf(0);
1938 }
1939
1940 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
1941 finderArgs, count);
1942
1943 closeSession(session);
1944 }
1945 }
1946
1947 return count.intValue();
1948 }
1949
1950 public int countByC_N(long companyId, String name)
1951 throws SystemException {
1952 Object[] finderArgs = new Object[] { new Long(companyId), name };
1953
1954 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
1955 finderArgs, this);
1956
1957 if (count == null) {
1958 Session session = null;
1959
1960 try {
1961 session = openSession();
1962
1963 StringBuilder query = new StringBuilder();
1964
1965 query.append("SELECT COUNT(group_) ");
1966 query.append("FROM Group group_ WHERE ");
1967
1968 query.append("group_.companyId = ?");
1969
1970 query.append(" AND ");
1971
1972 if (name == null) {
1973 query.append("group_.name IS NULL");
1974 }
1975 else {
1976 query.append("group_.name = ?");
1977 }
1978
1979 query.append(" ");
1980
1981 Query q = session.createQuery(query.toString());
1982
1983 QueryPos qPos = QueryPos.getInstance(q);
1984
1985 qPos.add(companyId);
1986
1987 if (name != null) {
1988 qPos.add(name);
1989 }
1990
1991 count = (Long)q.uniqueResult();
1992 }
1993 catch (Exception e) {
1994 throw processException(e);
1995 }
1996 finally {
1997 if (count == null) {
1998 count = Long.valueOf(0);
1999 }
2000
2001 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2002 count);
2003
2004 closeSession(session);
2005 }
2006 }
2007
2008 return count.intValue();
2009 }
2010
2011 public int countByC_F(long companyId, String friendlyURL)
2012 throws SystemException {
2013 Object[] finderArgs = new Object[] { new Long(companyId), friendlyURL };
2014
2015 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
2016 finderArgs, this);
2017
2018 if (count == null) {
2019 Session session = null;
2020
2021 try {
2022 session = openSession();
2023
2024 StringBuilder query = new StringBuilder();
2025
2026 query.append("SELECT COUNT(group_) ");
2027 query.append("FROM Group group_ WHERE ");
2028
2029 query.append("group_.companyId = ?");
2030
2031 query.append(" AND ");
2032
2033 if (friendlyURL == null) {
2034 query.append("group_.friendlyURL IS NULL");
2035 }
2036 else {
2037 query.append("group_.friendlyURL = ?");
2038 }
2039
2040 query.append(" ");
2041
2042 Query q = session.createQuery(query.toString());
2043
2044 QueryPos qPos = QueryPos.getInstance(q);
2045
2046 qPos.add(companyId);
2047
2048 if (friendlyURL != null) {
2049 qPos.add(friendlyURL);
2050 }
2051
2052 count = (Long)q.uniqueResult();
2053 }
2054 catch (Exception e) {
2055 throw processException(e);
2056 }
2057 finally {
2058 if (count == null) {
2059 count = Long.valueOf(0);
2060 }
2061
2062 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
2063 count);
2064
2065 closeSession(session);
2066 }
2067 }
2068
2069 return count.intValue();
2070 }
2071
2072 public int countByT_A(int type, boolean active) throws SystemException {
2073 Object[] finderArgs = new Object[] {
2074 new Integer(type), Boolean.valueOf(active)
2075 };
2076
2077 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
2078 finderArgs, this);
2079
2080 if (count == null) {
2081 Session session = null;
2082
2083 try {
2084 session = openSession();
2085
2086 StringBuilder query = new StringBuilder();
2087
2088 query.append("SELECT COUNT(group_) ");
2089 query.append("FROM Group group_ WHERE ");
2090
2091 query.append("group_.type = ?");
2092
2093 query.append(" AND ");
2094
2095 query.append("group_.active = ?");
2096
2097 query.append(" ");
2098
2099 Query q = session.createQuery(query.toString());
2100
2101 QueryPos qPos = QueryPos.getInstance(q);
2102
2103 qPos.add(type);
2104
2105 qPos.add(active);
2106
2107 count = (Long)q.uniqueResult();
2108 }
2109 catch (Exception e) {
2110 throw processException(e);
2111 }
2112 finally {
2113 if (count == null) {
2114 count = Long.valueOf(0);
2115 }
2116
2117 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
2118 count);
2119
2120 closeSession(session);
2121 }
2122 }
2123
2124 return count.intValue();
2125 }
2126
2127 public int countByC_C_C(long companyId, long classNameId, long classPK)
2128 throws SystemException {
2129 Object[] finderArgs = new Object[] {
2130 new Long(companyId), new Long(classNameId), new Long(classPK)
2131 };
2132
2133 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
2134 finderArgs, this);
2135
2136 if (count == null) {
2137 Session session = null;
2138
2139 try {
2140 session = openSession();
2141
2142 StringBuilder query = new StringBuilder();
2143
2144 query.append("SELECT COUNT(group_) ");
2145 query.append("FROM Group group_ WHERE ");
2146
2147 query.append("group_.companyId = ?");
2148
2149 query.append(" AND ");
2150
2151 query.append("group_.classNameId = ?");
2152
2153 query.append(" AND ");
2154
2155 query.append("group_.classPK = ?");
2156
2157 query.append(" ");
2158
2159 Query q = session.createQuery(query.toString());
2160
2161 QueryPos qPos = QueryPos.getInstance(q);
2162
2163 qPos.add(companyId);
2164
2165 qPos.add(classNameId);
2166
2167 qPos.add(classPK);
2168
2169 count = (Long)q.uniqueResult();
2170 }
2171 catch (Exception e) {
2172 throw processException(e);
2173 }
2174 finally {
2175 if (count == null) {
2176 count = Long.valueOf(0);
2177 }
2178
2179 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
2180 finderArgs, count);
2181
2182 closeSession(session);
2183 }
2184 }
2185
2186 return count.intValue();
2187 }
2188
2189 public int countByC_L_N(long companyId, long liveGroupId, String name)
2190 throws SystemException {
2191 Object[] finderArgs = new Object[] {
2192 new Long(companyId), new Long(liveGroupId),
2193
2194 name
2195 };
2196
2197 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L_N,
2198 finderArgs, this);
2199
2200 if (count == null) {
2201 Session session = null;
2202
2203 try {
2204 session = openSession();
2205
2206 StringBuilder query = new StringBuilder();
2207
2208 query.append("SELECT COUNT(group_) ");
2209 query.append("FROM Group group_ WHERE ");
2210
2211 query.append("group_.companyId = ?");
2212
2213 query.append(" AND ");
2214
2215 query.append("group_.liveGroupId = ?");
2216
2217 query.append(" AND ");
2218
2219 if (name == null) {
2220 query.append("group_.name IS NULL");
2221 }
2222 else {
2223 query.append("group_.name = ?");
2224 }
2225
2226 query.append(" ");
2227
2228 Query q = session.createQuery(query.toString());
2229
2230 QueryPos qPos = QueryPos.getInstance(q);
2231
2232 qPos.add(companyId);
2233
2234 qPos.add(liveGroupId);
2235
2236 if (name != null) {
2237 qPos.add(name);
2238 }
2239
2240 count = (Long)q.uniqueResult();
2241 }
2242 catch (Exception e) {
2243 throw processException(e);
2244 }
2245 finally {
2246 if (count == null) {
2247 count = Long.valueOf(0);
2248 }
2249
2250 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N,
2251 finderArgs, count);
2252
2253 closeSession(session);
2254 }
2255 }
2256
2257 return count.intValue();
2258 }
2259
2260 public int countByC_C_L_N(long companyId, long classNameId,
2261 long liveGroupId, String name) throws SystemException {
2262 Object[] finderArgs = new Object[] {
2263 new Long(companyId), new Long(classNameId),
2264 new Long(liveGroupId),
2265
2266 name
2267 };
2268
2269 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_L_N,
2270 finderArgs, this);
2271
2272 if (count == null) {
2273 Session session = null;
2274
2275 try {
2276 session = openSession();
2277
2278 StringBuilder query = new StringBuilder();
2279
2280 query.append("SELECT COUNT(group_) ");
2281 query.append("FROM Group group_ WHERE ");
2282
2283 query.append("group_.companyId = ?");
2284
2285 query.append(" AND ");
2286
2287 query.append("group_.classNameId = ?");
2288
2289 query.append(" AND ");
2290
2291 query.append("group_.liveGroupId = ?");
2292
2293 query.append(" AND ");
2294
2295 if (name == null) {
2296 query.append("group_.name IS NULL");
2297 }
2298 else {
2299 query.append("group_.name = ?");
2300 }
2301
2302 query.append(" ");
2303
2304 Query q = session.createQuery(query.toString());
2305
2306 QueryPos qPos = QueryPos.getInstance(q);
2307
2308 qPos.add(companyId);
2309
2310 qPos.add(classNameId);
2311
2312 qPos.add(liveGroupId);
2313
2314 if (name != null) {
2315 qPos.add(name);
2316 }
2317
2318 count = (Long)q.uniqueResult();
2319 }
2320 catch (Exception e) {
2321 throw processException(e);
2322 }
2323 finally {
2324 if (count == null) {
2325 count = Long.valueOf(0);
2326 }
2327
2328 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N,
2329 finderArgs, count);
2330
2331 closeSession(session);
2332 }
2333 }
2334
2335 return count.intValue();
2336 }
2337
2338 public int countAll() throws SystemException {
2339 Object[] finderArgs = new Object[0];
2340
2341 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2342 finderArgs, this);
2343
2344 if (count == null) {
2345 Session session = null;
2346
2347 try {
2348 session = openSession();
2349
2350 Query q = session.createQuery(
2351 "SELECT COUNT(group_) FROM Group group_");
2352
2353 count = (Long)q.uniqueResult();
2354 }
2355 catch (Exception e) {
2356 throw processException(e);
2357 }
2358 finally {
2359 if (count == null) {
2360 count = Long.valueOf(0);
2361 }
2362
2363 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2364 count);
2365
2366 closeSession(session);
2367 }
2368 }
2369
2370 return count.intValue();
2371 }
2372
2373 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
2374 throws SystemException {
2375 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2376 }
2377
2378 public List<com.liferay.portal.model.Organization> getOrganizations(
2379 long pk, int start, int end) throws SystemException {
2380 return getOrganizations(pk, start, end, null);
2381 }
2382
2383 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2384 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, "Groups_Orgs",
2385 "getOrganizations",
2386 new String[] {
2387 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2388 "com.liferay.portal.kernel.util.OrderByComparator"
2389 });
2390
2391 public List<com.liferay.portal.model.Organization> getOrganizations(
2392 long pk, int start, int end, OrderByComparator obc)
2393 throws SystemException {
2394 Object[] finderArgs = new Object[] {
2395 new Long(pk), String.valueOf(start), String.valueOf(end),
2396 String.valueOf(obc)
2397 };
2398
2399 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
2400 finderArgs, this);
2401
2402 if (list == null) {
2403 Session session = null;
2404
2405 try {
2406 session = openSession();
2407
2408 StringBuilder sb = new StringBuilder();
2409
2410 sb.append(_SQL_GETORGANIZATIONS);
2411
2412 if (obc != null) {
2413 sb.append("ORDER BY ");
2414 sb.append(obc.getOrderBy());
2415 }
2416
2417 else {
2418 sb.append("ORDER BY ");
2419
2420 sb.append("Organization_.name ASC");
2421 }
2422
2423 String sql = sb.toString();
2424
2425 SQLQuery q = session.createSQLQuery(sql);
2426
2427 q.addEntity("Organization_",
2428 com.liferay.portal.model.impl.OrganizationImpl.class);
2429
2430 QueryPos qPos = QueryPos.getInstance(q);
2431
2432 qPos.add(pk);
2433
2434 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
2435 getDialect(), start, end);
2436 }
2437 catch (Exception e) {
2438 throw processException(e);
2439 }
2440 finally {
2441 if (list == null) {
2442 list = new ArrayList<com.liferay.portal.model.Organization>();
2443 }
2444
2445 organizationPersistence.cacheResult(list);
2446
2447 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
2448 finderArgs, list);
2449
2450 closeSession(session);
2451 }
2452 }
2453
2454 return list;
2455 }
2456
2457 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2458 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, "Groups_Orgs",
2459 "getOrganizationsSize", new String[] { Long.class.getName() });
2460
2461 public int getOrganizationsSize(long pk) throws SystemException {
2462 Object[] finderArgs = new Object[] { new Long(pk) };
2463
2464 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
2465 finderArgs, this);
2466
2467 if (count == null) {
2468 Session session = null;
2469
2470 try {
2471 session = openSession();
2472
2473 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
2474
2475 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2476
2477 QueryPos qPos = QueryPos.getInstance(q);
2478
2479 qPos.add(pk);
2480
2481 count = (Long)q.uniqueResult();
2482 }
2483 catch (Exception e) {
2484 throw processException(e);
2485 }
2486 finally {
2487 if (count == null) {
2488 count = Long.valueOf(0);
2489 }
2490
2491 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
2492 finderArgs, count);
2493
2494 closeSession(session);
2495 }
2496 }
2497
2498 return count.intValue();
2499 }
2500
2501 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2502 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, "Groups_Orgs",
2503 "containsOrganization",
2504 new String[] { Long.class.getName(), Long.class.getName() });
2505
2506 public boolean containsOrganization(long pk, long organizationPK)
2507 throws SystemException {
2508 Object[] finderArgs = new Object[] {
2509 new Long(pk),
2510
2511 new Long(organizationPK)
2512 };
2513
2514 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
2515 finderArgs, this);
2516
2517 if (value == null) {
2518 try {
2519 value = Boolean.valueOf(containsOrganization.contains(pk,
2520 organizationPK));
2521 }
2522 catch (Exception e) {
2523 throw processException(e);
2524 }
2525 finally {
2526 if (value == null) {
2527 value = Boolean.FALSE;
2528 }
2529
2530 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
2531 finderArgs, value);
2532 }
2533 }
2534
2535 return value.booleanValue();
2536 }
2537
2538 public boolean containsOrganizations(long pk) throws SystemException {
2539 if (getOrganizationsSize(pk) > 0) {
2540 return true;
2541 }
2542 else {
2543 return false;
2544 }
2545 }
2546
2547 public void addOrganization(long pk, long organizationPK)
2548 throws SystemException {
2549 try {
2550 addOrganization.add(pk, organizationPK);
2551 }
2552 catch (Exception e) {
2553 throw processException(e);
2554 }
2555 finally {
2556 FinderCacheUtil.clearCache("Groups_Orgs");
2557 }
2558 }
2559
2560 public void addOrganization(long pk,
2561 com.liferay.portal.model.Organization organization)
2562 throws SystemException {
2563 try {
2564 addOrganization.add(pk, organization.getPrimaryKey());
2565 }
2566 catch (Exception e) {
2567 throw processException(e);
2568 }
2569 finally {
2570 FinderCacheUtil.clearCache("Groups_Orgs");
2571 }
2572 }
2573
2574 public void addOrganizations(long pk, long[] organizationPKs)
2575 throws SystemException {
2576 try {
2577 for (long organizationPK : organizationPKs) {
2578 addOrganization.add(pk, organizationPK);
2579 }
2580 }
2581 catch (Exception e) {
2582 throw processException(e);
2583 }
2584 finally {
2585 FinderCacheUtil.clearCache("Groups_Orgs");
2586 }
2587 }
2588
2589 public void addOrganizations(long pk,
2590 List<com.liferay.portal.model.Organization> organizations)
2591 throws SystemException {
2592 try {
2593 for (com.liferay.portal.model.Organization organization : organizations) {
2594 addOrganization.add(pk, organization.getPrimaryKey());
2595 }
2596 }
2597 catch (Exception e) {
2598 throw processException(e);
2599 }
2600 finally {
2601 FinderCacheUtil.clearCache("Groups_Orgs");
2602 }
2603 }
2604
2605 public void clearOrganizations(long pk) throws SystemException {
2606 try {
2607 clearOrganizations.clear(pk);
2608 }
2609 catch (Exception e) {
2610 throw processException(e);
2611 }
2612 finally {
2613 FinderCacheUtil.clearCache("Groups_Orgs");
2614 }
2615 }
2616
2617 public void removeOrganization(long pk, long organizationPK)
2618 throws SystemException {
2619 try {
2620 removeOrganization.remove(pk, organizationPK);
2621 }
2622 catch (Exception e) {
2623 throw processException(e);
2624 }
2625 finally {
2626 FinderCacheUtil.clearCache("Groups_Orgs");
2627 }
2628 }
2629
2630 public void removeOrganization(long pk,
2631 com.liferay.portal.model.Organization organization)
2632 throws SystemException {
2633 try {
2634 removeOrganization.remove(pk, organization.getPrimaryKey());
2635 }
2636 catch (Exception e) {
2637 throw processException(e);
2638 }
2639 finally {
2640 FinderCacheUtil.clearCache("Groups_Orgs");
2641 }
2642 }
2643
2644 public void removeOrganizations(long pk, long[] organizationPKs)
2645 throws SystemException {
2646 try {
2647 for (long organizationPK : organizationPKs) {
2648 removeOrganization.remove(pk, organizationPK);
2649 }
2650 }
2651 catch (Exception e) {
2652 throw processException(e);
2653 }
2654 finally {
2655 FinderCacheUtil.clearCache("Groups_Orgs");
2656 }
2657 }
2658
2659 public void removeOrganizations(long pk,
2660 List<com.liferay.portal.model.Organization> organizations)
2661 throws SystemException {
2662 try {
2663 for (com.liferay.portal.model.Organization organization : organizations) {
2664 removeOrganization.remove(pk, organization.getPrimaryKey());
2665 }
2666 }
2667 catch (Exception e) {
2668 throw processException(e);
2669 }
2670 finally {
2671 FinderCacheUtil.clearCache("Groups_Orgs");
2672 }
2673 }
2674
2675 public void setOrganizations(long pk, long[] organizationPKs)
2676 throws SystemException {
2677 try {
2678 clearOrganizations.clear(pk);
2679
2680 for (long organizationPK : organizationPKs) {
2681 addOrganization.add(pk, organizationPK);
2682 }
2683 }
2684 catch (Exception e) {
2685 throw processException(e);
2686 }
2687 finally {
2688 FinderCacheUtil.clearCache("Groups_Orgs");
2689 }
2690 }
2691
2692 public void setOrganizations(long pk,
2693 List<com.liferay.portal.model.Organization> organizations)
2694 throws SystemException {
2695 try {
2696 clearOrganizations.clear(pk);
2697
2698 for (com.liferay.portal.model.Organization organization : organizations) {
2699 addOrganization.add(pk, organization.getPrimaryKey());
2700 }
2701 }
2702 catch (Exception e) {
2703 throw processException(e);
2704 }
2705 finally {
2706 FinderCacheUtil.clearCache("Groups_Orgs");
2707 }
2708 }
2709
2710 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
2711 throws SystemException {
2712 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2713 }
2714
2715 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2716 int start, int end) throws SystemException {
2717 return getPermissions(pk, start, end, null);
2718 }
2719
2720 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2721 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
2722 "Groups_Permissions", "getPermissions",
2723 new String[] {
2724 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2725 "com.liferay.portal.kernel.util.OrderByComparator"
2726 });
2727
2728 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
2729 int start, int end, OrderByComparator obc) throws SystemException {
2730 Object[] finderArgs = new Object[] {
2731 new Long(pk), String.valueOf(start), String.valueOf(end),
2732 String.valueOf(obc)
2733 };
2734
2735 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
2736 finderArgs, this);
2737
2738 if (list == null) {
2739 Session session = null;
2740
2741 try {
2742 session = openSession();
2743
2744 StringBuilder sb = new StringBuilder();
2745
2746 sb.append(_SQL_GETPERMISSIONS);
2747
2748 if (obc != null) {
2749 sb.append("ORDER BY ");
2750 sb.append(obc.getOrderBy());
2751 }
2752
2753 String sql = sb.toString();
2754
2755 SQLQuery q = session.createSQLQuery(sql);
2756
2757 q.addEntity("Permission_",
2758 com.liferay.portal.model.impl.PermissionImpl.class);
2759
2760 QueryPos qPos = QueryPos.getInstance(q);
2761
2762 qPos.add(pk);
2763
2764 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
2765 getDialect(), start, end);
2766 }
2767 catch (Exception e) {
2768 throw processException(e);
2769 }
2770 finally {
2771 if (list == null) {
2772 list = new ArrayList<com.liferay.portal.model.Permission>();
2773 }
2774
2775 permissionPersistence.cacheResult(list);
2776
2777 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
2778 finderArgs, list);
2779
2780 closeSession(session);
2781 }
2782 }
2783
2784 return list;
2785 }
2786
2787 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2788 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
2789 "Groups_Permissions", "getPermissionsSize",
2790 new String[] { Long.class.getName() });
2791
2792 public int getPermissionsSize(long pk) throws SystemException {
2793 Object[] finderArgs = new Object[] { new Long(pk) };
2794
2795 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
2796 finderArgs, this);
2797
2798 if (count == null) {
2799 Session session = null;
2800
2801 try {
2802 session = openSession();
2803
2804 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
2805
2806 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
2807
2808 QueryPos qPos = QueryPos.getInstance(q);
2809
2810 qPos.add(pk);
2811
2812 count = (Long)q.uniqueResult();
2813 }
2814 catch (Exception e) {
2815 throw processException(e);
2816 }
2817 finally {
2818 if (count == null) {
2819 count = Long.valueOf(0);
2820 }
2821
2822 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
2823 finderArgs, count);
2824
2825 closeSession(session);
2826 }
2827 }
2828
2829 return count.intValue();
2830 }
2831
2832 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
2833 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
2834 "Groups_Permissions", "containsPermission",
2835 new String[] { Long.class.getName(), Long.class.getName() });
2836
2837 public boolean containsPermission(long pk, long permissionPK)
2838 throws SystemException {
2839 Object[] finderArgs = new Object[] { new Long(pk), new Long(permissionPK) };
2840
2841 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
2842 finderArgs, this);
2843
2844 if (value == null) {
2845 try {
2846 value = Boolean.valueOf(containsPermission.contains(pk,
2847 permissionPK));
2848 }
2849 catch (Exception e) {
2850 throw processException(e);
2851 }
2852 finally {
2853 if (value == null) {
2854 value = Boolean.FALSE;
2855 }
2856
2857 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
2858 finderArgs, value);
2859 }
2860 }
2861
2862 return value.booleanValue();
2863 }
2864
2865 public boolean containsPermissions(long pk) throws SystemException {
2866 if (getPermissionsSize(pk) > 0) {
2867 return true;
2868 }
2869 else {
2870 return false;
2871 }
2872 }
2873
2874 public void addPermission(long pk, long permissionPK)
2875 throws SystemException {
2876 try {
2877 addPermission.add(pk, permissionPK);
2878 }
2879 catch (Exception e) {
2880 throw processException(e);
2881 }
2882 finally {
2883 FinderCacheUtil.clearCache("Groups_Permissions");
2884 }
2885 }
2886
2887 public void addPermission(long pk,
2888 com.liferay.portal.model.Permission permission)
2889 throws SystemException {
2890 try {
2891 addPermission.add(pk, permission.getPrimaryKey());
2892 }
2893 catch (Exception e) {
2894 throw processException(e);
2895 }
2896 finally {
2897 FinderCacheUtil.clearCache("Groups_Permissions");
2898 }
2899 }
2900
2901 public void addPermissions(long pk, long[] permissionPKs)
2902 throws SystemException {
2903 try {
2904 for (long permissionPK : permissionPKs) {
2905 addPermission.add(pk, permissionPK);
2906 }
2907 }
2908 catch (Exception e) {
2909 throw processException(e);
2910 }
2911 finally {
2912 FinderCacheUtil.clearCache("Groups_Permissions");
2913 }
2914 }
2915
2916 public void addPermissions(long pk,
2917 List<com.liferay.portal.model.Permission> permissions)
2918 throws SystemException {
2919 try {
2920 for (com.liferay.portal.model.Permission permission : permissions) {
2921 addPermission.add(pk, permission.getPrimaryKey());
2922 }
2923 }
2924 catch (Exception e) {
2925 throw processException(e);
2926 }
2927 finally {
2928 FinderCacheUtil.clearCache("Groups_Permissions");
2929 }
2930 }
2931
2932 public void clearPermissions(long pk) throws SystemException {
2933 try {
2934 clearPermissions.clear(pk);
2935 }
2936 catch (Exception e) {
2937 throw processException(e);
2938 }
2939 finally {
2940 FinderCacheUtil.clearCache("Groups_Permissions");
2941 }
2942 }
2943
2944 public void removePermission(long pk, long permissionPK)
2945 throws SystemException {
2946 try {
2947 removePermission.remove(pk, permissionPK);
2948 }
2949 catch (Exception e) {
2950 throw processException(e);
2951 }
2952 finally {
2953 FinderCacheUtil.clearCache("Groups_Permissions");
2954 }
2955 }
2956
2957 public void removePermission(long pk,
2958 com.liferay.portal.model.Permission permission)
2959 throws SystemException {
2960 try {
2961 removePermission.remove(pk, permission.getPrimaryKey());
2962 }
2963 catch (Exception e) {
2964 throw processException(e);
2965 }
2966 finally {
2967 FinderCacheUtil.clearCache("Groups_Permissions");
2968 }
2969 }
2970
2971 public void removePermissions(long pk, long[] permissionPKs)
2972 throws SystemException {
2973 try {
2974 for (long permissionPK : permissionPKs) {
2975 removePermission.remove(pk, permissionPK);
2976 }
2977 }
2978 catch (Exception e) {
2979 throw processException(e);
2980 }
2981 finally {
2982 FinderCacheUtil.clearCache("Groups_Permissions");
2983 }
2984 }
2985
2986 public void removePermissions(long pk,
2987 List<com.liferay.portal.model.Permission> permissions)
2988 throws SystemException {
2989 try {
2990 for (com.liferay.portal.model.Permission permission : permissions) {
2991 removePermission.remove(pk, permission.getPrimaryKey());
2992 }
2993 }
2994 catch (Exception e) {
2995 throw processException(e);
2996 }
2997 finally {
2998 FinderCacheUtil.clearCache("Groups_Permissions");
2999 }
3000 }
3001
3002 public void setPermissions(long pk, long[] permissionPKs)
3003 throws SystemException {
3004 try {
3005 clearPermissions.clear(pk);
3006
3007 for (long permissionPK : permissionPKs) {
3008 addPermission.add(pk, permissionPK);
3009 }
3010 }
3011 catch (Exception e) {
3012 throw processException(e);
3013 }
3014 finally {
3015 FinderCacheUtil.clearCache("Groups_Permissions");
3016 }
3017 }
3018
3019 public void setPermissions(long pk,
3020 List<com.liferay.portal.model.Permission> permissions)
3021 throws SystemException {
3022 try {
3023 clearPermissions.clear(pk);
3024
3025 for (com.liferay.portal.model.Permission permission : permissions) {
3026 addPermission.add(pk, permission.getPrimaryKey());
3027 }
3028 }
3029 catch (Exception e) {
3030 throw processException(e);
3031 }
3032 finally {
3033 FinderCacheUtil.clearCache("Groups_Permissions");
3034 }
3035 }
3036
3037 public List<com.liferay.portal.model.Role> getRoles(long pk)
3038 throws SystemException {
3039 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3040 }
3041
3042 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
3043 int end) throws SystemException {
3044 return getRoles(pk, start, end, null);
3045 }
3046
3047 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3048 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, "Groups_Roles",
3049 "getRoles",
3050 new String[] {
3051 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3052 "com.liferay.portal.kernel.util.OrderByComparator"
3053 });
3054
3055 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
3056 int end, OrderByComparator obc) throws SystemException {
3057 Object[] finderArgs = new Object[] {
3058 new Long(pk), String.valueOf(start), String.valueOf(end),
3059 String.valueOf(obc)
3060 };
3061
3062 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
3063 finderArgs, this);
3064
3065 if (list == null) {
3066 Session session = null;
3067
3068 try {
3069 session = openSession();
3070
3071 StringBuilder sb = new StringBuilder();
3072
3073 sb.append(_SQL_GETROLES);
3074
3075 if (obc != null) {
3076 sb.append("ORDER BY ");
3077 sb.append(obc.getOrderBy());
3078 }
3079
3080 else {
3081 sb.append("ORDER BY ");
3082
3083 sb.append("Role_.name ASC");
3084 }
3085
3086 String sql = sb.toString();
3087
3088 SQLQuery q = session.createSQLQuery(sql);
3089
3090 q.addEntity("Role_",
3091 com.liferay.portal.model.impl.RoleImpl.class);
3092
3093 QueryPos qPos = QueryPos.getInstance(q);
3094
3095 qPos.add(pk);
3096
3097 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
3098 getDialect(), start, end);
3099 }
3100 catch (Exception e) {
3101 throw processException(e);
3102 }
3103 finally {
3104 if (list == null) {
3105 list = new ArrayList<com.liferay.portal.model.Role>();
3106 }
3107
3108 rolePersistence.cacheResult(list);
3109
3110 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
3111 list);
3112
3113 closeSession(session);
3114 }
3115 }
3116
3117 return list;
3118 }
3119
3120 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3121 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, "Groups_Roles",
3122 "getRolesSize", new String[] { Long.class.getName() });
3123
3124 public int getRolesSize(long pk) throws SystemException {
3125 Object[] finderArgs = new Object[] { new Long(pk) };
3126
3127 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
3128 finderArgs, this);
3129
3130 if (count == null) {
3131 Session session = null;
3132
3133 try {
3134 session = openSession();
3135
3136 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
3137
3138 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3139
3140 QueryPos qPos = QueryPos.getInstance(q);
3141
3142 qPos.add(pk);
3143
3144 count = (Long)q.uniqueResult();
3145 }
3146 catch (Exception e) {
3147 throw processException(e);
3148 }
3149 finally {
3150 if (count == null) {
3151 count = Long.valueOf(0);
3152 }
3153
3154 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
3155 finderArgs, count);
3156
3157 closeSession(session);
3158 }
3159 }
3160
3161 return count.intValue();
3162 }
3163
3164 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
3165 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, "Groups_Roles",
3166 "containsRole",
3167 new String[] { Long.class.getName(), Long.class.getName() });
3168
3169 public boolean containsRole(long pk, long rolePK) throws SystemException {
3170 Object[] finderArgs = new Object[] { new Long(pk), new Long(rolePK) };
3171
3172 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
3173 finderArgs, this);
3174
3175 if (value == null) {
3176 try {
3177 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
3178 }
3179 catch (Exception e) {
3180 throw processException(e);
3181 }
3182 finally {
3183 if (value == null) {
3184 value = Boolean.FALSE;
3185 }
3186
3187 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
3188 finderArgs, value);
3189 }
3190 }
3191
3192 return value.booleanValue();
3193 }
3194
3195 public boolean containsRoles(long pk) throws SystemException {
3196 if (getRolesSize(pk) > 0) {
3197 return true;
3198 }
3199 else {
3200 return false;
3201 }
3202 }
3203
3204 public void addRole(long pk, long rolePK) throws SystemException {
3205 try {
3206 addRole.add(pk, rolePK);
3207 }
3208 catch (Exception e) {
3209 throw processException(e);
3210 }
3211 finally {
3212 FinderCacheUtil.clearCache("Groups_Roles");
3213 }
3214 }
3215
3216 public void addRole(long pk, com.liferay.portal.model.Role role)
3217 throws SystemException {
3218 try {
3219 addRole.add(pk, role.getPrimaryKey());
3220 }
3221 catch (Exception e) {
3222 throw processException(e);
3223 }
3224 finally {
3225 FinderCacheUtil.clearCache("Groups_Roles");
3226 }
3227 }
3228
3229 public void addRoles(long pk, long[] rolePKs) throws SystemException {
3230 try {
3231 for (long rolePK : rolePKs) {
3232 addRole.add(pk, rolePK);
3233 }
3234 }
3235 catch (Exception e) {
3236 throw processException(e);
3237 }
3238 finally {
3239 FinderCacheUtil.clearCache("Groups_Roles");
3240 }
3241 }
3242
3243 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
3244 throws SystemException {
3245 try {
3246 for (com.liferay.portal.model.Role role : roles) {
3247 addRole.add(pk, role.getPrimaryKey());
3248 }
3249 }
3250 catch (Exception e) {
3251 throw processException(e);
3252 }
3253 finally {
3254 FinderCacheUtil.clearCache("Groups_Roles");
3255 }
3256 }
3257
3258 public void clearRoles(long pk) throws SystemException {
3259 try {
3260 clearRoles.clear(pk);
3261 }
3262 catch (Exception e) {
3263 throw processException(e);
3264 }
3265 finally {
3266 FinderCacheUtil.clearCache("Groups_Roles");
3267 }
3268 }
3269
3270 public void removeRole(long pk, long rolePK) throws SystemException {
3271 try {
3272 removeRole.remove(pk, rolePK);
3273 }
3274 catch (Exception e) {
3275 throw processException(e);
3276 }
3277 finally {
3278 FinderCacheUtil.clearCache("Groups_Roles");
3279 }
3280 }
3281
3282 public void removeRole(long pk, com.liferay.portal.model.Role role)
3283 throws SystemException {
3284 try {
3285 removeRole.remove(pk, role.getPrimaryKey());
3286 }
3287 catch (Exception e) {
3288 throw processException(e);
3289 }
3290 finally {
3291 FinderCacheUtil.clearCache("Groups_Roles");
3292 }
3293 }
3294
3295 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
3296 try {
3297 for (long rolePK : rolePKs) {
3298 removeRole.remove(pk, rolePK);
3299 }
3300 }
3301 catch (Exception e) {
3302 throw processException(e);
3303 }
3304 finally {
3305 FinderCacheUtil.clearCache("Groups_Roles");
3306 }
3307 }
3308
3309 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
3310 throws SystemException {
3311 try {
3312 for (com.liferay.portal.model.Role role : roles) {
3313 removeRole.remove(pk, role.getPrimaryKey());
3314 }
3315 }
3316 catch (Exception e) {
3317 throw processException(e);
3318 }
3319 finally {
3320 FinderCacheUtil.clearCache("Groups_Roles");
3321 }
3322 }
3323
3324 public void setRoles(long pk, long[] rolePKs) throws SystemException {
3325 try {
3326 clearRoles.clear(pk);
3327
3328 for (long rolePK : rolePKs) {
3329 addRole.add(pk, rolePK);
3330 }
3331 }
3332 catch (Exception e) {
3333 throw processException(e);
3334 }
3335 finally {
3336 FinderCacheUtil.clearCache("Groups_Roles");
3337 }
3338 }
3339
3340 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
3341 throws SystemException {
3342 try {
3343 clearRoles.clear(pk);
3344
3345 for (com.liferay.portal.model.Role role : roles) {
3346 addRole.add(pk, role.getPrimaryKey());
3347 }
3348 }
3349 catch (Exception e) {
3350 throw processException(e);
3351 }
3352 finally {
3353 FinderCacheUtil.clearCache("Groups_Roles");
3354 }
3355 }
3356
3357 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
3358 throws SystemException {
3359 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3360 }
3361
3362 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
3363 int start, int end) throws SystemException {
3364 return getUserGroups(pk, start, end, null);
3365 }
3366
3367 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
3368 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
3369 "Groups_UserGroups", "getUserGroups",
3370 new String[] {
3371 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3372 "com.liferay.portal.kernel.util.OrderByComparator"
3373 });
3374
3375 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
3376 int start, int end, OrderByComparator obc) throws SystemException {
3377 Object[] finderArgs = new Object[] {
3378 new Long(pk), String.valueOf(start), String.valueOf(end),
3379 String.valueOf(obc)
3380 };
3381
3382 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
3383 finderArgs, this);
3384
3385 if (list == null) {
3386 Session session = null;
3387
3388 try {
3389 session = openSession();
3390
3391 StringBuilder sb = new StringBuilder();
3392
3393 sb.append(_SQL_GETUSERGROUPS);
3394
3395 if (obc != null) {
3396 sb.append("ORDER BY ");
3397 sb.append(obc.getOrderBy());
3398 }
3399
3400 else {
3401 sb.append("ORDER BY ");
3402
3403 sb.append("UserGroup.name ASC");
3404 }
3405
3406 String sql = sb.toString();
3407
3408 SQLQuery q = session.createSQLQuery(sql);
3409
3410 q.addEntity("UserGroup",
3411 com.liferay.portal.model.impl.UserGroupImpl.class);
3412
3413 QueryPos qPos = QueryPos.getInstance(q);
3414
3415 qPos.add(pk);
3416
3417 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
3418 getDialect(), start, end);
3419 }
3420 catch (Exception e) {
3421 throw processException(e);
3422 }
3423 finally {
3424 if (list == null) {
3425 list = new ArrayList<com.liferay.portal.model.UserGroup>();
3426 }
3427
3428 userGroupPersistence.cacheResult(list);
3429
3430 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
3431 finderArgs, list);
3432
3433 closeSession(session);
3434 }
3435 }
3436
3437 return list;
3438 }
3439
3440 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
3441 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
3442 "Groups_UserGroups", "getUserGroupsSize",
3443 new String[] { Long.class.getName() });
3444
3445 public int getUserGroupsSize(long pk) throws SystemException {
3446 Object[] finderArgs = new Object[] { new Long(pk) };
3447
3448 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
3449 finderArgs, this);
3450
3451 if (count == null) {
3452 Session session = null;
3453
3454 try {
3455 session = openSession();
3456
3457 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
3458
3459 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3460
3461 QueryPos qPos = QueryPos.getInstance(q);
3462
3463 qPos.add(pk);
3464
3465 count = (Long)q.uniqueResult();
3466 }
3467 catch (Exception e) {
3468 throw processException(e);
3469 }
3470 finally {
3471 if (count == null) {
3472 count = Long.valueOf(0);
3473 }
3474
3475 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
3476 finderArgs, count);
3477
3478 closeSession(session);
3479 }
3480 }
3481
3482 return count.intValue();
3483 }
3484
3485 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
3486 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
3487 "Groups_UserGroups", "containsUserGroup",
3488 new String[] { Long.class.getName(), Long.class.getName() });
3489
3490 public boolean containsUserGroup(long pk, long userGroupPK)
3491 throws SystemException {
3492 Object[] finderArgs = new Object[] { new Long(pk), new Long(userGroupPK) };
3493
3494 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
3495 finderArgs, this);
3496
3497 if (value == null) {
3498 try {
3499 value = Boolean.valueOf(containsUserGroup.contains(pk,
3500 userGroupPK));
3501 }
3502 catch (Exception e) {
3503 throw processException(e);
3504 }
3505 finally {
3506 if (value == null) {
3507 value = Boolean.FALSE;
3508 }
3509
3510 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
3511 finderArgs, value);
3512 }
3513 }
3514
3515 return value.booleanValue();
3516 }
3517
3518 public boolean containsUserGroups(long pk) throws SystemException {
3519 if (getUserGroupsSize(pk) > 0) {
3520 return true;
3521 }
3522 else {
3523 return false;
3524 }
3525 }
3526
3527 public void addUserGroup(long pk, long userGroupPK)
3528 throws SystemException {
3529 try {
3530 addUserGroup.add(pk, userGroupPK);
3531 }
3532 catch (Exception e) {
3533 throw processException(e);
3534 }
3535 finally {
3536 FinderCacheUtil.clearCache("Groups_UserGroups");
3537 }
3538 }
3539
3540 public void addUserGroup(long pk,
3541 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
3542 try {
3543 addUserGroup.add(pk, userGroup.getPrimaryKey());
3544 }
3545 catch (Exception e) {
3546 throw processException(e);
3547 }
3548 finally {
3549 FinderCacheUtil.clearCache("Groups_UserGroups");
3550 }
3551 }
3552
3553 public void addUserGroups(long pk, long[] userGroupPKs)
3554 throws SystemException {
3555 try {
3556 for (long userGroupPK : userGroupPKs) {
3557 addUserGroup.add(pk, userGroupPK);
3558 }
3559 }
3560 catch (Exception e) {
3561 throw processException(e);
3562 }
3563 finally {
3564 FinderCacheUtil.clearCache("Groups_UserGroups");
3565 }
3566 }
3567
3568 public void addUserGroups(long pk,
3569 List<com.liferay.portal.model.UserGroup> userGroups)
3570 throws SystemException {
3571 try {
3572 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3573 addUserGroup.add(pk, userGroup.getPrimaryKey());
3574 }
3575 }
3576 catch (Exception e) {
3577 throw processException(e);
3578 }
3579 finally {
3580 FinderCacheUtil.clearCache("Groups_UserGroups");
3581 }
3582 }
3583
3584 public void clearUserGroups(long pk) throws SystemException {
3585 try {
3586 clearUserGroups.clear(pk);
3587 }
3588 catch (Exception e) {
3589 throw processException(e);
3590 }
3591 finally {
3592 FinderCacheUtil.clearCache("Groups_UserGroups");
3593 }
3594 }
3595
3596 public void removeUserGroup(long pk, long userGroupPK)
3597 throws SystemException {
3598 try {
3599 removeUserGroup.remove(pk, userGroupPK);
3600 }
3601 catch (Exception e) {
3602 throw processException(e);
3603 }
3604 finally {
3605 FinderCacheUtil.clearCache("Groups_UserGroups");
3606 }
3607 }
3608
3609 public void removeUserGroup(long pk,
3610 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
3611 try {
3612 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
3613 }
3614 catch (Exception e) {
3615 throw processException(e);
3616 }
3617 finally {
3618 FinderCacheUtil.clearCache("Groups_UserGroups");
3619 }
3620 }
3621
3622 public void removeUserGroups(long pk, long[] userGroupPKs)
3623 throws SystemException {
3624 try {
3625 for (long userGroupPK : userGroupPKs) {
3626 removeUserGroup.remove(pk, userGroupPK);
3627 }
3628 }
3629 catch (Exception e) {
3630 throw processException(e);
3631 }
3632 finally {
3633 FinderCacheUtil.clearCache("Groups_UserGroups");
3634 }
3635 }
3636
3637 public void removeUserGroups(long pk,
3638 List<com.liferay.portal.model.UserGroup> userGroups)
3639 throws SystemException {
3640 try {
3641 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3642 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
3643 }
3644 }
3645 catch (Exception e) {
3646 throw processException(e);
3647 }
3648 finally {
3649 FinderCacheUtil.clearCache("Groups_UserGroups");
3650 }
3651 }
3652
3653 public void setUserGroups(long pk, long[] userGroupPKs)
3654 throws SystemException {
3655 try {
3656 clearUserGroups.clear(pk);
3657
3658 for (long userGroupPK : userGroupPKs) {
3659 addUserGroup.add(pk, userGroupPK);
3660 }
3661 }
3662 catch (Exception e) {
3663 throw processException(e);
3664 }
3665 finally {
3666 FinderCacheUtil.clearCache("Groups_UserGroups");
3667 }
3668 }
3669
3670 public void setUserGroups(long pk,
3671 List<com.liferay.portal.model.UserGroup> userGroups)
3672 throws SystemException {
3673 try {
3674 clearUserGroups.clear(pk);
3675
3676 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3677 addUserGroup.add(pk, userGroup.getPrimaryKey());
3678 }
3679 }
3680 catch (Exception e) {
3681 throw processException(e);
3682 }
3683 finally {
3684 FinderCacheUtil.clearCache("Groups_UserGroups");
3685 }
3686 }
3687
3688 public List<com.liferay.portal.model.User> getUsers(long pk)
3689 throws SystemException {
3690 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3691 }
3692
3693 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3694 int end) throws SystemException {
3695 return getUsers(pk, start, end, null);
3696 }
3697
3698 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3699 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
3700 "getUsers",
3701 new String[] {
3702 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3703 "com.liferay.portal.kernel.util.OrderByComparator"
3704 });
3705
3706 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
3707 int end, OrderByComparator obc) throws SystemException {
3708 Object[] finderArgs = new Object[] {
3709 new Long(pk), String.valueOf(start), String.valueOf(end),
3710 String.valueOf(obc)
3711 };
3712
3713 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
3714 finderArgs, this);
3715
3716 if (list == null) {
3717 Session session = null;
3718
3719 try {
3720 session = openSession();
3721
3722 StringBuilder sb = new StringBuilder();
3723
3724 sb.append(_SQL_GETUSERS);
3725
3726 if (obc != null) {
3727 sb.append("ORDER BY ");
3728 sb.append(obc.getOrderBy());
3729 }
3730
3731 String sql = sb.toString();
3732
3733 SQLQuery q = session.createSQLQuery(sql);
3734
3735 q.addEntity("User_",
3736 com.liferay.portal.model.impl.UserImpl.class);
3737
3738 QueryPos qPos = QueryPos.getInstance(q);
3739
3740 qPos.add(pk);
3741
3742 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
3743 getDialect(), start, end);
3744 }
3745 catch (Exception e) {
3746 throw processException(e);
3747 }
3748 finally {
3749 if (list == null) {
3750 list = new ArrayList<com.liferay.portal.model.User>();
3751 }
3752
3753 userPersistence.cacheResult(list);
3754
3755 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
3756 list);
3757
3758 closeSession(session);
3759 }
3760 }
3761
3762 return list;
3763 }
3764
3765 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3766 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
3767 "getUsersSize", new String[] { Long.class.getName() });
3768
3769 public int getUsersSize(long pk) throws SystemException {
3770 Object[] finderArgs = new Object[] { new Long(pk) };
3771
3772 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
3773 finderArgs, this);
3774
3775 if (count == null) {
3776 Session session = null;
3777
3778 try {
3779 session = openSession();
3780
3781 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
3782
3783 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3784
3785 QueryPos qPos = QueryPos.getInstance(q);
3786
3787 qPos.add(pk);
3788
3789 count = (Long)q.uniqueResult();
3790 }
3791 catch (Exception e) {
3792 throw processException(e);
3793 }
3794 finally {
3795 if (count == null) {
3796 count = Long.valueOf(0);
3797 }
3798
3799 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
3800 finderArgs, count);
3801
3802 closeSession(session);
3803 }
3804 }
3805
3806 return count.intValue();
3807 }
3808
3809 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
3810 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, "Users_Groups",
3811 "containsUser",
3812 new String[] { Long.class.getName(), Long.class.getName() });
3813
3814 public boolean containsUser(long pk, long userPK) throws SystemException {
3815 Object[] finderArgs = new Object[] { new Long(pk), new Long(userPK) };
3816
3817 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
3818 finderArgs, this);
3819
3820 if (value == null) {
3821 try {
3822 value = Boolean.valueOf(containsUser.contains(pk, userPK));
3823 }
3824 catch (Exception e) {
3825 throw processException(e);
3826 }
3827 finally {
3828 if (value == null) {
3829 value = Boolean.FALSE;
3830 }
3831
3832 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
3833 finderArgs, value);
3834 }
3835 }
3836
3837 return value.booleanValue();
3838 }
3839
3840 public boolean containsUsers(long pk) throws SystemException {
3841 if (getUsersSize(pk) > 0) {
3842 return true;
3843 }
3844 else {
3845 return false;
3846 }
3847 }
3848
3849 public void addUser(long pk, long userPK) throws SystemException {
3850 try {
3851 addUser.add(pk, userPK);
3852 }
3853 catch (Exception e) {
3854 throw processException(e);
3855 }
3856 finally {
3857 FinderCacheUtil.clearCache("Users_Groups");
3858 }
3859 }
3860
3861 public void addUser(long pk, com.liferay.portal.model.User user)
3862 throws SystemException {
3863 try {
3864 addUser.add(pk, user.getPrimaryKey());
3865 }
3866 catch (Exception e) {
3867 throw processException(e);
3868 }
3869 finally {
3870 FinderCacheUtil.clearCache("Users_Groups");
3871 }
3872 }
3873
3874 public void addUsers(long pk, long[] userPKs) throws SystemException {
3875 try {
3876 for (long userPK : userPKs) {
3877 addUser.add(pk, userPK);
3878 }
3879 }
3880 catch (Exception e) {
3881 throw processException(e);
3882 }
3883 finally {
3884 FinderCacheUtil.clearCache("Users_Groups");
3885 }
3886 }
3887
3888 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
3889 throws SystemException {
3890 try {
3891 for (com.liferay.portal.model.User user : users) {
3892 addUser.add(pk, user.getPrimaryKey());
3893 }
3894 }
3895 catch (Exception e) {
3896 throw processException(e);
3897 }
3898 finally {
3899 FinderCacheUtil.clearCache("Users_Groups");
3900 }
3901 }
3902
3903 public void clearUsers(long pk) throws SystemException {
3904 try {
3905 clearUsers.clear(pk);
3906 }
3907 catch (Exception e) {
3908 throw processException(e);
3909 }
3910 finally {
3911 FinderCacheUtil.clearCache("Users_Groups");
3912 }
3913 }
3914
3915 public void removeUser(long pk, long userPK) throws SystemException {
3916 try {
3917 removeUser.remove(pk, userPK);
3918 }
3919 catch (Exception e) {
3920 throw processException(e);
3921 }
3922 finally {
3923 FinderCacheUtil.clearCache("Users_Groups");
3924 }
3925 }
3926
3927 public void removeUser(long pk, com.liferay.portal.model.User user)
3928 throws SystemException {
3929 try {
3930 removeUser.remove(pk, user.getPrimaryKey());
3931 }
3932 catch (Exception e) {
3933 throw processException(e);
3934 }
3935 finally {
3936 FinderCacheUtil.clearCache("Users_Groups");
3937 }
3938 }
3939
3940 public void removeUsers(long pk, long[] userPKs) throws SystemException {
3941 try {
3942 for (long userPK : userPKs) {
3943 removeUser.remove(pk, userPK);
3944 }
3945 }
3946 catch (Exception e) {
3947 throw processException(e);
3948 }
3949 finally {
3950 FinderCacheUtil.clearCache("Users_Groups");
3951 }
3952 }
3953
3954 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
3955 throws SystemException {
3956 try {
3957 for (com.liferay.portal.model.User user : users) {
3958 removeUser.remove(pk, user.getPrimaryKey());
3959 }
3960 }
3961 catch (Exception e) {
3962 throw processException(e);
3963 }
3964 finally {
3965 FinderCacheUtil.clearCache("Users_Groups");
3966 }
3967 }
3968
3969 public void setUsers(long pk, long[] userPKs) throws SystemException {
3970 try {
3971 clearUsers.clear(pk);
3972
3973 for (long userPK : userPKs) {
3974 addUser.add(pk, userPK);
3975 }
3976 }
3977 catch (Exception e) {
3978 throw processException(e);
3979 }
3980 finally {
3981 FinderCacheUtil.clearCache("Users_Groups");
3982 }
3983 }
3984
3985 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
3986 throws SystemException {
3987 try {
3988 clearUsers.clear(pk);
3989
3990 for (com.liferay.portal.model.User user : users) {
3991 addUser.add(pk, user.getPrimaryKey());
3992 }
3993 }
3994 catch (Exception e) {
3995 throw processException(e);
3996 }
3997 finally {
3998 FinderCacheUtil.clearCache("Users_Groups");
3999 }
4000 }
4001
4002 public void afterPropertiesSet() {
4003 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4004 com.liferay.portal.util.PropsUtil.get(
4005 "value.object.listener.com.liferay.portal.model.Group")));
4006
4007 if (listenerClassNames.length > 0) {
4008 try {
4009 List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
4010
4011 for (String listenerClassName : listenerClassNames) {
4012 listenersList.add((ModelListener<Group>)Class.forName(
4013 listenerClassName).newInstance());
4014 }
4015
4016 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4017 }
4018 catch (Exception e) {
4019 _log.error(e);
4020 }
4021 }
4022
4023 containsOrganization = new ContainsOrganization(this);
4024
4025 addOrganization = new AddOrganization(this);
4026 clearOrganizations = new ClearOrganizations(this);
4027 removeOrganization = new RemoveOrganization(this);
4028
4029 containsPermission = new ContainsPermission(this);
4030
4031 addPermission = new AddPermission(this);
4032 clearPermissions = new ClearPermissions(this);
4033 removePermission = new RemovePermission(this);
4034
4035 containsRole = new ContainsRole(this);
4036
4037 addRole = new AddRole(this);
4038 clearRoles = new ClearRoles(this);
4039 removeRole = new RemoveRole(this);
4040
4041 containsUserGroup = new ContainsUserGroup(this);
4042
4043 addUserGroup = new AddUserGroup(this);
4044 clearUserGroups = new ClearUserGroups(this);
4045 removeUserGroup = new RemoveUserGroup(this);
4046
4047 containsUser = new ContainsUser(this);
4048
4049 addUser = new AddUser(this);
4050 clearUsers = new ClearUsers(this);
4051 removeUser = new RemoveUser(this);
4052 }
4053
4054 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
4055 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
4056 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
4057 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
4058 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
4059 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
4060 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
4061 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
4062 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
4063 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
4064 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
4065 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
4066 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
4067 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
4068 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
4069 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
4070 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
4071 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
4072 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
4073 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
4074 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
4075 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
4076 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
4077 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
4078 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
4079 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
4080 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
4081 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
4082 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
4083 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
4084 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
4085 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4086 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
4087 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
4088 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
4089 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
4090 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
4091 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
4092 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
4093 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4094 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
4095 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
4096 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
4097 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
4098 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
4099 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
4100 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
4101 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
4102 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
4103 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
4104 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
4105 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
4106 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
4107 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
4108 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
4109 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
4110 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
4111 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
4112 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
4113 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
4114 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
4115 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
4116 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
4117 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
4118 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
4119 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
4120 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
4121 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
4122 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
4123 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
4124 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
4125 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
4126 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
4127 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
4128 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
4129 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
4130 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
4131 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
4132 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
4133 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
4134 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
4135 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
4136 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
4137 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
4138 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
4139 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
4140 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
4141 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
4142 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
4143 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
4144 @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence.impl")
4145 protected com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence blogsEntryPersistence;
4146 @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence.impl")
4147 protected com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence blogsStatsUserPersistence;
4148 @BeanReference(name = "com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence.impl")
4149 protected com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence bookmarksFolderPersistence;
4150 @BeanReference(name = "com.liferay.portlet.calendar.service.persistence.CalEventPersistence.impl")
4151 protected com.liferay.portlet.calendar.service.persistence.CalEventPersistence calEventPersistence;
4152 @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence.impl")
4153 protected com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence dlFolderPersistence;
4154 @BeanReference(name = "com.liferay.portlet.imagegallery.service.persistence.IGFolderPersistence.impl")
4155 protected com.liferay.portlet.imagegallery.service.persistence.IGFolderPersistence igFolderPersistence;
4156 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence.impl")
4157 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
4158 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence.impl")
4159 protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
4160 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence.impl")
4161 protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
4162 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBBanPersistence.impl")
4163 protected com.liferay.portlet.messageboards.service.persistence.MBBanPersistence mbBanPersistence;
4164 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence.impl")
4165 protected com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence mbCategoryPersistence;
4166 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence.impl")
4167 protected com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence mbStatsUserPersistence;
4168 @BeanReference(name = "com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence.impl")
4169 protected com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence pollsQuestionPersistence;
4170 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence.impl")
4171 protected com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence shoppingCartPersistence;
4172 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence.impl")
4173 protected com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence shoppingCategoryPersistence;
4174 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence.impl")
4175 protected com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence shoppingCouponPersistence;
4176 @BeanReference(name = "com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence.impl")
4177 protected com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence shoppingOrderPersistence;
4178 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence.impl")
4179 protected com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence scFrameworkVersionPersistence;
4180 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence.impl")
4181 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence scProductEntryPersistence;
4182 @BeanReference(name = "com.liferay.portlet.tasks.service.persistence.TasksProposalPersistence.impl")
4183 protected com.liferay.portlet.tasks.service.persistence.TasksProposalPersistence tasksProposalPersistence;
4184 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence.impl")
4185 protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
4186 protected ContainsOrganization containsOrganization;
4187 protected AddOrganization addOrganization;
4188 protected ClearOrganizations clearOrganizations;
4189 protected RemoveOrganization removeOrganization;
4190 protected ContainsPermission containsPermission;
4191 protected AddPermission addPermission;
4192 protected ClearPermissions clearPermissions;
4193 protected RemovePermission removePermission;
4194 protected ContainsRole containsRole;
4195 protected AddRole addRole;
4196 protected ClearRoles clearRoles;
4197 protected RemoveRole removeRole;
4198 protected ContainsUserGroup containsUserGroup;
4199 protected AddUserGroup addUserGroup;
4200 protected ClearUserGroups clearUserGroups;
4201 protected RemoveUserGroup removeUserGroup;
4202 protected ContainsUser containsUser;
4203 protected AddUser addUser;
4204 protected ClearUsers clearUsers;
4205 protected RemoveUser removeUser;
4206
4207 protected class ContainsOrganization {
4208 protected ContainsOrganization(GroupPersistenceImpl persistenceImpl) {
4209 super();
4210
4211 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4212 _SQL_CONTAINSORGANIZATION,
4213 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4214 }
4215
4216 protected boolean contains(long groupId, long organizationId) {
4217 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4218 new Long(groupId), new Long(organizationId)
4219 });
4220
4221 if (results.size() > 0) {
4222 Integer count = results.get(0);
4223
4224 if (count.intValue() > 0) {
4225 return true;
4226 }
4227 }
4228
4229 return false;
4230 }
4231
4232 private MappingSqlQuery _mappingSqlQuery;
4233 }
4234
4235 protected class AddOrganization {
4236 protected AddOrganization(GroupPersistenceImpl persistenceImpl) {
4237 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4238 "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
4239 new int[] { Types.BIGINT, Types.BIGINT });
4240 _persistenceImpl = persistenceImpl;
4241 }
4242
4243 protected void add(long groupId, long organizationId) {
4244 if (!_persistenceImpl.containsOrganization.contains(groupId,
4245 organizationId)) {
4246 _sqlUpdate.update(new Object[] {
4247 new Long(groupId), new Long(organizationId)
4248 });
4249 }
4250 }
4251
4252 private SqlUpdate _sqlUpdate;
4253 private GroupPersistenceImpl _persistenceImpl;
4254 }
4255
4256 protected class ClearOrganizations {
4257 protected ClearOrganizations(GroupPersistenceImpl persistenceImpl) {
4258 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4259 "DELETE FROM Groups_Orgs WHERE groupId = ?",
4260 new int[] { Types.BIGINT });
4261 }
4262
4263 protected void clear(long groupId) {
4264 _sqlUpdate.update(new Object[] { new Long(groupId) });
4265 }
4266
4267 private SqlUpdate _sqlUpdate;
4268 }
4269
4270 protected class RemoveOrganization {
4271 protected RemoveOrganization(GroupPersistenceImpl persistenceImpl) {
4272 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4273 "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
4274 new int[] { Types.BIGINT, Types.BIGINT });
4275 }
4276
4277 protected void remove(long groupId, long organizationId) {
4278 _sqlUpdate.update(new Object[] {
4279 new Long(groupId), new Long(organizationId)
4280 });
4281 }
4282
4283 private SqlUpdate _sqlUpdate;
4284 }
4285
4286 protected class ContainsPermission {
4287 protected ContainsPermission(GroupPersistenceImpl persistenceImpl) {
4288 super();
4289
4290 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4291 _SQL_CONTAINSPERMISSION,
4292 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4293 }
4294
4295 protected boolean contains(long groupId, long permissionId) {
4296 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4297 new Long(groupId), new Long(permissionId)
4298 });
4299
4300 if (results.size() > 0) {
4301 Integer count = results.get(0);
4302
4303 if (count.intValue() > 0) {
4304 return true;
4305 }
4306 }
4307
4308 return false;
4309 }
4310
4311 private MappingSqlQuery _mappingSqlQuery;
4312 }
4313
4314 protected class AddPermission {
4315 protected AddPermission(GroupPersistenceImpl persistenceImpl) {
4316 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4317 "INSERT INTO Groups_Permissions (groupId, permissionId) VALUES (?, ?)",
4318 new int[] { Types.BIGINT, Types.BIGINT });
4319 _persistenceImpl = persistenceImpl;
4320 }
4321
4322 protected void add(long groupId, long permissionId) {
4323 if (!_persistenceImpl.containsPermission.contains(groupId,
4324 permissionId)) {
4325 _sqlUpdate.update(new Object[] {
4326 new Long(groupId), new Long(permissionId)
4327 });
4328 }
4329 }
4330
4331 private SqlUpdate _sqlUpdate;
4332 private GroupPersistenceImpl _persistenceImpl;
4333 }
4334
4335 protected class ClearPermissions {
4336 protected ClearPermissions(GroupPersistenceImpl persistenceImpl) {
4337 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4338 "DELETE FROM Groups_Permissions WHERE groupId = ?",
4339 new int[] { Types.BIGINT });
4340 }
4341
4342 protected void clear(long groupId) {
4343 _sqlUpdate.update(new Object[] { new Long(groupId) });
4344 }
4345
4346 private SqlUpdate _sqlUpdate;
4347 }
4348
4349 protected class RemovePermission {
4350 protected RemovePermission(GroupPersistenceImpl persistenceImpl) {
4351 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4352 "DELETE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?",
4353 new int[] { Types.BIGINT, Types.BIGINT });
4354 }
4355
4356 protected void remove(long groupId, long permissionId) {
4357 _sqlUpdate.update(new Object[] {
4358 new Long(groupId), new Long(permissionId)
4359 });
4360 }
4361
4362 private SqlUpdate _sqlUpdate;
4363 }
4364
4365 protected class ContainsRole {
4366 protected ContainsRole(GroupPersistenceImpl persistenceImpl) {
4367 super();
4368
4369 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4370 _SQL_CONTAINSROLE,
4371 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4372 }
4373
4374 protected boolean contains(long groupId, long roleId) {
4375 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4376 new Long(groupId), new Long(roleId)
4377 });
4378
4379 if (results.size() > 0) {
4380 Integer count = results.get(0);
4381
4382 if (count.intValue() > 0) {
4383 return true;
4384 }
4385 }
4386
4387 return false;
4388 }
4389
4390 private MappingSqlQuery _mappingSqlQuery;
4391 }
4392
4393 protected class AddRole {
4394 protected AddRole(GroupPersistenceImpl persistenceImpl) {
4395 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4396 "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
4397 new int[] { Types.BIGINT, Types.BIGINT });
4398 _persistenceImpl = persistenceImpl;
4399 }
4400
4401 protected void add(long groupId, long roleId) {
4402 if (!_persistenceImpl.containsRole.contains(groupId, roleId)) {
4403 _sqlUpdate.update(new Object[] {
4404 new Long(groupId), new Long(roleId)
4405 });
4406 }
4407 }
4408
4409 private SqlUpdate _sqlUpdate;
4410 private GroupPersistenceImpl _persistenceImpl;
4411 }
4412
4413 protected class ClearRoles {
4414 protected ClearRoles(GroupPersistenceImpl persistenceImpl) {
4415 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4416 "DELETE FROM Groups_Roles WHERE groupId = ?",
4417 new int[] { Types.BIGINT });
4418 }
4419
4420 protected void clear(long groupId) {
4421 _sqlUpdate.update(new Object[] { new Long(groupId) });
4422 }
4423
4424 private SqlUpdate _sqlUpdate;
4425 }
4426
4427 protected class RemoveRole {
4428 protected RemoveRole(GroupPersistenceImpl persistenceImpl) {
4429 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4430 "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
4431 new int[] { Types.BIGINT, Types.BIGINT });
4432 }
4433
4434 protected void remove(long groupId, long roleId) {
4435 _sqlUpdate.update(new Object[] { new Long(groupId), new Long(roleId) });
4436 }
4437
4438 private SqlUpdate _sqlUpdate;
4439 }
4440
4441 protected class ContainsUserGroup {
4442 protected ContainsUserGroup(GroupPersistenceImpl persistenceImpl) {
4443 super();
4444
4445 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4446 _SQL_CONTAINSUSERGROUP,
4447 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4448 }
4449
4450 protected boolean contains(long groupId, long userGroupId) {
4451 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4452 new Long(groupId), new Long(userGroupId)
4453 });
4454
4455 if (results.size() > 0) {
4456 Integer count = results.get(0);
4457
4458 if (count.intValue() > 0) {
4459 return true;
4460 }
4461 }
4462
4463 return false;
4464 }
4465
4466 private MappingSqlQuery _mappingSqlQuery;
4467 }
4468
4469 protected class AddUserGroup {
4470 protected AddUserGroup(GroupPersistenceImpl persistenceImpl) {
4471 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4472 "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
4473 new int[] { Types.BIGINT, Types.BIGINT });
4474 _persistenceImpl = persistenceImpl;
4475 }
4476
4477 protected void add(long groupId, long userGroupId) {
4478 if (!_persistenceImpl.containsUserGroup.contains(groupId,
4479 userGroupId)) {
4480 _sqlUpdate.update(new Object[] {
4481 new Long(groupId), new Long(userGroupId)
4482 });
4483 }
4484 }
4485
4486 private SqlUpdate _sqlUpdate;
4487 private GroupPersistenceImpl _persistenceImpl;
4488 }
4489
4490 protected class ClearUserGroups {
4491 protected ClearUserGroups(GroupPersistenceImpl persistenceImpl) {
4492 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4493 "DELETE FROM Groups_UserGroups WHERE groupId = ?",
4494 new int[] { Types.BIGINT });
4495 }
4496
4497 protected void clear(long groupId) {
4498 _sqlUpdate.update(new Object[] { new Long(groupId) });
4499 }
4500
4501 private SqlUpdate _sqlUpdate;
4502 }
4503
4504 protected class RemoveUserGroup {
4505 protected RemoveUserGroup(GroupPersistenceImpl persistenceImpl) {
4506 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4507 "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
4508 new int[] { Types.BIGINT, Types.BIGINT });
4509 }
4510
4511 protected void remove(long groupId, long userGroupId) {
4512 _sqlUpdate.update(new Object[] {
4513 new Long(groupId), new Long(userGroupId)
4514 });
4515 }
4516
4517 private SqlUpdate _sqlUpdate;
4518 }
4519
4520 protected class ContainsUser {
4521 protected ContainsUser(GroupPersistenceImpl persistenceImpl) {
4522 super();
4523
4524 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4525 _SQL_CONTAINSUSER,
4526 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
4527 }
4528
4529 protected boolean contains(long groupId, long userId) {
4530 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4531 new Long(groupId), new Long(userId)
4532 });
4533
4534 if (results.size() > 0) {
4535 Integer count = results.get(0);
4536
4537 if (count.intValue() > 0) {
4538 return true;
4539 }
4540 }
4541
4542 return false;
4543 }
4544
4545 private MappingSqlQuery _mappingSqlQuery;
4546 }
4547
4548 protected class AddUser {
4549 protected AddUser(GroupPersistenceImpl persistenceImpl) {
4550 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4551 "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
4552 new int[] { Types.BIGINT, Types.BIGINT });
4553 _persistenceImpl = persistenceImpl;
4554 }
4555
4556 protected void add(long groupId, long userId) {
4557 if (!_persistenceImpl.containsUser.contains(groupId, userId)) {
4558 _sqlUpdate.update(new Object[] {
4559 new Long(groupId), new Long(userId)
4560 });
4561 }
4562 }
4563
4564 private SqlUpdate _sqlUpdate;
4565 private GroupPersistenceImpl _persistenceImpl;
4566 }
4567
4568 protected class ClearUsers {
4569 protected ClearUsers(GroupPersistenceImpl persistenceImpl) {
4570 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4571 "DELETE FROM Users_Groups WHERE groupId = ?",
4572 new int[] { Types.BIGINT });
4573 }
4574
4575 protected void clear(long groupId) {
4576 _sqlUpdate.update(new Object[] { new Long(groupId) });
4577 }
4578
4579 private SqlUpdate _sqlUpdate;
4580 }
4581
4582 protected class RemoveUser {
4583 protected RemoveUser(GroupPersistenceImpl persistenceImpl) {
4584 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4585 "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
4586 new int[] { Types.BIGINT, Types.BIGINT });
4587 }
4588
4589 protected void remove(long groupId, long userId) {
4590 _sqlUpdate.update(new Object[] { new Long(groupId), new Long(userId) });
4591 }
4592
4593 private SqlUpdate _sqlUpdate;
4594 }
4595
4596 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
4597 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
4598 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
4599 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Groups_Permissions ON (Groups_Permissions.permissionId = Permission_.permissionId) WHERE (Groups_Permissions.groupId = ?)";
4600 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ?";
4601 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?";
4602 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
4603 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
4604 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
4605 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
4606 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
4607 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
4608 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
4609 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
4610 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
4611 private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
4612}