001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchGroupException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.model.CacheModel;
045 import com.liferay.portal.model.Group;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.model.impl.GroupImpl;
048 import com.liferay.portal.model.impl.GroupModelImpl;
049 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050
051 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
052 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
053 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
054 import com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence;
055 import com.liferay.portlet.calendar.service.persistence.CalEventPersistence;
056 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
057 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
058 import com.liferay.portlet.journal.service.persistence.JournalStructurePersistence;
059 import com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence;
060 import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
061 import com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence;
062 import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
063 import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
064 import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
065 import com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence;
066 import com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence;
067 import com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence;
068 import com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence;
069 import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
070 import com.liferay.portlet.wiki.service.persistence.WikiNodePersistence;
071
072 import java.io.Serializable;
073
074 import java.util.ArrayList;
075 import java.util.Collections;
076 import java.util.List;
077 import java.util.Set;
078
079
091 public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
092 implements GroupPersistence {
093
098 public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
099 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100 ".List1";
101 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
102 ".List2";
103 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
104 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
105 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
106 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
107 new String[] {
108 Long.class.getName(),
109
110 "java.lang.Integer", "java.lang.Integer",
111 "com.liferay.portal.kernel.util.OrderByComparator"
112 });
113 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
114 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
115 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
117 new String[] { Long.class.getName() },
118 GroupModelImpl.COMPANYID_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
120 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
122 new String[] { Long.class.getName() });
123 public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
124 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
125 FINDER_CLASS_NAME_ENTITY, "fetchByLiveGroupId",
126 new String[] { Long.class.getName() },
127 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK);
128 public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
129 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLiveGroupId",
131 new String[] { Long.class.getName() });
132 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
133 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
134 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
135 new String[] { Long.class.getName(), String.class.getName() },
136 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
137 GroupModelImpl.NAME_COLUMN_BITMASK);
138 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
139 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
140 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
141 new String[] { Long.class.getName(), String.class.getName() });
142 public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
143 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
144 FINDER_CLASS_NAME_ENTITY, "fetchByC_F",
145 new String[] { Long.class.getName(), String.class.getName() },
146 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
147 GroupModelImpl.FRIENDLYURL_COLUMN_BITMASK);
148 public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
149 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
150 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_F",
151 new String[] { Long.class.getName(), String.class.getName() });
152 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
153 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
154 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
155 new String[] {
156 Integer.class.getName(), Boolean.class.getName(),
157
158 "java.lang.Integer", "java.lang.Integer",
159 "com.liferay.portal.kernel.util.OrderByComparator"
160 });
161 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
162 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
163 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
164 new String[] { Integer.class.getName(), Boolean.class.getName() },
165 GroupModelImpl.TYPE_COLUMN_BITMASK |
166 GroupModelImpl.ACTIVE_COLUMN_BITMASK);
167 public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
168 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
169 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
170 new String[] { Integer.class.getName(), Boolean.class.getName() });
171 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
172 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
173 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
174 new String[] {
175 Long.class.getName(), Long.class.getName(), Long.class.getName()
176 },
177 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
178 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
179 GroupModelImpl.CLASSPK_COLUMN_BITMASK);
180 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
181 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
183 new String[] {
184 Long.class.getName(), Long.class.getName(), Long.class.getName()
185 });
186 public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
187 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
188 FINDER_CLASS_NAME_ENTITY, "fetchByC_L_N",
189 new String[] {
190 Long.class.getName(), Long.class.getName(),
191 String.class.getName()
192 },
193 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
194 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
195 GroupModelImpl.NAME_COLUMN_BITMASK);
196 public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
197 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L_N",
199 new String[] {
200 Long.class.getName(), Long.class.getName(),
201 String.class.getName()
202 });
203 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
204 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
205 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_L_N",
206 new String[] {
207 Long.class.getName(), Long.class.getName(), Long.class.getName(),
208 String.class.getName()
209 },
210 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
211 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
212 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
213 GroupModelImpl.NAME_COLUMN_BITMASK);
214 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
215 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
216 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_L_N",
217 new String[] {
218 Long.class.getName(), Long.class.getName(), Long.class.getName(),
219 String.class.getName()
220 });
221 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
222 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
223 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
224 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
225 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
226 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
227 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
228 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
229 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
230
231
236 public void cacheResult(Group group) {
237 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
238 GroupImpl.class, group.getPrimaryKey(), group);
239
240 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
241 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
242
243 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
244 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
245 group);
246
247 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
248 new Object[] {
249 Long.valueOf(group.getCompanyId()),
250
251 group.getFriendlyURL()
252 }, group);
253
254 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
255 new Object[] {
256 Long.valueOf(group.getCompanyId()),
257 Long.valueOf(group.getClassNameId()),
258 Long.valueOf(group.getClassPK())
259 }, group);
260
261 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
262 new Object[] {
263 Long.valueOf(group.getCompanyId()),
264 Long.valueOf(group.getLiveGroupId()),
265
266 group.getName()
267 }, group);
268
269 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
270 new Object[] {
271 Long.valueOf(group.getCompanyId()),
272 Long.valueOf(group.getClassNameId()),
273 Long.valueOf(group.getLiveGroupId()),
274
275 group.getName()
276 }, group);
277
278 group.resetOriginalValues();
279 }
280
281
286 public void cacheResult(List<Group> groups) {
287 for (Group group : groups) {
288 if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
289 GroupImpl.class, group.getPrimaryKey()) == null) {
290 cacheResult(group);
291 }
292 else {
293 group.resetOriginalValues();
294 }
295 }
296 }
297
298
305 @Override
306 public void clearCache() {
307 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
308 CacheRegistryUtil.clear(GroupImpl.class.getName());
309 }
310
311 EntityCacheUtil.clearCache(GroupImpl.class.getName());
312
313 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
314 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
316 }
317
318
325 @Override
326 public void clearCache(Group group) {
327 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
328 GroupImpl.class, group.getPrimaryKey());
329
330 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
332
333 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
334 new Object[] { Long.valueOf(group.getLiveGroupId()) });
335
336 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
337 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() });
338
339 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
340 new Object[] {
341 Long.valueOf(group.getCompanyId()),
342
343 group.getFriendlyURL()
344 });
345
346 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
347 new Object[] {
348 Long.valueOf(group.getCompanyId()),
349 Long.valueOf(group.getClassNameId()),
350 Long.valueOf(group.getClassPK())
351 });
352
353 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
354 new Object[] {
355 Long.valueOf(group.getCompanyId()),
356 Long.valueOf(group.getLiveGroupId()),
357
358 group.getName()
359 });
360
361 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
362 new Object[] {
363 Long.valueOf(group.getCompanyId()),
364 Long.valueOf(group.getClassNameId()),
365 Long.valueOf(group.getLiveGroupId()),
366
367 group.getName()
368 });
369 }
370
371
377 public Group create(long groupId) {
378 Group group = new GroupImpl();
379
380 group.setNew(true);
381 group.setPrimaryKey(groupId);
382
383 return group;
384 }
385
386
394 @Override
395 public Group remove(Serializable primaryKey)
396 throws NoSuchModelException, SystemException {
397 return remove(((Long)primaryKey).longValue());
398 }
399
400
408 public Group remove(long groupId)
409 throws NoSuchGroupException, SystemException {
410 Session session = null;
411
412 try {
413 session = openSession();
414
415 Group group = (Group)session.get(GroupImpl.class,
416 Long.valueOf(groupId));
417
418 if (group == null) {
419 if (_log.isWarnEnabled()) {
420 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
421 }
422
423 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
424 groupId);
425 }
426
427 return groupPersistence.remove(group);
428 }
429 catch (NoSuchGroupException nsee) {
430 throw nsee;
431 }
432 catch (Exception e) {
433 throw processException(e);
434 }
435 finally {
436 closeSession(session);
437 }
438 }
439
440
447 @Override
448 public Group remove(Group group) throws SystemException {
449 return super.remove(group);
450 }
451
452 @Override
453 protected Group removeImpl(Group group) throws SystemException {
454 group = toUnwrappedModel(group);
455
456 try {
457 clearOrganizations.clear(group.getPrimaryKey());
458 }
459 catch (Exception e) {
460 throw processException(e);
461 }
462 finally {
463 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
464 }
465
466 try {
467 clearPermissions.clear(group.getPrimaryKey());
468 }
469 catch (Exception e) {
470 throw processException(e);
471 }
472 finally {
473 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
474 }
475
476 try {
477 clearRoles.clear(group.getPrimaryKey());
478 }
479 catch (Exception e) {
480 throw processException(e);
481 }
482 finally {
483 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
484 }
485
486 try {
487 clearUserGroups.clear(group.getPrimaryKey());
488 }
489 catch (Exception e) {
490 throw processException(e);
491 }
492 finally {
493 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
494 }
495
496 try {
497 clearUsers.clear(group.getPrimaryKey());
498 }
499 catch (Exception e) {
500 throw processException(e);
501 }
502 finally {
503 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
504 }
505
506 Session session = null;
507
508 try {
509 session = openSession();
510
511 BatchSessionUtil.delete(session, group);
512 }
513 catch (Exception e) {
514 throw processException(e);
515 }
516 finally {
517 closeSession(session);
518 }
519
520 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
521 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
522
523 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
524
525 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
526 new Object[] { Long.valueOf(groupModelImpl.getLiveGroupId()) });
527
528 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
529 new Object[] {
530 Long.valueOf(groupModelImpl.getCompanyId()),
531
532 groupModelImpl.getName()
533 });
534
535 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
536 new Object[] {
537 Long.valueOf(groupModelImpl.getCompanyId()),
538
539 groupModelImpl.getFriendlyURL()
540 });
541
542 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
543 new Object[] {
544 Long.valueOf(groupModelImpl.getCompanyId()),
545 Long.valueOf(groupModelImpl.getClassNameId()),
546 Long.valueOf(groupModelImpl.getClassPK())
547 });
548
549 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
550 new Object[] {
551 Long.valueOf(groupModelImpl.getCompanyId()),
552 Long.valueOf(groupModelImpl.getLiveGroupId()),
553
554 groupModelImpl.getName()
555 });
556
557 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
558 new Object[] {
559 Long.valueOf(groupModelImpl.getCompanyId()),
560 Long.valueOf(groupModelImpl.getClassNameId()),
561 Long.valueOf(groupModelImpl.getLiveGroupId()),
562
563 groupModelImpl.getName()
564 });
565
566 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
567 GroupImpl.class, group.getPrimaryKey());
568
569 return group;
570 }
571
572 @Override
573 public Group updateImpl(com.liferay.portal.model.Group group, boolean merge)
574 throws SystemException {
575 group = toUnwrappedModel(group);
576
577 boolean isNew = group.isNew();
578
579 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
580
581 Session session = null;
582
583 try {
584 session = openSession();
585
586 BatchSessionUtil.update(session, group, merge);
587
588 group.setNew(false);
589 }
590 catch (Exception e) {
591 throw processException(e);
592 }
593 finally {
594 closeSession(session);
595 }
596
597 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
598
599 if (isNew || !GroupModelImpl.COLUMN_BITMASK_ENABLED) {
600 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
601 }
602
603 else {
604 if ((groupModelImpl.getColumnBitmask() &
605 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
606 Object[] args = new Object[] {
607 Long.valueOf(groupModelImpl.getOriginalCompanyId())
608 };
609
610 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
611 args);
612 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
613 args);
614
615 args = new Object[] { Long.valueOf(groupModelImpl.getCompanyId()) };
616
617 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
618 args);
619 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
620 args);
621 }
622
623 if ((groupModelImpl.getColumnBitmask() &
624 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
625 Object[] args = new Object[] {
626 Integer.valueOf(groupModelImpl.getOriginalType()),
627 Boolean.valueOf(groupModelImpl.getOriginalActive())
628 };
629
630 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
631 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
632 args);
633
634 args = new Object[] {
635 Integer.valueOf(groupModelImpl.getType()),
636 Boolean.valueOf(groupModelImpl.getActive())
637 };
638
639 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
640 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
641 args);
642 }
643 }
644
645 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
646 GroupImpl.class, group.getPrimaryKey(), group);
647
648 if (isNew) {
649 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
650 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
651
652 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
653 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
654 group);
655
656 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
657 new Object[] {
658 Long.valueOf(group.getCompanyId()),
659
660 group.getFriendlyURL()
661 }, group);
662
663 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
664 new Object[] {
665 Long.valueOf(group.getCompanyId()),
666 Long.valueOf(group.getClassNameId()),
667 Long.valueOf(group.getClassPK())
668 }, group);
669
670 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
671 new Object[] {
672 Long.valueOf(group.getCompanyId()),
673 Long.valueOf(group.getLiveGroupId()),
674
675 group.getName()
676 }, group);
677
678 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
679 new Object[] {
680 Long.valueOf(group.getCompanyId()),
681 Long.valueOf(group.getClassNameId()),
682 Long.valueOf(group.getLiveGroupId()),
683
684 group.getName()
685 }, group);
686 }
687 else {
688 if ((groupModelImpl.getColumnBitmask() &
689 FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
690 Object[] args = new Object[] {
691 Long.valueOf(groupModelImpl.getOriginalLiveGroupId())
692 };
693
694 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
695 args);
696 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
697 args);
698
699 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
700 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
701 }
702
703 if ((groupModelImpl.getColumnBitmask() &
704 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
705 Object[] args = new Object[] {
706 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
707
708 groupModelImpl.getOriginalName()
709 };
710
711 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
712 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
713
714 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
715 new Object[] {
716 Long.valueOf(group.getCompanyId()),
717
718 group.getName()
719 }, group);
720 }
721
722 if ((groupModelImpl.getColumnBitmask() &
723 FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
724 Object[] args = new Object[] {
725 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
726
727 groupModelImpl.getOriginalFriendlyURL()
728 };
729
730 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
731 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
732
733 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
734 new Object[] {
735 Long.valueOf(group.getCompanyId()),
736
737 group.getFriendlyURL()
738 }, group);
739 }
740
741 if ((groupModelImpl.getColumnBitmask() &
742 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
743 Object[] args = new Object[] {
744 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
745 Long.valueOf(groupModelImpl.getOriginalClassNameId()),
746 Long.valueOf(groupModelImpl.getOriginalClassPK())
747 };
748
749 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
750 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
751
752 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
753 new Object[] {
754 Long.valueOf(group.getCompanyId()),
755 Long.valueOf(group.getClassNameId()),
756 Long.valueOf(group.getClassPK())
757 }, group);
758 }
759
760 if ((groupModelImpl.getColumnBitmask() &
761 FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
762 Object[] args = new Object[] {
763 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
764 Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
765
766 groupModelImpl.getOriginalName()
767 };
768
769 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
770 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
771
772 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
773 new Object[] {
774 Long.valueOf(group.getCompanyId()),
775 Long.valueOf(group.getLiveGroupId()),
776
777 group.getName()
778 }, group);
779 }
780
781 if ((groupModelImpl.getColumnBitmask() &
782 FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
783 Object[] args = new Object[] {
784 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
785 Long.valueOf(groupModelImpl.getOriginalClassNameId()),
786 Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
787
788 groupModelImpl.getOriginalName()
789 };
790
791 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
792 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
793
794 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
795 new Object[] {
796 Long.valueOf(group.getCompanyId()),
797 Long.valueOf(group.getClassNameId()),
798 Long.valueOf(group.getLiveGroupId()),
799
800 group.getName()
801 }, group);
802 }
803 }
804
805 return group;
806 }
807
808 protected Group toUnwrappedModel(Group group) {
809 if (group instanceof GroupImpl) {
810 return group;
811 }
812
813 GroupImpl groupImpl = new GroupImpl();
814
815 groupImpl.setNew(group.isNew());
816 groupImpl.setPrimaryKey(group.getPrimaryKey());
817
818 groupImpl.setGroupId(group.getGroupId());
819 groupImpl.setCompanyId(group.getCompanyId());
820 groupImpl.setCreatorUserId(group.getCreatorUserId());
821 groupImpl.setClassNameId(group.getClassNameId());
822 groupImpl.setClassPK(group.getClassPK());
823 groupImpl.setParentGroupId(group.getParentGroupId());
824 groupImpl.setLiveGroupId(group.getLiveGroupId());
825 groupImpl.setName(group.getName());
826 groupImpl.setDescription(group.getDescription());
827 groupImpl.setType(group.getType());
828 groupImpl.setTypeSettings(group.getTypeSettings());
829 groupImpl.setFriendlyURL(group.getFriendlyURL());
830 groupImpl.setSite(group.isSite());
831 groupImpl.setActive(group.isActive());
832
833 return groupImpl;
834 }
835
836
844 @Override
845 public Group findByPrimaryKey(Serializable primaryKey)
846 throws NoSuchModelException, SystemException {
847 return findByPrimaryKey(((Long)primaryKey).longValue());
848 }
849
850
858 public Group findByPrimaryKey(long groupId)
859 throws NoSuchGroupException, SystemException {
860 Group group = fetchByPrimaryKey(groupId);
861
862 if (group == null) {
863 if (_log.isWarnEnabled()) {
864 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
865 }
866
867 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
868 groupId);
869 }
870
871 return group;
872 }
873
874
881 @Override
882 public Group fetchByPrimaryKey(Serializable primaryKey)
883 throws SystemException {
884 return fetchByPrimaryKey(((Long)primaryKey).longValue());
885 }
886
887
894 public Group fetchByPrimaryKey(long groupId) throws SystemException {
895 Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
896 GroupImpl.class, groupId);
897
898 if (group == _nullGroup) {
899 return null;
900 }
901
902 if (group == null) {
903 Session session = null;
904
905 boolean hasException = false;
906
907 try {
908 session = openSession();
909
910 group = (Group)session.get(GroupImpl.class,
911 Long.valueOf(groupId));
912 }
913 catch (Exception e) {
914 hasException = true;
915
916 throw processException(e);
917 }
918 finally {
919 if (group != null) {
920 cacheResult(group);
921 }
922 else if (!hasException) {
923 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
924 GroupImpl.class, groupId, _nullGroup);
925 }
926
927 closeSession(session);
928 }
929 }
930
931 return group;
932 }
933
934
941 public List<Group> findByCompanyId(long companyId)
942 throws SystemException {
943 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
944 null);
945 }
946
947
960 public List<Group> findByCompanyId(long companyId, int start, int end)
961 throws SystemException {
962 return findByCompanyId(companyId, start, end, null);
963 }
964
965
979 public List<Group> findByCompanyId(long companyId, int start, int end,
980 OrderByComparator orderByComparator) throws SystemException {
981 FinderPath finderPath = null;
982 Object[] finderArgs = null;
983
984 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
985 (orderByComparator == null)) {
986 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
987 finderArgs = new Object[] { companyId };
988 }
989 else {
990 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
991 finderArgs = new Object[] { companyId, start, end, orderByComparator };
992 }
993
994 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
995 finderArgs, this);
996
997 if (list == null) {
998 StringBundler query = null;
999
1000 if (orderByComparator != null) {
1001 query = new StringBundler(3 +
1002 (orderByComparator.getOrderByFields().length * 3));
1003 }
1004 else {
1005 query = new StringBundler(3);
1006 }
1007
1008 query.append(_SQL_SELECT_GROUP__WHERE);
1009
1010 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1011
1012 if (orderByComparator != null) {
1013 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1014 orderByComparator);
1015 }
1016
1017 else {
1018 query.append(GroupModelImpl.ORDER_BY_JPQL);
1019 }
1020
1021 String sql = query.toString();
1022
1023 Session session = null;
1024
1025 try {
1026 session = openSession();
1027
1028 Query q = session.createQuery(sql);
1029
1030 QueryPos qPos = QueryPos.getInstance(q);
1031
1032 qPos.add(companyId);
1033
1034 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1035 }
1036 catch (Exception e) {
1037 throw processException(e);
1038 }
1039 finally {
1040 if (list == null) {
1041 FinderCacheUtil.removeResult(finderPath, finderArgs);
1042 }
1043 else {
1044 cacheResult(list);
1045
1046 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1047 }
1048
1049 closeSession(session);
1050 }
1051 }
1052
1053 return list;
1054 }
1055
1056
1069 public Group findByCompanyId_First(long companyId,
1070 OrderByComparator orderByComparator)
1071 throws NoSuchGroupException, SystemException {
1072 List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1073
1074 if (list.isEmpty()) {
1075 StringBundler msg = new StringBundler(4);
1076
1077 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1078
1079 msg.append("companyId=");
1080 msg.append(companyId);
1081
1082 msg.append(StringPool.CLOSE_CURLY_BRACE);
1083
1084 throw new NoSuchGroupException(msg.toString());
1085 }
1086 else {
1087 return list.get(0);
1088 }
1089 }
1090
1091
1104 public Group findByCompanyId_Last(long companyId,
1105 OrderByComparator orderByComparator)
1106 throws NoSuchGroupException, SystemException {
1107 int count = countByCompanyId(companyId);
1108
1109 List<Group> list = findByCompanyId(companyId, count - 1, count,
1110 orderByComparator);
1111
1112 if (list.isEmpty()) {
1113 StringBundler msg = new StringBundler(4);
1114
1115 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1116
1117 msg.append("companyId=");
1118 msg.append(companyId);
1119
1120 msg.append(StringPool.CLOSE_CURLY_BRACE);
1121
1122 throw new NoSuchGroupException(msg.toString());
1123 }
1124 else {
1125 return list.get(0);
1126 }
1127 }
1128
1129
1143 public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
1144 OrderByComparator orderByComparator)
1145 throws NoSuchGroupException, SystemException {
1146 Group group = findByPrimaryKey(groupId);
1147
1148 Session session = null;
1149
1150 try {
1151 session = openSession();
1152
1153 Group[] array = new GroupImpl[3];
1154
1155 array[0] = getByCompanyId_PrevAndNext(session, group, companyId,
1156 orderByComparator, true);
1157
1158 array[1] = group;
1159
1160 array[2] = getByCompanyId_PrevAndNext(session, group, companyId,
1161 orderByComparator, false);
1162
1163 return array;
1164 }
1165 catch (Exception e) {
1166 throw processException(e);
1167 }
1168 finally {
1169 closeSession(session);
1170 }
1171 }
1172
1173 protected Group getByCompanyId_PrevAndNext(Session session, Group group,
1174 long companyId, OrderByComparator orderByComparator, boolean previous) {
1175 StringBundler query = null;
1176
1177 if (orderByComparator != null) {
1178 query = new StringBundler(6 +
1179 (orderByComparator.getOrderByFields().length * 6));
1180 }
1181 else {
1182 query = new StringBundler(3);
1183 }
1184
1185 query.append(_SQL_SELECT_GROUP__WHERE);
1186
1187 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1188
1189 if (orderByComparator != null) {
1190 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1191
1192 if (orderByConditionFields.length > 0) {
1193 query.append(WHERE_AND);
1194 }
1195
1196 for (int i = 0; i < orderByConditionFields.length; i++) {
1197 query.append(_ORDER_BY_ENTITY_ALIAS);
1198 query.append(orderByConditionFields[i]);
1199
1200 if ((i + 1) < orderByConditionFields.length) {
1201 if (orderByComparator.isAscending() ^ previous) {
1202 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1203 }
1204 else {
1205 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1206 }
1207 }
1208 else {
1209 if (orderByComparator.isAscending() ^ previous) {
1210 query.append(WHERE_GREATER_THAN);
1211 }
1212 else {
1213 query.append(WHERE_LESSER_THAN);
1214 }
1215 }
1216 }
1217
1218 query.append(ORDER_BY_CLAUSE);
1219
1220 String[] orderByFields = orderByComparator.getOrderByFields();
1221
1222 for (int i = 0; i < orderByFields.length; i++) {
1223 query.append(_ORDER_BY_ENTITY_ALIAS);
1224 query.append(orderByFields[i]);
1225
1226 if ((i + 1) < orderByFields.length) {
1227 if (orderByComparator.isAscending() ^ previous) {
1228 query.append(ORDER_BY_ASC_HAS_NEXT);
1229 }
1230 else {
1231 query.append(ORDER_BY_DESC_HAS_NEXT);
1232 }
1233 }
1234 else {
1235 if (orderByComparator.isAscending() ^ previous) {
1236 query.append(ORDER_BY_ASC);
1237 }
1238 else {
1239 query.append(ORDER_BY_DESC);
1240 }
1241 }
1242 }
1243 }
1244
1245 else {
1246 query.append(GroupModelImpl.ORDER_BY_JPQL);
1247 }
1248
1249 String sql = query.toString();
1250
1251 Query q = session.createQuery(sql);
1252
1253 q.setFirstResult(0);
1254 q.setMaxResults(2);
1255
1256 QueryPos qPos = QueryPos.getInstance(q);
1257
1258 qPos.add(companyId);
1259
1260 if (orderByComparator != null) {
1261 Object[] values = orderByComparator.getOrderByConditionValues(group);
1262
1263 for (Object value : values) {
1264 qPos.add(value);
1265 }
1266 }
1267
1268 List<Group> list = q.list();
1269
1270 if (list.size() == 2) {
1271 return list.get(1);
1272 }
1273 else {
1274 return null;
1275 }
1276 }
1277
1278
1286 public Group findByLiveGroupId(long liveGroupId)
1287 throws NoSuchGroupException, SystemException {
1288 Group group = fetchByLiveGroupId(liveGroupId);
1289
1290 if (group == null) {
1291 StringBundler msg = new StringBundler(4);
1292
1293 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1294
1295 msg.append("liveGroupId=");
1296 msg.append(liveGroupId);
1297
1298 msg.append(StringPool.CLOSE_CURLY_BRACE);
1299
1300 if (_log.isWarnEnabled()) {
1301 _log.warn(msg.toString());
1302 }
1303
1304 throw new NoSuchGroupException(msg.toString());
1305 }
1306
1307 return group;
1308 }
1309
1310
1317 public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
1318 return fetchByLiveGroupId(liveGroupId, true);
1319 }
1320
1321
1329 public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
1330 throws SystemException {
1331 Object[] finderArgs = new Object[] { liveGroupId };
1332
1333 Object result = null;
1334
1335 if (retrieveFromCache) {
1336 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1337 finderArgs, this);
1338 }
1339
1340 if (result == null) {
1341 StringBundler query = new StringBundler(3);
1342
1343 query.append(_SQL_SELECT_GROUP__WHERE);
1344
1345 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
1346
1347 query.append(GroupModelImpl.ORDER_BY_JPQL);
1348
1349 String sql = query.toString();
1350
1351 Session session = null;
1352
1353 try {
1354 session = openSession();
1355
1356 Query q = session.createQuery(sql);
1357
1358 QueryPos qPos = QueryPos.getInstance(q);
1359
1360 qPos.add(liveGroupId);
1361
1362 List<Group> list = q.list();
1363
1364 result = list;
1365
1366 Group group = null;
1367
1368 if (list.isEmpty()) {
1369 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1370 finderArgs, list);
1371 }
1372 else {
1373 group = list.get(0);
1374
1375 cacheResult(group);
1376
1377 if ((group.getLiveGroupId() != liveGroupId)) {
1378 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1379 finderArgs, group);
1380 }
1381 }
1382
1383 return group;
1384 }
1385 catch (Exception e) {
1386 throw processException(e);
1387 }
1388 finally {
1389 if (result == null) {
1390 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1391 finderArgs);
1392 }
1393
1394 closeSession(session);
1395 }
1396 }
1397 else {
1398 if (result instanceof List<?>) {
1399 return null;
1400 }
1401 else {
1402 return (Group)result;
1403 }
1404 }
1405 }
1406
1407
1416 public Group findByC_N(long companyId, String name)
1417 throws NoSuchGroupException, SystemException {
1418 Group group = fetchByC_N(companyId, name);
1419
1420 if (group == null) {
1421 StringBundler msg = new StringBundler(6);
1422
1423 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1424
1425 msg.append("companyId=");
1426 msg.append(companyId);
1427
1428 msg.append(", name=");
1429 msg.append(name);
1430
1431 msg.append(StringPool.CLOSE_CURLY_BRACE);
1432
1433 if (_log.isWarnEnabled()) {
1434 _log.warn(msg.toString());
1435 }
1436
1437 throw new NoSuchGroupException(msg.toString());
1438 }
1439
1440 return group;
1441 }
1442
1443
1451 public Group fetchByC_N(long companyId, String name)
1452 throws SystemException {
1453 return fetchByC_N(companyId, name, true);
1454 }
1455
1456
1465 public Group fetchByC_N(long companyId, String name,
1466 boolean retrieveFromCache) throws SystemException {
1467 Object[] finderArgs = new Object[] { companyId, name };
1468
1469 Object result = null;
1470
1471 if (retrieveFromCache) {
1472 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1473 finderArgs, this);
1474 }
1475
1476 if (result == null) {
1477 StringBundler query = new StringBundler(4);
1478
1479 query.append(_SQL_SELECT_GROUP__WHERE);
1480
1481 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1482
1483 if (name == null) {
1484 query.append(_FINDER_COLUMN_C_N_NAME_1);
1485 }
1486 else {
1487 if (name.equals(StringPool.BLANK)) {
1488 query.append(_FINDER_COLUMN_C_N_NAME_3);
1489 }
1490 else {
1491 query.append(_FINDER_COLUMN_C_N_NAME_2);
1492 }
1493 }
1494
1495 query.append(GroupModelImpl.ORDER_BY_JPQL);
1496
1497 String sql = query.toString();
1498
1499 Session session = null;
1500
1501 try {
1502 session = openSession();
1503
1504 Query q = session.createQuery(sql);
1505
1506 QueryPos qPos = QueryPos.getInstance(q);
1507
1508 qPos.add(companyId);
1509
1510 if (name != null) {
1511 qPos.add(name);
1512 }
1513
1514 List<Group> list = q.list();
1515
1516 result = list;
1517
1518 Group group = null;
1519
1520 if (list.isEmpty()) {
1521 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1522 finderArgs, list);
1523 }
1524 else {
1525 group = list.get(0);
1526
1527 cacheResult(group);
1528
1529 if ((group.getCompanyId() != companyId) ||
1530 (group.getName() == null) ||
1531 !group.getName().equals(name)) {
1532 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1533 finderArgs, group);
1534 }
1535 }
1536
1537 return group;
1538 }
1539 catch (Exception e) {
1540 throw processException(e);
1541 }
1542 finally {
1543 if (result == null) {
1544 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
1545 finderArgs);
1546 }
1547
1548 closeSession(session);
1549 }
1550 }
1551 else {
1552 if (result instanceof List<?>) {
1553 return null;
1554 }
1555 else {
1556 return (Group)result;
1557 }
1558 }
1559 }
1560
1561
1570 public Group findByC_F(long companyId, String friendlyURL)
1571 throws NoSuchGroupException, SystemException {
1572 Group group = fetchByC_F(companyId, friendlyURL);
1573
1574 if (group == null) {
1575 StringBundler msg = new StringBundler(6);
1576
1577 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1578
1579 msg.append("companyId=");
1580 msg.append(companyId);
1581
1582 msg.append(", friendlyURL=");
1583 msg.append(friendlyURL);
1584
1585 msg.append(StringPool.CLOSE_CURLY_BRACE);
1586
1587 if (_log.isWarnEnabled()) {
1588 _log.warn(msg.toString());
1589 }
1590
1591 throw new NoSuchGroupException(msg.toString());
1592 }
1593
1594 return group;
1595 }
1596
1597
1605 public Group fetchByC_F(long companyId, String friendlyURL)
1606 throws SystemException {
1607 return fetchByC_F(companyId, friendlyURL, true);
1608 }
1609
1610
1619 public Group fetchByC_F(long companyId, String friendlyURL,
1620 boolean retrieveFromCache) throws SystemException {
1621 Object[] finderArgs = new Object[] { companyId, friendlyURL };
1622
1623 Object result = null;
1624
1625 if (retrieveFromCache) {
1626 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
1627 finderArgs, this);
1628 }
1629
1630 if (result == null) {
1631 StringBundler query = new StringBundler(4);
1632
1633 query.append(_SQL_SELECT_GROUP__WHERE);
1634
1635 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
1636
1637 if (friendlyURL == null) {
1638 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
1639 }
1640 else {
1641 if (friendlyURL.equals(StringPool.BLANK)) {
1642 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
1643 }
1644 else {
1645 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
1646 }
1647 }
1648
1649 query.append(GroupModelImpl.ORDER_BY_JPQL);
1650
1651 String sql = query.toString();
1652
1653 Session session = null;
1654
1655 try {
1656 session = openSession();
1657
1658 Query q = session.createQuery(sql);
1659
1660 QueryPos qPos = QueryPos.getInstance(q);
1661
1662 qPos.add(companyId);
1663
1664 if (friendlyURL != null) {
1665 qPos.add(friendlyURL);
1666 }
1667
1668 List<Group> list = q.list();
1669
1670 result = list;
1671
1672 Group group = null;
1673
1674 if (list.isEmpty()) {
1675 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1676 finderArgs, list);
1677 }
1678 else {
1679 group = list.get(0);
1680
1681 cacheResult(group);
1682
1683 if ((group.getCompanyId() != companyId) ||
1684 (group.getFriendlyURL() == null) ||
1685 !group.getFriendlyURL().equals(friendlyURL)) {
1686 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1687 finderArgs, group);
1688 }
1689 }
1690
1691 return group;
1692 }
1693 catch (Exception e) {
1694 throw processException(e);
1695 }
1696 finally {
1697 if (result == null) {
1698 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
1699 finderArgs);
1700 }
1701
1702 closeSession(session);
1703 }
1704 }
1705 else {
1706 if (result instanceof List<?>) {
1707 return null;
1708 }
1709 else {
1710 return (Group)result;
1711 }
1712 }
1713 }
1714
1715
1723 public List<Group> findByT_A(int type, boolean active)
1724 throws SystemException {
1725 return findByT_A(type, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1726 null);
1727 }
1728
1729
1743 public List<Group> findByT_A(int type, boolean active, int start, int end)
1744 throws SystemException {
1745 return findByT_A(type, active, start, end, null);
1746 }
1747
1748
1763 public List<Group> findByT_A(int type, boolean active, int start, int end,
1764 OrderByComparator orderByComparator) throws SystemException {
1765 FinderPath finderPath = null;
1766 Object[] finderArgs = null;
1767
1768 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1769 (orderByComparator == null)) {
1770 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
1771 finderArgs = new Object[] { type, active };
1772 }
1773 else {
1774 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
1775 finderArgs = new Object[] {
1776 type, active,
1777
1778 start, end, orderByComparator
1779 };
1780 }
1781
1782 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1783 finderArgs, this);
1784
1785 if (list == null) {
1786 StringBundler query = null;
1787
1788 if (orderByComparator != null) {
1789 query = new StringBundler(4 +
1790 (orderByComparator.getOrderByFields().length * 3));
1791 }
1792 else {
1793 query = new StringBundler(4);
1794 }
1795
1796 query.append(_SQL_SELECT_GROUP__WHERE);
1797
1798 query.append(_FINDER_COLUMN_T_A_TYPE_2);
1799
1800 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1801
1802 if (orderByComparator != null) {
1803 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1804 orderByComparator);
1805 }
1806
1807 else {
1808 query.append(GroupModelImpl.ORDER_BY_JPQL);
1809 }
1810
1811 String sql = query.toString();
1812
1813 Session session = null;
1814
1815 try {
1816 session = openSession();
1817
1818 Query q = session.createQuery(sql);
1819
1820 QueryPos qPos = QueryPos.getInstance(q);
1821
1822 qPos.add(type);
1823
1824 qPos.add(active);
1825
1826 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1827 }
1828 catch (Exception e) {
1829 throw processException(e);
1830 }
1831 finally {
1832 if (list == null) {
1833 FinderCacheUtil.removeResult(finderPath, finderArgs);
1834 }
1835 else {
1836 cacheResult(list);
1837
1838 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1839 }
1840
1841 closeSession(session);
1842 }
1843 }
1844
1845 return list;
1846 }
1847
1848
1862 public Group findByT_A_First(int type, boolean active,
1863 OrderByComparator orderByComparator)
1864 throws NoSuchGroupException, SystemException {
1865 List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
1866
1867 if (list.isEmpty()) {
1868 StringBundler msg = new StringBundler(6);
1869
1870 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1871
1872 msg.append("type=");
1873 msg.append(type);
1874
1875 msg.append(", active=");
1876 msg.append(active);
1877
1878 msg.append(StringPool.CLOSE_CURLY_BRACE);
1879
1880 throw new NoSuchGroupException(msg.toString());
1881 }
1882 else {
1883 return list.get(0);
1884 }
1885 }
1886
1887
1901 public Group findByT_A_Last(int type, boolean active,
1902 OrderByComparator orderByComparator)
1903 throws NoSuchGroupException, SystemException {
1904 int count = countByT_A(type, active);
1905
1906 List<Group> list = findByT_A(type, active, count - 1, count,
1907 orderByComparator);
1908
1909 if (list.isEmpty()) {
1910 StringBundler msg = new StringBundler(6);
1911
1912 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1913
1914 msg.append("type=");
1915 msg.append(type);
1916
1917 msg.append(", active=");
1918 msg.append(active);
1919
1920 msg.append(StringPool.CLOSE_CURLY_BRACE);
1921
1922 throw new NoSuchGroupException(msg.toString());
1923 }
1924 else {
1925 return list.get(0);
1926 }
1927 }
1928
1929
1944 public Group[] findByT_A_PrevAndNext(long groupId, int type,
1945 boolean active, OrderByComparator orderByComparator)
1946 throws NoSuchGroupException, SystemException {
1947 Group group = findByPrimaryKey(groupId);
1948
1949 Session session = null;
1950
1951 try {
1952 session = openSession();
1953
1954 Group[] array = new GroupImpl[3];
1955
1956 array[0] = getByT_A_PrevAndNext(session, group, type, active,
1957 orderByComparator, true);
1958
1959 array[1] = group;
1960
1961 array[2] = getByT_A_PrevAndNext(session, group, type, active,
1962 orderByComparator, false);
1963
1964 return array;
1965 }
1966 catch (Exception e) {
1967 throw processException(e);
1968 }
1969 finally {
1970 closeSession(session);
1971 }
1972 }
1973
1974 protected Group getByT_A_PrevAndNext(Session session, Group group,
1975 int type, boolean active, OrderByComparator orderByComparator,
1976 boolean previous) {
1977 StringBundler query = null;
1978
1979 if (orderByComparator != null) {
1980 query = new StringBundler(6 +
1981 (orderByComparator.getOrderByFields().length * 6));
1982 }
1983 else {
1984 query = new StringBundler(3);
1985 }
1986
1987 query.append(_SQL_SELECT_GROUP__WHERE);
1988
1989 query.append(_FINDER_COLUMN_T_A_TYPE_2);
1990
1991 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1992
1993 if (orderByComparator != null) {
1994 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1995
1996 if (orderByConditionFields.length > 0) {
1997 query.append(WHERE_AND);
1998 }
1999
2000 for (int i = 0; i < orderByConditionFields.length; i++) {
2001 query.append(_ORDER_BY_ENTITY_ALIAS);
2002 query.append(orderByConditionFields[i]);
2003
2004 if ((i + 1) < orderByConditionFields.length) {
2005 if (orderByComparator.isAscending() ^ previous) {
2006 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2007 }
2008 else {
2009 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2010 }
2011 }
2012 else {
2013 if (orderByComparator.isAscending() ^ previous) {
2014 query.append(WHERE_GREATER_THAN);
2015 }
2016 else {
2017 query.append(WHERE_LESSER_THAN);
2018 }
2019 }
2020 }
2021
2022 query.append(ORDER_BY_CLAUSE);
2023
2024 String[] orderByFields = orderByComparator.getOrderByFields();
2025
2026 for (int i = 0; i < orderByFields.length; i++) {
2027 query.append(_ORDER_BY_ENTITY_ALIAS);
2028 query.append(orderByFields[i]);
2029
2030 if ((i + 1) < orderByFields.length) {
2031 if (orderByComparator.isAscending() ^ previous) {
2032 query.append(ORDER_BY_ASC_HAS_NEXT);
2033 }
2034 else {
2035 query.append(ORDER_BY_DESC_HAS_NEXT);
2036 }
2037 }
2038 else {
2039 if (orderByComparator.isAscending() ^ previous) {
2040 query.append(ORDER_BY_ASC);
2041 }
2042 else {
2043 query.append(ORDER_BY_DESC);
2044 }
2045 }
2046 }
2047 }
2048
2049 else {
2050 query.append(GroupModelImpl.ORDER_BY_JPQL);
2051 }
2052
2053 String sql = query.toString();
2054
2055 Query q = session.createQuery(sql);
2056
2057 q.setFirstResult(0);
2058 q.setMaxResults(2);
2059
2060 QueryPos qPos = QueryPos.getInstance(q);
2061
2062 qPos.add(type);
2063
2064 qPos.add(active);
2065
2066 if (orderByComparator != null) {
2067 Object[] values = orderByComparator.getOrderByConditionValues(group);
2068
2069 for (Object value : values) {
2070 qPos.add(value);
2071 }
2072 }
2073
2074 List<Group> list = q.list();
2075
2076 if (list.size() == 2) {
2077 return list.get(1);
2078 }
2079 else {
2080 return null;
2081 }
2082 }
2083
2084
2094 public Group findByC_C_C(long companyId, long classNameId, long classPK)
2095 throws NoSuchGroupException, SystemException {
2096 Group group = fetchByC_C_C(companyId, classNameId, classPK);
2097
2098 if (group == null) {
2099 StringBundler msg = new StringBundler(8);
2100
2101 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2102
2103 msg.append("companyId=");
2104 msg.append(companyId);
2105
2106 msg.append(", classNameId=");
2107 msg.append(classNameId);
2108
2109 msg.append(", classPK=");
2110 msg.append(classPK);
2111
2112 msg.append(StringPool.CLOSE_CURLY_BRACE);
2113
2114 if (_log.isWarnEnabled()) {
2115 _log.warn(msg.toString());
2116 }
2117
2118 throw new NoSuchGroupException(msg.toString());
2119 }
2120
2121 return group;
2122 }
2123
2124
2133 public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
2134 throws SystemException {
2135 return fetchByC_C_C(companyId, classNameId, classPK, true);
2136 }
2137
2138
2148 public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
2149 boolean retrieveFromCache) throws SystemException {
2150 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2151
2152 Object result = null;
2153
2154 if (retrieveFromCache) {
2155 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
2156 finderArgs, this);
2157 }
2158
2159 if (result == null) {
2160 StringBundler query = new StringBundler(5);
2161
2162 query.append(_SQL_SELECT_GROUP__WHERE);
2163
2164 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2165
2166 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2167
2168 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2169
2170 query.append(GroupModelImpl.ORDER_BY_JPQL);
2171
2172 String sql = query.toString();
2173
2174 Session session = null;
2175
2176 try {
2177 session = openSession();
2178
2179 Query q = session.createQuery(sql);
2180
2181 QueryPos qPos = QueryPos.getInstance(q);
2182
2183 qPos.add(companyId);
2184
2185 qPos.add(classNameId);
2186
2187 qPos.add(classPK);
2188
2189 List<Group> list = q.list();
2190
2191 result = list;
2192
2193 Group group = null;
2194
2195 if (list.isEmpty()) {
2196 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2197 finderArgs, list);
2198 }
2199 else {
2200 group = list.get(0);
2201
2202 cacheResult(group);
2203
2204 if ((group.getCompanyId() != companyId) ||
2205 (group.getClassNameId() != classNameId) ||
2206 (group.getClassPK() != classPK)) {
2207 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2208 finderArgs, group);
2209 }
2210 }
2211
2212 return group;
2213 }
2214 catch (Exception e) {
2215 throw processException(e);
2216 }
2217 finally {
2218 if (result == null) {
2219 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
2220 finderArgs);
2221 }
2222
2223 closeSession(session);
2224 }
2225 }
2226 else {
2227 if (result instanceof List<?>) {
2228 return null;
2229 }
2230 else {
2231 return (Group)result;
2232 }
2233 }
2234 }
2235
2236
2246 public Group findByC_L_N(long companyId, long liveGroupId, String name)
2247 throws NoSuchGroupException, SystemException {
2248 Group group = fetchByC_L_N(companyId, liveGroupId, name);
2249
2250 if (group == null) {
2251 StringBundler msg = new StringBundler(8);
2252
2253 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2254
2255 msg.append("companyId=");
2256 msg.append(companyId);
2257
2258 msg.append(", liveGroupId=");
2259 msg.append(liveGroupId);
2260
2261 msg.append(", name=");
2262 msg.append(name);
2263
2264 msg.append(StringPool.CLOSE_CURLY_BRACE);
2265
2266 if (_log.isWarnEnabled()) {
2267 _log.warn(msg.toString());
2268 }
2269
2270 throw new NoSuchGroupException(msg.toString());
2271 }
2272
2273 return group;
2274 }
2275
2276
2285 public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
2286 throws SystemException {
2287 return fetchByC_L_N(companyId, liveGroupId, name, true);
2288 }
2289
2290
2300 public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
2301 boolean retrieveFromCache) throws SystemException {
2302 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
2303
2304 Object result = null;
2305
2306 if (retrieveFromCache) {
2307 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
2308 finderArgs, this);
2309 }
2310
2311 if (result == null) {
2312 StringBundler query = new StringBundler(5);
2313
2314 query.append(_SQL_SELECT_GROUP__WHERE);
2315
2316 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
2317
2318 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
2319
2320 if (name == null) {
2321 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
2322 }
2323 else {
2324 if (name.equals(StringPool.BLANK)) {
2325 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
2326 }
2327 else {
2328 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
2329 }
2330 }
2331
2332 query.append(GroupModelImpl.ORDER_BY_JPQL);
2333
2334 String sql = query.toString();
2335
2336 Session session = null;
2337
2338 try {
2339 session = openSession();
2340
2341 Query q = session.createQuery(sql);
2342
2343 QueryPos qPos = QueryPos.getInstance(q);
2344
2345 qPos.add(companyId);
2346
2347 qPos.add(liveGroupId);
2348
2349 if (name != null) {
2350 qPos.add(name);
2351 }
2352
2353 List<Group> list = q.list();
2354
2355 result = list;
2356
2357 Group group = null;
2358
2359 if (list.isEmpty()) {
2360 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
2361 finderArgs, list);
2362 }
2363 else {
2364 group = list.get(0);
2365
2366 cacheResult(group);
2367
2368 if ((group.getCompanyId() != companyId) ||
2369 (group.getLiveGroupId() != liveGroupId) ||
2370 (group.getName() == null) ||
2371 !group.getName().equals(name)) {
2372 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
2373 finderArgs, group);
2374 }
2375 }
2376
2377 return group;
2378 }
2379 catch (Exception e) {
2380 throw processException(e);
2381 }
2382 finally {
2383 if (result == null) {
2384 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
2385 finderArgs);
2386 }
2387
2388 closeSession(session);
2389 }
2390 }
2391 else {
2392 if (result instanceof List<?>) {
2393 return null;
2394 }
2395 else {
2396 return (Group)result;
2397 }
2398 }
2399 }
2400
2401
2412 public Group findByC_C_L_N(long companyId, long classNameId,
2413 long liveGroupId, String name)
2414 throws NoSuchGroupException, SystemException {
2415 Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
2416
2417 if (group == null) {
2418 StringBundler msg = new StringBundler(10);
2419
2420 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2421
2422 msg.append("companyId=");
2423 msg.append(companyId);
2424
2425 msg.append(", classNameId=");
2426 msg.append(classNameId);
2427
2428 msg.append(", liveGroupId=");
2429 msg.append(liveGroupId);
2430
2431 msg.append(", name=");
2432 msg.append(name);
2433
2434 msg.append(StringPool.CLOSE_CURLY_BRACE);
2435
2436 if (_log.isWarnEnabled()) {
2437 _log.warn(msg.toString());
2438 }
2439
2440 throw new NoSuchGroupException(msg.toString());
2441 }
2442
2443 return group;
2444 }
2445
2446
2456 public Group fetchByC_C_L_N(long companyId, long classNameId,
2457 long liveGroupId, String name) throws SystemException {
2458 return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
2459 }
2460
2461
2472 public Group fetchByC_C_L_N(long companyId, long classNameId,
2473 long liveGroupId, String name, boolean retrieveFromCache)
2474 throws SystemException {
2475 Object[] finderArgs = new Object[] {
2476 companyId, classNameId, liveGroupId, name
2477 };
2478
2479 Object result = null;
2480
2481 if (retrieveFromCache) {
2482 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2483 finderArgs, this);
2484 }
2485
2486 if (result == null) {
2487 StringBundler query = new StringBundler(6);
2488
2489 query.append(_SQL_SELECT_GROUP__WHERE);
2490
2491 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
2492
2493 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
2494
2495 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
2496
2497 if (name == null) {
2498 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
2499 }
2500 else {
2501 if (name.equals(StringPool.BLANK)) {
2502 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
2503 }
2504 else {
2505 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
2506 }
2507 }
2508
2509 query.append(GroupModelImpl.ORDER_BY_JPQL);
2510
2511 String sql = query.toString();
2512
2513 Session session = null;
2514
2515 try {
2516 session = openSession();
2517
2518 Query q = session.createQuery(sql);
2519
2520 QueryPos qPos = QueryPos.getInstance(q);
2521
2522 qPos.add(companyId);
2523
2524 qPos.add(classNameId);
2525
2526 qPos.add(liveGroupId);
2527
2528 if (name != null) {
2529 qPos.add(name);
2530 }
2531
2532 List<Group> list = q.list();
2533
2534 result = list;
2535
2536 Group group = null;
2537
2538 if (list.isEmpty()) {
2539 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2540 finderArgs, list);
2541 }
2542 else {
2543 group = list.get(0);
2544
2545 cacheResult(group);
2546
2547 if ((group.getCompanyId() != companyId) ||
2548 (group.getClassNameId() != classNameId) ||
2549 (group.getLiveGroupId() != liveGroupId) ||
2550 (group.getName() == null) ||
2551 !group.getName().equals(name)) {
2552 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2553 finderArgs, group);
2554 }
2555 }
2556
2557 return group;
2558 }
2559 catch (Exception e) {
2560 throw processException(e);
2561 }
2562 finally {
2563 if (result == null) {
2564 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2565 finderArgs);
2566 }
2567
2568 closeSession(session);
2569 }
2570 }
2571 else {
2572 if (result instanceof List<?>) {
2573 return null;
2574 }
2575 else {
2576 return (Group)result;
2577 }
2578 }
2579 }
2580
2581
2587 public List<Group> findAll() throws SystemException {
2588 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2589 }
2590
2591
2603 public List<Group> findAll(int start, int end) throws SystemException {
2604 return findAll(start, end, null);
2605 }
2606
2607
2620 public List<Group> findAll(int start, int end,
2621 OrderByComparator orderByComparator) throws SystemException {
2622 FinderPath finderPath = null;
2623 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2624
2625 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2626 (orderByComparator == null)) {
2627 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2628 finderArgs = FINDER_ARGS_EMPTY;
2629 }
2630 else {
2631 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2632 finderArgs = new Object[] { start, end, orderByComparator };
2633 }
2634
2635 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2636 finderArgs, this);
2637
2638 if (list == null) {
2639 StringBundler query = null;
2640 String sql = null;
2641
2642 if (orderByComparator != null) {
2643 query = new StringBundler(2 +
2644 (orderByComparator.getOrderByFields().length * 3));
2645
2646 query.append(_SQL_SELECT_GROUP_);
2647
2648 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2649 orderByComparator);
2650
2651 sql = query.toString();
2652 }
2653 else {
2654 sql = _SQL_SELECT_GROUP_.concat(GroupModelImpl.ORDER_BY_JPQL);
2655 }
2656
2657 Session session = null;
2658
2659 try {
2660 session = openSession();
2661
2662 Query q = session.createQuery(sql);
2663
2664 if (orderByComparator == null) {
2665 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2666 end, false);
2667
2668 Collections.sort(list);
2669 }
2670 else {
2671 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2672 end);
2673 }
2674 }
2675 catch (Exception e) {
2676 throw processException(e);
2677 }
2678 finally {
2679 if (list == null) {
2680 FinderCacheUtil.removeResult(finderPath, finderArgs);
2681 }
2682 else {
2683 cacheResult(list);
2684
2685 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2686 }
2687
2688 closeSession(session);
2689 }
2690 }
2691
2692 return list;
2693 }
2694
2695
2701 public void removeByCompanyId(long companyId) throws SystemException {
2702 for (Group group : findByCompanyId(companyId)) {
2703 groupPersistence.remove(group);
2704 }
2705 }
2706
2707
2713 public void removeByLiveGroupId(long liveGroupId)
2714 throws NoSuchGroupException, SystemException {
2715 Group group = findByLiveGroupId(liveGroupId);
2716
2717 groupPersistence.remove(group);
2718 }
2719
2720
2727 public void removeByC_N(long companyId, String name)
2728 throws NoSuchGroupException, SystemException {
2729 Group group = findByC_N(companyId, name);
2730
2731 groupPersistence.remove(group);
2732 }
2733
2734
2741 public void removeByC_F(long companyId, String friendlyURL)
2742 throws NoSuchGroupException, SystemException {
2743 Group group = findByC_F(companyId, friendlyURL);
2744
2745 groupPersistence.remove(group);
2746 }
2747
2748
2755 public void removeByT_A(int type, boolean active) throws SystemException {
2756 for (Group group : findByT_A(type, active)) {
2757 groupPersistence.remove(group);
2758 }
2759 }
2760
2761
2769 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2770 throws NoSuchGroupException, SystemException {
2771 Group group = findByC_C_C(companyId, classNameId, classPK);
2772
2773 groupPersistence.remove(group);
2774 }
2775
2776
2784 public void removeByC_L_N(long companyId, long liveGroupId, String name)
2785 throws NoSuchGroupException, SystemException {
2786 Group group = findByC_L_N(companyId, liveGroupId, name);
2787
2788 groupPersistence.remove(group);
2789 }
2790
2791
2800 public void removeByC_C_L_N(long companyId, long classNameId,
2801 long liveGroupId, String name)
2802 throws NoSuchGroupException, SystemException {
2803 Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
2804
2805 groupPersistence.remove(group);
2806 }
2807
2808
2813 public void removeAll() throws SystemException {
2814 for (Group group : findAll()) {
2815 groupPersistence.remove(group);
2816 }
2817 }
2818
2819
2826 public int countByCompanyId(long companyId) throws SystemException {
2827 Object[] finderArgs = new Object[] { companyId };
2828
2829 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2830 finderArgs, this);
2831
2832 if (count == null) {
2833 StringBundler query = new StringBundler(2);
2834
2835 query.append(_SQL_COUNT_GROUP__WHERE);
2836
2837 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2838
2839 String sql = query.toString();
2840
2841 Session session = null;
2842
2843 try {
2844 session = openSession();
2845
2846 Query q = session.createQuery(sql);
2847
2848 QueryPos qPos = QueryPos.getInstance(q);
2849
2850 qPos.add(companyId);
2851
2852 count = (Long)q.uniqueResult();
2853 }
2854 catch (Exception e) {
2855 throw processException(e);
2856 }
2857 finally {
2858 if (count == null) {
2859 count = Long.valueOf(0);
2860 }
2861
2862 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2863 finderArgs, count);
2864
2865 closeSession(session);
2866 }
2867 }
2868
2869 return count.intValue();
2870 }
2871
2872
2879 public int countByLiveGroupId(long liveGroupId) throws SystemException {
2880 Object[] finderArgs = new Object[] { liveGroupId };
2881
2882 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
2883 finderArgs, this);
2884
2885 if (count == null) {
2886 StringBundler query = new StringBundler(2);
2887
2888 query.append(_SQL_COUNT_GROUP__WHERE);
2889
2890 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
2891
2892 String sql = query.toString();
2893
2894 Session session = null;
2895
2896 try {
2897 session = openSession();
2898
2899 Query q = session.createQuery(sql);
2900
2901 QueryPos qPos = QueryPos.getInstance(q);
2902
2903 qPos.add(liveGroupId);
2904
2905 count = (Long)q.uniqueResult();
2906 }
2907 catch (Exception e) {
2908 throw processException(e);
2909 }
2910 finally {
2911 if (count == null) {
2912 count = Long.valueOf(0);
2913 }
2914
2915 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
2916 finderArgs, count);
2917
2918 closeSession(session);
2919 }
2920 }
2921
2922 return count.intValue();
2923 }
2924
2925
2933 public int countByC_N(long companyId, String name)
2934 throws SystemException {
2935 Object[] finderArgs = new Object[] { companyId, name };
2936
2937 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
2938 finderArgs, this);
2939
2940 if (count == null) {
2941 StringBundler query = new StringBundler(3);
2942
2943 query.append(_SQL_COUNT_GROUP__WHERE);
2944
2945 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2946
2947 if (name == null) {
2948 query.append(_FINDER_COLUMN_C_N_NAME_1);
2949 }
2950 else {
2951 if (name.equals(StringPool.BLANK)) {
2952 query.append(_FINDER_COLUMN_C_N_NAME_3);
2953 }
2954 else {
2955 query.append(_FINDER_COLUMN_C_N_NAME_2);
2956 }
2957 }
2958
2959 String sql = query.toString();
2960
2961 Session session = null;
2962
2963 try {
2964 session = openSession();
2965
2966 Query q = session.createQuery(sql);
2967
2968 QueryPos qPos = QueryPos.getInstance(q);
2969
2970 qPos.add(companyId);
2971
2972 if (name != null) {
2973 qPos.add(name);
2974 }
2975
2976 count = (Long)q.uniqueResult();
2977 }
2978 catch (Exception e) {
2979 throw processException(e);
2980 }
2981 finally {
2982 if (count == null) {
2983 count = Long.valueOf(0);
2984 }
2985
2986 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2987 count);
2988
2989 closeSession(session);
2990 }
2991 }
2992
2993 return count.intValue();
2994 }
2995
2996
3004 public int countByC_F(long companyId, String friendlyURL)
3005 throws SystemException {
3006 Object[] finderArgs = new Object[] { companyId, friendlyURL };
3007
3008 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
3009 finderArgs, this);
3010
3011 if (count == null) {
3012 StringBundler query = new StringBundler(3);
3013
3014 query.append(_SQL_COUNT_GROUP__WHERE);
3015
3016 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
3017
3018 if (friendlyURL == null) {
3019 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
3020 }
3021 else {
3022 if (friendlyURL.equals(StringPool.BLANK)) {
3023 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
3024 }
3025 else {
3026 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
3027 }
3028 }
3029
3030 String sql = query.toString();
3031
3032 Session session = null;
3033
3034 try {
3035 session = openSession();
3036
3037 Query q = session.createQuery(sql);
3038
3039 QueryPos qPos = QueryPos.getInstance(q);
3040
3041 qPos.add(companyId);
3042
3043 if (friendlyURL != null) {
3044 qPos.add(friendlyURL);
3045 }
3046
3047 count = (Long)q.uniqueResult();
3048 }
3049 catch (Exception e) {
3050 throw processException(e);
3051 }
3052 finally {
3053 if (count == null) {
3054 count = Long.valueOf(0);
3055 }
3056
3057 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
3058 count);
3059
3060 closeSession(session);
3061 }
3062 }
3063
3064 return count.intValue();
3065 }
3066
3067
3075 public int countByT_A(int type, boolean active) throws SystemException {
3076 Object[] finderArgs = new Object[] { type, active };
3077
3078 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
3079 finderArgs, this);
3080
3081 if (count == null) {
3082 StringBundler query = new StringBundler(3);
3083
3084 query.append(_SQL_COUNT_GROUP__WHERE);
3085
3086 query.append(_FINDER_COLUMN_T_A_TYPE_2);
3087
3088 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
3089
3090 String sql = query.toString();
3091
3092 Session session = null;
3093
3094 try {
3095 session = openSession();
3096
3097 Query q = session.createQuery(sql);
3098
3099 QueryPos qPos = QueryPos.getInstance(q);
3100
3101 qPos.add(type);
3102
3103 qPos.add(active);
3104
3105 count = (Long)q.uniqueResult();
3106 }
3107 catch (Exception e) {
3108 throw processException(e);
3109 }
3110 finally {
3111 if (count == null) {
3112 count = Long.valueOf(0);
3113 }
3114
3115 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
3116 count);
3117
3118 closeSession(session);
3119 }
3120 }
3121
3122 return count.intValue();
3123 }
3124
3125
3134 public int countByC_C_C(long companyId, long classNameId, long classPK)
3135 throws SystemException {
3136 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3137
3138 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
3139 finderArgs, this);
3140
3141 if (count == null) {
3142 StringBundler query = new StringBundler(4);
3143
3144 query.append(_SQL_COUNT_GROUP__WHERE);
3145
3146 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3147
3148 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3149
3150 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3151
3152 String sql = query.toString();
3153
3154 Session session = null;
3155
3156 try {
3157 session = openSession();
3158
3159 Query q = session.createQuery(sql);
3160
3161 QueryPos qPos = QueryPos.getInstance(q);
3162
3163 qPos.add(companyId);
3164
3165 qPos.add(classNameId);
3166
3167 qPos.add(classPK);
3168
3169 count = (Long)q.uniqueResult();
3170 }
3171 catch (Exception e) {
3172 throw processException(e);
3173 }
3174 finally {
3175 if (count == null) {
3176 count = Long.valueOf(0);
3177 }
3178
3179 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
3180 finderArgs, count);
3181
3182 closeSession(session);
3183 }
3184 }
3185
3186 return count.intValue();
3187 }
3188
3189
3198 public int countByC_L_N(long companyId, long liveGroupId, String name)
3199 throws SystemException {
3200 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
3201
3202 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L_N,
3203 finderArgs, this);
3204
3205 if (count == null) {
3206 StringBundler query = new StringBundler(4);
3207
3208 query.append(_SQL_COUNT_GROUP__WHERE);
3209
3210 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
3211
3212 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
3213
3214 if (name == null) {
3215 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
3216 }
3217 else {
3218 if (name.equals(StringPool.BLANK)) {
3219 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
3220 }
3221 else {
3222 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
3223 }
3224 }
3225
3226 String sql = query.toString();
3227
3228 Session session = null;
3229
3230 try {
3231 session = openSession();
3232
3233 Query q = session.createQuery(sql);
3234
3235 QueryPos qPos = QueryPos.getInstance(q);
3236
3237 qPos.add(companyId);
3238
3239 qPos.add(liveGroupId);
3240
3241 if (name != null) {
3242 qPos.add(name);
3243 }
3244
3245 count = (Long)q.uniqueResult();
3246 }
3247 catch (Exception e) {
3248 throw processException(e);
3249 }
3250 finally {
3251 if (count == null) {
3252 count = Long.valueOf(0);
3253 }
3254
3255 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N,
3256 finderArgs, count);
3257
3258 closeSession(session);
3259 }
3260 }
3261
3262 return count.intValue();
3263 }
3264
3265
3275 public int countByC_C_L_N(long companyId, long classNameId,
3276 long liveGroupId, String name) throws SystemException {
3277 Object[] finderArgs = new Object[] {
3278 companyId, classNameId, liveGroupId, name
3279 };
3280
3281 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_L_N,
3282 finderArgs, this);
3283
3284 if (count == null) {
3285 StringBundler query = new StringBundler(5);
3286
3287 query.append(_SQL_COUNT_GROUP__WHERE);
3288
3289 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
3290
3291 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
3292
3293 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
3294
3295 if (name == null) {
3296 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
3297 }
3298 else {
3299 if (name.equals(StringPool.BLANK)) {
3300 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
3301 }
3302 else {
3303 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
3304 }
3305 }
3306
3307 String sql = query.toString();
3308
3309 Session session = null;
3310
3311 try {
3312 session = openSession();
3313
3314 Query q = session.createQuery(sql);
3315
3316 QueryPos qPos = QueryPos.getInstance(q);
3317
3318 qPos.add(companyId);
3319
3320 qPos.add(classNameId);
3321
3322 qPos.add(liveGroupId);
3323
3324 if (name != null) {
3325 qPos.add(name);
3326 }
3327
3328 count = (Long)q.uniqueResult();
3329 }
3330 catch (Exception e) {
3331 throw processException(e);
3332 }
3333 finally {
3334 if (count == null) {
3335 count = Long.valueOf(0);
3336 }
3337
3338 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N,
3339 finderArgs, count);
3340
3341 closeSession(session);
3342 }
3343 }
3344
3345 return count.intValue();
3346 }
3347
3348
3354 public int countAll() throws SystemException {
3355 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3356 FINDER_ARGS_EMPTY, this);
3357
3358 if (count == null) {
3359 Session session = null;
3360
3361 try {
3362 session = openSession();
3363
3364 Query q = session.createQuery(_SQL_COUNT_GROUP_);
3365
3366 count = (Long)q.uniqueResult();
3367 }
3368 catch (Exception e) {
3369 throw processException(e);
3370 }
3371 finally {
3372 if (count == null) {
3373 count = Long.valueOf(0);
3374 }
3375
3376 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3377 FINDER_ARGS_EMPTY, count);
3378
3379 closeSession(session);
3380 }
3381 }
3382
3383 return count.intValue();
3384 }
3385
3386
3393 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
3394 throws SystemException {
3395 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3396 }
3397
3398
3411 public List<com.liferay.portal.model.Organization> getOrganizations(
3412 long pk, int start, int end) throws SystemException {
3413 return getOrganizations(pk, start, end, null);
3414 }
3415
3416 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3417 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3418 com.liferay.portal.model.impl.OrganizationImpl.class,
3419 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getOrganizations",
3420 new String[] {
3421 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3422 "com.liferay.portal.kernel.util.OrderByComparator"
3423 });
3424
3425
3439 public List<com.liferay.portal.model.Organization> getOrganizations(
3440 long pk, int start, int end, OrderByComparator orderByComparator)
3441 throws SystemException {
3442 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3443
3444 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
3445 finderArgs, this);
3446
3447 if (list == null) {
3448 Session session = null;
3449
3450 try {
3451 session = openSession();
3452
3453 String sql = null;
3454
3455 if (orderByComparator != null) {
3456 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
3457 .concat(orderByComparator.getOrderBy());
3458 }
3459 else {
3460 sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
3461 }
3462
3463 SQLQuery q = session.createSQLQuery(sql);
3464
3465 q.addEntity("Organization_",
3466 com.liferay.portal.model.impl.OrganizationImpl.class);
3467
3468 QueryPos qPos = QueryPos.getInstance(q);
3469
3470 qPos.add(pk);
3471
3472 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
3473 getDialect(), start, end);
3474 }
3475 catch (Exception e) {
3476 throw processException(e);
3477 }
3478 finally {
3479 if (list == null) {
3480 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
3481 finderArgs);
3482 }
3483 else {
3484 organizationPersistence.cacheResult(list);
3485
3486 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
3487 finderArgs, list);
3488 }
3489
3490 closeSession(session);
3491 }
3492 }
3493
3494 return list;
3495 }
3496
3497 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3498 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
3499 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3500 "getOrganizationsSize", new String[] { Long.class.getName() });
3501
3502
3509 public int getOrganizationsSize(long pk) throws SystemException {
3510 Object[] finderArgs = new Object[] { pk };
3511
3512 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3513 finderArgs, this);
3514
3515 if (count == null) {
3516 Session session = null;
3517
3518 try {
3519 session = openSession();
3520
3521 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
3522
3523 q.addScalar(COUNT_COLUMN_NAME,
3524 com.liferay.portal.kernel.dao.orm.Type.LONG);
3525
3526 QueryPos qPos = QueryPos.getInstance(q);
3527
3528 qPos.add(pk);
3529
3530 count = (Long)q.uniqueResult();
3531 }
3532 catch (Exception e) {
3533 throw processException(e);
3534 }
3535 finally {
3536 if (count == null) {
3537 count = Long.valueOf(0);
3538 }
3539
3540 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3541 finderArgs, count);
3542
3543 closeSession(session);
3544 }
3545 }
3546
3547 return count.intValue();
3548 }
3549
3550 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3551 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Boolean.class,
3552 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3553 "containsOrganization",
3554 new String[] { Long.class.getName(), Long.class.getName() });
3555
3556
3564 public boolean containsOrganization(long pk, long organizationPK)
3565 throws SystemException {
3566 Object[] finderArgs = new Object[] { pk, organizationPK };
3567
3568 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3569 finderArgs, this);
3570
3571 if (value == null) {
3572 try {
3573 value = Boolean.valueOf(containsOrganization.contains(pk,
3574 organizationPK));
3575 }
3576 catch (Exception e) {
3577 throw processException(e);
3578 }
3579 finally {
3580 if (value == null) {
3581 value = Boolean.FALSE;
3582 }
3583
3584 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3585 finderArgs, value);
3586 }
3587 }
3588
3589 return value.booleanValue();
3590 }
3591
3592
3599 public boolean containsOrganizations(long pk) throws SystemException {
3600 if (getOrganizationsSize(pk) > 0) {
3601 return true;
3602 }
3603 else {
3604 return false;
3605 }
3606 }
3607
3608
3615 public void addOrganization(long pk, long organizationPK)
3616 throws SystemException {
3617 try {
3618 addOrganization.add(pk, organizationPK);
3619 }
3620 catch (Exception e) {
3621 throw processException(e);
3622 }
3623 finally {
3624 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3625 }
3626 }
3627
3628
3635 public void addOrganization(long pk,
3636 com.liferay.portal.model.Organization organization)
3637 throws SystemException {
3638 try {
3639 addOrganization.add(pk, organization.getPrimaryKey());
3640 }
3641 catch (Exception e) {
3642 throw processException(e);
3643 }
3644 finally {
3645 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3646 }
3647 }
3648
3649
3656 public void addOrganizations(long pk, long[] organizationPKs)
3657 throws SystemException {
3658 try {
3659 for (long organizationPK : organizationPKs) {
3660 addOrganization.add(pk, organizationPK);
3661 }
3662 }
3663 catch (Exception e) {
3664 throw processException(e);
3665 }
3666 finally {
3667 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3668 }
3669 }
3670
3671
3678 public void addOrganizations(long pk,
3679 List<com.liferay.portal.model.Organization> organizations)
3680 throws SystemException {
3681 try {
3682 for (com.liferay.portal.model.Organization organization : organizations) {
3683 addOrganization.add(pk, organization.getPrimaryKey());
3684 }
3685 }
3686 catch (Exception e) {
3687 throw processException(e);
3688 }
3689 finally {
3690 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3691 }
3692 }
3693
3694
3700 public void clearOrganizations(long pk) throws SystemException {
3701 try {
3702 clearOrganizations.clear(pk);
3703 }
3704 catch (Exception e) {
3705 throw processException(e);
3706 }
3707 finally {
3708 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3709 }
3710 }
3711
3712
3719 public void removeOrganization(long pk, long organizationPK)
3720 throws SystemException {
3721 try {
3722 removeOrganization.remove(pk, organizationPK);
3723 }
3724 catch (Exception e) {
3725 throw processException(e);
3726 }
3727 finally {
3728 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3729 }
3730 }
3731
3732
3739 public void removeOrganization(long pk,
3740 com.liferay.portal.model.Organization organization)
3741 throws SystemException {
3742 try {
3743 removeOrganization.remove(pk, organization.getPrimaryKey());
3744 }
3745 catch (Exception e) {
3746 throw processException(e);
3747 }
3748 finally {
3749 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3750 }
3751 }
3752
3753
3760 public void removeOrganizations(long pk, long[] organizationPKs)
3761 throws SystemException {
3762 try {
3763 for (long organizationPK : organizationPKs) {
3764 removeOrganization.remove(pk, organizationPK);
3765 }
3766 }
3767 catch (Exception e) {
3768 throw processException(e);
3769 }
3770 finally {
3771 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3772 }
3773 }
3774
3775
3782 public void removeOrganizations(long pk,
3783 List<com.liferay.portal.model.Organization> organizations)
3784 throws SystemException {
3785 try {
3786 for (com.liferay.portal.model.Organization organization : organizations) {
3787 removeOrganization.remove(pk, organization.getPrimaryKey());
3788 }
3789 }
3790 catch (Exception e) {
3791 throw processException(e);
3792 }
3793 finally {
3794 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3795 }
3796 }
3797
3798
3805 public void setOrganizations(long pk, long[] organizationPKs)
3806 throws SystemException {
3807 try {
3808 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
3809
3810 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
3811
3812 for (com.liferay.portal.model.Organization organization : organizations) {
3813 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
3814 removeOrganization.remove(pk, organization.getPrimaryKey());
3815 }
3816 }
3817
3818 for (Long organizationPK : organizationPKSet) {
3819 addOrganization.add(pk, organizationPK);
3820 }
3821 }
3822 catch (Exception e) {
3823 throw processException(e);
3824 }
3825 finally {
3826 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3827 }
3828 }
3829
3830
3837 public void setOrganizations(long pk,
3838 List<com.liferay.portal.model.Organization> organizations)
3839 throws SystemException {
3840 try {
3841 long[] organizationPKs = new long[organizations.size()];
3842
3843 for (int i = 0; i < organizations.size(); i++) {
3844 com.liferay.portal.model.Organization organization = organizations.get(i);
3845
3846 organizationPKs[i] = organization.getPrimaryKey();
3847 }
3848
3849 setOrganizations(pk, organizationPKs);
3850 }
3851 catch (Exception e) {
3852 throw processException(e);
3853 }
3854 finally {
3855 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3856 }
3857 }
3858
3859
3866 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
3867 throws SystemException {
3868 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3869 }
3870
3871
3884 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3885 int start, int end) throws SystemException {
3886 return getPermissions(pk, start, end, null);
3887 }
3888
3889 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3890 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
3891 com.liferay.portal.model.impl.PermissionImpl.class,
3892 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3893 "getPermissions",
3894 new String[] {
3895 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3896 "com.liferay.portal.kernel.util.OrderByComparator"
3897 });
3898
3899
3913 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3914 int start, int end, OrderByComparator orderByComparator)
3915 throws SystemException {
3916 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3917
3918 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
3919 finderArgs, this);
3920
3921 if (list == null) {
3922 Session session = null;
3923
3924 try {
3925 session = openSession();
3926
3927 String sql = null;
3928
3929 if (orderByComparator != null) {
3930 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
3931 .concat(orderByComparator.getOrderBy());
3932 }
3933 else {
3934 sql = _SQL_GETPERMISSIONS;
3935 }
3936
3937 SQLQuery q = session.createSQLQuery(sql);
3938
3939 q.addEntity("Permission_",
3940 com.liferay.portal.model.impl.PermissionImpl.class);
3941
3942 QueryPos qPos = QueryPos.getInstance(q);
3943
3944 qPos.add(pk);
3945
3946 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
3947 getDialect(), start, end);
3948 }
3949 catch (Exception e) {
3950 throw processException(e);
3951 }
3952 finally {
3953 if (list == null) {
3954 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
3955 finderArgs);
3956 }
3957 else {
3958 permissionPersistence.cacheResult(list);
3959
3960 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
3961 finderArgs, list);
3962 }
3963
3964 closeSession(session);
3965 }
3966 }
3967
3968 return list;
3969 }
3970
3971 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3972 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS, Long.class,
3973 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3974 "getPermissionsSize", new String[] { Long.class.getName() });
3975
3976
3983 public int getPermissionsSize(long pk) throws SystemException {
3984 Object[] finderArgs = new Object[] { pk };
3985
3986 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3987 finderArgs, this);
3988
3989 if (count == null) {
3990 Session session = null;
3991
3992 try {
3993 session = openSession();
3994
3995 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3996
3997 q.addScalar(COUNT_COLUMN_NAME,
3998 com.liferay.portal.kernel.dao.orm.Type.LONG);
3999
4000 QueryPos qPos = QueryPos.getInstance(q);
4001
4002 qPos.add(pk);
4003
4004 count = (Long)q.uniqueResult();
4005 }
4006 catch (Exception e) {
4007 throw processException(e);
4008 }
4009 finally {
4010 if (count == null) {
4011 count = Long.valueOf(0);
4012 }
4013
4014 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
4015 finderArgs, count);
4016
4017 closeSession(session);
4018 }
4019 }
4020
4021 return count.intValue();
4022 }
4023
4024 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
4025 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
4026 Boolean.class,
4027 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
4028 "containsPermission",
4029 new String[] { Long.class.getName(), Long.class.getName() });
4030
4031
4039 public boolean containsPermission(long pk, long permissionPK)
4040 throws SystemException {
4041 Object[] finderArgs = new Object[] { pk, permissionPK };
4042
4043 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
4044 finderArgs, this);
4045
4046 if (value == null) {
4047 try {
4048 value = Boolean.valueOf(containsPermission.contains(pk,
4049 permissionPK));
4050 }
4051 catch (Exception e) {
4052 throw processException(e);
4053 }
4054 finally {
4055 if (value == null) {
4056 value = Boolean.FALSE;
4057 }
4058
4059 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
4060 finderArgs, value);
4061 }
4062 }
4063
4064 return value.booleanValue();
4065 }
4066
4067
4074 public boolean containsPermissions(long pk) throws SystemException {
4075 if (getPermissionsSize(pk) > 0) {
4076 return true;
4077 }
4078 else {
4079 return false;
4080 }
4081 }
4082
4083
4090 public void addPermission(long pk, long permissionPK)
4091 throws SystemException {
4092 try {
4093 addPermission.add(pk, permissionPK);
4094 }
4095 catch (Exception e) {
4096 throw processException(e);
4097 }
4098 finally {
4099 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4100 }
4101 }
4102
4103
4110 public void addPermission(long pk,
4111 com.liferay.portal.model.Permission permission)
4112 throws SystemException {
4113 try {
4114 addPermission.add(pk, permission.getPrimaryKey());
4115 }
4116 catch (Exception e) {
4117 throw processException(e);
4118 }
4119 finally {
4120 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4121 }
4122 }
4123
4124
4131 public void addPermissions(long pk, long[] permissionPKs)
4132 throws SystemException {
4133 try {
4134 for (long permissionPK : permissionPKs) {
4135 addPermission.add(pk, permissionPK);
4136 }
4137 }
4138 catch (Exception e) {
4139 throw processException(e);
4140 }
4141 finally {
4142 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4143 }
4144 }
4145
4146
4153 public void addPermissions(long pk,
4154 List<com.liferay.portal.model.Permission> permissions)
4155 throws SystemException {
4156 try {
4157 for (com.liferay.portal.model.Permission permission : permissions) {
4158 addPermission.add(pk, permission.getPrimaryKey());
4159 }
4160 }
4161 catch (Exception e) {
4162 throw processException(e);
4163 }
4164 finally {
4165 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4166 }
4167 }
4168
4169
4175 public void clearPermissions(long pk) throws SystemException {
4176 try {
4177 clearPermissions.clear(pk);
4178 }
4179 catch (Exception e) {
4180 throw processException(e);
4181 }
4182 finally {
4183 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4184 }
4185 }
4186
4187
4194 public void removePermission(long pk, long permissionPK)
4195 throws SystemException {
4196 try {
4197 removePermission.remove(pk, permissionPK);
4198 }
4199 catch (Exception e) {
4200 throw processException(e);
4201 }
4202 finally {
4203 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4204 }
4205 }
4206
4207
4214 public void removePermission(long pk,
4215 com.liferay.portal.model.Permission permission)
4216 throws SystemException {
4217 try {
4218 removePermission.remove(pk, permission.getPrimaryKey());
4219 }
4220 catch (Exception e) {
4221 throw processException(e);
4222 }
4223 finally {
4224 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4225 }
4226 }
4227
4228
4235 public void removePermissions(long pk, long[] permissionPKs)
4236 throws SystemException {
4237 try {
4238 for (long permissionPK : permissionPKs) {
4239 removePermission.remove(pk, permissionPK);
4240 }
4241 }
4242 catch (Exception e) {
4243 throw processException(e);
4244 }
4245 finally {
4246 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4247 }
4248 }
4249
4250
4257 public void removePermissions(long pk,
4258 List<com.liferay.portal.model.Permission> permissions)
4259 throws SystemException {
4260 try {
4261 for (com.liferay.portal.model.Permission permission : permissions) {
4262 removePermission.remove(pk, permission.getPrimaryKey());
4263 }
4264 }
4265 catch (Exception e) {
4266 throw processException(e);
4267 }
4268 finally {
4269 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4270 }
4271 }
4272
4273
4280 public void setPermissions(long pk, long[] permissionPKs)
4281 throws SystemException {
4282 try {
4283 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
4284
4285 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
4286
4287 for (com.liferay.portal.model.Permission permission : permissions) {
4288 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
4289 removePermission.remove(pk, permission.getPrimaryKey());
4290 }
4291 }
4292
4293 for (Long permissionPK : permissionPKSet) {
4294 addPermission.add(pk, permissionPK);
4295 }
4296 }
4297 catch (Exception e) {
4298 throw processException(e);
4299 }
4300 finally {
4301 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4302 }
4303 }
4304
4305
4312 public void setPermissions(long pk,
4313 List<com.liferay.portal.model.Permission> permissions)
4314 throws SystemException {
4315 try {
4316 long[] permissionPKs = new long[permissions.size()];
4317
4318 for (int i = 0; i < permissions.size(); i++) {
4319 com.liferay.portal.model.Permission permission = permissions.get(i);
4320
4321 permissionPKs[i] = permission.getPrimaryKey();
4322 }
4323
4324 setPermissions(pk, permissionPKs);
4325 }
4326 catch (Exception e) {
4327 throw processException(e);
4328 }
4329 finally {
4330 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4331 }
4332 }
4333
4334
4341 public List<com.liferay.portal.model.Role> getRoles(long pk)
4342 throws SystemException {
4343 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4344 }
4345
4346
4359 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4360 int end) throws SystemException {
4361 return getRoles(pk, start, end, null);
4362 }
4363
4364 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4365 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4366 com.liferay.portal.model.impl.RoleImpl.class,
4367 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRoles",
4368 new String[] {
4369 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4370 "com.liferay.portal.kernel.util.OrderByComparator"
4371 });
4372
4373
4387 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4388 int end, OrderByComparator orderByComparator) throws SystemException {
4389 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4390
4391 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
4392 finderArgs, this);
4393
4394 if (list == null) {
4395 Session session = null;
4396
4397 try {
4398 session = openSession();
4399
4400 String sql = null;
4401
4402 if (orderByComparator != null) {
4403 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
4404 .concat(orderByComparator.getOrderBy());
4405 }
4406 else {
4407 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
4408 }
4409
4410 SQLQuery q = session.createSQLQuery(sql);
4411
4412 q.addEntity("Role_",
4413 com.liferay.portal.model.impl.RoleImpl.class);
4414
4415 QueryPos qPos = QueryPos.getInstance(q);
4416
4417 qPos.add(pk);
4418
4419 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
4420 getDialect(), start, end);
4421 }
4422 catch (Exception e) {
4423 throw processException(e);
4424 }
4425 finally {
4426 if (list == null) {
4427 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
4428 finderArgs);
4429 }
4430 else {
4431 rolePersistence.cacheResult(list);
4432
4433 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
4434 finderArgs, list);
4435 }
4436
4437 closeSession(session);
4438 }
4439 }
4440
4441 return list;
4442 }
4443
4444 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4445 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4446 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRolesSize",
4447 new String[] { Long.class.getName() });
4448
4449
4456 public int getRolesSize(long pk) throws SystemException {
4457 Object[] finderArgs = new Object[] { pk };
4458
4459 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
4460 finderArgs, this);
4461
4462 if (count == null) {
4463 Session session = null;
4464
4465 try {
4466 session = openSession();
4467
4468 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
4469
4470 q.addScalar(COUNT_COLUMN_NAME,
4471 com.liferay.portal.kernel.dao.orm.Type.LONG);
4472
4473 QueryPos qPos = QueryPos.getInstance(q);
4474
4475 qPos.add(pk);
4476
4477 count = (Long)q.uniqueResult();
4478 }
4479 catch (Exception e) {
4480 throw processException(e);
4481 }
4482 finally {
4483 if (count == null) {
4484 count = Long.valueOf(0);
4485 }
4486
4487 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
4488 finderArgs, count);
4489
4490 closeSession(session);
4491 }
4492 }
4493
4494 return count.intValue();
4495 }
4496
4497 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4498 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
4499 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsRole",
4500 new String[] { Long.class.getName(), Long.class.getName() });
4501
4502
4510 public boolean containsRole(long pk, long rolePK) throws SystemException {
4511 Object[] finderArgs = new Object[] { pk, rolePK };
4512
4513 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
4514 finderArgs, this);
4515
4516 if (value == null) {
4517 try {
4518 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
4519 }
4520 catch (Exception e) {
4521 throw processException(e);
4522 }
4523 finally {
4524 if (value == null) {
4525 value = Boolean.FALSE;
4526 }
4527
4528 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
4529 finderArgs, value);
4530 }
4531 }
4532
4533 return value.booleanValue();
4534 }
4535
4536
4543 public boolean containsRoles(long pk) throws SystemException {
4544 if (getRolesSize(pk) > 0) {
4545 return true;
4546 }
4547 else {
4548 return false;
4549 }
4550 }
4551
4552
4559 public void addRole(long pk, long rolePK) throws SystemException {
4560 try {
4561 addRole.add(pk, rolePK);
4562 }
4563 catch (Exception e) {
4564 throw processException(e);
4565 }
4566 finally {
4567 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4568 }
4569 }
4570
4571
4578 public void addRole(long pk, com.liferay.portal.model.Role role)
4579 throws SystemException {
4580 try {
4581 addRole.add(pk, role.getPrimaryKey());
4582 }
4583 catch (Exception e) {
4584 throw processException(e);
4585 }
4586 finally {
4587 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4588 }
4589 }
4590
4591
4598 public void addRoles(long pk, long[] rolePKs) throws SystemException {
4599 try {
4600 for (long rolePK : rolePKs) {
4601 addRole.add(pk, rolePK);
4602 }
4603 }
4604 catch (Exception e) {
4605 throw processException(e);
4606 }
4607 finally {
4608 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4609 }
4610 }
4611
4612
4619 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
4620 throws SystemException {
4621 try {
4622 for (com.liferay.portal.model.Role role : roles) {
4623 addRole.add(pk, role.getPrimaryKey());
4624 }
4625 }
4626 catch (Exception e) {
4627 throw processException(e);
4628 }
4629 finally {
4630 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4631 }
4632 }
4633
4634
4640 public void clearRoles(long pk) throws SystemException {
4641 try {
4642 clearRoles.clear(pk);
4643 }
4644 catch (Exception e) {
4645 throw processException(e);
4646 }
4647 finally {
4648 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4649 }
4650 }
4651
4652
4659 public void removeRole(long pk, long rolePK) throws SystemException {
4660 try {
4661 removeRole.remove(pk, rolePK);
4662 }
4663 catch (Exception e) {
4664 throw processException(e);
4665 }
4666 finally {
4667 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4668 }
4669 }
4670
4671
4678 public void removeRole(long pk, com.liferay.portal.model.Role role)
4679 throws SystemException {
4680 try {
4681 removeRole.remove(pk, role.getPrimaryKey());
4682 }
4683 catch (Exception e) {
4684 throw processException(e);
4685 }
4686 finally {
4687 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4688 }
4689 }
4690
4691
4698 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
4699 try {
4700 for (long rolePK : rolePKs) {
4701 removeRole.remove(pk, rolePK);
4702 }
4703 }
4704 catch (Exception e) {
4705 throw processException(e);
4706 }
4707 finally {
4708 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4709 }
4710 }
4711
4712
4719 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
4720 throws SystemException {
4721 try {
4722 for (com.liferay.portal.model.Role role : roles) {
4723 removeRole.remove(pk, role.getPrimaryKey());
4724 }
4725 }
4726 catch (Exception e) {
4727 throw processException(e);
4728 }
4729 finally {
4730 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4731 }
4732 }
4733
4734
4741 public void setRoles(long pk, long[] rolePKs) throws SystemException {
4742 try {
4743 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
4744
4745 List<com.liferay.portal.model.Role> roles = getRoles(pk);
4746
4747 for (com.liferay.portal.model.Role role : roles) {
4748 if (!rolePKSet.remove(role.getPrimaryKey())) {
4749 removeRole.remove(pk, role.getPrimaryKey());
4750 }
4751 }
4752
4753 for (Long rolePK : rolePKSet) {
4754 addRole.add(pk, rolePK);
4755 }
4756 }
4757 catch (Exception e) {
4758 throw processException(e);
4759 }
4760 finally {
4761 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4762 }
4763 }
4764
4765
4772 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
4773 throws SystemException {
4774 try {
4775 long[] rolePKs = new long[roles.size()];
4776
4777 for (int i = 0; i < roles.size(); i++) {
4778 com.liferay.portal.model.Role role = roles.get(i);
4779
4780 rolePKs[i] = role.getPrimaryKey();
4781 }
4782
4783 setRoles(pk, rolePKs);
4784 }
4785 catch (Exception e) {
4786 throw processException(e);
4787 }
4788 finally {
4789 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4790 }
4791 }
4792
4793
4800 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
4801 throws SystemException {
4802 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4803 }
4804
4805
4818 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4819 int start, int end) throws SystemException {
4820 return getUserGroups(pk, start, end, null);
4821 }
4822
4823 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4824 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
4825 com.liferay.portal.model.impl.UserGroupImpl.class,
4826 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
4827 "getUserGroups",
4828 new String[] {
4829 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4830 "com.liferay.portal.kernel.util.OrderByComparator"
4831 });
4832
4833
4847 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4848 int start, int end, OrderByComparator orderByComparator)
4849 throws SystemException {
4850 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4851
4852 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
4853 finderArgs, this);
4854
4855 if (list == null) {
4856 Session session = null;
4857
4858 try {
4859 session = openSession();
4860
4861 String sql = null;
4862
4863 if (orderByComparator != null) {
4864 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
4865 .concat(orderByComparator.getOrderBy());
4866 }
4867 else {
4868 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
4869 }
4870
4871 SQLQuery q = session.createSQLQuery(sql);
4872
4873 q.addEntity("UserGroup",
4874 com.liferay.portal.model.impl.UserGroupImpl.class);
4875
4876 QueryPos qPos = QueryPos.getInstance(q);
4877
4878 qPos.add(pk);
4879
4880 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
4881 getDialect(), start, end);
4882 }
4883 catch (Exception e) {
4884 throw processException(e);
4885 }
4886 finally {
4887 if (list == null) {
4888 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
4889 finderArgs);
4890 }
4891 else {
4892 userGroupPersistence.cacheResult(list);
4893
4894 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
4895 finderArgs, list);
4896 }
4897
4898 closeSession(session);
4899 }
4900 }
4901
4902 return list;
4903 }
4904
4905 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4906 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS, Long.class,
4907 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
4908 "getUserGroupsSize", new String[] { Long.class.getName() });
4909
4910
4917 public int getUserGroupsSize(long pk) throws SystemException {
4918 Object[] finderArgs = new Object[] { pk };
4919
4920 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4921 finderArgs, this);
4922
4923 if (count == null) {
4924 Session session = null;
4925
4926 try {
4927 session = openSession();
4928
4929 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
4930
4931 q.addScalar(COUNT_COLUMN_NAME,
4932 com.liferay.portal.kernel.dao.orm.Type.LONG);
4933
4934 QueryPos qPos = QueryPos.getInstance(q);
4935
4936 qPos.add(pk);
4937
4938 count = (Long)q.uniqueResult();
4939 }
4940 catch (Exception e) {
4941 throw processException(e);
4942 }
4943 finally {
4944 if (count == null) {
4945 count = Long.valueOf(0);
4946 }
4947
4948 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4949 finderArgs, count);
4950
4951 closeSession(session);
4952 }
4953 }
4954
4955 return count.intValue();
4956 }
4957
4958 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4959 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
4960 Boolean.class, GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
4961 "containsUserGroup",
4962 new String[] { Long.class.getName(), Long.class.getName() });
4963
4964
4972 public boolean containsUserGroup(long pk, long userGroupPK)
4973 throws SystemException {
4974 Object[] finderArgs = new Object[] { pk, userGroupPK };
4975
4976 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
4977 finderArgs, this);
4978
4979 if (value == null) {
4980 try {
4981 value = Boolean.valueOf(containsUserGroup.contains(pk,
4982 userGroupPK));
4983 }
4984 catch (Exception e) {
4985 throw processException(e);
4986 }
4987 finally {
4988 if (value == null) {
4989 value = Boolean.FALSE;
4990 }
4991
4992 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
4993 finderArgs, value);
4994 }
4995 }
4996
4997 return value.booleanValue();
4998 }
4999
5000
5007 public boolean containsUserGroups(long pk) throws SystemException {
5008 if (getUserGroupsSize(pk) > 0) {
5009 return true;
5010 }
5011 else {
5012 return false;
5013 }
5014 }
5015
5016
5023 public void addUserGroup(long pk, long userGroupPK)
5024 throws SystemException {
5025 try {
5026 addUserGroup.add(pk, userGroupPK);
5027 }
5028 catch (Exception e) {
5029 throw processException(e);
5030 }
5031 finally {
5032 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5033 }
5034 }
5035
5036
5043 public void addUserGroup(long pk,
5044 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5045 try {
5046 addUserGroup.add(pk, userGroup.getPrimaryKey());
5047 }
5048 catch (Exception e) {
5049 throw processException(e);
5050 }
5051 finally {
5052 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5053 }
5054 }
5055
5056
5063 public void addUserGroups(long pk, long[] userGroupPKs)
5064 throws SystemException {
5065 try {
5066 for (long userGroupPK : userGroupPKs) {
5067 addUserGroup.add(pk, userGroupPK);
5068 }
5069 }
5070 catch (Exception e) {
5071 throw processException(e);
5072 }
5073 finally {
5074 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5075 }
5076 }
5077
5078
5085 public void addUserGroups(long pk,
5086 List<com.liferay.portal.model.UserGroup> userGroups)
5087 throws SystemException {
5088 try {
5089 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5090 addUserGroup.add(pk, userGroup.getPrimaryKey());
5091 }
5092 }
5093 catch (Exception e) {
5094 throw processException(e);
5095 }
5096 finally {
5097 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5098 }
5099 }
5100
5101
5107 public void clearUserGroups(long pk) throws SystemException {
5108 try {
5109 clearUserGroups.clear(pk);
5110 }
5111 catch (Exception e) {
5112 throw processException(e);
5113 }
5114 finally {
5115 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5116 }
5117 }
5118
5119
5126 public void removeUserGroup(long pk, long userGroupPK)
5127 throws SystemException {
5128 try {
5129 removeUserGroup.remove(pk, userGroupPK);
5130 }
5131 catch (Exception e) {
5132 throw processException(e);
5133 }
5134 finally {
5135 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5136 }
5137 }
5138
5139
5146 public void removeUserGroup(long pk,
5147 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5148 try {
5149 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5150 }
5151 catch (Exception e) {
5152 throw processException(e);
5153 }
5154 finally {
5155 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5156 }
5157 }
5158
5159
5166 public void removeUserGroups(long pk, long[] userGroupPKs)
5167 throws SystemException {
5168 try {
5169 for (long userGroupPK : userGroupPKs) {
5170 removeUserGroup.remove(pk, userGroupPK);
5171 }
5172 }
5173 catch (Exception e) {
5174 throw processException(e);
5175 }
5176 finally {
5177 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5178 }
5179 }
5180
5181
5188 public void removeUserGroups(long pk,
5189 List<com.liferay.portal.model.UserGroup> userGroups)
5190 throws SystemException {
5191 try {
5192 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5193 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5194 }
5195 }
5196 catch (Exception e) {
5197 throw processException(e);
5198 }
5199 finally {
5200 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5201 }
5202 }
5203
5204
5211 public void setUserGroups(long pk, long[] userGroupPKs)
5212 throws SystemException {
5213 try {
5214 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
5215
5216 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
5217
5218 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5219 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
5220 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5221 }
5222 }
5223
5224 for (Long userGroupPK : userGroupPKSet) {
5225 addUserGroup.add(pk, userGroupPK);
5226 }
5227 }
5228 catch (Exception e) {
5229 throw processException(e);
5230 }
5231 finally {
5232 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5233 }
5234 }
5235
5236
5243 public void setUserGroups(long pk,
5244 List<com.liferay.portal.model.UserGroup> userGroups)
5245 throws SystemException {
5246 try {
5247 long[] userGroupPKs = new long[userGroups.size()];
5248
5249 for (int i = 0; i < userGroups.size(); i++) {
5250 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
5251
5252 userGroupPKs[i] = userGroup.getPrimaryKey();
5253 }
5254
5255 setUserGroups(pk, userGroupPKs);
5256 }
5257 catch (Exception e) {
5258 throw processException(e);
5259 }
5260 finally {
5261 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5262 }
5263 }
5264
5265
5272 public List<com.liferay.portal.model.User> getUsers(long pk)
5273 throws SystemException {
5274 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5275 }
5276
5277
5290 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5291 int end) throws SystemException {
5292 return getUsers(pk, start, end, null);
5293 }
5294
5295 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5296 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
5297 com.liferay.portal.model.impl.UserImpl.class,
5298 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsers",
5299 new String[] {
5300 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5301 "com.liferay.portal.kernel.util.OrderByComparator"
5302 });
5303
5304
5318 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5319 int end, OrderByComparator orderByComparator) throws SystemException {
5320 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5321
5322 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5323 finderArgs, this);
5324
5325 if (list == null) {
5326 Session session = null;
5327
5328 try {
5329 session = openSession();
5330
5331 String sql = null;
5332
5333 if (orderByComparator != null) {
5334 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5335 .concat(orderByComparator.getOrderBy());
5336 }
5337 else {
5338 sql = _SQL_GETUSERS;
5339 }
5340
5341 SQLQuery q = session.createSQLQuery(sql);
5342
5343 q.addEntity("User_",
5344 com.liferay.portal.model.impl.UserImpl.class);
5345
5346 QueryPos qPos = QueryPos.getInstance(q);
5347
5348 qPos.add(pk);
5349
5350 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5351 getDialect(), start, end);
5352 }
5353 catch (Exception e) {
5354 throw processException(e);
5355 }
5356 finally {
5357 if (list == null) {
5358 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5359 finderArgs);
5360 }
5361 else {
5362 userPersistence.cacheResult(list);
5363
5364 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5365 finderArgs, list);
5366 }
5367
5368 closeSession(session);
5369 }
5370 }
5371
5372 return list;
5373 }
5374
5375 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5376 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
5377 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsersSize",
5378 new String[] { Long.class.getName() });
5379
5380
5387 public int getUsersSize(long pk) throws SystemException {
5388 Object[] finderArgs = new Object[] { pk };
5389
5390 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5391 finderArgs, this);
5392
5393 if (count == null) {
5394 Session session = null;
5395
5396 try {
5397 session = openSession();
5398
5399 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5400
5401 q.addScalar(COUNT_COLUMN_NAME,
5402 com.liferay.portal.kernel.dao.orm.Type.LONG);
5403
5404 QueryPos qPos = QueryPos.getInstance(q);
5405
5406 qPos.add(pk);
5407
5408 count = (Long)q.uniqueResult();
5409 }
5410 catch (Exception e) {
5411 throw processException(e);
5412 }
5413 finally {
5414 if (count == null) {
5415 count = Long.valueOf(0);
5416 }
5417
5418 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5419 finderArgs, count);
5420
5421 closeSession(session);
5422 }
5423 }
5424
5425 return count.intValue();
5426 }
5427
5428 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5429 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
5430 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsUser",
5431 new String[] { Long.class.getName(), Long.class.getName() });
5432
5433
5441 public boolean containsUser(long pk, long userPK) throws SystemException {
5442 Object[] finderArgs = new Object[] { pk, userPK };
5443
5444 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5445 finderArgs, this);
5446
5447 if (value == null) {
5448 try {
5449 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5450 }
5451 catch (Exception e) {
5452 throw processException(e);
5453 }
5454 finally {
5455 if (value == null) {
5456 value = Boolean.FALSE;
5457 }
5458
5459 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
5460 finderArgs, value);
5461 }
5462 }
5463
5464 return value.booleanValue();
5465 }
5466
5467
5474 public boolean containsUsers(long pk) throws SystemException {
5475 if (getUsersSize(pk) > 0) {
5476 return true;
5477 }
5478 else {
5479 return false;
5480 }
5481 }
5482
5483
5490 public void addUser(long pk, long userPK) throws SystemException {
5491 try {
5492 addUser.add(pk, userPK);
5493 }
5494 catch (Exception e) {
5495 throw processException(e);
5496 }
5497 finally {
5498 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5499 }
5500 }
5501
5502
5509 public void addUser(long pk, com.liferay.portal.model.User user)
5510 throws SystemException {
5511 try {
5512 addUser.add(pk, user.getPrimaryKey());
5513 }
5514 catch (Exception e) {
5515 throw processException(e);
5516 }
5517 finally {
5518 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5519 }
5520 }
5521
5522
5529 public void addUsers(long pk, long[] userPKs) throws SystemException {
5530 try {
5531 for (long userPK : userPKs) {
5532 addUser.add(pk, userPK);
5533 }
5534 }
5535 catch (Exception e) {
5536 throw processException(e);
5537 }
5538 finally {
5539 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5540 }
5541 }
5542
5543
5550 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
5551 throws SystemException {
5552 try {
5553 for (com.liferay.portal.model.User user : users) {
5554 addUser.add(pk, user.getPrimaryKey());
5555 }
5556 }
5557 catch (Exception e) {
5558 throw processException(e);
5559 }
5560 finally {
5561 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5562 }
5563 }
5564
5565
5571 public void clearUsers(long pk) throws SystemException {
5572 try {
5573 clearUsers.clear(pk);
5574 }
5575 catch (Exception e) {
5576 throw processException(e);
5577 }
5578 finally {
5579 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5580 }
5581 }
5582
5583
5590 public void removeUser(long pk, long userPK) throws SystemException {
5591 try {
5592 removeUser.remove(pk, userPK);
5593 }
5594 catch (Exception e) {
5595 throw processException(e);
5596 }
5597 finally {
5598 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5599 }
5600 }
5601
5602
5609 public void removeUser(long pk, com.liferay.portal.model.User user)
5610 throws SystemException {
5611 try {
5612 removeUser.remove(pk, user.getPrimaryKey());
5613 }
5614 catch (Exception e) {
5615 throw processException(e);
5616 }
5617 finally {
5618 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5619 }
5620 }
5621
5622
5629 public void removeUsers(long pk, long[] userPKs) throws SystemException {
5630 try {
5631 for (long userPK : userPKs) {
5632 removeUser.remove(pk, userPK);
5633 }
5634 }
5635 catch (Exception e) {
5636 throw processException(e);
5637 }
5638 finally {
5639 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5640 }
5641 }
5642
5643
5650 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
5651 throws SystemException {
5652 try {
5653 for (com.liferay.portal.model.User user : users) {
5654 removeUser.remove(pk, user.getPrimaryKey());
5655 }
5656 }
5657 catch (Exception e) {
5658 throw processException(e);
5659 }
5660 finally {
5661 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5662 }
5663 }
5664
5665
5672 public void setUsers(long pk, long[] userPKs) throws SystemException {
5673 try {
5674 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
5675
5676 List<com.liferay.portal.model.User> users = getUsers(pk);
5677
5678 for (com.liferay.portal.model.User user : users) {
5679 if (!userPKSet.remove(user.getPrimaryKey())) {
5680 removeUser.remove(pk, user.getPrimaryKey());
5681 }
5682 }
5683
5684 for (Long userPK : userPKSet) {
5685 addUser.add(pk, userPK);
5686 }
5687 }
5688 catch (Exception e) {
5689 throw processException(e);
5690 }
5691 finally {
5692 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5693 }
5694 }
5695
5696
5703 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
5704 throws SystemException {
5705 try {
5706 long[] userPKs = new long[users.size()];
5707
5708 for (int i = 0; i < users.size(); i++) {
5709 com.liferay.portal.model.User user = users.get(i);
5710
5711 userPKs[i] = user.getPrimaryKey();
5712 }
5713
5714 setUsers(pk, userPKs);
5715 }
5716 catch (Exception e) {
5717 throw processException(e);
5718 }
5719 finally {
5720 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5721 }
5722 }
5723
5724
5727 public void afterPropertiesSet() {
5728 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5729 com.liferay.portal.util.PropsUtil.get(
5730 "value.object.listener.com.liferay.portal.model.Group")));
5731
5732 if (listenerClassNames.length > 0) {
5733 try {
5734 List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
5735
5736 for (String listenerClassName : listenerClassNames) {
5737 listenersList.add((ModelListener<Group>)InstanceFactory.newInstance(
5738 listenerClassName));
5739 }
5740
5741 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5742 }
5743 catch (Exception e) {
5744 _log.error(e);
5745 }
5746 }
5747
5748 containsOrganization = new ContainsOrganization(this);
5749
5750 addOrganization = new AddOrganization(this);
5751 clearOrganizations = new ClearOrganizations(this);
5752 removeOrganization = new RemoveOrganization(this);
5753
5754 containsPermission = new ContainsPermission(this);
5755
5756 addPermission = new AddPermission(this);
5757 clearPermissions = new ClearPermissions(this);
5758 removePermission = new RemovePermission(this);
5759
5760 containsRole = new ContainsRole(this);
5761
5762 addRole = new AddRole(this);
5763 clearRoles = new ClearRoles(this);
5764 removeRole = new RemoveRole(this);
5765
5766 containsUserGroup = new ContainsUserGroup(this);
5767
5768 addUserGroup = new AddUserGroup(this);
5769 clearUserGroups = new ClearUserGroups(this);
5770 removeUserGroup = new RemoveUserGroup(this);
5771
5772 containsUser = new ContainsUser(this);
5773
5774 addUser = new AddUser(this);
5775 clearUsers = new ClearUsers(this);
5776 removeUser = new RemoveUser(this);
5777 }
5778
5779 public void destroy() {
5780 EntityCacheUtil.removeCache(GroupImpl.class.getName());
5781 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5782 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5783 }
5784
5785 @BeanReference(type = AccountPersistence.class)
5786 protected AccountPersistence accountPersistence;
5787 @BeanReference(type = AddressPersistence.class)
5788 protected AddressPersistence addressPersistence;
5789 @BeanReference(type = BrowserTrackerPersistence.class)
5790 protected BrowserTrackerPersistence browserTrackerPersistence;
5791 @BeanReference(type = ClassNamePersistence.class)
5792 protected ClassNamePersistence classNamePersistence;
5793 @BeanReference(type = ClusterGroupPersistence.class)
5794 protected ClusterGroupPersistence clusterGroupPersistence;
5795 @BeanReference(type = CompanyPersistence.class)
5796 protected CompanyPersistence companyPersistence;
5797 @BeanReference(type = ContactPersistence.class)
5798 protected ContactPersistence contactPersistence;
5799 @BeanReference(type = CountryPersistence.class)
5800 protected CountryPersistence countryPersistence;
5801 @BeanReference(type = EmailAddressPersistence.class)
5802 protected EmailAddressPersistence emailAddressPersistence;
5803 @BeanReference(type = GroupPersistence.class)
5804 protected GroupPersistence groupPersistence;
5805 @BeanReference(type = ImagePersistence.class)
5806 protected ImagePersistence imagePersistence;
5807 @BeanReference(type = LayoutPersistence.class)
5808 protected LayoutPersistence layoutPersistence;
5809 @BeanReference(type = LayoutBranchPersistence.class)
5810 protected LayoutBranchPersistence layoutBranchPersistence;
5811 @BeanReference(type = LayoutPrototypePersistence.class)
5812 protected LayoutPrototypePersistence layoutPrototypePersistence;
5813 @BeanReference(type = LayoutRevisionPersistence.class)
5814 protected LayoutRevisionPersistence layoutRevisionPersistence;
5815 @BeanReference(type = LayoutSetPersistence.class)
5816 protected LayoutSetPersistence layoutSetPersistence;
5817 @BeanReference(type = LayoutSetBranchPersistence.class)
5818 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
5819 @BeanReference(type = LayoutSetPrototypePersistence.class)
5820 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
5821 @BeanReference(type = ListTypePersistence.class)
5822 protected ListTypePersistence listTypePersistence;
5823 @BeanReference(type = LockPersistence.class)
5824 protected LockPersistence lockPersistence;
5825 @BeanReference(type = MembershipRequestPersistence.class)
5826 protected MembershipRequestPersistence membershipRequestPersistence;
5827 @BeanReference(type = OrganizationPersistence.class)
5828 protected OrganizationPersistence organizationPersistence;
5829 @BeanReference(type = OrgGroupPermissionPersistence.class)
5830 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
5831 @BeanReference(type = OrgGroupRolePersistence.class)
5832 protected OrgGroupRolePersistence orgGroupRolePersistence;
5833 @BeanReference(type = OrgLaborPersistence.class)
5834 protected OrgLaborPersistence orgLaborPersistence;
5835 @BeanReference(type = PasswordPolicyPersistence.class)
5836 protected PasswordPolicyPersistence passwordPolicyPersistence;
5837 @BeanReference(type = PasswordPolicyRelPersistence.class)
5838 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
5839 @BeanReference(type = PasswordTrackerPersistence.class)
5840 protected PasswordTrackerPersistence passwordTrackerPersistence;
5841 @BeanReference(type = PermissionPersistence.class)
5842 protected PermissionPersistence permissionPersistence;
5843 @BeanReference(type = PhonePersistence.class)
5844 protected PhonePersistence phonePersistence;
5845 @BeanReference(type = PluginSettingPersistence.class)
5846 protected PluginSettingPersistence pluginSettingPersistence;
5847 @BeanReference(type = PortalPreferencesPersistence.class)
5848 protected PortalPreferencesPersistence portalPreferencesPersistence;
5849 @BeanReference(type = PortletPersistence.class)
5850 protected PortletPersistence portletPersistence;
5851 @BeanReference(type = PortletItemPersistence.class)
5852 protected PortletItemPersistence portletItemPersistence;
5853 @BeanReference(type = PortletPreferencesPersistence.class)
5854 protected PortletPreferencesPersistence portletPreferencesPersistence;
5855 @BeanReference(type = RegionPersistence.class)
5856 protected RegionPersistence regionPersistence;
5857 @BeanReference(type = ReleasePersistence.class)
5858 protected ReleasePersistence releasePersistence;
5859 @BeanReference(type = RepositoryPersistence.class)
5860 protected RepositoryPersistence repositoryPersistence;
5861 @BeanReference(type = RepositoryEntryPersistence.class)
5862 protected RepositoryEntryPersistence repositoryEntryPersistence;
5863 @BeanReference(type = ResourcePersistence.class)
5864 protected ResourcePersistence resourcePersistence;
5865 @BeanReference(type = ResourceActionPersistence.class)
5866 protected ResourceActionPersistence resourceActionPersistence;
5867 @BeanReference(type = ResourceBlockPersistence.class)
5868 protected ResourceBlockPersistence resourceBlockPersistence;
5869 @BeanReference(type = ResourceBlockPermissionPersistence.class)
5870 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
5871 @BeanReference(type = ResourceCodePersistence.class)
5872 protected ResourceCodePersistence resourceCodePersistence;
5873 @BeanReference(type = ResourcePermissionPersistence.class)
5874 protected ResourcePermissionPersistence resourcePermissionPersistence;
5875 @BeanReference(type = ResourceTypePermissionPersistence.class)
5876 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
5877 @BeanReference(type = RolePersistence.class)
5878 protected RolePersistence rolePersistence;
5879 @BeanReference(type = ServiceComponentPersistence.class)
5880 protected ServiceComponentPersistence serviceComponentPersistence;
5881 @BeanReference(type = ShardPersistence.class)
5882 protected ShardPersistence shardPersistence;
5883 @BeanReference(type = SubscriptionPersistence.class)
5884 protected SubscriptionPersistence subscriptionPersistence;
5885 @BeanReference(type = TeamPersistence.class)
5886 protected TeamPersistence teamPersistence;
5887 @BeanReference(type = TicketPersistence.class)
5888 protected TicketPersistence ticketPersistence;
5889 @BeanReference(type = UserPersistence.class)
5890 protected UserPersistence userPersistence;
5891 @BeanReference(type = UserGroupPersistence.class)
5892 protected UserGroupPersistence userGroupPersistence;
5893 @BeanReference(type = UserGroupGroupRolePersistence.class)
5894 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
5895 @BeanReference(type = UserGroupRolePersistence.class)
5896 protected UserGroupRolePersistence userGroupRolePersistence;
5897 @BeanReference(type = UserIdMapperPersistence.class)
5898 protected UserIdMapperPersistence userIdMapperPersistence;
5899 @BeanReference(type = UserNotificationEventPersistence.class)
5900 protected UserNotificationEventPersistence userNotificationEventPersistence;
5901 @BeanReference(type = UserTrackerPersistence.class)
5902 protected UserTrackerPersistence userTrackerPersistence;
5903 @BeanReference(type = UserTrackerPathPersistence.class)
5904 protected UserTrackerPathPersistence userTrackerPathPersistence;
5905 @BeanReference(type = VirtualHostPersistence.class)
5906 protected VirtualHostPersistence virtualHostPersistence;
5907 @BeanReference(type = WebDAVPropsPersistence.class)
5908 protected WebDAVPropsPersistence webDAVPropsPersistence;
5909 @BeanReference(type = WebsitePersistence.class)
5910 protected WebsitePersistence websitePersistence;
5911 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
5912 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
5913 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
5914 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
5915 @BeanReference(type = AssetEntryPersistence.class)
5916 protected AssetEntryPersistence assetEntryPersistence;
5917 @BeanReference(type = BlogsEntryPersistence.class)
5918 protected BlogsEntryPersistence blogsEntryPersistence;
5919 @BeanReference(type = BlogsStatsUserPersistence.class)
5920 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
5921 @BeanReference(type = BookmarksFolderPersistence.class)
5922 protected BookmarksFolderPersistence bookmarksFolderPersistence;
5923 @BeanReference(type = CalEventPersistence.class)
5924 protected CalEventPersistence calEventPersistence;
5925 @BeanReference(type = DLFileEntryTypePersistence.class)
5926 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
5927 @BeanReference(type = JournalArticlePersistence.class)
5928 protected JournalArticlePersistence journalArticlePersistence;
5929 @BeanReference(type = JournalStructurePersistence.class)
5930 protected JournalStructurePersistence journalStructurePersistence;
5931 @BeanReference(type = JournalTemplatePersistence.class)
5932 protected JournalTemplatePersistence journalTemplatePersistence;
5933 @BeanReference(type = MBBanPersistence.class)
5934 protected MBBanPersistence mbBanPersistence;
5935 @BeanReference(type = MBCategoryPersistence.class)
5936 protected MBCategoryPersistence mbCategoryPersistence;
5937 @BeanReference(type = MBStatsUserPersistence.class)
5938 protected MBStatsUserPersistence mbStatsUserPersistence;
5939 @BeanReference(type = PollsQuestionPersistence.class)
5940 protected PollsQuestionPersistence pollsQuestionPersistence;
5941 @BeanReference(type = ShoppingCartPersistence.class)
5942 protected ShoppingCartPersistence shoppingCartPersistence;
5943 @BeanReference(type = ShoppingCategoryPersistence.class)
5944 protected ShoppingCategoryPersistence shoppingCategoryPersistence;
5945 @BeanReference(type = ShoppingCouponPersistence.class)
5946 protected ShoppingCouponPersistence shoppingCouponPersistence;
5947 @BeanReference(type = ShoppingOrderPersistence.class)
5948 protected ShoppingOrderPersistence shoppingOrderPersistence;
5949 @BeanReference(type = SCFrameworkVersionPersistence.class)
5950 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
5951 @BeanReference(type = SCProductEntryPersistence.class)
5952 protected SCProductEntryPersistence scProductEntryPersistence;
5953 @BeanReference(type = WikiNodePersistence.class)
5954 protected WikiNodePersistence wikiNodePersistence;
5955 protected ContainsOrganization containsOrganization;
5956 protected AddOrganization addOrganization;
5957 protected ClearOrganizations clearOrganizations;
5958 protected RemoveOrganization removeOrganization;
5959 protected ContainsPermission containsPermission;
5960 protected AddPermission addPermission;
5961 protected ClearPermissions clearPermissions;
5962 protected RemovePermission removePermission;
5963 protected ContainsRole containsRole;
5964 protected AddRole addRole;
5965 protected ClearRoles clearRoles;
5966 protected RemoveRole removeRole;
5967 protected ContainsUserGroup containsUserGroup;
5968 protected AddUserGroup addUserGroup;
5969 protected ClearUserGroups clearUserGroups;
5970 protected RemoveUserGroup removeUserGroup;
5971 protected ContainsUser containsUser;
5972 protected AddUser addUser;
5973 protected ClearUsers clearUsers;
5974 protected RemoveUser removeUser;
5975
5976 protected class ContainsOrganization {
5977 protected ContainsOrganization(GroupPersistenceImpl persistenceImpl) {
5978 super();
5979
5980 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5981 _SQL_CONTAINSORGANIZATION,
5982 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
5983 RowMapper.COUNT);
5984 }
5985
5986 protected boolean contains(long groupId, long organizationId) {
5987 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5988 new Long(groupId), new Long(organizationId)
5989 });
5990
5991 if (results.size() > 0) {
5992 Integer count = results.get(0);
5993
5994 if (count.intValue() > 0) {
5995 return true;
5996 }
5997 }
5998
5999 return false;
6000 }
6001
6002 private MappingSqlQuery<Integer> _mappingSqlQuery;
6003 }
6004
6005 protected class AddOrganization {
6006 protected AddOrganization(GroupPersistenceImpl persistenceImpl) {
6007 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6008 "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
6009 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6010 _persistenceImpl = persistenceImpl;
6011 }
6012
6013 protected void add(long groupId, long organizationId)
6014 throws SystemException {
6015 if (!_persistenceImpl.containsOrganization.contains(groupId,
6016 organizationId)) {
6017 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6018 organizationPersistence.getListeners();
6019
6020 for (ModelListener<Group> listener : listeners) {
6021 listener.onBeforeAddAssociation(groupId,
6022 com.liferay.portal.model.Organization.class.getName(),
6023 organizationId);
6024 }
6025
6026 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6027 listener.onBeforeAddAssociation(organizationId,
6028 Group.class.getName(), groupId);
6029 }
6030
6031 _sqlUpdate.update(new Object[] {
6032 new Long(groupId), new Long(organizationId)
6033 });
6034
6035 for (ModelListener<Group> listener : listeners) {
6036 listener.onAfterAddAssociation(groupId,
6037 com.liferay.portal.model.Organization.class.getName(),
6038 organizationId);
6039 }
6040
6041 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6042 listener.onAfterAddAssociation(organizationId,
6043 Group.class.getName(), groupId);
6044 }
6045 }
6046 }
6047
6048 private SqlUpdate _sqlUpdate;
6049 private GroupPersistenceImpl _persistenceImpl;
6050 }
6051
6052 protected class ClearOrganizations {
6053 protected ClearOrganizations(GroupPersistenceImpl persistenceImpl) {
6054 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6055 "DELETE FROM Groups_Orgs WHERE groupId = ?",
6056 new int[] { java.sql.Types.BIGINT });
6057 }
6058
6059 protected void clear(long groupId) throws SystemException {
6060 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6061 organizationPersistence.getListeners();
6062
6063 List<com.liferay.portal.model.Organization> organizations = null;
6064
6065 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6066 organizations = getOrganizations(groupId);
6067
6068 for (com.liferay.portal.model.Organization organization : organizations) {
6069 for (ModelListener<Group> listener : listeners) {
6070 listener.onBeforeRemoveAssociation(groupId,
6071 com.liferay.portal.model.Organization.class.getName(),
6072 organization.getPrimaryKey());
6073 }
6074
6075 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6076 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
6077 Group.class.getName(), groupId);
6078 }
6079 }
6080 }
6081
6082 _sqlUpdate.update(new Object[] { new Long(groupId) });
6083
6084 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6085 for (com.liferay.portal.model.Organization organization : organizations) {
6086 for (ModelListener<Group> listener : listeners) {
6087 listener.onAfterRemoveAssociation(groupId,
6088 com.liferay.portal.model.Organization.class.getName(),
6089 organization.getPrimaryKey());
6090 }
6091
6092 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6093 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
6094 Group.class.getName(), groupId);
6095 }
6096 }
6097 }
6098 }
6099
6100 private SqlUpdate _sqlUpdate;
6101 }
6102
6103 protected class RemoveOrganization {
6104 protected RemoveOrganization(GroupPersistenceImpl persistenceImpl) {
6105 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6106 "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
6107 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6108 _persistenceImpl = persistenceImpl;
6109 }
6110
6111 protected void remove(long groupId, long organizationId)
6112 throws SystemException {
6113 if (_persistenceImpl.containsOrganization.contains(groupId,
6114 organizationId)) {
6115 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6116 organizationPersistence.getListeners();
6117
6118 for (ModelListener<Group> listener : listeners) {
6119 listener.onBeforeRemoveAssociation(groupId,
6120 com.liferay.portal.model.Organization.class.getName(),
6121 organizationId);
6122 }
6123
6124 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6125 listener.onBeforeRemoveAssociation(organizationId,
6126 Group.class.getName(), groupId);
6127 }
6128
6129 _sqlUpdate.update(new Object[] {
6130 new Long(groupId), new Long(organizationId)
6131 });
6132
6133 for (ModelListener<Group> listener : listeners) {
6134 listener.onAfterRemoveAssociation(groupId,
6135 com.liferay.portal.model.Organization.class.getName(),
6136 organizationId);
6137 }
6138
6139 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6140 listener.onAfterRemoveAssociation(organizationId,
6141 Group.class.getName(), groupId);
6142 }
6143 }
6144 }
6145
6146 private SqlUpdate _sqlUpdate;
6147 private GroupPersistenceImpl _persistenceImpl;
6148 }
6149
6150 protected class ContainsPermission {
6151 protected ContainsPermission(GroupPersistenceImpl persistenceImpl) {
6152 super();
6153
6154 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6155 _SQL_CONTAINSPERMISSION,
6156 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6157 RowMapper.COUNT);
6158 }
6159
6160 protected boolean contains(long groupId, long permissionId) {
6161 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6162 new Long(groupId), new Long(permissionId)
6163 });
6164
6165 if (results.size() > 0) {
6166 Integer count = results.get(0);
6167
6168 if (count.intValue() > 0) {
6169 return true;
6170 }
6171 }
6172
6173 return false;
6174 }
6175
6176 private MappingSqlQuery<Integer> _mappingSqlQuery;
6177 }
6178
6179 protected class AddPermission {
6180 protected AddPermission(GroupPersistenceImpl persistenceImpl) {
6181 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6182 "INSERT INTO Groups_Permissions (groupId, permissionId) VALUES (?, ?)",
6183 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6184 _persistenceImpl = persistenceImpl;
6185 }
6186
6187 protected void add(long groupId, long permissionId)
6188 throws SystemException {
6189 if (!_persistenceImpl.containsPermission.contains(groupId,
6190 permissionId)) {
6191 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6192 permissionPersistence.getListeners();
6193
6194 for (ModelListener<Group> listener : listeners) {
6195 listener.onBeforeAddAssociation(groupId,
6196 com.liferay.portal.model.Permission.class.getName(),
6197 permissionId);
6198 }
6199
6200 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6201 listener.onBeforeAddAssociation(permissionId,
6202 Group.class.getName(), groupId);
6203 }
6204
6205 _sqlUpdate.update(new Object[] {
6206 new Long(groupId), new Long(permissionId)
6207 });
6208
6209 for (ModelListener<Group> listener : listeners) {
6210 listener.onAfterAddAssociation(groupId,
6211 com.liferay.portal.model.Permission.class.getName(),
6212 permissionId);
6213 }
6214
6215 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6216 listener.onAfterAddAssociation(permissionId,
6217 Group.class.getName(), groupId);
6218 }
6219 }
6220 }
6221
6222 private SqlUpdate _sqlUpdate;
6223 private GroupPersistenceImpl _persistenceImpl;
6224 }
6225
6226 protected class ClearPermissions {
6227 protected ClearPermissions(GroupPersistenceImpl persistenceImpl) {
6228 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6229 "DELETE FROM Groups_Permissions WHERE groupId = ?",
6230 new int[] { java.sql.Types.BIGINT });
6231 }
6232
6233 protected void clear(long groupId) throws SystemException {
6234 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6235 permissionPersistence.getListeners();
6236
6237 List<com.liferay.portal.model.Permission> permissions = null;
6238
6239 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6240 permissions = getPermissions(groupId);
6241
6242 for (com.liferay.portal.model.Permission permission : permissions) {
6243 for (ModelListener<Group> listener : listeners) {
6244 listener.onBeforeRemoveAssociation(groupId,
6245 com.liferay.portal.model.Permission.class.getName(),
6246 permission.getPrimaryKey());
6247 }
6248
6249 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6250 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6251 Group.class.getName(), groupId);
6252 }
6253 }
6254 }
6255
6256 _sqlUpdate.update(new Object[] { new Long(groupId) });
6257
6258 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6259 for (com.liferay.portal.model.Permission permission : permissions) {
6260 for (ModelListener<Group> listener : listeners) {
6261 listener.onAfterRemoveAssociation(groupId,
6262 com.liferay.portal.model.Permission.class.getName(),
6263 permission.getPrimaryKey());
6264 }
6265
6266 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6267 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6268 Group.class.getName(), groupId);
6269 }
6270 }
6271 }
6272 }
6273
6274 private SqlUpdate _sqlUpdate;
6275 }
6276
6277 protected class RemovePermission {
6278 protected RemovePermission(GroupPersistenceImpl persistenceImpl) {
6279 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6280 "DELETE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?",
6281 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6282 _persistenceImpl = persistenceImpl;
6283 }
6284
6285 protected void remove(long groupId, long permissionId)
6286 throws SystemException {
6287 if (_persistenceImpl.containsPermission.contains(groupId,
6288 permissionId)) {
6289 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6290 permissionPersistence.getListeners();
6291
6292 for (ModelListener<Group> listener : listeners) {
6293 listener.onBeforeRemoveAssociation(groupId,
6294 com.liferay.portal.model.Permission.class.getName(),
6295 permissionId);
6296 }
6297
6298 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6299 listener.onBeforeRemoveAssociation(permissionId,
6300 Group.class.getName(), groupId);
6301 }
6302
6303 _sqlUpdate.update(new Object[] {
6304 new Long(groupId), new Long(permissionId)
6305 });
6306
6307 for (ModelListener<Group> listener : listeners) {
6308 listener.onAfterRemoveAssociation(groupId,
6309 com.liferay.portal.model.Permission.class.getName(),
6310 permissionId);
6311 }
6312
6313 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6314 listener.onAfterRemoveAssociation(permissionId,
6315 Group.class.getName(), groupId);
6316 }
6317 }
6318 }
6319
6320 private SqlUpdate _sqlUpdate;
6321 private GroupPersistenceImpl _persistenceImpl;
6322 }
6323
6324 protected class ContainsRole {
6325 protected ContainsRole(GroupPersistenceImpl persistenceImpl) {
6326 super();
6327
6328 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6329 _SQL_CONTAINSROLE,
6330 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6331 RowMapper.COUNT);
6332 }
6333
6334 protected boolean contains(long groupId, long roleId) {
6335 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6336 new Long(groupId), new Long(roleId)
6337 });
6338
6339 if (results.size() > 0) {
6340 Integer count = results.get(0);
6341
6342 if (count.intValue() > 0) {
6343 return true;
6344 }
6345 }
6346
6347 return false;
6348 }
6349
6350 private MappingSqlQuery<Integer> _mappingSqlQuery;
6351 }
6352
6353 protected class AddRole {
6354 protected AddRole(GroupPersistenceImpl persistenceImpl) {
6355 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6356 "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
6357 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6358 _persistenceImpl = persistenceImpl;
6359 }
6360
6361 protected void add(long groupId, long roleId) throws SystemException {
6362 if (!_persistenceImpl.containsRole.contains(groupId, roleId)) {
6363 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6364
6365 for (ModelListener<Group> listener : listeners) {
6366 listener.onBeforeAddAssociation(groupId,
6367 com.liferay.portal.model.Role.class.getName(), roleId);
6368 }
6369
6370 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6371 listener.onBeforeAddAssociation(roleId,
6372 Group.class.getName(), groupId);
6373 }
6374
6375 _sqlUpdate.update(new Object[] {
6376 new Long(groupId), new Long(roleId)
6377 });
6378
6379 for (ModelListener<Group> listener : listeners) {
6380 listener.onAfterAddAssociation(groupId,
6381 com.liferay.portal.model.Role.class.getName(), roleId);
6382 }
6383
6384 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6385 listener.onAfterAddAssociation(roleId,
6386 Group.class.getName(), groupId);
6387 }
6388 }
6389 }
6390
6391 private SqlUpdate _sqlUpdate;
6392 private GroupPersistenceImpl _persistenceImpl;
6393 }
6394
6395 protected class ClearRoles {
6396 protected ClearRoles(GroupPersistenceImpl persistenceImpl) {
6397 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6398 "DELETE FROM Groups_Roles WHERE groupId = ?",
6399 new int[] { java.sql.Types.BIGINT });
6400 }
6401
6402 protected void clear(long groupId) throws SystemException {
6403 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6404
6405 List<com.liferay.portal.model.Role> roles = null;
6406
6407 if ((listeners.length > 0) || (roleListeners.length > 0)) {
6408 roles = getRoles(groupId);
6409
6410 for (com.liferay.portal.model.Role role : roles) {
6411 for (ModelListener<Group> listener : listeners) {
6412 listener.onBeforeRemoveAssociation(groupId,
6413 com.liferay.portal.model.Role.class.getName(),
6414 role.getPrimaryKey());
6415 }
6416
6417 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6418 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
6419 Group.class.getName(), groupId);
6420 }
6421 }
6422 }
6423
6424 _sqlUpdate.update(new Object[] { new Long(groupId) });
6425
6426 if ((listeners.length > 0) || (roleListeners.length > 0)) {
6427 for (com.liferay.portal.model.Role role : roles) {
6428 for (ModelListener<Group> listener : listeners) {
6429 listener.onAfterRemoveAssociation(groupId,
6430 com.liferay.portal.model.Role.class.getName(),
6431 role.getPrimaryKey());
6432 }
6433
6434 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6435 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
6436 Group.class.getName(), groupId);
6437 }
6438 }
6439 }
6440 }
6441
6442 private SqlUpdate _sqlUpdate;
6443 }
6444
6445 protected class RemoveRole {
6446 protected RemoveRole(GroupPersistenceImpl persistenceImpl) {
6447 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6448 "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
6449 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6450 _persistenceImpl = persistenceImpl;
6451 }
6452
6453 protected void remove(long groupId, long roleId)
6454 throws SystemException {
6455 if (_persistenceImpl.containsRole.contains(groupId, roleId)) {
6456 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6457
6458 for (ModelListener<Group> listener : listeners) {
6459 listener.onBeforeRemoveAssociation(groupId,
6460 com.liferay.portal.model.Role.class.getName(), roleId);
6461 }
6462
6463 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6464 listener.onBeforeRemoveAssociation(roleId,
6465 Group.class.getName(), groupId);
6466 }
6467
6468 _sqlUpdate.update(new Object[] {
6469 new Long(groupId), new Long(roleId)
6470 });
6471
6472 for (ModelListener<Group> listener : listeners) {
6473 listener.onAfterRemoveAssociation(groupId,
6474 com.liferay.portal.model.Role.class.getName(), roleId);
6475 }
6476
6477 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6478 listener.onAfterRemoveAssociation(roleId,
6479 Group.class.getName(), groupId);
6480 }
6481 }
6482 }
6483
6484 private SqlUpdate _sqlUpdate;
6485 private GroupPersistenceImpl _persistenceImpl;
6486 }
6487
6488 protected class ContainsUserGroup {
6489 protected ContainsUserGroup(GroupPersistenceImpl persistenceImpl) {
6490 super();
6491
6492 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6493 _SQL_CONTAINSUSERGROUP,
6494 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6495 RowMapper.COUNT);
6496 }
6497
6498 protected boolean contains(long groupId, long userGroupId) {
6499 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6500 new Long(groupId), new Long(userGroupId)
6501 });
6502
6503 if (results.size() > 0) {
6504 Integer count = results.get(0);
6505
6506 if (count.intValue() > 0) {
6507 return true;
6508 }
6509 }
6510
6511 return false;
6512 }
6513
6514 private MappingSqlQuery<Integer> _mappingSqlQuery;
6515 }
6516
6517 protected class AddUserGroup {
6518 protected AddUserGroup(GroupPersistenceImpl persistenceImpl) {
6519 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6520 "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
6521 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6522 _persistenceImpl = persistenceImpl;
6523 }
6524
6525 protected void add(long groupId, long userGroupId)
6526 throws SystemException {
6527 if (!_persistenceImpl.containsUserGroup.contains(groupId,
6528 userGroupId)) {
6529 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6530 userGroupPersistence.getListeners();
6531
6532 for (ModelListener<Group> listener : listeners) {
6533 listener.onBeforeAddAssociation(groupId,
6534 com.liferay.portal.model.UserGroup.class.getName(),
6535 userGroupId);
6536 }
6537
6538 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6539 listener.onBeforeAddAssociation(userGroupId,
6540 Group.class.getName(), groupId);
6541 }
6542
6543 _sqlUpdate.update(new Object[] {
6544 new Long(groupId), new Long(userGroupId)
6545 });
6546
6547 for (ModelListener<Group> listener : listeners) {
6548 listener.onAfterAddAssociation(groupId,
6549 com.liferay.portal.model.UserGroup.class.getName(),
6550 userGroupId);
6551 }
6552
6553 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6554 listener.onAfterAddAssociation(userGroupId,
6555 Group.class.getName(), groupId);
6556 }
6557 }
6558 }
6559
6560 private SqlUpdate _sqlUpdate;
6561 private GroupPersistenceImpl _persistenceImpl;
6562 }
6563
6564 protected class ClearUserGroups {
6565 protected ClearUserGroups(GroupPersistenceImpl persistenceImpl) {
6566 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6567 "DELETE FROM Groups_UserGroups WHERE groupId = ?",
6568 new int[] { java.sql.Types.BIGINT });
6569 }
6570
6571 protected void clear(long groupId) throws SystemException {
6572 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6573 userGroupPersistence.getListeners();
6574
6575 List<com.liferay.portal.model.UserGroup> userGroups = null;
6576
6577 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
6578 userGroups = getUserGroups(groupId);
6579
6580 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
6581 for (ModelListener<Group> listener : listeners) {
6582 listener.onBeforeRemoveAssociation(groupId,
6583 com.liferay.portal.model.UserGroup.class.getName(),
6584 userGroup.getPrimaryKey());
6585 }
6586
6587 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6588 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
6589 Group.class.getName(), groupId);
6590 }
6591 }
6592 }
6593
6594 _sqlUpdate.update(new Object[] { new Long(groupId) });
6595
6596 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
6597 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
6598 for (ModelListener<Group> listener : listeners) {
6599 listener.onAfterRemoveAssociation(groupId,
6600 com.liferay.portal.model.UserGroup.class.getName(),
6601 userGroup.getPrimaryKey());
6602 }
6603
6604 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6605 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
6606 Group.class.getName(), groupId);
6607 }
6608 }
6609 }
6610 }
6611
6612 private SqlUpdate _sqlUpdate;
6613 }
6614
6615 protected class RemoveUserGroup {
6616 protected RemoveUserGroup(GroupPersistenceImpl persistenceImpl) {
6617 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6618 "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
6619 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6620 _persistenceImpl = persistenceImpl;
6621 }
6622
6623 protected void remove(long groupId, long userGroupId)
6624 throws SystemException {
6625 if (_persistenceImpl.containsUserGroup.contains(groupId, userGroupId)) {
6626 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6627 userGroupPersistence.getListeners();
6628
6629 for (ModelListener<Group> listener : listeners) {
6630 listener.onBeforeRemoveAssociation(groupId,
6631 com.liferay.portal.model.UserGroup.class.getName(),
6632 userGroupId);
6633 }
6634
6635 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6636 listener.onBeforeRemoveAssociation(userGroupId,
6637 Group.class.getName(), groupId);
6638 }
6639
6640 _sqlUpdate.update(new Object[] {
6641 new Long(groupId), new Long(userGroupId)
6642 });
6643
6644 for (ModelListener<Group> listener : listeners) {
6645 listener.onAfterRemoveAssociation(groupId,
6646 com.liferay.portal.model.UserGroup.class.getName(),
6647 userGroupId);
6648 }
6649
6650 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6651 listener.onAfterRemoveAssociation(userGroupId,
6652 Group.class.getName(), groupId);
6653 }
6654 }
6655 }
6656
6657 private SqlUpdate _sqlUpdate;
6658 private GroupPersistenceImpl _persistenceImpl;
6659 }
6660
6661 protected class ContainsUser {
6662 protected ContainsUser(GroupPersistenceImpl persistenceImpl) {
6663 super();
6664
6665 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6666 _SQL_CONTAINSUSER,
6667 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6668 RowMapper.COUNT);
6669 }
6670
6671 protected boolean contains(long groupId, long userId) {
6672 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6673 new Long(groupId), new Long(userId)
6674 });
6675
6676 if (results.size() > 0) {
6677 Integer count = results.get(0);
6678
6679 if (count.intValue() > 0) {
6680 return true;
6681 }
6682 }
6683
6684 return false;
6685 }
6686
6687 private MappingSqlQuery<Integer> _mappingSqlQuery;
6688 }
6689
6690 protected class AddUser {
6691 protected AddUser(GroupPersistenceImpl persistenceImpl) {
6692 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6693 "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
6694 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6695 _persistenceImpl = persistenceImpl;
6696 }
6697
6698 protected void add(long groupId, long userId) throws SystemException {
6699 if (!_persistenceImpl.containsUser.contains(groupId, userId)) {
6700 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6701
6702 for (ModelListener<Group> listener : listeners) {
6703 listener.onBeforeAddAssociation(groupId,
6704 com.liferay.portal.model.User.class.getName(), userId);
6705 }
6706
6707 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6708 listener.onBeforeAddAssociation(userId,
6709 Group.class.getName(), groupId);
6710 }
6711
6712 _sqlUpdate.update(new Object[] {
6713 new Long(groupId), new Long(userId)
6714 });
6715
6716 for (ModelListener<Group> listener : listeners) {
6717 listener.onAfterAddAssociation(groupId,
6718 com.liferay.portal.model.User.class.getName(), userId);
6719 }
6720
6721 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6722 listener.onAfterAddAssociation(userId,
6723 Group.class.getName(), groupId);
6724 }
6725 }
6726 }
6727
6728 private SqlUpdate _sqlUpdate;
6729 private GroupPersistenceImpl _persistenceImpl;
6730 }
6731
6732 protected class ClearUsers {
6733 protected ClearUsers(GroupPersistenceImpl persistenceImpl) {
6734 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6735 "DELETE FROM Users_Groups WHERE groupId = ?",
6736 new int[] { java.sql.Types.BIGINT });
6737 }
6738
6739 protected void clear(long groupId) throws SystemException {
6740 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6741
6742 List<com.liferay.portal.model.User> users = null;
6743
6744 if ((listeners.length > 0) || (userListeners.length > 0)) {
6745 users = getUsers(groupId);
6746
6747 for (com.liferay.portal.model.User user : users) {
6748 for (ModelListener<Group> listener : listeners) {
6749 listener.onBeforeRemoveAssociation(groupId,
6750 com.liferay.portal.model.User.class.getName(),
6751 user.getPrimaryKey());
6752 }
6753
6754 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6755 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6756 Group.class.getName(), groupId);
6757 }
6758 }
6759 }
6760
6761 _sqlUpdate.update(new Object[] { new Long(groupId) });
6762
6763 if ((listeners.length > 0) || (userListeners.length > 0)) {
6764 for (com.liferay.portal.model.User user : users) {
6765 for (ModelListener<Group> listener : listeners) {
6766 listener.onAfterRemoveAssociation(groupId,
6767 com.liferay.portal.model.User.class.getName(),
6768 user.getPrimaryKey());
6769 }
6770
6771 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6772 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6773 Group.class.getName(), groupId);
6774 }
6775 }
6776 }
6777 }
6778
6779 private SqlUpdate _sqlUpdate;
6780 }
6781
6782 protected class RemoveUser {
6783 protected RemoveUser(GroupPersistenceImpl persistenceImpl) {
6784 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6785 "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
6786 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6787 _persistenceImpl = persistenceImpl;
6788 }
6789
6790 protected void remove(long groupId, long userId)
6791 throws SystemException {
6792 if (_persistenceImpl.containsUser.contains(groupId, userId)) {
6793 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6794
6795 for (ModelListener<Group> listener : listeners) {
6796 listener.onBeforeRemoveAssociation(groupId,
6797 com.liferay.portal.model.User.class.getName(), userId);
6798 }
6799
6800 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6801 listener.onBeforeRemoveAssociation(userId,
6802 Group.class.getName(), groupId);
6803 }
6804
6805 _sqlUpdate.update(new Object[] {
6806 new Long(groupId), new Long(userId)
6807 });
6808
6809 for (ModelListener<Group> listener : listeners) {
6810 listener.onAfterRemoveAssociation(groupId,
6811 com.liferay.portal.model.User.class.getName(), userId);
6812 }
6813
6814 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6815 listener.onAfterRemoveAssociation(userId,
6816 Group.class.getName(), groupId);
6817 }
6818 }
6819 }
6820
6821 private SqlUpdate _sqlUpdate;
6822 private GroupPersistenceImpl _persistenceImpl;
6823 }
6824
6825 private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
6826 private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
6827 private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
6828 private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
6829 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
6830 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
6831 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
6832 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Groups_Permissions ON (Groups_Permissions.permissionId = Permission_.permissionId) WHERE (Groups_Permissions.groupId = ?)";
6833 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ?";
6834 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?";
6835 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
6836 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
6837 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
6838 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
6839 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
6840 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
6841 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
6842 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
6843 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
6844 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
6845 private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
6846 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
6847 private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
6848 private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
6849 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
6850 private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
6851 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
6852 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
6853 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = ?)";
6854 private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
6855 private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
6856 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
6857 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
6858 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
6859 private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
6860 private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
6861 private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
6862 private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
6863 private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
6864 private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
6865 private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
6866 private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
6867 private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
6868 private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
6869 private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
6870 private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
6871 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
6872 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
6873 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6874 private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
6875 private static Group _nullGroup = new GroupImpl() {
6876 @Override
6877 public Object clone() {
6878 return this;
6879 }
6880
6881 @Override
6882 public CacheModel<Group> toCacheModel() {
6883 return _nullGroupCacheModel;
6884 }
6885 };
6886
6887 private static CacheModel<Group> _nullGroupCacheModel = new CacheModel<Group>() {
6888 public Group toEntityModel() {
6889 return _nullGroup;
6890 }
6891 };
6892 }