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.asset.service.persistence.AssetVocabularyPersistence;
053 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
054 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
055 import com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence;
056 import com.liferay.portlet.calendar.service.persistence.CalEventPersistence;
057 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
058 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
059 import com.liferay.portlet.journal.service.persistence.JournalStructurePersistence;
060 import com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence;
061 import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
062 import com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence;
063 import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
064 import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
065 import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
066 import com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence;
067 import com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence;
068 import com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence;
069 import com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence;
070 import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
071 import com.liferay.portlet.wiki.service.persistence.WikiNodePersistence;
072
073 import java.io.Serializable;
074
075 import java.util.ArrayList;
076 import java.util.Collections;
077 import java.util.List;
078 import java.util.Set;
079
080
092 public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
093 implements GroupPersistence {
094
099 public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
100 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
101 ".List1";
102 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
103 ".List2";
104 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
105 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
106 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
107 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
108 new String[] {
109 Long.class.getName(),
110
111 "java.lang.Integer", "java.lang.Integer",
112 "com.liferay.portal.kernel.util.OrderByComparator"
113 });
114 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
115 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
116 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
118 new String[] { Long.class.getName() },
119 GroupModelImpl.COMPANYID_COLUMN_BITMASK);
120 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
121 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
123 new String[] { Long.class.getName() });
124 public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
125 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
126 FINDER_CLASS_NAME_ENTITY, "fetchByLiveGroupId",
127 new String[] { Long.class.getName() },
128 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK);
129 public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
130 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLiveGroupId",
132 new String[] { Long.class.getName() });
133 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
134 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
135 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
136 new String[] { Long.class.getName(), String.class.getName() },
137 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
138 GroupModelImpl.NAME_COLUMN_BITMASK);
139 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
140 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
141 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
142 new String[] { Long.class.getName(), String.class.getName() });
143 public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
144 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
145 FINDER_CLASS_NAME_ENTITY, "fetchByC_F",
146 new String[] { Long.class.getName(), String.class.getName() },
147 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
148 GroupModelImpl.FRIENDLYURL_COLUMN_BITMASK);
149 public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
150 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
151 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_F",
152 new String[] { Long.class.getName(), String.class.getName() });
153 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
154 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
155 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
156 new String[] {
157 Integer.class.getName(), Boolean.class.getName(),
158
159 "java.lang.Integer", "java.lang.Integer",
160 "com.liferay.portal.kernel.util.OrderByComparator"
161 });
162 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
163 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
164 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
165 new String[] { Integer.class.getName(), Boolean.class.getName() },
166 GroupModelImpl.TYPE_COLUMN_BITMASK |
167 GroupModelImpl.ACTIVE_COLUMN_BITMASK);
168 public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
169 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
170 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
171 new String[] { Integer.class.getName(), Boolean.class.getName() });
172 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
173 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
174 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
175 new String[] {
176 Long.class.getName(), Long.class.getName(), Long.class.getName()
177 },
178 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
179 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
180 GroupModelImpl.CLASSPK_COLUMN_BITMASK);
181 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
182 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
183 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
184 new String[] {
185 Long.class.getName(), Long.class.getName(), Long.class.getName()
186 });
187 public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
188 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
189 FINDER_CLASS_NAME_ENTITY, "fetchByC_L_N",
190 new String[] {
191 Long.class.getName(), Long.class.getName(),
192 String.class.getName()
193 },
194 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
195 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
196 GroupModelImpl.NAME_COLUMN_BITMASK);
197 public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
198 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
199 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L_N",
200 new String[] {
201 Long.class.getName(), Long.class.getName(),
202 String.class.getName()
203 });
204 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
205 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
206 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_L_N",
207 new String[] {
208 Long.class.getName(), Long.class.getName(), Long.class.getName(),
209 String.class.getName()
210 },
211 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
212 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
213 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
214 GroupModelImpl.NAME_COLUMN_BITMASK);
215 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
216 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
217 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_L_N",
218 new String[] {
219 Long.class.getName(), Long.class.getName(), Long.class.getName(),
220 String.class.getName()
221 });
222 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
223 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
224 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
225 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
226 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
227 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
228 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
229 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
230 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
231
232
237 public void cacheResult(Group group) {
238 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
239 GroupImpl.class, group.getPrimaryKey(), group);
240
241 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
242 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
243
244 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
245 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
246 group);
247
248 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
249 new Object[] {
250 Long.valueOf(group.getCompanyId()),
251
252 group.getFriendlyURL()
253 }, group);
254
255 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
256 new Object[] {
257 Long.valueOf(group.getCompanyId()),
258 Long.valueOf(group.getClassNameId()),
259 Long.valueOf(group.getClassPK())
260 }, group);
261
262 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
263 new Object[] {
264 Long.valueOf(group.getCompanyId()),
265 Long.valueOf(group.getLiveGroupId()),
266
267 group.getName()
268 }, group);
269
270 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
271 new Object[] {
272 Long.valueOf(group.getCompanyId()),
273 Long.valueOf(group.getClassNameId()),
274 Long.valueOf(group.getLiveGroupId()),
275
276 group.getName()
277 }, group);
278
279 group.resetOriginalValues();
280 }
281
282
287 public void cacheResult(List<Group> groups) {
288 for (Group group : groups) {
289 if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
290 GroupImpl.class, group.getPrimaryKey()) == null) {
291 cacheResult(group);
292 }
293 else {
294 group.resetOriginalValues();
295 }
296 }
297 }
298
299
306 @Override
307 public void clearCache() {
308 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
309 CacheRegistryUtil.clear(GroupImpl.class.getName());
310 }
311
312 EntityCacheUtil.clearCache(GroupImpl.class.getName());
313
314 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
316 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
317 }
318
319
326 @Override
327 public void clearCache(Group group) {
328 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
329 GroupImpl.class, group.getPrimaryKey());
330
331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
332 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
333
334 clearUniqueFindersCache(group);
335 }
336
337 @Override
338 public void clearCache(List<Group> groups) {
339 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
340 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
341
342 for (Group group : groups) {
343 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
344 GroupImpl.class, group.getPrimaryKey());
345
346 clearUniqueFindersCache(group);
347 }
348 }
349
350 protected void clearUniqueFindersCache(Group group) {
351 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
352 new Object[] { Long.valueOf(group.getLiveGroupId()) });
353
354 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
355 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() });
356
357 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
358 new Object[] {
359 Long.valueOf(group.getCompanyId()),
360
361 group.getFriendlyURL()
362 });
363
364 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
365 new Object[] {
366 Long.valueOf(group.getCompanyId()),
367 Long.valueOf(group.getClassNameId()),
368 Long.valueOf(group.getClassPK())
369 });
370
371 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
372 new Object[] {
373 Long.valueOf(group.getCompanyId()),
374 Long.valueOf(group.getLiveGroupId()),
375
376 group.getName()
377 });
378
379 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
380 new Object[] {
381 Long.valueOf(group.getCompanyId()),
382 Long.valueOf(group.getClassNameId()),
383 Long.valueOf(group.getLiveGroupId()),
384
385 group.getName()
386 });
387 }
388
389
395 public Group create(long groupId) {
396 Group group = new GroupImpl();
397
398 group.setNew(true);
399 group.setPrimaryKey(groupId);
400
401 return group;
402 }
403
404
412 public Group remove(long groupId)
413 throws NoSuchGroupException, SystemException {
414 return remove(Long.valueOf(groupId));
415 }
416
417
425 @Override
426 public Group remove(Serializable primaryKey)
427 throws NoSuchGroupException, SystemException {
428 Session session = null;
429
430 try {
431 session = openSession();
432
433 Group group = (Group)session.get(GroupImpl.class, primaryKey);
434
435 if (group == null) {
436 if (_log.isWarnEnabled()) {
437 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
438 }
439
440 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
441 primaryKey);
442 }
443
444 return remove(group);
445 }
446 catch (NoSuchGroupException nsee) {
447 throw nsee;
448 }
449 catch (Exception e) {
450 throw processException(e);
451 }
452 finally {
453 closeSession(session);
454 }
455 }
456
457 @Override
458 protected Group removeImpl(Group group) throws SystemException {
459 group = toUnwrappedModel(group);
460
461 try {
462 clearOrganizations.clear(group.getPrimaryKey());
463 }
464 catch (Exception e) {
465 throw processException(e);
466 }
467 finally {
468 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
469 }
470
471 try {
472 clearPermissions.clear(group.getPrimaryKey());
473 }
474 catch (Exception e) {
475 throw processException(e);
476 }
477 finally {
478 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
479 }
480
481 try {
482 clearRoles.clear(group.getPrimaryKey());
483 }
484 catch (Exception e) {
485 throw processException(e);
486 }
487 finally {
488 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
489 }
490
491 try {
492 clearUserGroups.clear(group.getPrimaryKey());
493 }
494 catch (Exception e) {
495 throw processException(e);
496 }
497 finally {
498 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
499 }
500
501 try {
502 clearUsers.clear(group.getPrimaryKey());
503 }
504 catch (Exception e) {
505 throw processException(e);
506 }
507 finally {
508 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
509 }
510
511 Session session = null;
512
513 try {
514 session = openSession();
515
516 BatchSessionUtil.delete(session, group);
517 }
518 catch (Exception e) {
519 throw processException(e);
520 }
521 finally {
522 closeSession(session);
523 }
524
525 clearCache(group);
526
527 return group;
528 }
529
530 @Override
531 public Group updateImpl(com.liferay.portal.model.Group group, boolean merge)
532 throws SystemException {
533 group = toUnwrappedModel(group);
534
535 boolean isNew = group.isNew();
536
537 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
538
539 Session session = null;
540
541 try {
542 session = openSession();
543
544 BatchSessionUtil.update(session, group, merge);
545
546 group.setNew(false);
547 }
548 catch (Exception e) {
549 throw processException(e);
550 }
551 finally {
552 closeSession(session);
553 }
554
555 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
556
557 if (isNew || !GroupModelImpl.COLUMN_BITMASK_ENABLED) {
558 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
559 }
560
561 else {
562 if ((groupModelImpl.getColumnBitmask() &
563 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
564 Object[] args = new Object[] {
565 Long.valueOf(groupModelImpl.getOriginalCompanyId())
566 };
567
568 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
569 args);
570 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
571 args);
572
573 args = new Object[] { Long.valueOf(groupModelImpl.getCompanyId()) };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
576 args);
577 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
578 args);
579 }
580
581 if ((groupModelImpl.getColumnBitmask() &
582 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
583 Object[] args = new Object[] {
584 Integer.valueOf(groupModelImpl.getOriginalType()),
585 Boolean.valueOf(groupModelImpl.getOriginalActive())
586 };
587
588 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
589 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
590 args);
591
592 args = new Object[] {
593 Integer.valueOf(groupModelImpl.getType()),
594 Boolean.valueOf(groupModelImpl.getActive())
595 };
596
597 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
598 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
599 args);
600 }
601 }
602
603 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
604 GroupImpl.class, group.getPrimaryKey(), group);
605
606 if (isNew) {
607 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
608 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
609
610 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
611 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
612 group);
613
614 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
615 new Object[] {
616 Long.valueOf(group.getCompanyId()),
617
618 group.getFriendlyURL()
619 }, group);
620
621 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
622 new Object[] {
623 Long.valueOf(group.getCompanyId()),
624 Long.valueOf(group.getClassNameId()),
625 Long.valueOf(group.getClassPK())
626 }, group);
627
628 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
629 new Object[] {
630 Long.valueOf(group.getCompanyId()),
631 Long.valueOf(group.getLiveGroupId()),
632
633 group.getName()
634 }, group);
635
636 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
637 new Object[] {
638 Long.valueOf(group.getCompanyId()),
639 Long.valueOf(group.getClassNameId()),
640 Long.valueOf(group.getLiveGroupId()),
641
642 group.getName()
643 }, group);
644 }
645 else {
646 if ((groupModelImpl.getColumnBitmask() &
647 FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
648 Object[] args = new Object[] {
649 Long.valueOf(groupModelImpl.getOriginalLiveGroupId())
650 };
651
652 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
653 args);
654 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
655 args);
656
657 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
658 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
659 }
660
661 if ((groupModelImpl.getColumnBitmask() &
662 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
663 Object[] args = new Object[] {
664 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
665
666 groupModelImpl.getOriginalName()
667 };
668
669 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
670 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
671
672 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
673 new Object[] {
674 Long.valueOf(group.getCompanyId()),
675
676 group.getName()
677 }, group);
678 }
679
680 if ((groupModelImpl.getColumnBitmask() &
681 FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
682 Object[] args = new Object[] {
683 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
684
685 groupModelImpl.getOriginalFriendlyURL()
686 };
687
688 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
689 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
690
691 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
692 new Object[] {
693 Long.valueOf(group.getCompanyId()),
694
695 group.getFriendlyURL()
696 }, group);
697 }
698
699 if ((groupModelImpl.getColumnBitmask() &
700 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
701 Object[] args = new Object[] {
702 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
703 Long.valueOf(groupModelImpl.getOriginalClassNameId()),
704 Long.valueOf(groupModelImpl.getOriginalClassPK())
705 };
706
707 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
708 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
709
710 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
711 new Object[] {
712 Long.valueOf(group.getCompanyId()),
713 Long.valueOf(group.getClassNameId()),
714 Long.valueOf(group.getClassPK())
715 }, group);
716 }
717
718 if ((groupModelImpl.getColumnBitmask() &
719 FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
720 Object[] args = new Object[] {
721 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
722 Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
723
724 groupModelImpl.getOriginalName()
725 };
726
727 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
728 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
729
730 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
731 new Object[] {
732 Long.valueOf(group.getCompanyId()),
733 Long.valueOf(group.getLiveGroupId()),
734
735 group.getName()
736 }, group);
737 }
738
739 if ((groupModelImpl.getColumnBitmask() &
740 FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
741 Object[] args = new Object[] {
742 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
743 Long.valueOf(groupModelImpl.getOriginalClassNameId()),
744 Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
745
746 groupModelImpl.getOriginalName()
747 };
748
749 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
750 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
751
752 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
753 new Object[] {
754 Long.valueOf(group.getCompanyId()),
755 Long.valueOf(group.getClassNameId()),
756 Long.valueOf(group.getLiveGroupId()),
757
758 group.getName()
759 }, group);
760 }
761 }
762
763 return group;
764 }
765
766 protected Group toUnwrappedModel(Group group) {
767 if (group instanceof GroupImpl) {
768 return group;
769 }
770
771 GroupImpl groupImpl = new GroupImpl();
772
773 groupImpl.setNew(group.isNew());
774 groupImpl.setPrimaryKey(group.getPrimaryKey());
775
776 groupImpl.setGroupId(group.getGroupId());
777 groupImpl.setCompanyId(group.getCompanyId());
778 groupImpl.setCreatorUserId(group.getCreatorUserId());
779 groupImpl.setClassNameId(group.getClassNameId());
780 groupImpl.setClassPK(group.getClassPK());
781 groupImpl.setParentGroupId(group.getParentGroupId());
782 groupImpl.setLiveGroupId(group.getLiveGroupId());
783 groupImpl.setName(group.getName());
784 groupImpl.setDescription(group.getDescription());
785 groupImpl.setType(group.getType());
786 groupImpl.setTypeSettings(group.getTypeSettings());
787 groupImpl.setFriendlyURL(group.getFriendlyURL());
788 groupImpl.setSite(group.isSite());
789 groupImpl.setActive(group.isActive());
790
791 return groupImpl;
792 }
793
794
802 @Override
803 public Group findByPrimaryKey(Serializable primaryKey)
804 throws NoSuchModelException, SystemException {
805 return findByPrimaryKey(((Long)primaryKey).longValue());
806 }
807
808
816 public Group findByPrimaryKey(long groupId)
817 throws NoSuchGroupException, SystemException {
818 Group group = fetchByPrimaryKey(groupId);
819
820 if (group == null) {
821 if (_log.isWarnEnabled()) {
822 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
823 }
824
825 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
826 groupId);
827 }
828
829 return group;
830 }
831
832
839 @Override
840 public Group fetchByPrimaryKey(Serializable primaryKey)
841 throws SystemException {
842 return fetchByPrimaryKey(((Long)primaryKey).longValue());
843 }
844
845
852 public Group fetchByPrimaryKey(long groupId) throws SystemException {
853 Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
854 GroupImpl.class, groupId);
855
856 if (group == _nullGroup) {
857 return null;
858 }
859
860 if (group == null) {
861 Session session = null;
862
863 boolean hasException = false;
864
865 try {
866 session = openSession();
867
868 group = (Group)session.get(GroupImpl.class,
869 Long.valueOf(groupId));
870 }
871 catch (Exception e) {
872 hasException = true;
873
874 throw processException(e);
875 }
876 finally {
877 if (group != null) {
878 cacheResult(group);
879 }
880 else if (!hasException) {
881 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
882 GroupImpl.class, groupId, _nullGroup);
883 }
884
885 closeSession(session);
886 }
887 }
888
889 return group;
890 }
891
892
899 public List<Group> findByCompanyId(long companyId)
900 throws SystemException {
901 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
902 null);
903 }
904
905
918 public List<Group> findByCompanyId(long companyId, int start, int end)
919 throws SystemException {
920 return findByCompanyId(companyId, start, end, null);
921 }
922
923
937 public List<Group> findByCompanyId(long companyId, int start, int end,
938 OrderByComparator orderByComparator) throws SystemException {
939 FinderPath finderPath = null;
940 Object[] finderArgs = null;
941
942 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
943 (orderByComparator == null)) {
944 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
945 finderArgs = new Object[] { companyId };
946 }
947 else {
948 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
949 finderArgs = new Object[] { companyId, start, end, orderByComparator };
950 }
951
952 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
953 finderArgs, this);
954
955 if (list == null) {
956 StringBundler query = null;
957
958 if (orderByComparator != null) {
959 query = new StringBundler(3 +
960 (orderByComparator.getOrderByFields().length * 3));
961 }
962 else {
963 query = new StringBundler(3);
964 }
965
966 query.append(_SQL_SELECT_GROUP__WHERE);
967
968 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
969
970 if (orderByComparator != null) {
971 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
972 orderByComparator);
973 }
974
975 else {
976 query.append(GroupModelImpl.ORDER_BY_JPQL);
977 }
978
979 String sql = query.toString();
980
981 Session session = null;
982
983 try {
984 session = openSession();
985
986 Query q = session.createQuery(sql);
987
988 QueryPos qPos = QueryPos.getInstance(q);
989
990 qPos.add(companyId);
991
992 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
993 }
994 catch (Exception e) {
995 throw processException(e);
996 }
997 finally {
998 if (list == null) {
999 FinderCacheUtil.removeResult(finderPath, finderArgs);
1000 }
1001 else {
1002 cacheResult(list);
1003
1004 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1005 }
1006
1007 closeSession(session);
1008 }
1009 }
1010
1011 return list;
1012 }
1013
1014
1027 public Group findByCompanyId_First(long companyId,
1028 OrderByComparator orderByComparator)
1029 throws NoSuchGroupException, SystemException {
1030 List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1031
1032 if (list.isEmpty()) {
1033 StringBundler msg = new StringBundler(4);
1034
1035 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1036
1037 msg.append("companyId=");
1038 msg.append(companyId);
1039
1040 msg.append(StringPool.CLOSE_CURLY_BRACE);
1041
1042 throw new NoSuchGroupException(msg.toString());
1043 }
1044 else {
1045 return list.get(0);
1046 }
1047 }
1048
1049
1062 public Group findByCompanyId_Last(long companyId,
1063 OrderByComparator orderByComparator)
1064 throws NoSuchGroupException, SystemException {
1065 int count = countByCompanyId(companyId);
1066
1067 List<Group> list = findByCompanyId(companyId, count - 1, count,
1068 orderByComparator);
1069
1070 if (list.isEmpty()) {
1071 StringBundler msg = new StringBundler(4);
1072
1073 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074
1075 msg.append("companyId=");
1076 msg.append(companyId);
1077
1078 msg.append(StringPool.CLOSE_CURLY_BRACE);
1079
1080 throw new NoSuchGroupException(msg.toString());
1081 }
1082 else {
1083 return list.get(0);
1084 }
1085 }
1086
1087
1101 public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
1102 OrderByComparator orderByComparator)
1103 throws NoSuchGroupException, SystemException {
1104 Group group = findByPrimaryKey(groupId);
1105
1106 Session session = null;
1107
1108 try {
1109 session = openSession();
1110
1111 Group[] array = new GroupImpl[3];
1112
1113 array[0] = getByCompanyId_PrevAndNext(session, group, companyId,
1114 orderByComparator, true);
1115
1116 array[1] = group;
1117
1118 array[2] = getByCompanyId_PrevAndNext(session, group, companyId,
1119 orderByComparator, false);
1120
1121 return array;
1122 }
1123 catch (Exception e) {
1124 throw processException(e);
1125 }
1126 finally {
1127 closeSession(session);
1128 }
1129 }
1130
1131 protected Group getByCompanyId_PrevAndNext(Session session, Group group,
1132 long companyId, OrderByComparator orderByComparator, boolean previous) {
1133 StringBundler query = null;
1134
1135 if (orderByComparator != null) {
1136 query = new StringBundler(6 +
1137 (orderByComparator.getOrderByFields().length * 6));
1138 }
1139 else {
1140 query = new StringBundler(3);
1141 }
1142
1143 query.append(_SQL_SELECT_GROUP__WHERE);
1144
1145 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1146
1147 if (orderByComparator != null) {
1148 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1149
1150 if (orderByConditionFields.length > 0) {
1151 query.append(WHERE_AND);
1152 }
1153
1154 for (int i = 0; i < orderByConditionFields.length; i++) {
1155 query.append(_ORDER_BY_ENTITY_ALIAS);
1156 query.append(orderByConditionFields[i]);
1157
1158 if ((i + 1) < orderByConditionFields.length) {
1159 if (orderByComparator.isAscending() ^ previous) {
1160 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1161 }
1162 else {
1163 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1164 }
1165 }
1166 else {
1167 if (orderByComparator.isAscending() ^ previous) {
1168 query.append(WHERE_GREATER_THAN);
1169 }
1170 else {
1171 query.append(WHERE_LESSER_THAN);
1172 }
1173 }
1174 }
1175
1176 query.append(ORDER_BY_CLAUSE);
1177
1178 String[] orderByFields = orderByComparator.getOrderByFields();
1179
1180 for (int i = 0; i < orderByFields.length; i++) {
1181 query.append(_ORDER_BY_ENTITY_ALIAS);
1182 query.append(orderByFields[i]);
1183
1184 if ((i + 1) < orderByFields.length) {
1185 if (orderByComparator.isAscending() ^ previous) {
1186 query.append(ORDER_BY_ASC_HAS_NEXT);
1187 }
1188 else {
1189 query.append(ORDER_BY_DESC_HAS_NEXT);
1190 }
1191 }
1192 else {
1193 if (orderByComparator.isAscending() ^ previous) {
1194 query.append(ORDER_BY_ASC);
1195 }
1196 else {
1197 query.append(ORDER_BY_DESC);
1198 }
1199 }
1200 }
1201 }
1202
1203 else {
1204 query.append(GroupModelImpl.ORDER_BY_JPQL);
1205 }
1206
1207 String sql = query.toString();
1208
1209 Query q = session.createQuery(sql);
1210
1211 q.setFirstResult(0);
1212 q.setMaxResults(2);
1213
1214 QueryPos qPos = QueryPos.getInstance(q);
1215
1216 qPos.add(companyId);
1217
1218 if (orderByComparator != null) {
1219 Object[] values = orderByComparator.getOrderByConditionValues(group);
1220
1221 for (Object value : values) {
1222 qPos.add(value);
1223 }
1224 }
1225
1226 List<Group> list = q.list();
1227
1228 if (list.size() == 2) {
1229 return list.get(1);
1230 }
1231 else {
1232 return null;
1233 }
1234 }
1235
1236
1244 public Group findByLiveGroupId(long liveGroupId)
1245 throws NoSuchGroupException, SystemException {
1246 Group group = fetchByLiveGroupId(liveGroupId);
1247
1248 if (group == null) {
1249 StringBundler msg = new StringBundler(4);
1250
1251 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1252
1253 msg.append("liveGroupId=");
1254 msg.append(liveGroupId);
1255
1256 msg.append(StringPool.CLOSE_CURLY_BRACE);
1257
1258 if (_log.isWarnEnabled()) {
1259 _log.warn(msg.toString());
1260 }
1261
1262 throw new NoSuchGroupException(msg.toString());
1263 }
1264
1265 return group;
1266 }
1267
1268
1275 public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
1276 return fetchByLiveGroupId(liveGroupId, true);
1277 }
1278
1279
1287 public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
1288 throws SystemException {
1289 Object[] finderArgs = new Object[] { liveGroupId };
1290
1291 Object result = null;
1292
1293 if (retrieveFromCache) {
1294 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1295 finderArgs, this);
1296 }
1297
1298 if (result == null) {
1299 StringBundler query = new StringBundler(3);
1300
1301 query.append(_SQL_SELECT_GROUP__WHERE);
1302
1303 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
1304
1305 query.append(GroupModelImpl.ORDER_BY_JPQL);
1306
1307 String sql = query.toString();
1308
1309 Session session = null;
1310
1311 try {
1312 session = openSession();
1313
1314 Query q = session.createQuery(sql);
1315
1316 QueryPos qPos = QueryPos.getInstance(q);
1317
1318 qPos.add(liveGroupId);
1319
1320 List<Group> list = q.list();
1321
1322 result = list;
1323
1324 Group group = null;
1325
1326 if (list.isEmpty()) {
1327 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1328 finderArgs, list);
1329 }
1330 else {
1331 group = list.get(0);
1332
1333 cacheResult(group);
1334
1335 if ((group.getLiveGroupId() != liveGroupId)) {
1336 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1337 finderArgs, group);
1338 }
1339 }
1340
1341 return group;
1342 }
1343 catch (Exception e) {
1344 throw processException(e);
1345 }
1346 finally {
1347 if (result == null) {
1348 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1349 finderArgs);
1350 }
1351
1352 closeSession(session);
1353 }
1354 }
1355 else {
1356 if (result instanceof List<?>) {
1357 return null;
1358 }
1359 else {
1360 return (Group)result;
1361 }
1362 }
1363 }
1364
1365
1374 public Group findByC_N(long companyId, String name)
1375 throws NoSuchGroupException, SystemException {
1376 Group group = fetchByC_N(companyId, name);
1377
1378 if (group == null) {
1379 StringBundler msg = new StringBundler(6);
1380
1381 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1382
1383 msg.append("companyId=");
1384 msg.append(companyId);
1385
1386 msg.append(", name=");
1387 msg.append(name);
1388
1389 msg.append(StringPool.CLOSE_CURLY_BRACE);
1390
1391 if (_log.isWarnEnabled()) {
1392 _log.warn(msg.toString());
1393 }
1394
1395 throw new NoSuchGroupException(msg.toString());
1396 }
1397
1398 return group;
1399 }
1400
1401
1409 public Group fetchByC_N(long companyId, String name)
1410 throws SystemException {
1411 return fetchByC_N(companyId, name, true);
1412 }
1413
1414
1423 public Group fetchByC_N(long companyId, String name,
1424 boolean retrieveFromCache) throws SystemException {
1425 Object[] finderArgs = new Object[] { companyId, name };
1426
1427 Object result = null;
1428
1429 if (retrieveFromCache) {
1430 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1431 finderArgs, this);
1432 }
1433
1434 if (result == null) {
1435 StringBundler query = new StringBundler(4);
1436
1437 query.append(_SQL_SELECT_GROUP__WHERE);
1438
1439 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1440
1441 if (name == null) {
1442 query.append(_FINDER_COLUMN_C_N_NAME_1);
1443 }
1444 else {
1445 if (name.equals(StringPool.BLANK)) {
1446 query.append(_FINDER_COLUMN_C_N_NAME_3);
1447 }
1448 else {
1449 query.append(_FINDER_COLUMN_C_N_NAME_2);
1450 }
1451 }
1452
1453 query.append(GroupModelImpl.ORDER_BY_JPQL);
1454
1455 String sql = query.toString();
1456
1457 Session session = null;
1458
1459 try {
1460 session = openSession();
1461
1462 Query q = session.createQuery(sql);
1463
1464 QueryPos qPos = QueryPos.getInstance(q);
1465
1466 qPos.add(companyId);
1467
1468 if (name != null) {
1469 qPos.add(name);
1470 }
1471
1472 List<Group> list = q.list();
1473
1474 result = list;
1475
1476 Group group = null;
1477
1478 if (list.isEmpty()) {
1479 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1480 finderArgs, list);
1481 }
1482 else {
1483 group = list.get(0);
1484
1485 cacheResult(group);
1486
1487 if ((group.getCompanyId() != companyId) ||
1488 (group.getName() == null) ||
1489 !group.getName().equals(name)) {
1490 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1491 finderArgs, group);
1492 }
1493 }
1494
1495 return group;
1496 }
1497 catch (Exception e) {
1498 throw processException(e);
1499 }
1500 finally {
1501 if (result == null) {
1502 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
1503 finderArgs);
1504 }
1505
1506 closeSession(session);
1507 }
1508 }
1509 else {
1510 if (result instanceof List<?>) {
1511 return null;
1512 }
1513 else {
1514 return (Group)result;
1515 }
1516 }
1517 }
1518
1519
1528 public Group findByC_F(long companyId, String friendlyURL)
1529 throws NoSuchGroupException, SystemException {
1530 Group group = fetchByC_F(companyId, friendlyURL);
1531
1532 if (group == null) {
1533 StringBundler msg = new StringBundler(6);
1534
1535 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1536
1537 msg.append("companyId=");
1538 msg.append(companyId);
1539
1540 msg.append(", friendlyURL=");
1541 msg.append(friendlyURL);
1542
1543 msg.append(StringPool.CLOSE_CURLY_BRACE);
1544
1545 if (_log.isWarnEnabled()) {
1546 _log.warn(msg.toString());
1547 }
1548
1549 throw new NoSuchGroupException(msg.toString());
1550 }
1551
1552 return group;
1553 }
1554
1555
1563 public Group fetchByC_F(long companyId, String friendlyURL)
1564 throws SystemException {
1565 return fetchByC_F(companyId, friendlyURL, true);
1566 }
1567
1568
1577 public Group fetchByC_F(long companyId, String friendlyURL,
1578 boolean retrieveFromCache) throws SystemException {
1579 Object[] finderArgs = new Object[] { companyId, friendlyURL };
1580
1581 Object result = null;
1582
1583 if (retrieveFromCache) {
1584 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
1585 finderArgs, this);
1586 }
1587
1588 if (result == null) {
1589 StringBundler query = new StringBundler(4);
1590
1591 query.append(_SQL_SELECT_GROUP__WHERE);
1592
1593 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
1594
1595 if (friendlyURL == null) {
1596 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
1597 }
1598 else {
1599 if (friendlyURL.equals(StringPool.BLANK)) {
1600 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
1601 }
1602 else {
1603 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
1604 }
1605 }
1606
1607 query.append(GroupModelImpl.ORDER_BY_JPQL);
1608
1609 String sql = query.toString();
1610
1611 Session session = null;
1612
1613 try {
1614 session = openSession();
1615
1616 Query q = session.createQuery(sql);
1617
1618 QueryPos qPos = QueryPos.getInstance(q);
1619
1620 qPos.add(companyId);
1621
1622 if (friendlyURL != null) {
1623 qPos.add(friendlyURL);
1624 }
1625
1626 List<Group> list = q.list();
1627
1628 result = list;
1629
1630 Group group = null;
1631
1632 if (list.isEmpty()) {
1633 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1634 finderArgs, list);
1635 }
1636 else {
1637 group = list.get(0);
1638
1639 cacheResult(group);
1640
1641 if ((group.getCompanyId() != companyId) ||
1642 (group.getFriendlyURL() == null) ||
1643 !group.getFriendlyURL().equals(friendlyURL)) {
1644 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1645 finderArgs, group);
1646 }
1647 }
1648
1649 return group;
1650 }
1651 catch (Exception e) {
1652 throw processException(e);
1653 }
1654 finally {
1655 if (result == null) {
1656 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
1657 finderArgs);
1658 }
1659
1660 closeSession(session);
1661 }
1662 }
1663 else {
1664 if (result instanceof List<?>) {
1665 return null;
1666 }
1667 else {
1668 return (Group)result;
1669 }
1670 }
1671 }
1672
1673
1681 public List<Group> findByT_A(int type, boolean active)
1682 throws SystemException {
1683 return findByT_A(type, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1684 null);
1685 }
1686
1687
1701 public List<Group> findByT_A(int type, boolean active, int start, int end)
1702 throws SystemException {
1703 return findByT_A(type, active, start, end, null);
1704 }
1705
1706
1721 public List<Group> findByT_A(int type, boolean active, int start, int end,
1722 OrderByComparator orderByComparator) throws SystemException {
1723 FinderPath finderPath = null;
1724 Object[] finderArgs = null;
1725
1726 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1727 (orderByComparator == null)) {
1728 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
1729 finderArgs = new Object[] { type, active };
1730 }
1731 else {
1732 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
1733 finderArgs = new Object[] {
1734 type, active,
1735
1736 start, end, orderByComparator
1737 };
1738 }
1739
1740 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1741 finderArgs, this);
1742
1743 if (list == null) {
1744 StringBundler query = null;
1745
1746 if (orderByComparator != null) {
1747 query = new StringBundler(4 +
1748 (orderByComparator.getOrderByFields().length * 3));
1749 }
1750 else {
1751 query = new StringBundler(4);
1752 }
1753
1754 query.append(_SQL_SELECT_GROUP__WHERE);
1755
1756 query.append(_FINDER_COLUMN_T_A_TYPE_2);
1757
1758 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1759
1760 if (orderByComparator != null) {
1761 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1762 orderByComparator);
1763 }
1764
1765 else {
1766 query.append(GroupModelImpl.ORDER_BY_JPQL);
1767 }
1768
1769 String sql = query.toString();
1770
1771 Session session = null;
1772
1773 try {
1774 session = openSession();
1775
1776 Query q = session.createQuery(sql);
1777
1778 QueryPos qPos = QueryPos.getInstance(q);
1779
1780 qPos.add(type);
1781
1782 qPos.add(active);
1783
1784 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1785 }
1786 catch (Exception e) {
1787 throw processException(e);
1788 }
1789 finally {
1790 if (list == null) {
1791 FinderCacheUtil.removeResult(finderPath, finderArgs);
1792 }
1793 else {
1794 cacheResult(list);
1795
1796 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1797 }
1798
1799 closeSession(session);
1800 }
1801 }
1802
1803 return list;
1804 }
1805
1806
1820 public Group findByT_A_First(int type, boolean active,
1821 OrderByComparator orderByComparator)
1822 throws NoSuchGroupException, SystemException {
1823 List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
1824
1825 if (list.isEmpty()) {
1826 StringBundler msg = new StringBundler(6);
1827
1828 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1829
1830 msg.append("type=");
1831 msg.append(type);
1832
1833 msg.append(", active=");
1834 msg.append(active);
1835
1836 msg.append(StringPool.CLOSE_CURLY_BRACE);
1837
1838 throw new NoSuchGroupException(msg.toString());
1839 }
1840 else {
1841 return list.get(0);
1842 }
1843 }
1844
1845
1859 public Group findByT_A_Last(int type, boolean active,
1860 OrderByComparator orderByComparator)
1861 throws NoSuchGroupException, SystemException {
1862 int count = countByT_A(type, active);
1863
1864 List<Group> list = findByT_A(type, active, count - 1, count,
1865 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
1902 public Group[] findByT_A_PrevAndNext(long groupId, int type,
1903 boolean active, OrderByComparator orderByComparator)
1904 throws NoSuchGroupException, SystemException {
1905 Group group = findByPrimaryKey(groupId);
1906
1907 Session session = null;
1908
1909 try {
1910 session = openSession();
1911
1912 Group[] array = new GroupImpl[3];
1913
1914 array[0] = getByT_A_PrevAndNext(session, group, type, active,
1915 orderByComparator, true);
1916
1917 array[1] = group;
1918
1919 array[2] = getByT_A_PrevAndNext(session, group, type, active,
1920 orderByComparator, false);
1921
1922 return array;
1923 }
1924 catch (Exception e) {
1925 throw processException(e);
1926 }
1927 finally {
1928 closeSession(session);
1929 }
1930 }
1931
1932 protected Group getByT_A_PrevAndNext(Session session, Group group,
1933 int type, boolean active, OrderByComparator orderByComparator,
1934 boolean previous) {
1935 StringBundler query = null;
1936
1937 if (orderByComparator != null) {
1938 query = new StringBundler(6 +
1939 (orderByComparator.getOrderByFields().length * 6));
1940 }
1941 else {
1942 query = new StringBundler(3);
1943 }
1944
1945 query.append(_SQL_SELECT_GROUP__WHERE);
1946
1947 query.append(_FINDER_COLUMN_T_A_TYPE_2);
1948
1949 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1950
1951 if (orderByComparator != null) {
1952 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1953
1954 if (orderByConditionFields.length > 0) {
1955 query.append(WHERE_AND);
1956 }
1957
1958 for (int i = 0; i < orderByConditionFields.length; i++) {
1959 query.append(_ORDER_BY_ENTITY_ALIAS);
1960 query.append(orderByConditionFields[i]);
1961
1962 if ((i + 1) < orderByConditionFields.length) {
1963 if (orderByComparator.isAscending() ^ previous) {
1964 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1965 }
1966 else {
1967 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1968 }
1969 }
1970 else {
1971 if (orderByComparator.isAscending() ^ previous) {
1972 query.append(WHERE_GREATER_THAN);
1973 }
1974 else {
1975 query.append(WHERE_LESSER_THAN);
1976 }
1977 }
1978 }
1979
1980 query.append(ORDER_BY_CLAUSE);
1981
1982 String[] orderByFields = orderByComparator.getOrderByFields();
1983
1984 for (int i = 0; i < orderByFields.length; i++) {
1985 query.append(_ORDER_BY_ENTITY_ALIAS);
1986 query.append(orderByFields[i]);
1987
1988 if ((i + 1) < orderByFields.length) {
1989 if (orderByComparator.isAscending() ^ previous) {
1990 query.append(ORDER_BY_ASC_HAS_NEXT);
1991 }
1992 else {
1993 query.append(ORDER_BY_DESC_HAS_NEXT);
1994 }
1995 }
1996 else {
1997 if (orderByComparator.isAscending() ^ previous) {
1998 query.append(ORDER_BY_ASC);
1999 }
2000 else {
2001 query.append(ORDER_BY_DESC);
2002 }
2003 }
2004 }
2005 }
2006
2007 else {
2008 query.append(GroupModelImpl.ORDER_BY_JPQL);
2009 }
2010
2011 String sql = query.toString();
2012
2013 Query q = session.createQuery(sql);
2014
2015 q.setFirstResult(0);
2016 q.setMaxResults(2);
2017
2018 QueryPos qPos = QueryPos.getInstance(q);
2019
2020 qPos.add(type);
2021
2022 qPos.add(active);
2023
2024 if (orderByComparator != null) {
2025 Object[] values = orderByComparator.getOrderByConditionValues(group);
2026
2027 for (Object value : values) {
2028 qPos.add(value);
2029 }
2030 }
2031
2032 List<Group> list = q.list();
2033
2034 if (list.size() == 2) {
2035 return list.get(1);
2036 }
2037 else {
2038 return null;
2039 }
2040 }
2041
2042
2052 public Group findByC_C_C(long companyId, long classNameId, long classPK)
2053 throws NoSuchGroupException, SystemException {
2054 Group group = fetchByC_C_C(companyId, classNameId, classPK);
2055
2056 if (group == null) {
2057 StringBundler msg = new StringBundler(8);
2058
2059 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2060
2061 msg.append("companyId=");
2062 msg.append(companyId);
2063
2064 msg.append(", classNameId=");
2065 msg.append(classNameId);
2066
2067 msg.append(", classPK=");
2068 msg.append(classPK);
2069
2070 msg.append(StringPool.CLOSE_CURLY_BRACE);
2071
2072 if (_log.isWarnEnabled()) {
2073 _log.warn(msg.toString());
2074 }
2075
2076 throw new NoSuchGroupException(msg.toString());
2077 }
2078
2079 return group;
2080 }
2081
2082
2091 public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
2092 throws SystemException {
2093 return fetchByC_C_C(companyId, classNameId, classPK, true);
2094 }
2095
2096
2106 public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
2107 boolean retrieveFromCache) throws SystemException {
2108 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2109
2110 Object result = null;
2111
2112 if (retrieveFromCache) {
2113 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
2114 finderArgs, this);
2115 }
2116
2117 if (result == null) {
2118 StringBundler query = new StringBundler(5);
2119
2120 query.append(_SQL_SELECT_GROUP__WHERE);
2121
2122 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2123
2124 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2125
2126 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2127
2128 query.append(GroupModelImpl.ORDER_BY_JPQL);
2129
2130 String sql = query.toString();
2131
2132 Session session = null;
2133
2134 try {
2135 session = openSession();
2136
2137 Query q = session.createQuery(sql);
2138
2139 QueryPos qPos = QueryPos.getInstance(q);
2140
2141 qPos.add(companyId);
2142
2143 qPos.add(classNameId);
2144
2145 qPos.add(classPK);
2146
2147 List<Group> list = q.list();
2148
2149 result = list;
2150
2151 Group group = null;
2152
2153 if (list.isEmpty()) {
2154 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2155 finderArgs, list);
2156 }
2157 else {
2158 group = list.get(0);
2159
2160 cacheResult(group);
2161
2162 if ((group.getCompanyId() != companyId) ||
2163 (group.getClassNameId() != classNameId) ||
2164 (group.getClassPK() != classPK)) {
2165 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2166 finderArgs, group);
2167 }
2168 }
2169
2170 return group;
2171 }
2172 catch (Exception e) {
2173 throw processException(e);
2174 }
2175 finally {
2176 if (result == null) {
2177 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
2178 finderArgs);
2179 }
2180
2181 closeSession(session);
2182 }
2183 }
2184 else {
2185 if (result instanceof List<?>) {
2186 return null;
2187 }
2188 else {
2189 return (Group)result;
2190 }
2191 }
2192 }
2193
2194
2204 public Group findByC_L_N(long companyId, long liveGroupId, String name)
2205 throws NoSuchGroupException, SystemException {
2206 Group group = fetchByC_L_N(companyId, liveGroupId, name);
2207
2208 if (group == null) {
2209 StringBundler msg = new StringBundler(8);
2210
2211 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2212
2213 msg.append("companyId=");
2214 msg.append(companyId);
2215
2216 msg.append(", liveGroupId=");
2217 msg.append(liveGroupId);
2218
2219 msg.append(", name=");
2220 msg.append(name);
2221
2222 msg.append(StringPool.CLOSE_CURLY_BRACE);
2223
2224 if (_log.isWarnEnabled()) {
2225 _log.warn(msg.toString());
2226 }
2227
2228 throw new NoSuchGroupException(msg.toString());
2229 }
2230
2231 return group;
2232 }
2233
2234
2243 public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
2244 throws SystemException {
2245 return fetchByC_L_N(companyId, liveGroupId, name, true);
2246 }
2247
2248
2258 public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
2259 boolean retrieveFromCache) throws SystemException {
2260 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
2261
2262 Object result = null;
2263
2264 if (retrieveFromCache) {
2265 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
2266 finderArgs, this);
2267 }
2268
2269 if (result == null) {
2270 StringBundler query = new StringBundler(5);
2271
2272 query.append(_SQL_SELECT_GROUP__WHERE);
2273
2274 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
2275
2276 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
2277
2278 if (name == null) {
2279 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
2280 }
2281 else {
2282 if (name.equals(StringPool.BLANK)) {
2283 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
2284 }
2285 else {
2286 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
2287 }
2288 }
2289
2290 query.append(GroupModelImpl.ORDER_BY_JPQL);
2291
2292 String sql = query.toString();
2293
2294 Session session = null;
2295
2296 try {
2297 session = openSession();
2298
2299 Query q = session.createQuery(sql);
2300
2301 QueryPos qPos = QueryPos.getInstance(q);
2302
2303 qPos.add(companyId);
2304
2305 qPos.add(liveGroupId);
2306
2307 if (name != null) {
2308 qPos.add(name);
2309 }
2310
2311 List<Group> list = q.list();
2312
2313 result = list;
2314
2315 Group group = null;
2316
2317 if (list.isEmpty()) {
2318 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
2319 finderArgs, list);
2320 }
2321 else {
2322 group = list.get(0);
2323
2324 cacheResult(group);
2325
2326 if ((group.getCompanyId() != companyId) ||
2327 (group.getLiveGroupId() != liveGroupId) ||
2328 (group.getName() == null) ||
2329 !group.getName().equals(name)) {
2330 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
2331 finderArgs, group);
2332 }
2333 }
2334
2335 return group;
2336 }
2337 catch (Exception e) {
2338 throw processException(e);
2339 }
2340 finally {
2341 if (result == null) {
2342 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
2343 finderArgs);
2344 }
2345
2346 closeSession(session);
2347 }
2348 }
2349 else {
2350 if (result instanceof List<?>) {
2351 return null;
2352 }
2353 else {
2354 return (Group)result;
2355 }
2356 }
2357 }
2358
2359
2370 public Group findByC_C_L_N(long companyId, long classNameId,
2371 long liveGroupId, String name)
2372 throws NoSuchGroupException, SystemException {
2373 Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
2374
2375 if (group == null) {
2376 StringBundler msg = new StringBundler(10);
2377
2378 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2379
2380 msg.append("companyId=");
2381 msg.append(companyId);
2382
2383 msg.append(", classNameId=");
2384 msg.append(classNameId);
2385
2386 msg.append(", liveGroupId=");
2387 msg.append(liveGroupId);
2388
2389 msg.append(", name=");
2390 msg.append(name);
2391
2392 msg.append(StringPool.CLOSE_CURLY_BRACE);
2393
2394 if (_log.isWarnEnabled()) {
2395 _log.warn(msg.toString());
2396 }
2397
2398 throw new NoSuchGroupException(msg.toString());
2399 }
2400
2401 return group;
2402 }
2403
2404
2414 public Group fetchByC_C_L_N(long companyId, long classNameId,
2415 long liveGroupId, String name) throws SystemException {
2416 return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
2417 }
2418
2419
2430 public Group fetchByC_C_L_N(long companyId, long classNameId,
2431 long liveGroupId, String name, boolean retrieveFromCache)
2432 throws SystemException {
2433 Object[] finderArgs = new Object[] {
2434 companyId, classNameId, liveGroupId, name
2435 };
2436
2437 Object result = null;
2438
2439 if (retrieveFromCache) {
2440 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2441 finderArgs, this);
2442 }
2443
2444 if (result == null) {
2445 StringBundler query = new StringBundler(6);
2446
2447 query.append(_SQL_SELECT_GROUP__WHERE);
2448
2449 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
2450
2451 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
2452
2453 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
2454
2455 if (name == null) {
2456 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
2457 }
2458 else {
2459 if (name.equals(StringPool.BLANK)) {
2460 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
2461 }
2462 else {
2463 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
2464 }
2465 }
2466
2467 query.append(GroupModelImpl.ORDER_BY_JPQL);
2468
2469 String sql = query.toString();
2470
2471 Session session = null;
2472
2473 try {
2474 session = openSession();
2475
2476 Query q = session.createQuery(sql);
2477
2478 QueryPos qPos = QueryPos.getInstance(q);
2479
2480 qPos.add(companyId);
2481
2482 qPos.add(classNameId);
2483
2484 qPos.add(liveGroupId);
2485
2486 if (name != null) {
2487 qPos.add(name);
2488 }
2489
2490 List<Group> list = q.list();
2491
2492 result = list;
2493
2494 Group group = null;
2495
2496 if (list.isEmpty()) {
2497 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2498 finderArgs, list);
2499 }
2500 else {
2501 group = list.get(0);
2502
2503 cacheResult(group);
2504
2505 if ((group.getCompanyId() != companyId) ||
2506 (group.getClassNameId() != classNameId) ||
2507 (group.getLiveGroupId() != liveGroupId) ||
2508 (group.getName() == null) ||
2509 !group.getName().equals(name)) {
2510 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2511 finderArgs, group);
2512 }
2513 }
2514
2515 return group;
2516 }
2517 catch (Exception e) {
2518 throw processException(e);
2519 }
2520 finally {
2521 if (result == null) {
2522 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2523 finderArgs);
2524 }
2525
2526 closeSession(session);
2527 }
2528 }
2529 else {
2530 if (result instanceof List<?>) {
2531 return null;
2532 }
2533 else {
2534 return (Group)result;
2535 }
2536 }
2537 }
2538
2539
2545 public List<Group> findAll() throws SystemException {
2546 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2547 }
2548
2549
2561 public List<Group> findAll(int start, int end) throws SystemException {
2562 return findAll(start, end, null);
2563 }
2564
2565
2578 public List<Group> findAll(int start, int end,
2579 OrderByComparator orderByComparator) throws SystemException {
2580 FinderPath finderPath = null;
2581 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2582
2583 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2584 (orderByComparator == null)) {
2585 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2586 finderArgs = FINDER_ARGS_EMPTY;
2587 }
2588 else {
2589 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2590 finderArgs = new Object[] { start, end, orderByComparator };
2591 }
2592
2593 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2594 finderArgs, this);
2595
2596 if (list == null) {
2597 StringBundler query = null;
2598 String sql = null;
2599
2600 if (orderByComparator != null) {
2601 query = new StringBundler(2 +
2602 (orderByComparator.getOrderByFields().length * 3));
2603
2604 query.append(_SQL_SELECT_GROUP_);
2605
2606 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2607 orderByComparator);
2608
2609 sql = query.toString();
2610 }
2611 else {
2612 sql = _SQL_SELECT_GROUP_.concat(GroupModelImpl.ORDER_BY_JPQL);
2613 }
2614
2615 Session session = null;
2616
2617 try {
2618 session = openSession();
2619
2620 Query q = session.createQuery(sql);
2621
2622 if (orderByComparator == null) {
2623 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2624 end, false);
2625
2626 Collections.sort(list);
2627 }
2628 else {
2629 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2630 end);
2631 }
2632 }
2633 catch (Exception e) {
2634 throw processException(e);
2635 }
2636 finally {
2637 if (list == null) {
2638 FinderCacheUtil.removeResult(finderPath, finderArgs);
2639 }
2640 else {
2641 cacheResult(list);
2642
2643 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2644 }
2645
2646 closeSession(session);
2647 }
2648 }
2649
2650 return list;
2651 }
2652
2653
2659 public void removeByCompanyId(long companyId) throws SystemException {
2660 for (Group group : findByCompanyId(companyId)) {
2661 remove(group);
2662 }
2663 }
2664
2665
2671 public void removeByLiveGroupId(long liveGroupId)
2672 throws NoSuchGroupException, SystemException {
2673 Group group = findByLiveGroupId(liveGroupId);
2674
2675 remove(group);
2676 }
2677
2678
2685 public void removeByC_N(long companyId, String name)
2686 throws NoSuchGroupException, SystemException {
2687 Group group = findByC_N(companyId, name);
2688
2689 remove(group);
2690 }
2691
2692
2699 public void removeByC_F(long companyId, String friendlyURL)
2700 throws NoSuchGroupException, SystemException {
2701 Group group = findByC_F(companyId, friendlyURL);
2702
2703 remove(group);
2704 }
2705
2706
2713 public void removeByT_A(int type, boolean active) throws SystemException {
2714 for (Group group : findByT_A(type, active)) {
2715 remove(group);
2716 }
2717 }
2718
2719
2727 public void removeByC_C_C(long companyId, long classNameId, long classPK)
2728 throws NoSuchGroupException, SystemException {
2729 Group group = findByC_C_C(companyId, classNameId, classPK);
2730
2731 remove(group);
2732 }
2733
2734
2742 public void removeByC_L_N(long companyId, long liveGroupId, String name)
2743 throws NoSuchGroupException, SystemException {
2744 Group group = findByC_L_N(companyId, liveGroupId, name);
2745
2746 remove(group);
2747 }
2748
2749
2758 public void removeByC_C_L_N(long companyId, long classNameId,
2759 long liveGroupId, String name)
2760 throws NoSuchGroupException, SystemException {
2761 Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
2762
2763 remove(group);
2764 }
2765
2766
2771 public void removeAll() throws SystemException {
2772 for (Group group : findAll()) {
2773 remove(group);
2774 }
2775 }
2776
2777
2784 public int countByCompanyId(long companyId) throws SystemException {
2785 Object[] finderArgs = new Object[] { companyId };
2786
2787 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2788 finderArgs, this);
2789
2790 if (count == null) {
2791 StringBundler query = new StringBundler(2);
2792
2793 query.append(_SQL_COUNT_GROUP__WHERE);
2794
2795 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2796
2797 String sql = query.toString();
2798
2799 Session session = null;
2800
2801 try {
2802 session = openSession();
2803
2804 Query q = session.createQuery(sql);
2805
2806 QueryPos qPos = QueryPos.getInstance(q);
2807
2808 qPos.add(companyId);
2809
2810 count = (Long)q.uniqueResult();
2811 }
2812 catch (Exception e) {
2813 throw processException(e);
2814 }
2815 finally {
2816 if (count == null) {
2817 count = Long.valueOf(0);
2818 }
2819
2820 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2821 finderArgs, count);
2822
2823 closeSession(session);
2824 }
2825 }
2826
2827 return count.intValue();
2828 }
2829
2830
2837 public int countByLiveGroupId(long liveGroupId) throws SystemException {
2838 Object[] finderArgs = new Object[] { liveGroupId };
2839
2840 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
2841 finderArgs, this);
2842
2843 if (count == null) {
2844 StringBundler query = new StringBundler(2);
2845
2846 query.append(_SQL_COUNT_GROUP__WHERE);
2847
2848 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
2849
2850 String sql = query.toString();
2851
2852 Session session = null;
2853
2854 try {
2855 session = openSession();
2856
2857 Query q = session.createQuery(sql);
2858
2859 QueryPos qPos = QueryPos.getInstance(q);
2860
2861 qPos.add(liveGroupId);
2862
2863 count = (Long)q.uniqueResult();
2864 }
2865 catch (Exception e) {
2866 throw processException(e);
2867 }
2868 finally {
2869 if (count == null) {
2870 count = Long.valueOf(0);
2871 }
2872
2873 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
2874 finderArgs, count);
2875
2876 closeSession(session);
2877 }
2878 }
2879
2880 return count.intValue();
2881 }
2882
2883
2891 public int countByC_N(long companyId, String name)
2892 throws SystemException {
2893 Object[] finderArgs = new Object[] { companyId, name };
2894
2895 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
2896 finderArgs, this);
2897
2898 if (count == null) {
2899 StringBundler query = new StringBundler(3);
2900
2901 query.append(_SQL_COUNT_GROUP__WHERE);
2902
2903 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2904
2905 if (name == null) {
2906 query.append(_FINDER_COLUMN_C_N_NAME_1);
2907 }
2908 else {
2909 if (name.equals(StringPool.BLANK)) {
2910 query.append(_FINDER_COLUMN_C_N_NAME_3);
2911 }
2912 else {
2913 query.append(_FINDER_COLUMN_C_N_NAME_2);
2914 }
2915 }
2916
2917 String sql = query.toString();
2918
2919 Session session = null;
2920
2921 try {
2922 session = openSession();
2923
2924 Query q = session.createQuery(sql);
2925
2926 QueryPos qPos = QueryPos.getInstance(q);
2927
2928 qPos.add(companyId);
2929
2930 if (name != null) {
2931 qPos.add(name);
2932 }
2933
2934 count = (Long)q.uniqueResult();
2935 }
2936 catch (Exception e) {
2937 throw processException(e);
2938 }
2939 finally {
2940 if (count == null) {
2941 count = Long.valueOf(0);
2942 }
2943
2944 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
2945 count);
2946
2947 closeSession(session);
2948 }
2949 }
2950
2951 return count.intValue();
2952 }
2953
2954
2962 public int countByC_F(long companyId, String friendlyURL)
2963 throws SystemException {
2964 Object[] finderArgs = new Object[] { companyId, friendlyURL };
2965
2966 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
2967 finderArgs, this);
2968
2969 if (count == null) {
2970 StringBundler query = new StringBundler(3);
2971
2972 query.append(_SQL_COUNT_GROUP__WHERE);
2973
2974 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
2975
2976 if (friendlyURL == null) {
2977 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
2978 }
2979 else {
2980 if (friendlyURL.equals(StringPool.BLANK)) {
2981 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
2982 }
2983 else {
2984 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
2985 }
2986 }
2987
2988 String sql = query.toString();
2989
2990 Session session = null;
2991
2992 try {
2993 session = openSession();
2994
2995 Query q = session.createQuery(sql);
2996
2997 QueryPos qPos = QueryPos.getInstance(q);
2998
2999 qPos.add(companyId);
3000
3001 if (friendlyURL != null) {
3002 qPos.add(friendlyURL);
3003 }
3004
3005 count = (Long)q.uniqueResult();
3006 }
3007 catch (Exception e) {
3008 throw processException(e);
3009 }
3010 finally {
3011 if (count == null) {
3012 count = Long.valueOf(0);
3013 }
3014
3015 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
3016 count);
3017
3018 closeSession(session);
3019 }
3020 }
3021
3022 return count.intValue();
3023 }
3024
3025
3033 public int countByT_A(int type, boolean active) throws SystemException {
3034 Object[] finderArgs = new Object[] { type, active };
3035
3036 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
3037 finderArgs, this);
3038
3039 if (count == null) {
3040 StringBundler query = new StringBundler(3);
3041
3042 query.append(_SQL_COUNT_GROUP__WHERE);
3043
3044 query.append(_FINDER_COLUMN_T_A_TYPE_2);
3045
3046 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
3047
3048 String sql = query.toString();
3049
3050 Session session = null;
3051
3052 try {
3053 session = openSession();
3054
3055 Query q = session.createQuery(sql);
3056
3057 QueryPos qPos = QueryPos.getInstance(q);
3058
3059 qPos.add(type);
3060
3061 qPos.add(active);
3062
3063 count = (Long)q.uniqueResult();
3064 }
3065 catch (Exception e) {
3066 throw processException(e);
3067 }
3068 finally {
3069 if (count == null) {
3070 count = Long.valueOf(0);
3071 }
3072
3073 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
3074 count);
3075
3076 closeSession(session);
3077 }
3078 }
3079
3080 return count.intValue();
3081 }
3082
3083
3092 public int countByC_C_C(long companyId, long classNameId, long classPK)
3093 throws SystemException {
3094 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3095
3096 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
3097 finderArgs, this);
3098
3099 if (count == null) {
3100 StringBundler query = new StringBundler(4);
3101
3102 query.append(_SQL_COUNT_GROUP__WHERE);
3103
3104 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3105
3106 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3107
3108 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3109
3110 String sql = query.toString();
3111
3112 Session session = null;
3113
3114 try {
3115 session = openSession();
3116
3117 Query q = session.createQuery(sql);
3118
3119 QueryPos qPos = QueryPos.getInstance(q);
3120
3121 qPos.add(companyId);
3122
3123 qPos.add(classNameId);
3124
3125 qPos.add(classPK);
3126
3127 count = (Long)q.uniqueResult();
3128 }
3129 catch (Exception e) {
3130 throw processException(e);
3131 }
3132 finally {
3133 if (count == null) {
3134 count = Long.valueOf(0);
3135 }
3136
3137 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
3138 finderArgs, count);
3139
3140 closeSession(session);
3141 }
3142 }
3143
3144 return count.intValue();
3145 }
3146
3147
3156 public int countByC_L_N(long companyId, long liveGroupId, String name)
3157 throws SystemException {
3158 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
3159
3160 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L_N,
3161 finderArgs, this);
3162
3163 if (count == null) {
3164 StringBundler query = new StringBundler(4);
3165
3166 query.append(_SQL_COUNT_GROUP__WHERE);
3167
3168 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
3169
3170 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
3171
3172 if (name == null) {
3173 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
3174 }
3175 else {
3176 if (name.equals(StringPool.BLANK)) {
3177 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
3178 }
3179 else {
3180 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
3181 }
3182 }
3183
3184 String sql = query.toString();
3185
3186 Session session = null;
3187
3188 try {
3189 session = openSession();
3190
3191 Query q = session.createQuery(sql);
3192
3193 QueryPos qPos = QueryPos.getInstance(q);
3194
3195 qPos.add(companyId);
3196
3197 qPos.add(liveGroupId);
3198
3199 if (name != null) {
3200 qPos.add(name);
3201 }
3202
3203 count = (Long)q.uniqueResult();
3204 }
3205 catch (Exception e) {
3206 throw processException(e);
3207 }
3208 finally {
3209 if (count == null) {
3210 count = Long.valueOf(0);
3211 }
3212
3213 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N,
3214 finderArgs, count);
3215
3216 closeSession(session);
3217 }
3218 }
3219
3220 return count.intValue();
3221 }
3222
3223
3233 public int countByC_C_L_N(long companyId, long classNameId,
3234 long liveGroupId, String name) throws SystemException {
3235 Object[] finderArgs = new Object[] {
3236 companyId, classNameId, liveGroupId, name
3237 };
3238
3239 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_L_N,
3240 finderArgs, this);
3241
3242 if (count == null) {
3243 StringBundler query = new StringBundler(5);
3244
3245 query.append(_SQL_COUNT_GROUP__WHERE);
3246
3247 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
3248
3249 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
3250
3251 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
3252
3253 if (name == null) {
3254 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
3255 }
3256 else {
3257 if (name.equals(StringPool.BLANK)) {
3258 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
3259 }
3260 else {
3261 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
3262 }
3263 }
3264
3265 String sql = query.toString();
3266
3267 Session session = null;
3268
3269 try {
3270 session = openSession();
3271
3272 Query q = session.createQuery(sql);
3273
3274 QueryPos qPos = QueryPos.getInstance(q);
3275
3276 qPos.add(companyId);
3277
3278 qPos.add(classNameId);
3279
3280 qPos.add(liveGroupId);
3281
3282 if (name != null) {
3283 qPos.add(name);
3284 }
3285
3286 count = (Long)q.uniqueResult();
3287 }
3288 catch (Exception e) {
3289 throw processException(e);
3290 }
3291 finally {
3292 if (count == null) {
3293 count = Long.valueOf(0);
3294 }
3295
3296 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N,
3297 finderArgs, count);
3298
3299 closeSession(session);
3300 }
3301 }
3302
3303 return count.intValue();
3304 }
3305
3306
3312 public int countAll() throws SystemException {
3313 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3314 FINDER_ARGS_EMPTY, this);
3315
3316 if (count == null) {
3317 Session session = null;
3318
3319 try {
3320 session = openSession();
3321
3322 Query q = session.createQuery(_SQL_COUNT_GROUP_);
3323
3324 count = (Long)q.uniqueResult();
3325 }
3326 catch (Exception e) {
3327 throw processException(e);
3328 }
3329 finally {
3330 if (count == null) {
3331 count = Long.valueOf(0);
3332 }
3333
3334 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3335 FINDER_ARGS_EMPTY, count);
3336
3337 closeSession(session);
3338 }
3339 }
3340
3341 return count.intValue();
3342 }
3343
3344
3351 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
3352 throws SystemException {
3353 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3354 }
3355
3356
3369 public List<com.liferay.portal.model.Organization> getOrganizations(
3370 long pk, int start, int end) throws SystemException {
3371 return getOrganizations(pk, start, end, null);
3372 }
3373
3374 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3375 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3376 com.liferay.portal.model.impl.OrganizationImpl.class,
3377 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getOrganizations",
3378 new String[] {
3379 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3380 "com.liferay.portal.kernel.util.OrderByComparator"
3381 });
3382
3383
3397 public List<com.liferay.portal.model.Organization> getOrganizations(
3398 long pk, int start, int end, OrderByComparator orderByComparator)
3399 throws SystemException {
3400 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3401
3402 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
3403 finderArgs, this);
3404
3405 if (list == null) {
3406 Session session = null;
3407
3408 try {
3409 session = openSession();
3410
3411 String sql = null;
3412
3413 if (orderByComparator != null) {
3414 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
3415 .concat(orderByComparator.getOrderBy());
3416 }
3417 else {
3418 sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
3419 }
3420
3421 SQLQuery q = session.createSQLQuery(sql);
3422
3423 q.addEntity("Organization_",
3424 com.liferay.portal.model.impl.OrganizationImpl.class);
3425
3426 QueryPos qPos = QueryPos.getInstance(q);
3427
3428 qPos.add(pk);
3429
3430 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
3431 getDialect(), start, end);
3432 }
3433 catch (Exception e) {
3434 throw processException(e);
3435 }
3436 finally {
3437 if (list == null) {
3438 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
3439 finderArgs);
3440 }
3441 else {
3442 organizationPersistence.cacheResult(list);
3443
3444 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
3445 finderArgs, list);
3446 }
3447
3448 closeSession(session);
3449 }
3450 }
3451
3452 return list;
3453 }
3454
3455 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3456 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
3457 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3458 "getOrganizationsSize", new String[] { Long.class.getName() });
3459
3460
3467 public int getOrganizationsSize(long pk) throws SystemException {
3468 Object[] finderArgs = new Object[] { pk };
3469
3470 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3471 finderArgs, this);
3472
3473 if (count == null) {
3474 Session session = null;
3475
3476 try {
3477 session = openSession();
3478
3479 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
3480
3481 q.addScalar(COUNT_COLUMN_NAME,
3482 com.liferay.portal.kernel.dao.orm.Type.LONG);
3483
3484 QueryPos qPos = QueryPos.getInstance(q);
3485
3486 qPos.add(pk);
3487
3488 count = (Long)q.uniqueResult();
3489 }
3490 catch (Exception e) {
3491 throw processException(e);
3492 }
3493 finally {
3494 if (count == null) {
3495 count = Long.valueOf(0);
3496 }
3497
3498 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3499 finderArgs, count);
3500
3501 closeSession(session);
3502 }
3503 }
3504
3505 return count.intValue();
3506 }
3507
3508 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3509 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Boolean.class,
3510 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3511 "containsOrganization",
3512 new String[] { Long.class.getName(), Long.class.getName() });
3513
3514
3522 public boolean containsOrganization(long pk, long organizationPK)
3523 throws SystemException {
3524 Object[] finderArgs = new Object[] { pk, organizationPK };
3525
3526 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3527 finderArgs, this);
3528
3529 if (value == null) {
3530 try {
3531 value = Boolean.valueOf(containsOrganization.contains(pk,
3532 organizationPK));
3533 }
3534 catch (Exception e) {
3535 throw processException(e);
3536 }
3537 finally {
3538 if (value == null) {
3539 value = Boolean.FALSE;
3540 }
3541
3542 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3543 finderArgs, value);
3544 }
3545 }
3546
3547 return value.booleanValue();
3548 }
3549
3550
3557 public boolean containsOrganizations(long pk) throws SystemException {
3558 if (getOrganizationsSize(pk) > 0) {
3559 return true;
3560 }
3561 else {
3562 return false;
3563 }
3564 }
3565
3566
3573 public void addOrganization(long pk, long organizationPK)
3574 throws SystemException {
3575 try {
3576 addOrganization.add(pk, organizationPK);
3577 }
3578 catch (Exception e) {
3579 throw processException(e);
3580 }
3581 finally {
3582 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3583 }
3584 }
3585
3586
3593 public void addOrganization(long pk,
3594 com.liferay.portal.model.Organization organization)
3595 throws SystemException {
3596 try {
3597 addOrganization.add(pk, organization.getPrimaryKey());
3598 }
3599 catch (Exception e) {
3600 throw processException(e);
3601 }
3602 finally {
3603 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3604 }
3605 }
3606
3607
3614 public void addOrganizations(long pk, long[] organizationPKs)
3615 throws SystemException {
3616 try {
3617 for (long organizationPK : organizationPKs) {
3618 addOrganization.add(pk, organizationPK);
3619 }
3620 }
3621 catch (Exception e) {
3622 throw processException(e);
3623 }
3624 finally {
3625 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3626 }
3627 }
3628
3629
3636 public void addOrganizations(long pk,
3637 List<com.liferay.portal.model.Organization> organizations)
3638 throws SystemException {
3639 try {
3640 for (com.liferay.portal.model.Organization organization : organizations) {
3641 addOrganization.add(pk, organization.getPrimaryKey());
3642 }
3643 }
3644 catch (Exception e) {
3645 throw processException(e);
3646 }
3647 finally {
3648 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3649 }
3650 }
3651
3652
3658 public void clearOrganizations(long pk) throws SystemException {
3659 try {
3660 clearOrganizations.clear(pk);
3661 }
3662 catch (Exception e) {
3663 throw processException(e);
3664 }
3665 finally {
3666 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3667 }
3668 }
3669
3670
3677 public void removeOrganization(long pk, long organizationPK)
3678 throws SystemException {
3679 try {
3680 removeOrganization.remove(pk, organizationPK);
3681 }
3682 catch (Exception e) {
3683 throw processException(e);
3684 }
3685 finally {
3686 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3687 }
3688 }
3689
3690
3697 public void removeOrganization(long pk,
3698 com.liferay.portal.model.Organization organization)
3699 throws SystemException {
3700 try {
3701 removeOrganization.remove(pk, organization.getPrimaryKey());
3702 }
3703 catch (Exception e) {
3704 throw processException(e);
3705 }
3706 finally {
3707 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3708 }
3709 }
3710
3711
3718 public void removeOrganizations(long pk, long[] organizationPKs)
3719 throws SystemException {
3720 try {
3721 for (long organizationPK : organizationPKs) {
3722 removeOrganization.remove(pk, organizationPK);
3723 }
3724 }
3725 catch (Exception e) {
3726 throw processException(e);
3727 }
3728 finally {
3729 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3730 }
3731 }
3732
3733
3740 public void removeOrganizations(long pk,
3741 List<com.liferay.portal.model.Organization> organizations)
3742 throws SystemException {
3743 try {
3744 for (com.liferay.portal.model.Organization organization : organizations) {
3745 removeOrganization.remove(pk, organization.getPrimaryKey());
3746 }
3747 }
3748 catch (Exception e) {
3749 throw processException(e);
3750 }
3751 finally {
3752 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3753 }
3754 }
3755
3756
3763 public void setOrganizations(long pk, long[] organizationPKs)
3764 throws SystemException {
3765 try {
3766 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
3767
3768 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
3769
3770 for (com.liferay.portal.model.Organization organization : organizations) {
3771 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
3772 removeOrganization.remove(pk, organization.getPrimaryKey());
3773 }
3774 }
3775
3776 for (Long organizationPK : organizationPKSet) {
3777 addOrganization.add(pk, organizationPK);
3778 }
3779 }
3780 catch (Exception e) {
3781 throw processException(e);
3782 }
3783 finally {
3784 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3785 }
3786 }
3787
3788
3795 public void setOrganizations(long pk,
3796 List<com.liferay.portal.model.Organization> organizations)
3797 throws SystemException {
3798 try {
3799 long[] organizationPKs = new long[organizations.size()];
3800
3801 for (int i = 0; i < organizations.size(); i++) {
3802 com.liferay.portal.model.Organization organization = organizations.get(i);
3803
3804 organizationPKs[i] = organization.getPrimaryKey();
3805 }
3806
3807 setOrganizations(pk, organizationPKs);
3808 }
3809 catch (Exception e) {
3810 throw processException(e);
3811 }
3812 finally {
3813 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3814 }
3815 }
3816
3817
3824 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
3825 throws SystemException {
3826 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3827 }
3828
3829
3842 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3843 int start, int end) throws SystemException {
3844 return getPermissions(pk, start, end, null);
3845 }
3846
3847 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3848 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
3849 com.liferay.portal.model.impl.PermissionImpl.class,
3850 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3851 "getPermissions",
3852 new String[] {
3853 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3854 "com.liferay.portal.kernel.util.OrderByComparator"
3855 });
3856
3857
3871 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3872 int start, int end, OrderByComparator orderByComparator)
3873 throws SystemException {
3874 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3875
3876 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
3877 finderArgs, this);
3878
3879 if (list == null) {
3880 Session session = null;
3881
3882 try {
3883 session = openSession();
3884
3885 String sql = null;
3886
3887 if (orderByComparator != null) {
3888 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
3889 .concat(orderByComparator.getOrderBy());
3890 }
3891 else {
3892 sql = _SQL_GETPERMISSIONS;
3893 }
3894
3895 SQLQuery q = session.createSQLQuery(sql);
3896
3897 q.addEntity("Permission_",
3898 com.liferay.portal.model.impl.PermissionImpl.class);
3899
3900 QueryPos qPos = QueryPos.getInstance(q);
3901
3902 qPos.add(pk);
3903
3904 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
3905 getDialect(), start, end);
3906 }
3907 catch (Exception e) {
3908 throw processException(e);
3909 }
3910 finally {
3911 if (list == null) {
3912 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
3913 finderArgs);
3914 }
3915 else {
3916 permissionPersistence.cacheResult(list);
3917
3918 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
3919 finderArgs, list);
3920 }
3921
3922 closeSession(session);
3923 }
3924 }
3925
3926 return list;
3927 }
3928
3929 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3930 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS, Long.class,
3931 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3932 "getPermissionsSize", new String[] { Long.class.getName() });
3933
3934
3941 public int getPermissionsSize(long pk) throws SystemException {
3942 Object[] finderArgs = new Object[] { pk };
3943
3944 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3945 finderArgs, this);
3946
3947 if (count == null) {
3948 Session session = null;
3949
3950 try {
3951 session = openSession();
3952
3953 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
3954
3955 q.addScalar(COUNT_COLUMN_NAME,
3956 com.liferay.portal.kernel.dao.orm.Type.LONG);
3957
3958 QueryPos qPos = QueryPos.getInstance(q);
3959
3960 qPos.add(pk);
3961
3962 count = (Long)q.uniqueResult();
3963 }
3964 catch (Exception e) {
3965 throw processException(e);
3966 }
3967 finally {
3968 if (count == null) {
3969 count = Long.valueOf(0);
3970 }
3971
3972 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
3973 finderArgs, count);
3974
3975 closeSession(session);
3976 }
3977 }
3978
3979 return count.intValue();
3980 }
3981
3982 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3983 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
3984 Boolean.class,
3985 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
3986 "containsPermission",
3987 new String[] { Long.class.getName(), Long.class.getName() });
3988
3989
3997 public boolean containsPermission(long pk, long permissionPK)
3998 throws SystemException {
3999 Object[] finderArgs = new Object[] { pk, permissionPK };
4000
4001 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
4002 finderArgs, this);
4003
4004 if (value == null) {
4005 try {
4006 value = Boolean.valueOf(containsPermission.contains(pk,
4007 permissionPK));
4008 }
4009 catch (Exception e) {
4010 throw processException(e);
4011 }
4012 finally {
4013 if (value == null) {
4014 value = Boolean.FALSE;
4015 }
4016
4017 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
4018 finderArgs, value);
4019 }
4020 }
4021
4022 return value.booleanValue();
4023 }
4024
4025
4032 public boolean containsPermissions(long pk) throws SystemException {
4033 if (getPermissionsSize(pk) > 0) {
4034 return true;
4035 }
4036 else {
4037 return false;
4038 }
4039 }
4040
4041
4048 public void addPermission(long pk, long permissionPK)
4049 throws SystemException {
4050 try {
4051 addPermission.add(pk, permissionPK);
4052 }
4053 catch (Exception e) {
4054 throw processException(e);
4055 }
4056 finally {
4057 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4058 }
4059 }
4060
4061
4068 public void addPermission(long pk,
4069 com.liferay.portal.model.Permission permission)
4070 throws SystemException {
4071 try {
4072 addPermission.add(pk, permission.getPrimaryKey());
4073 }
4074 catch (Exception e) {
4075 throw processException(e);
4076 }
4077 finally {
4078 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4079 }
4080 }
4081
4082
4089 public void addPermissions(long pk, long[] permissionPKs)
4090 throws SystemException {
4091 try {
4092 for (long permissionPK : permissionPKs) {
4093 addPermission.add(pk, permissionPK);
4094 }
4095 }
4096 catch (Exception e) {
4097 throw processException(e);
4098 }
4099 finally {
4100 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4101 }
4102 }
4103
4104
4111 public void addPermissions(long pk,
4112 List<com.liferay.portal.model.Permission> permissions)
4113 throws SystemException {
4114 try {
4115 for (com.liferay.portal.model.Permission permission : permissions) {
4116 addPermission.add(pk, permission.getPrimaryKey());
4117 }
4118 }
4119 catch (Exception e) {
4120 throw processException(e);
4121 }
4122 finally {
4123 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4124 }
4125 }
4126
4127
4133 public void clearPermissions(long pk) throws SystemException {
4134 try {
4135 clearPermissions.clear(pk);
4136 }
4137 catch (Exception e) {
4138 throw processException(e);
4139 }
4140 finally {
4141 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4142 }
4143 }
4144
4145
4152 public void removePermission(long pk, long permissionPK)
4153 throws SystemException {
4154 try {
4155 removePermission.remove(pk, permissionPK);
4156 }
4157 catch (Exception e) {
4158 throw processException(e);
4159 }
4160 finally {
4161 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4162 }
4163 }
4164
4165
4172 public void removePermission(long pk,
4173 com.liferay.portal.model.Permission permission)
4174 throws SystemException {
4175 try {
4176 removePermission.remove(pk, permission.getPrimaryKey());
4177 }
4178 catch (Exception e) {
4179 throw processException(e);
4180 }
4181 finally {
4182 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4183 }
4184 }
4185
4186
4193 public void removePermissions(long pk, long[] permissionPKs)
4194 throws SystemException {
4195 try {
4196 for (long permissionPK : permissionPKs) {
4197 removePermission.remove(pk, permissionPK);
4198 }
4199 }
4200 catch (Exception e) {
4201 throw processException(e);
4202 }
4203 finally {
4204 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4205 }
4206 }
4207
4208
4215 public void removePermissions(long pk,
4216 List<com.liferay.portal.model.Permission> permissions)
4217 throws SystemException {
4218 try {
4219 for (com.liferay.portal.model.Permission permission : permissions) {
4220 removePermission.remove(pk, permission.getPrimaryKey());
4221 }
4222 }
4223 catch (Exception e) {
4224 throw processException(e);
4225 }
4226 finally {
4227 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4228 }
4229 }
4230
4231
4238 public void setPermissions(long pk, long[] permissionPKs)
4239 throws SystemException {
4240 try {
4241 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
4242
4243 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
4244
4245 for (com.liferay.portal.model.Permission permission : permissions) {
4246 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
4247 removePermission.remove(pk, permission.getPrimaryKey());
4248 }
4249 }
4250
4251 for (Long permissionPK : permissionPKSet) {
4252 addPermission.add(pk, permissionPK);
4253 }
4254 }
4255 catch (Exception e) {
4256 throw processException(e);
4257 }
4258 finally {
4259 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4260 }
4261 }
4262
4263
4270 public void setPermissions(long pk,
4271 List<com.liferay.portal.model.Permission> permissions)
4272 throws SystemException {
4273 try {
4274 long[] permissionPKs = new long[permissions.size()];
4275
4276 for (int i = 0; i < permissions.size(); i++) {
4277 com.liferay.portal.model.Permission permission = permissions.get(i);
4278
4279 permissionPKs[i] = permission.getPrimaryKey();
4280 }
4281
4282 setPermissions(pk, permissionPKs);
4283 }
4284 catch (Exception e) {
4285 throw processException(e);
4286 }
4287 finally {
4288 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4289 }
4290 }
4291
4292
4299 public List<com.liferay.portal.model.Role> getRoles(long pk)
4300 throws SystemException {
4301 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4302 }
4303
4304
4317 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4318 int end) throws SystemException {
4319 return getRoles(pk, start, end, null);
4320 }
4321
4322 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4323 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4324 com.liferay.portal.model.impl.RoleImpl.class,
4325 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRoles",
4326 new String[] {
4327 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4328 "com.liferay.portal.kernel.util.OrderByComparator"
4329 });
4330
4331
4345 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4346 int end, OrderByComparator orderByComparator) throws SystemException {
4347 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4348
4349 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
4350 finderArgs, this);
4351
4352 if (list == null) {
4353 Session session = null;
4354
4355 try {
4356 session = openSession();
4357
4358 String sql = null;
4359
4360 if (orderByComparator != null) {
4361 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
4362 .concat(orderByComparator.getOrderBy());
4363 }
4364 else {
4365 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
4366 }
4367
4368 SQLQuery q = session.createSQLQuery(sql);
4369
4370 q.addEntity("Role_",
4371 com.liferay.portal.model.impl.RoleImpl.class);
4372
4373 QueryPos qPos = QueryPos.getInstance(q);
4374
4375 qPos.add(pk);
4376
4377 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
4378 getDialect(), start, end);
4379 }
4380 catch (Exception e) {
4381 throw processException(e);
4382 }
4383 finally {
4384 if (list == null) {
4385 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
4386 finderArgs);
4387 }
4388 else {
4389 rolePersistence.cacheResult(list);
4390
4391 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
4392 finderArgs, list);
4393 }
4394
4395 closeSession(session);
4396 }
4397 }
4398
4399 return list;
4400 }
4401
4402 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4403 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4404 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRolesSize",
4405 new String[] { Long.class.getName() });
4406
4407
4414 public int getRolesSize(long pk) throws SystemException {
4415 Object[] finderArgs = new Object[] { pk };
4416
4417 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
4418 finderArgs, this);
4419
4420 if (count == null) {
4421 Session session = null;
4422
4423 try {
4424 session = openSession();
4425
4426 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
4427
4428 q.addScalar(COUNT_COLUMN_NAME,
4429 com.liferay.portal.kernel.dao.orm.Type.LONG);
4430
4431 QueryPos qPos = QueryPos.getInstance(q);
4432
4433 qPos.add(pk);
4434
4435 count = (Long)q.uniqueResult();
4436 }
4437 catch (Exception e) {
4438 throw processException(e);
4439 }
4440 finally {
4441 if (count == null) {
4442 count = Long.valueOf(0);
4443 }
4444
4445 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
4446 finderArgs, count);
4447
4448 closeSession(session);
4449 }
4450 }
4451
4452 return count.intValue();
4453 }
4454
4455 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4456 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
4457 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsRole",
4458 new String[] { Long.class.getName(), Long.class.getName() });
4459
4460
4468 public boolean containsRole(long pk, long rolePK) throws SystemException {
4469 Object[] finderArgs = new Object[] { pk, rolePK };
4470
4471 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
4472 finderArgs, this);
4473
4474 if (value == null) {
4475 try {
4476 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
4477 }
4478 catch (Exception e) {
4479 throw processException(e);
4480 }
4481 finally {
4482 if (value == null) {
4483 value = Boolean.FALSE;
4484 }
4485
4486 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
4487 finderArgs, value);
4488 }
4489 }
4490
4491 return value.booleanValue();
4492 }
4493
4494
4501 public boolean containsRoles(long pk) throws SystemException {
4502 if (getRolesSize(pk) > 0) {
4503 return true;
4504 }
4505 else {
4506 return false;
4507 }
4508 }
4509
4510
4517 public void addRole(long pk, long rolePK) throws SystemException {
4518 try {
4519 addRole.add(pk, rolePK);
4520 }
4521 catch (Exception e) {
4522 throw processException(e);
4523 }
4524 finally {
4525 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4526 }
4527 }
4528
4529
4536 public void addRole(long pk, com.liferay.portal.model.Role role)
4537 throws SystemException {
4538 try {
4539 addRole.add(pk, role.getPrimaryKey());
4540 }
4541 catch (Exception e) {
4542 throw processException(e);
4543 }
4544 finally {
4545 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4546 }
4547 }
4548
4549
4556 public void addRoles(long pk, long[] rolePKs) throws SystemException {
4557 try {
4558 for (long rolePK : rolePKs) {
4559 addRole.add(pk, rolePK);
4560 }
4561 }
4562 catch (Exception e) {
4563 throw processException(e);
4564 }
4565 finally {
4566 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4567 }
4568 }
4569
4570
4577 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
4578 throws SystemException {
4579 try {
4580 for (com.liferay.portal.model.Role role : roles) {
4581 addRole.add(pk, role.getPrimaryKey());
4582 }
4583 }
4584 catch (Exception e) {
4585 throw processException(e);
4586 }
4587 finally {
4588 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4589 }
4590 }
4591
4592
4598 public void clearRoles(long pk) throws SystemException {
4599 try {
4600 clearRoles.clear(pk);
4601 }
4602 catch (Exception e) {
4603 throw processException(e);
4604 }
4605 finally {
4606 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4607 }
4608 }
4609
4610
4617 public void removeRole(long pk, long rolePK) throws SystemException {
4618 try {
4619 removeRole.remove(pk, rolePK);
4620 }
4621 catch (Exception e) {
4622 throw processException(e);
4623 }
4624 finally {
4625 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4626 }
4627 }
4628
4629
4636 public void removeRole(long pk, com.liferay.portal.model.Role role)
4637 throws SystemException {
4638 try {
4639 removeRole.remove(pk, role.getPrimaryKey());
4640 }
4641 catch (Exception e) {
4642 throw processException(e);
4643 }
4644 finally {
4645 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4646 }
4647 }
4648
4649
4656 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
4657 try {
4658 for (long rolePK : rolePKs) {
4659 removeRole.remove(pk, rolePK);
4660 }
4661 }
4662 catch (Exception e) {
4663 throw processException(e);
4664 }
4665 finally {
4666 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4667 }
4668 }
4669
4670
4677 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
4678 throws SystemException {
4679 try {
4680 for (com.liferay.portal.model.Role role : roles) {
4681 removeRole.remove(pk, role.getPrimaryKey());
4682 }
4683 }
4684 catch (Exception e) {
4685 throw processException(e);
4686 }
4687 finally {
4688 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4689 }
4690 }
4691
4692
4699 public void setRoles(long pk, long[] rolePKs) throws SystemException {
4700 try {
4701 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
4702
4703 List<com.liferay.portal.model.Role> roles = getRoles(pk);
4704
4705 for (com.liferay.portal.model.Role role : roles) {
4706 if (!rolePKSet.remove(role.getPrimaryKey())) {
4707 removeRole.remove(pk, role.getPrimaryKey());
4708 }
4709 }
4710
4711 for (Long rolePK : rolePKSet) {
4712 addRole.add(pk, rolePK);
4713 }
4714 }
4715 catch (Exception e) {
4716 throw processException(e);
4717 }
4718 finally {
4719 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4720 }
4721 }
4722
4723
4730 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
4731 throws SystemException {
4732 try {
4733 long[] rolePKs = new long[roles.size()];
4734
4735 for (int i = 0; i < roles.size(); i++) {
4736 com.liferay.portal.model.Role role = roles.get(i);
4737
4738 rolePKs[i] = role.getPrimaryKey();
4739 }
4740
4741 setRoles(pk, rolePKs);
4742 }
4743 catch (Exception e) {
4744 throw processException(e);
4745 }
4746 finally {
4747 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4748 }
4749 }
4750
4751
4758 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
4759 throws SystemException {
4760 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4761 }
4762
4763
4776 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4777 int start, int end) throws SystemException {
4778 return getUserGroups(pk, start, end, null);
4779 }
4780
4781 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4782 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
4783 com.liferay.portal.model.impl.UserGroupImpl.class,
4784 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
4785 "getUserGroups",
4786 new String[] {
4787 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4788 "com.liferay.portal.kernel.util.OrderByComparator"
4789 });
4790
4791
4805 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4806 int start, int end, OrderByComparator orderByComparator)
4807 throws SystemException {
4808 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4809
4810 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
4811 finderArgs, this);
4812
4813 if (list == null) {
4814 Session session = null;
4815
4816 try {
4817 session = openSession();
4818
4819 String sql = null;
4820
4821 if (orderByComparator != null) {
4822 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
4823 .concat(orderByComparator.getOrderBy());
4824 }
4825 else {
4826 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
4827 }
4828
4829 SQLQuery q = session.createSQLQuery(sql);
4830
4831 q.addEntity("UserGroup",
4832 com.liferay.portal.model.impl.UserGroupImpl.class);
4833
4834 QueryPos qPos = QueryPos.getInstance(q);
4835
4836 qPos.add(pk);
4837
4838 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
4839 getDialect(), start, end);
4840 }
4841 catch (Exception e) {
4842 throw processException(e);
4843 }
4844 finally {
4845 if (list == null) {
4846 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
4847 finderArgs);
4848 }
4849 else {
4850 userGroupPersistence.cacheResult(list);
4851
4852 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
4853 finderArgs, list);
4854 }
4855
4856 closeSession(session);
4857 }
4858 }
4859
4860 return list;
4861 }
4862
4863 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4864 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS, Long.class,
4865 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
4866 "getUserGroupsSize", new String[] { Long.class.getName() });
4867
4868
4875 public int getUserGroupsSize(long pk) throws SystemException {
4876 Object[] finderArgs = new Object[] { pk };
4877
4878 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4879 finderArgs, this);
4880
4881 if (count == null) {
4882 Session session = null;
4883
4884 try {
4885 session = openSession();
4886
4887 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
4888
4889 q.addScalar(COUNT_COLUMN_NAME,
4890 com.liferay.portal.kernel.dao.orm.Type.LONG);
4891
4892 QueryPos qPos = QueryPos.getInstance(q);
4893
4894 qPos.add(pk);
4895
4896 count = (Long)q.uniqueResult();
4897 }
4898 catch (Exception e) {
4899 throw processException(e);
4900 }
4901 finally {
4902 if (count == null) {
4903 count = Long.valueOf(0);
4904 }
4905
4906 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4907 finderArgs, count);
4908
4909 closeSession(session);
4910 }
4911 }
4912
4913 return count.intValue();
4914 }
4915
4916 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4917 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
4918 Boolean.class, GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
4919 "containsUserGroup",
4920 new String[] { Long.class.getName(), Long.class.getName() });
4921
4922
4930 public boolean containsUserGroup(long pk, long userGroupPK)
4931 throws SystemException {
4932 Object[] finderArgs = new Object[] { pk, userGroupPK };
4933
4934 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
4935 finderArgs, this);
4936
4937 if (value == null) {
4938 try {
4939 value = Boolean.valueOf(containsUserGroup.contains(pk,
4940 userGroupPK));
4941 }
4942 catch (Exception e) {
4943 throw processException(e);
4944 }
4945 finally {
4946 if (value == null) {
4947 value = Boolean.FALSE;
4948 }
4949
4950 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
4951 finderArgs, value);
4952 }
4953 }
4954
4955 return value.booleanValue();
4956 }
4957
4958
4965 public boolean containsUserGroups(long pk) throws SystemException {
4966 if (getUserGroupsSize(pk) > 0) {
4967 return true;
4968 }
4969 else {
4970 return false;
4971 }
4972 }
4973
4974
4981 public void addUserGroup(long pk, long userGroupPK)
4982 throws SystemException {
4983 try {
4984 addUserGroup.add(pk, userGroupPK);
4985 }
4986 catch (Exception e) {
4987 throw processException(e);
4988 }
4989 finally {
4990 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
4991 }
4992 }
4993
4994
5001 public void addUserGroup(long pk,
5002 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5003 try {
5004 addUserGroup.add(pk, userGroup.getPrimaryKey());
5005 }
5006 catch (Exception e) {
5007 throw processException(e);
5008 }
5009 finally {
5010 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5011 }
5012 }
5013
5014
5021 public void addUserGroups(long pk, long[] userGroupPKs)
5022 throws SystemException {
5023 try {
5024 for (long userGroupPK : userGroupPKs) {
5025 addUserGroup.add(pk, userGroupPK);
5026 }
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 addUserGroups(long pk,
5044 List<com.liferay.portal.model.UserGroup> userGroups)
5045 throws SystemException {
5046 try {
5047 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5048 addUserGroup.add(pk, userGroup.getPrimaryKey());
5049 }
5050 }
5051 catch (Exception e) {
5052 throw processException(e);
5053 }
5054 finally {
5055 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5056 }
5057 }
5058
5059
5065 public void clearUserGroups(long pk) throws SystemException {
5066 try {
5067 clearUserGroups.clear(pk);
5068 }
5069 catch (Exception e) {
5070 throw processException(e);
5071 }
5072 finally {
5073 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5074 }
5075 }
5076
5077
5084 public void removeUserGroup(long pk, long userGroupPK)
5085 throws SystemException {
5086 try {
5087 removeUserGroup.remove(pk, userGroupPK);
5088 }
5089 catch (Exception e) {
5090 throw processException(e);
5091 }
5092 finally {
5093 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5094 }
5095 }
5096
5097
5104 public void removeUserGroup(long pk,
5105 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5106 try {
5107 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5108 }
5109 catch (Exception e) {
5110 throw processException(e);
5111 }
5112 finally {
5113 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5114 }
5115 }
5116
5117
5124 public void removeUserGroups(long pk, long[] userGroupPKs)
5125 throws SystemException {
5126 try {
5127 for (long userGroupPK : userGroupPKs) {
5128 removeUserGroup.remove(pk, userGroupPK);
5129 }
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 removeUserGroups(long pk,
5147 List<com.liferay.portal.model.UserGroup> userGroups)
5148 throws SystemException {
5149 try {
5150 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5151 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5152 }
5153 }
5154 catch (Exception e) {
5155 throw processException(e);
5156 }
5157 finally {
5158 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5159 }
5160 }
5161
5162
5169 public void setUserGroups(long pk, long[] userGroupPKs)
5170 throws SystemException {
5171 try {
5172 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
5173
5174 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
5175
5176 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5177 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
5178 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5179 }
5180 }
5181
5182 for (Long userGroupPK : userGroupPKSet) {
5183 addUserGroup.add(pk, userGroupPK);
5184 }
5185 }
5186 catch (Exception e) {
5187 throw processException(e);
5188 }
5189 finally {
5190 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5191 }
5192 }
5193
5194
5201 public void setUserGroups(long pk,
5202 List<com.liferay.portal.model.UserGroup> userGroups)
5203 throws SystemException {
5204 try {
5205 long[] userGroupPKs = new long[userGroups.size()];
5206
5207 for (int i = 0; i < userGroups.size(); i++) {
5208 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
5209
5210 userGroupPKs[i] = userGroup.getPrimaryKey();
5211 }
5212
5213 setUserGroups(pk, userGroupPKs);
5214 }
5215 catch (Exception e) {
5216 throw processException(e);
5217 }
5218 finally {
5219 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5220 }
5221 }
5222
5223
5230 public List<com.liferay.portal.model.User> getUsers(long pk)
5231 throws SystemException {
5232 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5233 }
5234
5235
5248 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5249 int end) throws SystemException {
5250 return getUsers(pk, start, end, null);
5251 }
5252
5253 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5254 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
5255 com.liferay.portal.model.impl.UserImpl.class,
5256 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsers",
5257 new String[] {
5258 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5259 "com.liferay.portal.kernel.util.OrderByComparator"
5260 });
5261
5262
5276 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5277 int end, OrderByComparator orderByComparator) throws SystemException {
5278 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5279
5280 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5281 finderArgs, this);
5282
5283 if (list == null) {
5284 Session session = null;
5285
5286 try {
5287 session = openSession();
5288
5289 String sql = null;
5290
5291 if (orderByComparator != null) {
5292 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5293 .concat(orderByComparator.getOrderBy());
5294 }
5295 else {
5296 sql = _SQL_GETUSERS;
5297 }
5298
5299 SQLQuery q = session.createSQLQuery(sql);
5300
5301 q.addEntity("User_",
5302 com.liferay.portal.model.impl.UserImpl.class);
5303
5304 QueryPos qPos = QueryPos.getInstance(q);
5305
5306 qPos.add(pk);
5307
5308 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5309 getDialect(), start, end);
5310 }
5311 catch (Exception e) {
5312 throw processException(e);
5313 }
5314 finally {
5315 if (list == null) {
5316 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5317 finderArgs);
5318 }
5319 else {
5320 userPersistence.cacheResult(list);
5321
5322 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5323 finderArgs, list);
5324 }
5325
5326 closeSession(session);
5327 }
5328 }
5329
5330 return list;
5331 }
5332
5333 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5334 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
5335 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsersSize",
5336 new String[] { Long.class.getName() });
5337
5338
5345 public int getUsersSize(long pk) throws SystemException {
5346 Object[] finderArgs = new Object[] { pk };
5347
5348 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5349 finderArgs, this);
5350
5351 if (count == null) {
5352 Session session = null;
5353
5354 try {
5355 session = openSession();
5356
5357 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5358
5359 q.addScalar(COUNT_COLUMN_NAME,
5360 com.liferay.portal.kernel.dao.orm.Type.LONG);
5361
5362 QueryPos qPos = QueryPos.getInstance(q);
5363
5364 qPos.add(pk);
5365
5366 count = (Long)q.uniqueResult();
5367 }
5368 catch (Exception e) {
5369 throw processException(e);
5370 }
5371 finally {
5372 if (count == null) {
5373 count = Long.valueOf(0);
5374 }
5375
5376 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5377 finderArgs, count);
5378
5379 closeSession(session);
5380 }
5381 }
5382
5383 return count.intValue();
5384 }
5385
5386 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5387 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
5388 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsUser",
5389 new String[] { Long.class.getName(), Long.class.getName() });
5390
5391
5399 public boolean containsUser(long pk, long userPK) throws SystemException {
5400 Object[] finderArgs = new Object[] { pk, userPK };
5401
5402 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5403 finderArgs, this);
5404
5405 if (value == null) {
5406 try {
5407 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5408 }
5409 catch (Exception e) {
5410 throw processException(e);
5411 }
5412 finally {
5413 if (value == null) {
5414 value = Boolean.FALSE;
5415 }
5416
5417 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
5418 finderArgs, value);
5419 }
5420 }
5421
5422 return value.booleanValue();
5423 }
5424
5425
5432 public boolean containsUsers(long pk) throws SystemException {
5433 if (getUsersSize(pk) > 0) {
5434 return true;
5435 }
5436 else {
5437 return false;
5438 }
5439 }
5440
5441
5448 public void addUser(long pk, long userPK) throws SystemException {
5449 try {
5450 addUser.add(pk, userPK);
5451 }
5452 catch (Exception e) {
5453 throw processException(e);
5454 }
5455 finally {
5456 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5457 }
5458 }
5459
5460
5467 public void addUser(long pk, com.liferay.portal.model.User user)
5468 throws SystemException {
5469 try {
5470 addUser.add(pk, user.getPrimaryKey());
5471 }
5472 catch (Exception e) {
5473 throw processException(e);
5474 }
5475 finally {
5476 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5477 }
5478 }
5479
5480
5487 public void addUsers(long pk, long[] userPKs) throws SystemException {
5488 try {
5489 for (long userPK : userPKs) {
5490 addUser.add(pk, userPK);
5491 }
5492 }
5493 catch (Exception e) {
5494 throw processException(e);
5495 }
5496 finally {
5497 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5498 }
5499 }
5500
5501
5508 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
5509 throws SystemException {
5510 try {
5511 for (com.liferay.portal.model.User user : users) {
5512 addUser.add(pk, user.getPrimaryKey());
5513 }
5514 }
5515 catch (Exception e) {
5516 throw processException(e);
5517 }
5518 finally {
5519 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5520 }
5521 }
5522
5523
5529 public void clearUsers(long pk) throws SystemException {
5530 try {
5531 clearUsers.clear(pk);
5532 }
5533 catch (Exception e) {
5534 throw processException(e);
5535 }
5536 finally {
5537 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5538 }
5539 }
5540
5541
5548 public void removeUser(long pk, long userPK) throws SystemException {
5549 try {
5550 removeUser.remove(pk, userPK);
5551 }
5552 catch (Exception e) {
5553 throw processException(e);
5554 }
5555 finally {
5556 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5557 }
5558 }
5559
5560
5567 public void removeUser(long pk, com.liferay.portal.model.User user)
5568 throws SystemException {
5569 try {
5570 removeUser.remove(pk, user.getPrimaryKey());
5571 }
5572 catch (Exception e) {
5573 throw processException(e);
5574 }
5575 finally {
5576 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5577 }
5578 }
5579
5580
5587 public void removeUsers(long pk, long[] userPKs) throws SystemException {
5588 try {
5589 for (long userPK : userPKs) {
5590 removeUser.remove(pk, userPK);
5591 }
5592 }
5593 catch (Exception e) {
5594 throw processException(e);
5595 }
5596 finally {
5597 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5598 }
5599 }
5600
5601
5608 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
5609 throws SystemException {
5610 try {
5611 for (com.liferay.portal.model.User user : users) {
5612 removeUser.remove(pk, user.getPrimaryKey());
5613 }
5614 }
5615 catch (Exception e) {
5616 throw processException(e);
5617 }
5618 finally {
5619 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5620 }
5621 }
5622
5623
5630 public void setUsers(long pk, long[] userPKs) throws SystemException {
5631 try {
5632 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
5633
5634 List<com.liferay.portal.model.User> users = getUsers(pk);
5635
5636 for (com.liferay.portal.model.User user : users) {
5637 if (!userPKSet.remove(user.getPrimaryKey())) {
5638 removeUser.remove(pk, user.getPrimaryKey());
5639 }
5640 }
5641
5642 for (Long userPK : userPKSet) {
5643 addUser.add(pk, userPK);
5644 }
5645 }
5646 catch (Exception e) {
5647 throw processException(e);
5648 }
5649 finally {
5650 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5651 }
5652 }
5653
5654
5661 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
5662 throws SystemException {
5663 try {
5664 long[] userPKs = new long[users.size()];
5665
5666 for (int i = 0; i < users.size(); i++) {
5667 com.liferay.portal.model.User user = users.get(i);
5668
5669 userPKs[i] = user.getPrimaryKey();
5670 }
5671
5672 setUsers(pk, userPKs);
5673 }
5674 catch (Exception e) {
5675 throw processException(e);
5676 }
5677 finally {
5678 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5679 }
5680 }
5681
5682
5685 public void afterPropertiesSet() {
5686 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5687 com.liferay.portal.util.PropsUtil.get(
5688 "value.object.listener.com.liferay.portal.model.Group")));
5689
5690 if (listenerClassNames.length > 0) {
5691 try {
5692 List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
5693
5694 for (String listenerClassName : listenerClassNames) {
5695 listenersList.add((ModelListener<Group>)InstanceFactory.newInstance(
5696 listenerClassName));
5697 }
5698
5699 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5700 }
5701 catch (Exception e) {
5702 _log.error(e);
5703 }
5704 }
5705
5706 containsOrganization = new ContainsOrganization();
5707
5708 addOrganization = new AddOrganization();
5709 clearOrganizations = new ClearOrganizations();
5710 removeOrganization = new RemoveOrganization();
5711
5712 containsPermission = new ContainsPermission();
5713
5714 addPermission = new AddPermission();
5715 clearPermissions = new ClearPermissions();
5716 removePermission = new RemovePermission();
5717
5718 containsRole = new ContainsRole();
5719
5720 addRole = new AddRole();
5721 clearRoles = new ClearRoles();
5722 removeRole = new RemoveRole();
5723
5724 containsUserGroup = new ContainsUserGroup();
5725
5726 addUserGroup = new AddUserGroup();
5727 clearUserGroups = new ClearUserGroups();
5728 removeUserGroup = new RemoveUserGroup();
5729
5730 containsUser = new ContainsUser();
5731
5732 addUser = new AddUser();
5733 clearUsers = new ClearUsers();
5734 removeUser = new RemoveUser();
5735 }
5736
5737 public void destroy() {
5738 EntityCacheUtil.removeCache(GroupImpl.class.getName());
5739 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5740 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5741 }
5742
5743 @BeanReference(type = AccountPersistence.class)
5744 protected AccountPersistence accountPersistence;
5745 @BeanReference(type = AddressPersistence.class)
5746 protected AddressPersistence addressPersistence;
5747 @BeanReference(type = BrowserTrackerPersistence.class)
5748 protected BrowserTrackerPersistence browserTrackerPersistence;
5749 @BeanReference(type = ClassNamePersistence.class)
5750 protected ClassNamePersistence classNamePersistence;
5751 @BeanReference(type = ClusterGroupPersistence.class)
5752 protected ClusterGroupPersistence clusterGroupPersistence;
5753 @BeanReference(type = CompanyPersistence.class)
5754 protected CompanyPersistence companyPersistence;
5755 @BeanReference(type = ContactPersistence.class)
5756 protected ContactPersistence contactPersistence;
5757 @BeanReference(type = CountryPersistence.class)
5758 protected CountryPersistence countryPersistence;
5759 @BeanReference(type = EmailAddressPersistence.class)
5760 protected EmailAddressPersistence emailAddressPersistence;
5761 @BeanReference(type = GroupPersistence.class)
5762 protected GroupPersistence groupPersistence;
5763 @BeanReference(type = ImagePersistence.class)
5764 protected ImagePersistence imagePersistence;
5765 @BeanReference(type = LayoutPersistence.class)
5766 protected LayoutPersistence layoutPersistence;
5767 @BeanReference(type = LayoutBranchPersistence.class)
5768 protected LayoutBranchPersistence layoutBranchPersistence;
5769 @BeanReference(type = LayoutPrototypePersistence.class)
5770 protected LayoutPrototypePersistence layoutPrototypePersistence;
5771 @BeanReference(type = LayoutRevisionPersistence.class)
5772 protected LayoutRevisionPersistence layoutRevisionPersistence;
5773 @BeanReference(type = LayoutSetPersistence.class)
5774 protected LayoutSetPersistence layoutSetPersistence;
5775 @BeanReference(type = LayoutSetBranchPersistence.class)
5776 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
5777 @BeanReference(type = LayoutSetPrototypePersistence.class)
5778 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
5779 @BeanReference(type = ListTypePersistence.class)
5780 protected ListTypePersistence listTypePersistence;
5781 @BeanReference(type = LockPersistence.class)
5782 protected LockPersistence lockPersistence;
5783 @BeanReference(type = MembershipRequestPersistence.class)
5784 protected MembershipRequestPersistence membershipRequestPersistence;
5785 @BeanReference(type = OrganizationPersistence.class)
5786 protected OrganizationPersistence organizationPersistence;
5787 @BeanReference(type = OrgGroupPermissionPersistence.class)
5788 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
5789 @BeanReference(type = OrgGroupRolePersistence.class)
5790 protected OrgGroupRolePersistence orgGroupRolePersistence;
5791 @BeanReference(type = OrgLaborPersistence.class)
5792 protected OrgLaborPersistence orgLaborPersistence;
5793 @BeanReference(type = PasswordPolicyPersistence.class)
5794 protected PasswordPolicyPersistence passwordPolicyPersistence;
5795 @BeanReference(type = PasswordPolicyRelPersistence.class)
5796 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
5797 @BeanReference(type = PasswordTrackerPersistence.class)
5798 protected PasswordTrackerPersistence passwordTrackerPersistence;
5799 @BeanReference(type = PermissionPersistence.class)
5800 protected PermissionPersistence permissionPersistence;
5801 @BeanReference(type = PhonePersistence.class)
5802 protected PhonePersistence phonePersistence;
5803 @BeanReference(type = PluginSettingPersistence.class)
5804 protected PluginSettingPersistence pluginSettingPersistence;
5805 @BeanReference(type = PortalPreferencesPersistence.class)
5806 protected PortalPreferencesPersistence portalPreferencesPersistence;
5807 @BeanReference(type = PortletPersistence.class)
5808 protected PortletPersistence portletPersistence;
5809 @BeanReference(type = PortletItemPersistence.class)
5810 protected PortletItemPersistence portletItemPersistence;
5811 @BeanReference(type = PortletPreferencesPersistence.class)
5812 protected PortletPreferencesPersistence portletPreferencesPersistence;
5813 @BeanReference(type = RegionPersistence.class)
5814 protected RegionPersistence regionPersistence;
5815 @BeanReference(type = ReleasePersistence.class)
5816 protected ReleasePersistence releasePersistence;
5817 @BeanReference(type = RepositoryPersistence.class)
5818 protected RepositoryPersistence repositoryPersistence;
5819 @BeanReference(type = RepositoryEntryPersistence.class)
5820 protected RepositoryEntryPersistence repositoryEntryPersistence;
5821 @BeanReference(type = ResourcePersistence.class)
5822 protected ResourcePersistence resourcePersistence;
5823 @BeanReference(type = ResourceActionPersistence.class)
5824 protected ResourceActionPersistence resourceActionPersistence;
5825 @BeanReference(type = ResourceBlockPersistence.class)
5826 protected ResourceBlockPersistence resourceBlockPersistence;
5827 @BeanReference(type = ResourceBlockPermissionPersistence.class)
5828 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
5829 @BeanReference(type = ResourceCodePersistence.class)
5830 protected ResourceCodePersistence resourceCodePersistence;
5831 @BeanReference(type = ResourcePermissionPersistence.class)
5832 protected ResourcePermissionPersistence resourcePermissionPersistence;
5833 @BeanReference(type = ResourceTypePermissionPersistence.class)
5834 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
5835 @BeanReference(type = RolePersistence.class)
5836 protected RolePersistence rolePersistence;
5837 @BeanReference(type = ServiceComponentPersistence.class)
5838 protected ServiceComponentPersistence serviceComponentPersistence;
5839 @BeanReference(type = ShardPersistence.class)
5840 protected ShardPersistence shardPersistence;
5841 @BeanReference(type = SubscriptionPersistence.class)
5842 protected SubscriptionPersistence subscriptionPersistence;
5843 @BeanReference(type = TeamPersistence.class)
5844 protected TeamPersistence teamPersistence;
5845 @BeanReference(type = TicketPersistence.class)
5846 protected TicketPersistence ticketPersistence;
5847 @BeanReference(type = UserPersistence.class)
5848 protected UserPersistence userPersistence;
5849 @BeanReference(type = UserGroupPersistence.class)
5850 protected UserGroupPersistence userGroupPersistence;
5851 @BeanReference(type = UserGroupGroupRolePersistence.class)
5852 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
5853 @BeanReference(type = UserGroupRolePersistence.class)
5854 protected UserGroupRolePersistence userGroupRolePersistence;
5855 @BeanReference(type = UserIdMapperPersistence.class)
5856 protected UserIdMapperPersistence userIdMapperPersistence;
5857 @BeanReference(type = UserNotificationEventPersistence.class)
5858 protected UserNotificationEventPersistence userNotificationEventPersistence;
5859 @BeanReference(type = UserTrackerPersistence.class)
5860 protected UserTrackerPersistence userTrackerPersistence;
5861 @BeanReference(type = UserTrackerPathPersistence.class)
5862 protected UserTrackerPathPersistence userTrackerPathPersistence;
5863 @BeanReference(type = VirtualHostPersistence.class)
5864 protected VirtualHostPersistence virtualHostPersistence;
5865 @BeanReference(type = WebDAVPropsPersistence.class)
5866 protected WebDAVPropsPersistence webDAVPropsPersistence;
5867 @BeanReference(type = WebsitePersistence.class)
5868 protected WebsitePersistence websitePersistence;
5869 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
5870 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
5871 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
5872 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
5873 @BeanReference(type = AssetEntryPersistence.class)
5874 protected AssetEntryPersistence assetEntryPersistence;
5875 @BeanReference(type = AssetVocabularyPersistence.class)
5876 protected AssetVocabularyPersistence assetVocabularyPersistence;
5877 @BeanReference(type = BlogsEntryPersistence.class)
5878 protected BlogsEntryPersistence blogsEntryPersistence;
5879 @BeanReference(type = BlogsStatsUserPersistence.class)
5880 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
5881 @BeanReference(type = BookmarksFolderPersistence.class)
5882 protected BookmarksFolderPersistence bookmarksFolderPersistence;
5883 @BeanReference(type = CalEventPersistence.class)
5884 protected CalEventPersistence calEventPersistence;
5885 @BeanReference(type = DLFileEntryTypePersistence.class)
5886 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
5887 @BeanReference(type = JournalArticlePersistence.class)
5888 protected JournalArticlePersistence journalArticlePersistence;
5889 @BeanReference(type = JournalStructurePersistence.class)
5890 protected JournalStructurePersistence journalStructurePersistence;
5891 @BeanReference(type = JournalTemplatePersistence.class)
5892 protected JournalTemplatePersistence journalTemplatePersistence;
5893 @BeanReference(type = MBBanPersistence.class)
5894 protected MBBanPersistence mbBanPersistence;
5895 @BeanReference(type = MBCategoryPersistence.class)
5896 protected MBCategoryPersistence mbCategoryPersistence;
5897 @BeanReference(type = MBStatsUserPersistence.class)
5898 protected MBStatsUserPersistence mbStatsUserPersistence;
5899 @BeanReference(type = PollsQuestionPersistence.class)
5900 protected PollsQuestionPersistence pollsQuestionPersistence;
5901 @BeanReference(type = ShoppingCartPersistence.class)
5902 protected ShoppingCartPersistence shoppingCartPersistence;
5903 @BeanReference(type = ShoppingCategoryPersistence.class)
5904 protected ShoppingCategoryPersistence shoppingCategoryPersistence;
5905 @BeanReference(type = ShoppingCouponPersistence.class)
5906 protected ShoppingCouponPersistence shoppingCouponPersistence;
5907 @BeanReference(type = ShoppingOrderPersistence.class)
5908 protected ShoppingOrderPersistence shoppingOrderPersistence;
5909 @BeanReference(type = SCFrameworkVersionPersistence.class)
5910 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
5911 @BeanReference(type = SCProductEntryPersistence.class)
5912 protected SCProductEntryPersistence scProductEntryPersistence;
5913 @BeanReference(type = WikiNodePersistence.class)
5914 protected WikiNodePersistence wikiNodePersistence;
5915 protected ContainsOrganization containsOrganization;
5916 protected AddOrganization addOrganization;
5917 protected ClearOrganizations clearOrganizations;
5918 protected RemoveOrganization removeOrganization;
5919 protected ContainsPermission containsPermission;
5920 protected AddPermission addPermission;
5921 protected ClearPermissions clearPermissions;
5922 protected RemovePermission removePermission;
5923 protected ContainsRole containsRole;
5924 protected AddRole addRole;
5925 protected ClearRoles clearRoles;
5926 protected RemoveRole removeRole;
5927 protected ContainsUserGroup containsUserGroup;
5928 protected AddUserGroup addUserGroup;
5929 protected ClearUserGroups clearUserGroups;
5930 protected RemoveUserGroup removeUserGroup;
5931 protected ContainsUser containsUser;
5932 protected AddUser addUser;
5933 protected ClearUsers clearUsers;
5934 protected RemoveUser removeUser;
5935
5936 protected class ContainsOrganization {
5937 protected ContainsOrganization() {
5938 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5939 _SQL_CONTAINSORGANIZATION,
5940 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
5941 RowMapper.COUNT);
5942 }
5943
5944 protected boolean contains(long groupId, long organizationId) {
5945 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5946 new Long(groupId), new Long(organizationId)
5947 });
5948
5949 if (results.size() > 0) {
5950 Integer count = results.get(0);
5951
5952 if (count.intValue() > 0) {
5953 return true;
5954 }
5955 }
5956
5957 return false;
5958 }
5959
5960 private MappingSqlQuery<Integer> _mappingSqlQuery;
5961 }
5962
5963 protected class AddOrganization {
5964 protected AddOrganization() {
5965 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5966 "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
5967 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5968 }
5969
5970 protected void add(long groupId, long organizationId)
5971 throws SystemException {
5972 if (!containsOrganization.contains(groupId, organizationId)) {
5973 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5974 organizationPersistence.getListeners();
5975
5976 for (ModelListener<Group> listener : listeners) {
5977 listener.onBeforeAddAssociation(groupId,
5978 com.liferay.portal.model.Organization.class.getName(),
5979 organizationId);
5980 }
5981
5982 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5983 listener.onBeforeAddAssociation(organizationId,
5984 Group.class.getName(), groupId);
5985 }
5986
5987 _sqlUpdate.update(new Object[] {
5988 new Long(groupId), new Long(organizationId)
5989 });
5990
5991 for (ModelListener<Group> listener : listeners) {
5992 listener.onAfterAddAssociation(groupId,
5993 com.liferay.portal.model.Organization.class.getName(),
5994 organizationId);
5995 }
5996
5997 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5998 listener.onAfterAddAssociation(organizationId,
5999 Group.class.getName(), groupId);
6000 }
6001 }
6002 }
6003
6004 private SqlUpdate _sqlUpdate;
6005 }
6006
6007 protected class ClearOrganizations {
6008 protected ClearOrganizations() {
6009 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6010 "DELETE FROM Groups_Orgs WHERE groupId = ?",
6011 new int[] { java.sql.Types.BIGINT });
6012 }
6013
6014 protected void clear(long groupId) throws SystemException {
6015 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6016 organizationPersistence.getListeners();
6017
6018 List<com.liferay.portal.model.Organization> organizations = null;
6019
6020 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6021 organizations = getOrganizations(groupId);
6022
6023 for (com.liferay.portal.model.Organization organization : organizations) {
6024 for (ModelListener<Group> listener : listeners) {
6025 listener.onBeforeRemoveAssociation(groupId,
6026 com.liferay.portal.model.Organization.class.getName(),
6027 organization.getPrimaryKey());
6028 }
6029
6030 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6031 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
6032 Group.class.getName(), groupId);
6033 }
6034 }
6035 }
6036
6037 _sqlUpdate.update(new Object[] { new Long(groupId) });
6038
6039 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6040 for (com.liferay.portal.model.Organization organization : organizations) {
6041 for (ModelListener<Group> listener : listeners) {
6042 listener.onAfterRemoveAssociation(groupId,
6043 com.liferay.portal.model.Organization.class.getName(),
6044 organization.getPrimaryKey());
6045 }
6046
6047 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6048 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
6049 Group.class.getName(), groupId);
6050 }
6051 }
6052 }
6053 }
6054
6055 private SqlUpdate _sqlUpdate;
6056 }
6057
6058 protected class RemoveOrganization {
6059 protected RemoveOrganization() {
6060 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6061 "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
6062 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6063 }
6064
6065 protected void remove(long groupId, long organizationId)
6066 throws SystemException {
6067 if (containsOrganization.contains(groupId, organizationId)) {
6068 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6069 organizationPersistence.getListeners();
6070
6071 for (ModelListener<Group> listener : listeners) {
6072 listener.onBeforeRemoveAssociation(groupId,
6073 com.liferay.portal.model.Organization.class.getName(),
6074 organizationId);
6075 }
6076
6077 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6078 listener.onBeforeRemoveAssociation(organizationId,
6079 Group.class.getName(), groupId);
6080 }
6081
6082 _sqlUpdate.update(new Object[] {
6083 new Long(groupId), new Long(organizationId)
6084 });
6085
6086 for (ModelListener<Group> listener : listeners) {
6087 listener.onAfterRemoveAssociation(groupId,
6088 com.liferay.portal.model.Organization.class.getName(),
6089 organizationId);
6090 }
6091
6092 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6093 listener.onAfterRemoveAssociation(organizationId,
6094 Group.class.getName(), groupId);
6095 }
6096 }
6097 }
6098
6099 private SqlUpdate _sqlUpdate;
6100 }
6101
6102 protected class ContainsPermission {
6103 protected ContainsPermission() {
6104 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6105 _SQL_CONTAINSPERMISSION,
6106 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6107 RowMapper.COUNT);
6108 }
6109
6110 protected boolean contains(long groupId, long permissionId) {
6111 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6112 new Long(groupId), new Long(permissionId)
6113 });
6114
6115 if (results.size() > 0) {
6116 Integer count = results.get(0);
6117
6118 if (count.intValue() > 0) {
6119 return true;
6120 }
6121 }
6122
6123 return false;
6124 }
6125
6126 private MappingSqlQuery<Integer> _mappingSqlQuery;
6127 }
6128
6129 protected class AddPermission {
6130 protected AddPermission() {
6131 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6132 "INSERT INTO Groups_Permissions (groupId, permissionId) VALUES (?, ?)",
6133 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6134 }
6135
6136 protected void add(long groupId, long permissionId)
6137 throws SystemException {
6138 if (!containsPermission.contains(groupId, permissionId)) {
6139 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6140 permissionPersistence.getListeners();
6141
6142 for (ModelListener<Group> listener : listeners) {
6143 listener.onBeforeAddAssociation(groupId,
6144 com.liferay.portal.model.Permission.class.getName(),
6145 permissionId);
6146 }
6147
6148 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6149 listener.onBeforeAddAssociation(permissionId,
6150 Group.class.getName(), groupId);
6151 }
6152
6153 _sqlUpdate.update(new Object[] {
6154 new Long(groupId), new Long(permissionId)
6155 });
6156
6157 for (ModelListener<Group> listener : listeners) {
6158 listener.onAfterAddAssociation(groupId,
6159 com.liferay.portal.model.Permission.class.getName(),
6160 permissionId);
6161 }
6162
6163 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6164 listener.onAfterAddAssociation(permissionId,
6165 Group.class.getName(), groupId);
6166 }
6167 }
6168 }
6169
6170 private SqlUpdate _sqlUpdate;
6171 }
6172
6173 protected class ClearPermissions {
6174 protected ClearPermissions() {
6175 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6176 "DELETE FROM Groups_Permissions WHERE groupId = ?",
6177 new int[] { java.sql.Types.BIGINT });
6178 }
6179
6180 protected void clear(long groupId) throws SystemException {
6181 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6182 permissionPersistence.getListeners();
6183
6184 List<com.liferay.portal.model.Permission> permissions = null;
6185
6186 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6187 permissions = getPermissions(groupId);
6188
6189 for (com.liferay.portal.model.Permission permission : permissions) {
6190 for (ModelListener<Group> listener : listeners) {
6191 listener.onBeforeRemoveAssociation(groupId,
6192 com.liferay.portal.model.Permission.class.getName(),
6193 permission.getPrimaryKey());
6194 }
6195
6196 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6197 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6198 Group.class.getName(), groupId);
6199 }
6200 }
6201 }
6202
6203 _sqlUpdate.update(new Object[] { new Long(groupId) });
6204
6205 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6206 for (com.liferay.portal.model.Permission permission : permissions) {
6207 for (ModelListener<Group> listener : listeners) {
6208 listener.onAfterRemoveAssociation(groupId,
6209 com.liferay.portal.model.Permission.class.getName(),
6210 permission.getPrimaryKey());
6211 }
6212
6213 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6214 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6215 Group.class.getName(), groupId);
6216 }
6217 }
6218 }
6219 }
6220
6221 private SqlUpdate _sqlUpdate;
6222 }
6223
6224 protected class RemovePermission {
6225 protected RemovePermission() {
6226 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6227 "DELETE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?",
6228 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6229 }
6230
6231 protected void remove(long groupId, long permissionId)
6232 throws SystemException {
6233 if (containsPermission.contains(groupId, permissionId)) {
6234 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6235 permissionPersistence.getListeners();
6236
6237 for (ModelListener<Group> listener : listeners) {
6238 listener.onBeforeRemoveAssociation(groupId,
6239 com.liferay.portal.model.Permission.class.getName(),
6240 permissionId);
6241 }
6242
6243 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6244 listener.onBeforeRemoveAssociation(permissionId,
6245 Group.class.getName(), groupId);
6246 }
6247
6248 _sqlUpdate.update(new Object[] {
6249 new Long(groupId), new Long(permissionId)
6250 });
6251
6252 for (ModelListener<Group> listener : listeners) {
6253 listener.onAfterRemoveAssociation(groupId,
6254 com.liferay.portal.model.Permission.class.getName(),
6255 permissionId);
6256 }
6257
6258 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6259 listener.onAfterRemoveAssociation(permissionId,
6260 Group.class.getName(), groupId);
6261 }
6262 }
6263 }
6264
6265 private SqlUpdate _sqlUpdate;
6266 }
6267
6268 protected class ContainsRole {
6269 protected ContainsRole() {
6270 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6271 _SQL_CONTAINSROLE,
6272 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6273 RowMapper.COUNT);
6274 }
6275
6276 protected boolean contains(long groupId, long roleId) {
6277 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6278 new Long(groupId), new Long(roleId)
6279 });
6280
6281 if (results.size() > 0) {
6282 Integer count = results.get(0);
6283
6284 if (count.intValue() > 0) {
6285 return true;
6286 }
6287 }
6288
6289 return false;
6290 }
6291
6292 private MappingSqlQuery<Integer> _mappingSqlQuery;
6293 }
6294
6295 protected class AddRole {
6296 protected AddRole() {
6297 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6298 "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
6299 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6300 }
6301
6302 protected void add(long groupId, long roleId) throws SystemException {
6303 if (!containsRole.contains(groupId, roleId)) {
6304 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6305
6306 for (ModelListener<Group> listener : listeners) {
6307 listener.onBeforeAddAssociation(groupId,
6308 com.liferay.portal.model.Role.class.getName(), roleId);
6309 }
6310
6311 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6312 listener.onBeforeAddAssociation(roleId,
6313 Group.class.getName(), groupId);
6314 }
6315
6316 _sqlUpdate.update(new Object[] {
6317 new Long(groupId), new Long(roleId)
6318 });
6319
6320 for (ModelListener<Group> listener : listeners) {
6321 listener.onAfterAddAssociation(groupId,
6322 com.liferay.portal.model.Role.class.getName(), roleId);
6323 }
6324
6325 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6326 listener.onAfterAddAssociation(roleId,
6327 Group.class.getName(), groupId);
6328 }
6329 }
6330 }
6331
6332 private SqlUpdate _sqlUpdate;
6333 }
6334
6335 protected class ClearRoles {
6336 protected ClearRoles() {
6337 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6338 "DELETE FROM Groups_Roles WHERE groupId = ?",
6339 new int[] { java.sql.Types.BIGINT });
6340 }
6341
6342 protected void clear(long groupId) throws SystemException {
6343 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6344
6345 List<com.liferay.portal.model.Role> roles = null;
6346
6347 if ((listeners.length > 0) || (roleListeners.length > 0)) {
6348 roles = getRoles(groupId);
6349
6350 for (com.liferay.portal.model.Role role : roles) {
6351 for (ModelListener<Group> listener : listeners) {
6352 listener.onBeforeRemoveAssociation(groupId,
6353 com.liferay.portal.model.Role.class.getName(),
6354 role.getPrimaryKey());
6355 }
6356
6357 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6358 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
6359 Group.class.getName(), groupId);
6360 }
6361 }
6362 }
6363
6364 _sqlUpdate.update(new Object[] { new Long(groupId) });
6365
6366 if ((listeners.length > 0) || (roleListeners.length > 0)) {
6367 for (com.liferay.portal.model.Role role : roles) {
6368 for (ModelListener<Group> listener : listeners) {
6369 listener.onAfterRemoveAssociation(groupId,
6370 com.liferay.portal.model.Role.class.getName(),
6371 role.getPrimaryKey());
6372 }
6373
6374 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6375 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
6376 Group.class.getName(), groupId);
6377 }
6378 }
6379 }
6380 }
6381
6382 private SqlUpdate _sqlUpdate;
6383 }
6384
6385 protected class RemoveRole {
6386 protected RemoveRole() {
6387 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6388 "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
6389 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6390 }
6391
6392 protected void remove(long groupId, long roleId)
6393 throws SystemException {
6394 if (containsRole.contains(groupId, roleId)) {
6395 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6396
6397 for (ModelListener<Group> listener : listeners) {
6398 listener.onBeforeRemoveAssociation(groupId,
6399 com.liferay.portal.model.Role.class.getName(), roleId);
6400 }
6401
6402 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6403 listener.onBeforeRemoveAssociation(roleId,
6404 Group.class.getName(), groupId);
6405 }
6406
6407 _sqlUpdate.update(new Object[] {
6408 new Long(groupId), new Long(roleId)
6409 });
6410
6411 for (ModelListener<Group> listener : listeners) {
6412 listener.onAfterRemoveAssociation(groupId,
6413 com.liferay.portal.model.Role.class.getName(), roleId);
6414 }
6415
6416 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6417 listener.onAfterRemoveAssociation(roleId,
6418 Group.class.getName(), groupId);
6419 }
6420 }
6421 }
6422
6423 private SqlUpdate _sqlUpdate;
6424 }
6425
6426 protected class ContainsUserGroup {
6427 protected ContainsUserGroup() {
6428 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6429 _SQL_CONTAINSUSERGROUP,
6430 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6431 RowMapper.COUNT);
6432 }
6433
6434 protected boolean contains(long groupId, long userGroupId) {
6435 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6436 new Long(groupId), new Long(userGroupId)
6437 });
6438
6439 if (results.size() > 0) {
6440 Integer count = results.get(0);
6441
6442 if (count.intValue() > 0) {
6443 return true;
6444 }
6445 }
6446
6447 return false;
6448 }
6449
6450 private MappingSqlQuery<Integer> _mappingSqlQuery;
6451 }
6452
6453 protected class AddUserGroup {
6454 protected AddUserGroup() {
6455 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6456 "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
6457 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6458 }
6459
6460 protected void add(long groupId, long userGroupId)
6461 throws SystemException {
6462 if (!containsUserGroup.contains(groupId, userGroupId)) {
6463 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6464 userGroupPersistence.getListeners();
6465
6466 for (ModelListener<Group> listener : listeners) {
6467 listener.onBeforeAddAssociation(groupId,
6468 com.liferay.portal.model.UserGroup.class.getName(),
6469 userGroupId);
6470 }
6471
6472 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6473 listener.onBeforeAddAssociation(userGroupId,
6474 Group.class.getName(), groupId);
6475 }
6476
6477 _sqlUpdate.update(new Object[] {
6478 new Long(groupId), new Long(userGroupId)
6479 });
6480
6481 for (ModelListener<Group> listener : listeners) {
6482 listener.onAfterAddAssociation(groupId,
6483 com.liferay.portal.model.UserGroup.class.getName(),
6484 userGroupId);
6485 }
6486
6487 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6488 listener.onAfterAddAssociation(userGroupId,
6489 Group.class.getName(), groupId);
6490 }
6491 }
6492 }
6493
6494 private SqlUpdate _sqlUpdate;
6495 }
6496
6497 protected class ClearUserGroups {
6498 protected ClearUserGroups() {
6499 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6500 "DELETE FROM Groups_UserGroups WHERE groupId = ?",
6501 new int[] { java.sql.Types.BIGINT });
6502 }
6503
6504 protected void clear(long groupId) throws SystemException {
6505 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6506 userGroupPersistence.getListeners();
6507
6508 List<com.liferay.portal.model.UserGroup> userGroups = null;
6509
6510 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
6511 userGroups = getUserGroups(groupId);
6512
6513 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
6514 for (ModelListener<Group> listener : listeners) {
6515 listener.onBeforeRemoveAssociation(groupId,
6516 com.liferay.portal.model.UserGroup.class.getName(),
6517 userGroup.getPrimaryKey());
6518 }
6519
6520 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6521 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
6522 Group.class.getName(), groupId);
6523 }
6524 }
6525 }
6526
6527 _sqlUpdate.update(new Object[] { new Long(groupId) });
6528
6529 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
6530 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
6531 for (ModelListener<Group> listener : listeners) {
6532 listener.onAfterRemoveAssociation(groupId,
6533 com.liferay.portal.model.UserGroup.class.getName(),
6534 userGroup.getPrimaryKey());
6535 }
6536
6537 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6538 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
6539 Group.class.getName(), groupId);
6540 }
6541 }
6542 }
6543 }
6544
6545 private SqlUpdate _sqlUpdate;
6546 }
6547
6548 protected class RemoveUserGroup {
6549 protected RemoveUserGroup() {
6550 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6551 "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
6552 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6553 }
6554
6555 protected void remove(long groupId, long userGroupId)
6556 throws SystemException {
6557 if (containsUserGroup.contains(groupId, userGroupId)) {
6558 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6559 userGroupPersistence.getListeners();
6560
6561 for (ModelListener<Group> listener : listeners) {
6562 listener.onBeforeRemoveAssociation(groupId,
6563 com.liferay.portal.model.UserGroup.class.getName(),
6564 userGroupId);
6565 }
6566
6567 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6568 listener.onBeforeRemoveAssociation(userGroupId,
6569 Group.class.getName(), groupId);
6570 }
6571
6572 _sqlUpdate.update(new Object[] {
6573 new Long(groupId), new Long(userGroupId)
6574 });
6575
6576 for (ModelListener<Group> listener : listeners) {
6577 listener.onAfterRemoveAssociation(groupId,
6578 com.liferay.portal.model.UserGroup.class.getName(),
6579 userGroupId);
6580 }
6581
6582 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6583 listener.onAfterRemoveAssociation(userGroupId,
6584 Group.class.getName(), groupId);
6585 }
6586 }
6587 }
6588
6589 private SqlUpdate _sqlUpdate;
6590 }
6591
6592 protected class ContainsUser {
6593 protected ContainsUser() {
6594 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6595 _SQL_CONTAINSUSER,
6596 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6597 RowMapper.COUNT);
6598 }
6599
6600 protected boolean contains(long groupId, long userId) {
6601 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6602 new Long(groupId), new Long(userId)
6603 });
6604
6605 if (results.size() > 0) {
6606 Integer count = results.get(0);
6607
6608 if (count.intValue() > 0) {
6609 return true;
6610 }
6611 }
6612
6613 return false;
6614 }
6615
6616 private MappingSqlQuery<Integer> _mappingSqlQuery;
6617 }
6618
6619 protected class AddUser {
6620 protected AddUser() {
6621 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6622 "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
6623 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6624 }
6625
6626 protected void add(long groupId, long userId) throws SystemException {
6627 if (!containsUser.contains(groupId, userId)) {
6628 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6629
6630 for (ModelListener<Group> listener : listeners) {
6631 listener.onBeforeAddAssociation(groupId,
6632 com.liferay.portal.model.User.class.getName(), userId);
6633 }
6634
6635 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6636 listener.onBeforeAddAssociation(userId,
6637 Group.class.getName(), groupId);
6638 }
6639
6640 _sqlUpdate.update(new Object[] {
6641 new Long(groupId), new Long(userId)
6642 });
6643
6644 for (ModelListener<Group> listener : listeners) {
6645 listener.onAfterAddAssociation(groupId,
6646 com.liferay.portal.model.User.class.getName(), userId);
6647 }
6648
6649 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6650 listener.onAfterAddAssociation(userId,
6651 Group.class.getName(), groupId);
6652 }
6653 }
6654 }
6655
6656 private SqlUpdate _sqlUpdate;
6657 }
6658
6659 protected class ClearUsers {
6660 protected ClearUsers() {
6661 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6662 "DELETE FROM Users_Groups WHERE groupId = ?",
6663 new int[] { java.sql.Types.BIGINT });
6664 }
6665
6666 protected void clear(long groupId) throws SystemException {
6667 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6668
6669 List<com.liferay.portal.model.User> users = null;
6670
6671 if ((listeners.length > 0) || (userListeners.length > 0)) {
6672 users = getUsers(groupId);
6673
6674 for (com.liferay.portal.model.User user : users) {
6675 for (ModelListener<Group> listener : listeners) {
6676 listener.onBeforeRemoveAssociation(groupId,
6677 com.liferay.portal.model.User.class.getName(),
6678 user.getPrimaryKey());
6679 }
6680
6681 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6682 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6683 Group.class.getName(), groupId);
6684 }
6685 }
6686 }
6687
6688 _sqlUpdate.update(new Object[] { new Long(groupId) });
6689
6690 if ((listeners.length > 0) || (userListeners.length > 0)) {
6691 for (com.liferay.portal.model.User user : users) {
6692 for (ModelListener<Group> listener : listeners) {
6693 listener.onAfterRemoveAssociation(groupId,
6694 com.liferay.portal.model.User.class.getName(),
6695 user.getPrimaryKey());
6696 }
6697
6698 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6699 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6700 Group.class.getName(), groupId);
6701 }
6702 }
6703 }
6704 }
6705
6706 private SqlUpdate _sqlUpdate;
6707 }
6708
6709 protected class RemoveUser {
6710 protected RemoveUser() {
6711 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6712 "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
6713 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6714 }
6715
6716 protected void remove(long groupId, long userId)
6717 throws SystemException {
6718 if (containsUser.contains(groupId, userId)) {
6719 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6720
6721 for (ModelListener<Group> listener : listeners) {
6722 listener.onBeforeRemoveAssociation(groupId,
6723 com.liferay.portal.model.User.class.getName(), userId);
6724 }
6725
6726 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6727 listener.onBeforeRemoveAssociation(userId,
6728 Group.class.getName(), groupId);
6729 }
6730
6731 _sqlUpdate.update(new Object[] {
6732 new Long(groupId), new Long(userId)
6733 });
6734
6735 for (ModelListener<Group> listener : listeners) {
6736 listener.onAfterRemoveAssociation(groupId,
6737 com.liferay.portal.model.User.class.getName(), userId);
6738 }
6739
6740 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6741 listener.onAfterRemoveAssociation(userId,
6742 Group.class.getName(), groupId);
6743 }
6744 }
6745 }
6746
6747 private SqlUpdate _sqlUpdate;
6748 }
6749
6750 private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
6751 private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
6752 private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
6753 private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
6754 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
6755 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
6756 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
6757 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Groups_Permissions ON (Groups_Permissions.permissionId = Permission_.permissionId) WHERE (Groups_Permissions.groupId = ?)";
6758 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ?";
6759 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?";
6760 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
6761 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
6762 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
6763 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
6764 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
6765 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
6766 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
6767 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
6768 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
6769 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
6770 private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
6771 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
6772 private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
6773 private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
6774 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
6775 private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
6776 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
6777 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
6778 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = ?)";
6779 private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
6780 private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
6781 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
6782 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
6783 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
6784 private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
6785 private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
6786 private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
6787 private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
6788 private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
6789 private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
6790 private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
6791 private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
6792 private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
6793 private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
6794 private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
6795 private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
6796 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
6797 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
6798 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6799 private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
6800 private static Group _nullGroup = new GroupImpl() {
6801 @Override
6802 public Object clone() {
6803 return this;
6804 }
6805
6806 @Override
6807 public CacheModel<Group> toCacheModel() {
6808 return _nullGroupCacheModel;
6809 }
6810 };
6811
6812 private static CacheModel<Group> _nullGroupCacheModel = new CacheModel<Group>() {
6813 public Group toEntityModel() {
6814 return _nullGroup;
6815 }
6816 };
6817 }