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