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