001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchGroupException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.Group;
047 import com.liferay.portal.model.ModelListener;
048 import com.liferay.portal.model.impl.GroupImpl;
049 import com.liferay.portal.model.impl.GroupModelImpl;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
053 import com.liferay.portlet.asset.service.persistence.AssetVocabularyPersistence;
054 import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
055 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
056 import com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence;
057 import com.liferay.portlet.calendar.service.persistence.CalEventPersistence;
058 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
059 import com.liferay.portlet.journal.service.persistence.JournalArticlePersistence;
060 import com.liferay.portlet.journal.service.persistence.JournalStructurePersistence;
061 import com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence;
062 import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
063 import com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistence;
064 import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
065 import com.liferay.portlet.messageboards.service.persistence.MBThreadPersistence;
066 import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
067 import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
068 import com.liferay.portlet.shopping.service.persistence.ShoppingCategoryPersistence;
069 import com.liferay.portlet.shopping.service.persistence.ShoppingCouponPersistence;
070 import com.liferay.portlet.shopping.service.persistence.ShoppingOrderPersistence;
071 import com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence;
072 import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
073 import com.liferay.portlet.wiki.service.persistence.WikiNodePersistence;
074
075 import java.io.Serializable;
076
077 import java.util.ArrayList;
078 import java.util.Collections;
079 import java.util.List;
080 import java.util.Set;
081
082
094 public class GroupPersistenceImpl extends BasePersistenceImpl<Group>
095 implements GroupPersistence {
096
101 public static final String FINDER_CLASS_NAME_ENTITY = GroupImpl.class.getName();
102 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
103 ".List1";
104 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
105 ".List2";
106 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
107 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
108 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
109 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
110 new String[] {
111 Long.class.getName(),
112
113 "java.lang.Integer", "java.lang.Integer",
114 "com.liferay.portal.kernel.util.OrderByComparator"
115 });
116 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
117 new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
118 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
119 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
120 new String[] { Long.class.getName() },
121 GroupModelImpl.COMPANYID_COLUMN_BITMASK);
122 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
123 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
124 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
125 new String[] { Long.class.getName() });
126 public static final FinderPath FINDER_PATH_FETCH_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
127 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
128 FINDER_CLASS_NAME_ENTITY, "fetchByLiveGroupId",
129 new String[] { Long.class.getName() },
130 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK);
131 public static final FinderPath FINDER_PATH_COUNT_BY_LIVEGROUPID = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
132 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLiveGroupId",
134 new String[] { Long.class.getName() });
135 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
136 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
137 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
138 new String[] { Long.class.getName(), String.class.getName() },
139 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
140 GroupModelImpl.NAME_COLUMN_BITMASK);
141 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
142 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
143 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
144 new String[] { Long.class.getName(), String.class.getName() });
145 public static final FinderPath FINDER_PATH_FETCH_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
146 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
147 FINDER_CLASS_NAME_ENTITY, "fetchByC_F",
148 new String[] { Long.class.getName(), String.class.getName() },
149 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
150 GroupModelImpl.FRIENDLYURL_COLUMN_BITMASK);
151 public static final FinderPath FINDER_PATH_COUNT_BY_C_F = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
152 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
153 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_F",
154 new String[] { Long.class.getName(), String.class.getName() });
155 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
156 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
157 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByT_A",
158 new String[] {
159 Integer.class.getName(), Boolean.class.getName(),
160
161 "java.lang.Integer", "java.lang.Integer",
162 "com.liferay.portal.kernel.util.OrderByComparator"
163 });
164 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
165 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
166 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByT_A",
167 new String[] { Integer.class.getName(), Boolean.class.getName() },
168 GroupModelImpl.TYPE_COLUMN_BITMASK |
169 GroupModelImpl.ACTIVE_COLUMN_BITMASK);
170 public static final FinderPath FINDER_PATH_COUNT_BY_T_A = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
171 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
172 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByT_A",
173 new String[] { Integer.class.getName(), Boolean.class.getName() });
174 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
175 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
176 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_C",
177 new String[] {
178 Long.class.getName(), Long.class.getName(), Long.class.getName()
179 },
180 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
181 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
182 GroupModelImpl.CLASSPK_COLUMN_BITMASK);
183 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_C = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
184 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
185 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_C",
186 new String[] {
187 Long.class.getName(), Long.class.getName(), Long.class.getName()
188 });
189 public static final FinderPath FINDER_PATH_FETCH_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
190 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
191 FINDER_CLASS_NAME_ENTITY, "fetchByC_L_N",
192 new String[] {
193 Long.class.getName(), Long.class.getName(),
194 String.class.getName()
195 },
196 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
197 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
198 GroupModelImpl.NAME_COLUMN_BITMASK);
199 public static final FinderPath FINDER_PATH_COUNT_BY_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
200 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
201 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_L_N",
202 new String[] {
203 Long.class.getName(), Long.class.getName(),
204 String.class.getName()
205 });
206 public static final FinderPath FINDER_PATH_FETCH_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
207 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
208 FINDER_CLASS_NAME_ENTITY, "fetchByC_C_L_N",
209 new String[] {
210 Long.class.getName(), Long.class.getName(), Long.class.getName(),
211 String.class.getName()
212 },
213 GroupModelImpl.COMPANYID_COLUMN_BITMASK |
214 GroupModelImpl.CLASSNAMEID_COLUMN_BITMASK |
215 GroupModelImpl.LIVEGROUPID_COLUMN_BITMASK |
216 GroupModelImpl.NAME_COLUMN_BITMASK);
217 public static final FinderPath FINDER_PATH_COUNT_BY_C_C_L_N = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
218 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
219 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_L_N",
220 new String[] {
221 Long.class.getName(), Long.class.getName(), Long.class.getName(),
222 String.class.getName()
223 });
224 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
225 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
226 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
227 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
228 GroupModelImpl.FINDER_CACHE_ENABLED, GroupImpl.class,
229 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
230 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(GroupModelImpl.ENTITY_CACHE_ENABLED,
231 GroupModelImpl.FINDER_CACHE_ENABLED, Long.class,
232 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
233
234
239 public void cacheResult(Group group) {
240 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
241 GroupImpl.class, group.getPrimaryKey(), group);
242
243 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
244 new Object[] { Long.valueOf(group.getLiveGroupId()) }, group);
245
246 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
247 new Object[] { Long.valueOf(group.getCompanyId()), group.getName() },
248 group);
249
250 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
251 new Object[] {
252 Long.valueOf(group.getCompanyId()),
253
254 group.getFriendlyURL()
255 }, group);
256
257 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
258 new Object[] {
259 Long.valueOf(group.getCompanyId()),
260 Long.valueOf(group.getClassNameId()),
261 Long.valueOf(group.getClassPK())
262 }, group);
263
264 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
265 new Object[] {
266 Long.valueOf(group.getCompanyId()),
267 Long.valueOf(group.getLiveGroupId()),
268
269 group.getName()
270 }, group);
271
272 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
273 new Object[] {
274 Long.valueOf(group.getCompanyId()),
275 Long.valueOf(group.getClassNameId()),
276 Long.valueOf(group.getLiveGroupId()),
277
278 group.getName()
279 }, group);
280
281 group.resetOriginalValues();
282 }
283
284
289 public void cacheResult(List<Group> groups) {
290 for (Group group : groups) {
291 if (EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
292 GroupImpl.class, group.getPrimaryKey()) == null) {
293 cacheResult(group);
294 }
295 else {
296 group.resetOriginalValues();
297 }
298 }
299 }
300
301
308 @Override
309 public void clearCache() {
310 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
311 CacheRegistryUtil.clear(GroupImpl.class.getName());
312 }
313
314 EntityCacheUtil.clearCache(GroupImpl.class.getName());
315
316 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
317 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
318 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
319 }
320
321
328 @Override
329 public void clearCache(Group group) {
330 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
331 GroupImpl.class, group.getPrimaryKey());
332
333 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
334 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
335
336 clearUniqueFindersCache(group);
337 }
338
339 @Override
340 public void clearCache(List<Group> groups) {
341 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
342 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
343
344 for (Group group : groups) {
345 EntityCacheUtil.removeResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
346 GroupImpl.class, group.getPrimaryKey());
347
348 clearUniqueFindersCache(group);
349 }
350 }
351
352 protected void cacheUniqueFindersCache(Group group) {
353 if (group.isNew()) {
354 Object[] args = new Object[] { Long.valueOf(group.getLiveGroupId()) };
355
356 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args,
357 Long.valueOf(1));
358 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args,
359 group);
360
361 args = new Object[] {
362 Long.valueOf(group.getCompanyId()),
363
364 group.getName()
365 };
366
367 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
368 Long.valueOf(1));
369 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, group);
370
371 args = new Object[] {
372 Long.valueOf(group.getCompanyId()),
373
374 group.getFriendlyURL()
375 };
376
377 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, args,
378 Long.valueOf(1));
379 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F, args, group);
380
381 args = new Object[] {
382 Long.valueOf(group.getCompanyId()),
383 Long.valueOf(group.getClassNameId()),
384 Long.valueOf(group.getClassPK())
385 };
386
387 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
388 Long.valueOf(1));
389 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args, group);
390
391 args = new Object[] {
392 Long.valueOf(group.getCompanyId()),
393 Long.valueOf(group.getLiveGroupId()),
394
395 group.getName()
396 };
397
398 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N, args,
399 Long.valueOf(1));
400 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N, args, group);
401
402 args = new Object[] {
403 Long.valueOf(group.getCompanyId()),
404 Long.valueOf(group.getClassNameId()),
405 Long.valueOf(group.getLiveGroupId()),
406
407 group.getName()
408 };
409
410 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N, args,
411 Long.valueOf(1));
412 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N, args, group);
413 }
414 else {
415 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
416
417 if ((groupModelImpl.getColumnBitmask() &
418 FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
419 Object[] args = new Object[] {
420 Long.valueOf(group.getLiveGroupId())
421 };
422
423 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
424 args, Long.valueOf(1));
425 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
426 args, group);
427 }
428
429 if ((groupModelImpl.getColumnBitmask() &
430 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
431 Object[] args = new Object[] {
432 Long.valueOf(group.getCompanyId()),
433
434 group.getName()
435 };
436
437 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
438 Long.valueOf(1));
439 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args, group);
440 }
441
442 if ((groupModelImpl.getColumnBitmask() &
443 FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
444 Object[] args = new Object[] {
445 Long.valueOf(group.getCompanyId()),
446
447 group.getFriendlyURL()
448 };
449
450 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, args,
451 Long.valueOf(1));
452 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F, args, group);
453 }
454
455 if ((groupModelImpl.getColumnBitmask() &
456 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
457 Object[] args = new Object[] {
458 Long.valueOf(group.getCompanyId()),
459 Long.valueOf(group.getClassNameId()),
460 Long.valueOf(group.getClassPK())
461 };
462
463 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C, args,
464 Long.valueOf(1));
465 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C, args,
466 group);
467 }
468
469 if ((groupModelImpl.getColumnBitmask() &
470 FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
471 Object[] args = new Object[] {
472 Long.valueOf(group.getCompanyId()),
473 Long.valueOf(group.getLiveGroupId()),
474
475 group.getName()
476 };
477
478 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N, args,
479 Long.valueOf(1));
480 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N, args,
481 group);
482 }
483
484 if ((groupModelImpl.getColumnBitmask() &
485 FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
486 Object[] args = new Object[] {
487 Long.valueOf(group.getCompanyId()),
488 Long.valueOf(group.getClassNameId()),
489 Long.valueOf(group.getLiveGroupId()),
490
491 group.getName()
492 };
493
494 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N, args,
495 Long.valueOf(1));
496 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N, args,
497 group);
498 }
499 }
500 }
501
502 protected void clearUniqueFindersCache(Group group) {
503 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
504
505 Object[] args = new Object[] { Long.valueOf(group.getLiveGroupId()) };
506
507 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args);
508 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args);
509
510 if ((groupModelImpl.getColumnBitmask() &
511 FINDER_PATH_FETCH_BY_LIVEGROUPID.getColumnBitmask()) != 0) {
512 args = new Object[] {
513 Long.valueOf(groupModelImpl.getOriginalLiveGroupId())
514 };
515
516 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LIVEGROUPID, args);
517 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID, args);
518 }
519
520 args = new Object[] { Long.valueOf(group.getCompanyId()), group.getName() };
521
522 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
523 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
524
525 if ((groupModelImpl.getColumnBitmask() &
526 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
527 args = new Object[] {
528 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
529
530 groupModelImpl.getOriginalName()
531 };
532
533 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
534 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
535 }
536
537 args = new Object[] {
538 Long.valueOf(group.getCompanyId()),
539
540 group.getFriendlyURL()
541 };
542
543 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
544 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
545
546 if ((groupModelImpl.getColumnBitmask() &
547 FINDER_PATH_FETCH_BY_C_F.getColumnBitmask()) != 0) {
548 args = new Object[] {
549 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
550
551 groupModelImpl.getOriginalFriendlyURL()
552 };
553
554 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_F, args);
555 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F, args);
556 }
557
558 args = new Object[] {
559 Long.valueOf(group.getCompanyId()),
560 Long.valueOf(group.getClassNameId()),
561 Long.valueOf(group.getClassPK())
562 };
563
564 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
565 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
566
567 if ((groupModelImpl.getColumnBitmask() &
568 FINDER_PATH_FETCH_BY_C_C_C.getColumnBitmask()) != 0) {
569 args = new Object[] {
570 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
571 Long.valueOf(groupModelImpl.getOriginalClassNameId()),
572 Long.valueOf(groupModelImpl.getOriginalClassPK())
573 };
574
575 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_C, args);
576 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C, args);
577 }
578
579 args = new Object[] {
580 Long.valueOf(group.getCompanyId()),
581 Long.valueOf(group.getLiveGroupId()),
582
583 group.getName()
584 };
585
586 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
587 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
588
589 if ((groupModelImpl.getColumnBitmask() &
590 FINDER_PATH_FETCH_BY_C_L_N.getColumnBitmask()) != 0) {
591 args = new Object[] {
592 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
593 Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
594
595 groupModelImpl.getOriginalName()
596 };
597
598 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_L_N, args);
599 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N, args);
600 }
601
602 args = new Object[] {
603 Long.valueOf(group.getCompanyId()),
604 Long.valueOf(group.getClassNameId()),
605 Long.valueOf(group.getLiveGroupId()),
606
607 group.getName()
608 };
609
610 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
611 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
612
613 if ((groupModelImpl.getColumnBitmask() &
614 FINDER_PATH_FETCH_BY_C_C_L_N.getColumnBitmask()) != 0) {
615 args = new Object[] {
616 Long.valueOf(groupModelImpl.getOriginalCompanyId()),
617 Long.valueOf(groupModelImpl.getOriginalClassNameId()),
618 Long.valueOf(groupModelImpl.getOriginalLiveGroupId()),
619
620 groupModelImpl.getOriginalName()
621 };
622
623 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_L_N, args);
624 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N, args);
625 }
626 }
627
628
634 public Group create(long groupId) {
635 Group group = new GroupImpl();
636
637 group.setNew(true);
638 group.setPrimaryKey(groupId);
639
640 return group;
641 }
642
643
651 public Group remove(long groupId)
652 throws NoSuchGroupException, SystemException {
653 return remove(Long.valueOf(groupId));
654 }
655
656
664 @Override
665 public Group remove(Serializable primaryKey)
666 throws NoSuchGroupException, SystemException {
667 Session session = null;
668
669 try {
670 session = openSession();
671
672 Group group = (Group)session.get(GroupImpl.class, primaryKey);
673
674 if (group == null) {
675 if (_log.isWarnEnabled()) {
676 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
677 }
678
679 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
680 primaryKey);
681 }
682
683 return remove(group);
684 }
685 catch (NoSuchGroupException nsee) {
686 throw nsee;
687 }
688 catch (Exception e) {
689 throw processException(e);
690 }
691 finally {
692 closeSession(session);
693 }
694 }
695
696 @Override
697 protected Group removeImpl(Group group) throws SystemException {
698 group = toUnwrappedModel(group);
699
700 try {
701 clearOrganizations.clear(group.getPrimaryKey());
702 }
703 catch (Exception e) {
704 throw processException(e);
705 }
706 finally {
707 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
708 }
709
710 try {
711 clearPermissions.clear(group.getPrimaryKey());
712 }
713 catch (Exception e) {
714 throw processException(e);
715 }
716 finally {
717 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
718 }
719
720 try {
721 clearRoles.clear(group.getPrimaryKey());
722 }
723 catch (Exception e) {
724 throw processException(e);
725 }
726 finally {
727 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
728 }
729
730 try {
731 clearUserGroups.clear(group.getPrimaryKey());
732 }
733 catch (Exception e) {
734 throw processException(e);
735 }
736 finally {
737 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
738 }
739
740 try {
741 clearUsers.clear(group.getPrimaryKey());
742 }
743 catch (Exception e) {
744 throw processException(e);
745 }
746 finally {
747 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
748 }
749
750 Session session = null;
751
752 try {
753 session = openSession();
754
755 BatchSessionUtil.delete(session, group);
756 }
757 catch (Exception e) {
758 throw processException(e);
759 }
760 finally {
761 closeSession(session);
762 }
763
764 clearCache(group);
765
766 return group;
767 }
768
769 @Override
770 public Group updateImpl(com.liferay.portal.model.Group group, boolean merge)
771 throws SystemException {
772 group = toUnwrappedModel(group);
773
774 boolean isNew = group.isNew();
775
776 GroupModelImpl groupModelImpl = (GroupModelImpl)group;
777
778 Session session = null;
779
780 try {
781 session = openSession();
782
783 BatchSessionUtil.update(session, group, merge);
784
785 group.setNew(false);
786 }
787 catch (Exception e) {
788 throw processException(e);
789 }
790 finally {
791 closeSession(session);
792 }
793
794 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
795
796 if (isNew || !GroupModelImpl.COLUMN_BITMASK_ENABLED) {
797 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
798 }
799
800 else {
801 if ((groupModelImpl.getColumnBitmask() &
802 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
803 Object[] args = new Object[] {
804 Long.valueOf(groupModelImpl.getOriginalCompanyId())
805 };
806
807 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
808 args);
809 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
810 args);
811
812 args = new Object[] { Long.valueOf(groupModelImpl.getCompanyId()) };
813
814 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
815 args);
816 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
817 args);
818 }
819
820 if ((groupModelImpl.getColumnBitmask() &
821 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A.getColumnBitmask()) != 0) {
822 Object[] args = new Object[] {
823 Integer.valueOf(groupModelImpl.getOriginalType()),
824 Boolean.valueOf(groupModelImpl.getOriginalActive())
825 };
826
827 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
828 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
829 args);
830
831 args = new Object[] {
832 Integer.valueOf(groupModelImpl.getType()),
833 Boolean.valueOf(groupModelImpl.getActive())
834 };
835
836 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_T_A, args);
837 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A,
838 args);
839 }
840 }
841
842 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
843 GroupImpl.class, group.getPrimaryKey(), group);
844
845 clearUniqueFindersCache(group);
846 cacheUniqueFindersCache(group);
847
848 return group;
849 }
850
851 protected Group toUnwrappedModel(Group group) {
852 if (group instanceof GroupImpl) {
853 return group;
854 }
855
856 GroupImpl groupImpl = new GroupImpl();
857
858 groupImpl.setNew(group.isNew());
859 groupImpl.setPrimaryKey(group.getPrimaryKey());
860
861 groupImpl.setGroupId(group.getGroupId());
862 groupImpl.setCompanyId(group.getCompanyId());
863 groupImpl.setCreatorUserId(group.getCreatorUserId());
864 groupImpl.setClassNameId(group.getClassNameId());
865 groupImpl.setClassPK(group.getClassPK());
866 groupImpl.setParentGroupId(group.getParentGroupId());
867 groupImpl.setLiveGroupId(group.getLiveGroupId());
868 groupImpl.setName(group.getName());
869 groupImpl.setDescription(group.getDescription());
870 groupImpl.setType(group.getType());
871 groupImpl.setTypeSettings(group.getTypeSettings());
872 groupImpl.setFriendlyURL(group.getFriendlyURL());
873 groupImpl.setSite(group.isSite());
874 groupImpl.setActive(group.isActive());
875
876 return groupImpl;
877 }
878
879
887 @Override
888 public Group findByPrimaryKey(Serializable primaryKey)
889 throws NoSuchModelException, SystemException {
890 return findByPrimaryKey(((Long)primaryKey).longValue());
891 }
892
893
901 public Group findByPrimaryKey(long groupId)
902 throws NoSuchGroupException, SystemException {
903 Group group = fetchByPrimaryKey(groupId);
904
905 if (group == null) {
906 if (_log.isWarnEnabled()) {
907 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + groupId);
908 }
909
910 throw new NoSuchGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
911 groupId);
912 }
913
914 return group;
915 }
916
917
924 @Override
925 public Group fetchByPrimaryKey(Serializable primaryKey)
926 throws SystemException {
927 return fetchByPrimaryKey(((Long)primaryKey).longValue());
928 }
929
930
937 public Group fetchByPrimaryKey(long groupId) throws SystemException {
938 Group group = (Group)EntityCacheUtil.getResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
939 GroupImpl.class, groupId);
940
941 if (group == _nullGroup) {
942 return null;
943 }
944
945 if (group == null) {
946 Session session = null;
947
948 boolean hasException = false;
949
950 try {
951 session = openSession();
952
953 group = (Group)session.get(GroupImpl.class,
954 Long.valueOf(groupId));
955 }
956 catch (Exception e) {
957 hasException = true;
958
959 throw processException(e);
960 }
961 finally {
962 if (group != null) {
963 cacheResult(group);
964 }
965 else if (!hasException) {
966 EntityCacheUtil.putResult(GroupModelImpl.ENTITY_CACHE_ENABLED,
967 GroupImpl.class, groupId, _nullGroup);
968 }
969
970 closeSession(session);
971 }
972 }
973
974 return group;
975 }
976
977
984 public List<Group> findByCompanyId(long companyId)
985 throws SystemException {
986 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
987 null);
988 }
989
990
1003 public List<Group> findByCompanyId(long companyId, int start, int end)
1004 throws SystemException {
1005 return findByCompanyId(companyId, start, end, null);
1006 }
1007
1008
1022 public List<Group> findByCompanyId(long companyId, int start, int end,
1023 OrderByComparator orderByComparator) throws SystemException {
1024 FinderPath finderPath = null;
1025 Object[] finderArgs = null;
1026
1027 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1028 (orderByComparator == null)) {
1029 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1030 finderArgs = new Object[] { companyId };
1031 }
1032 else {
1033 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1034 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1035 }
1036
1037 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1038 finderArgs, this);
1039
1040 if ((list != null) && !list.isEmpty()) {
1041 for (Group group : list) {
1042 if ((companyId != group.getCompanyId())) {
1043 list = null;
1044
1045 break;
1046 }
1047 }
1048 }
1049
1050 if (list == null) {
1051 StringBundler query = null;
1052
1053 if (orderByComparator != null) {
1054 query = new StringBundler(3 +
1055 (orderByComparator.getOrderByFields().length * 3));
1056 }
1057 else {
1058 query = new StringBundler(3);
1059 }
1060
1061 query.append(_SQL_SELECT_GROUP__WHERE);
1062
1063 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1064
1065 if (orderByComparator != null) {
1066 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1067 orderByComparator);
1068 }
1069
1070 else {
1071 query.append(GroupModelImpl.ORDER_BY_JPQL);
1072 }
1073
1074 String sql = query.toString();
1075
1076 Session session = null;
1077
1078 try {
1079 session = openSession();
1080
1081 Query q = session.createQuery(sql);
1082
1083 QueryPos qPos = QueryPos.getInstance(q);
1084
1085 qPos.add(companyId);
1086
1087 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1088 }
1089 catch (Exception e) {
1090 throw processException(e);
1091 }
1092 finally {
1093 if (list == null) {
1094 FinderCacheUtil.removeResult(finderPath, finderArgs);
1095 }
1096 else {
1097 cacheResult(list);
1098
1099 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1100 }
1101
1102 closeSession(session);
1103 }
1104 }
1105
1106 return list;
1107 }
1108
1109
1118 public Group findByCompanyId_First(long companyId,
1119 OrderByComparator orderByComparator)
1120 throws NoSuchGroupException, SystemException {
1121 Group group = fetchByCompanyId_First(companyId, orderByComparator);
1122
1123 if (group != null) {
1124 return group;
1125 }
1126
1127 StringBundler msg = new StringBundler(4);
1128
1129 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1130
1131 msg.append("companyId=");
1132 msg.append(companyId);
1133
1134 msg.append(StringPool.CLOSE_CURLY_BRACE);
1135
1136 throw new NoSuchGroupException(msg.toString());
1137 }
1138
1139
1147 public Group fetchByCompanyId_First(long companyId,
1148 OrderByComparator orderByComparator) throws SystemException {
1149 List<Group> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1150
1151 if (!list.isEmpty()) {
1152 return list.get(0);
1153 }
1154
1155 return null;
1156 }
1157
1158
1167 public Group findByCompanyId_Last(long companyId,
1168 OrderByComparator orderByComparator)
1169 throws NoSuchGroupException, SystemException {
1170 Group group = fetchByCompanyId_Last(companyId, orderByComparator);
1171
1172 if (group != null) {
1173 return group;
1174 }
1175
1176 StringBundler msg = new StringBundler(4);
1177
1178 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1179
1180 msg.append("companyId=");
1181 msg.append(companyId);
1182
1183 msg.append(StringPool.CLOSE_CURLY_BRACE);
1184
1185 throw new NoSuchGroupException(msg.toString());
1186 }
1187
1188
1196 public Group fetchByCompanyId_Last(long companyId,
1197 OrderByComparator orderByComparator) throws SystemException {
1198 int count = countByCompanyId(companyId);
1199
1200 List<Group> list = findByCompanyId(companyId, count - 1, count,
1201 orderByComparator);
1202
1203 if (!list.isEmpty()) {
1204 return list.get(0);
1205 }
1206
1207 return null;
1208 }
1209
1210
1220 public Group[] findByCompanyId_PrevAndNext(long groupId, long companyId,
1221 OrderByComparator orderByComparator)
1222 throws NoSuchGroupException, SystemException {
1223 Group group = findByPrimaryKey(groupId);
1224
1225 Session session = null;
1226
1227 try {
1228 session = openSession();
1229
1230 Group[] array = new GroupImpl[3];
1231
1232 array[0] = getByCompanyId_PrevAndNext(session, group, companyId,
1233 orderByComparator, true);
1234
1235 array[1] = group;
1236
1237 array[2] = getByCompanyId_PrevAndNext(session, group, companyId,
1238 orderByComparator, false);
1239
1240 return array;
1241 }
1242 catch (Exception e) {
1243 throw processException(e);
1244 }
1245 finally {
1246 closeSession(session);
1247 }
1248 }
1249
1250 protected Group getByCompanyId_PrevAndNext(Session session, Group group,
1251 long companyId, OrderByComparator orderByComparator, boolean previous) {
1252 StringBundler query = null;
1253
1254 if (orderByComparator != null) {
1255 query = new StringBundler(6 +
1256 (orderByComparator.getOrderByFields().length * 6));
1257 }
1258 else {
1259 query = new StringBundler(3);
1260 }
1261
1262 query.append(_SQL_SELECT_GROUP__WHERE);
1263
1264 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1265
1266 if (orderByComparator != null) {
1267 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1268
1269 if (orderByConditionFields.length > 0) {
1270 query.append(WHERE_AND);
1271 }
1272
1273 for (int i = 0; i < orderByConditionFields.length; i++) {
1274 query.append(_ORDER_BY_ENTITY_ALIAS);
1275 query.append(orderByConditionFields[i]);
1276
1277 if ((i + 1) < orderByConditionFields.length) {
1278 if (orderByComparator.isAscending() ^ previous) {
1279 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1280 }
1281 else {
1282 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1283 }
1284 }
1285 else {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(WHERE_GREATER_THAN);
1288 }
1289 else {
1290 query.append(WHERE_LESSER_THAN);
1291 }
1292 }
1293 }
1294
1295 query.append(ORDER_BY_CLAUSE);
1296
1297 String[] orderByFields = orderByComparator.getOrderByFields();
1298
1299 for (int i = 0; i < orderByFields.length; i++) {
1300 query.append(_ORDER_BY_ENTITY_ALIAS);
1301 query.append(orderByFields[i]);
1302
1303 if ((i + 1) < orderByFields.length) {
1304 if (orderByComparator.isAscending() ^ previous) {
1305 query.append(ORDER_BY_ASC_HAS_NEXT);
1306 }
1307 else {
1308 query.append(ORDER_BY_DESC_HAS_NEXT);
1309 }
1310 }
1311 else {
1312 if (orderByComparator.isAscending() ^ previous) {
1313 query.append(ORDER_BY_ASC);
1314 }
1315 else {
1316 query.append(ORDER_BY_DESC);
1317 }
1318 }
1319 }
1320 }
1321
1322 else {
1323 query.append(GroupModelImpl.ORDER_BY_JPQL);
1324 }
1325
1326 String sql = query.toString();
1327
1328 Query q = session.createQuery(sql);
1329
1330 q.setFirstResult(0);
1331 q.setMaxResults(2);
1332
1333 QueryPos qPos = QueryPos.getInstance(q);
1334
1335 qPos.add(companyId);
1336
1337 if (orderByComparator != null) {
1338 Object[] values = orderByComparator.getOrderByConditionValues(group);
1339
1340 for (Object value : values) {
1341 qPos.add(value);
1342 }
1343 }
1344
1345 List<Group> list = q.list();
1346
1347 if (list.size() == 2) {
1348 return list.get(1);
1349 }
1350 else {
1351 return null;
1352 }
1353 }
1354
1355
1363 public Group findByLiveGroupId(long liveGroupId)
1364 throws NoSuchGroupException, SystemException {
1365 Group group = fetchByLiveGroupId(liveGroupId);
1366
1367 if (group == null) {
1368 StringBundler msg = new StringBundler(4);
1369
1370 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1371
1372 msg.append("liveGroupId=");
1373 msg.append(liveGroupId);
1374
1375 msg.append(StringPool.CLOSE_CURLY_BRACE);
1376
1377 if (_log.isWarnEnabled()) {
1378 _log.warn(msg.toString());
1379 }
1380
1381 throw new NoSuchGroupException(msg.toString());
1382 }
1383
1384 return group;
1385 }
1386
1387
1394 public Group fetchByLiveGroupId(long liveGroupId) throws SystemException {
1395 return fetchByLiveGroupId(liveGroupId, true);
1396 }
1397
1398
1406 public Group fetchByLiveGroupId(long liveGroupId, boolean retrieveFromCache)
1407 throws SystemException {
1408 Object[] finderArgs = new Object[] { liveGroupId };
1409
1410 Object result = null;
1411
1412 if (retrieveFromCache) {
1413 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1414 finderArgs, this);
1415 }
1416
1417 if (result instanceof Group) {
1418 Group group = (Group)result;
1419
1420 if ((liveGroupId != group.getLiveGroupId())) {
1421 result = null;
1422 }
1423 }
1424
1425 if (result == null) {
1426 StringBundler query = new StringBundler(3);
1427
1428 query.append(_SQL_SELECT_GROUP__WHERE);
1429
1430 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
1431
1432 query.append(GroupModelImpl.ORDER_BY_JPQL);
1433
1434 String sql = query.toString();
1435
1436 Session session = null;
1437
1438 try {
1439 session = openSession();
1440
1441 Query q = session.createQuery(sql);
1442
1443 QueryPos qPos = QueryPos.getInstance(q);
1444
1445 qPos.add(liveGroupId);
1446
1447 List<Group> list = q.list();
1448
1449 result = list;
1450
1451 Group group = null;
1452
1453 if (list.isEmpty()) {
1454 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1455 finderArgs, list);
1456 }
1457 else {
1458 group = list.get(0);
1459
1460 cacheResult(group);
1461
1462 if ((group.getLiveGroupId() != liveGroupId)) {
1463 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1464 finderArgs, group);
1465 }
1466 }
1467
1468 return group;
1469 }
1470 catch (Exception e) {
1471 throw processException(e);
1472 }
1473 finally {
1474 if (result == null) {
1475 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LIVEGROUPID,
1476 finderArgs);
1477 }
1478
1479 closeSession(session);
1480 }
1481 }
1482 else {
1483 if (result instanceof List<?>) {
1484 return null;
1485 }
1486 else {
1487 return (Group)result;
1488 }
1489 }
1490 }
1491
1492
1501 public Group findByC_N(long companyId, String name)
1502 throws NoSuchGroupException, SystemException {
1503 Group group = fetchByC_N(companyId, name);
1504
1505 if (group == null) {
1506 StringBundler msg = new StringBundler(6);
1507
1508 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1509
1510 msg.append("companyId=");
1511 msg.append(companyId);
1512
1513 msg.append(", name=");
1514 msg.append(name);
1515
1516 msg.append(StringPool.CLOSE_CURLY_BRACE);
1517
1518 if (_log.isWarnEnabled()) {
1519 _log.warn(msg.toString());
1520 }
1521
1522 throw new NoSuchGroupException(msg.toString());
1523 }
1524
1525 return group;
1526 }
1527
1528
1536 public Group fetchByC_N(long companyId, String name)
1537 throws SystemException {
1538 return fetchByC_N(companyId, name, true);
1539 }
1540
1541
1550 public Group fetchByC_N(long companyId, String name,
1551 boolean retrieveFromCache) throws SystemException {
1552 Object[] finderArgs = new Object[] { companyId, name };
1553
1554 Object result = null;
1555
1556 if (retrieveFromCache) {
1557 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
1558 finderArgs, this);
1559 }
1560
1561 if (result instanceof Group) {
1562 Group group = (Group)result;
1563
1564 if ((companyId != group.getCompanyId()) ||
1565 !Validator.equals(name, group.getName())) {
1566 result = null;
1567 }
1568 }
1569
1570 if (result == null) {
1571 StringBundler query = new StringBundler(4);
1572
1573 query.append(_SQL_SELECT_GROUP__WHERE);
1574
1575 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
1576
1577 if (name == null) {
1578 query.append(_FINDER_COLUMN_C_N_NAME_1);
1579 }
1580 else {
1581 if (name.equals(StringPool.BLANK)) {
1582 query.append(_FINDER_COLUMN_C_N_NAME_3);
1583 }
1584 else {
1585 query.append(_FINDER_COLUMN_C_N_NAME_2);
1586 }
1587 }
1588
1589 query.append(GroupModelImpl.ORDER_BY_JPQL);
1590
1591 String sql = query.toString();
1592
1593 Session session = null;
1594
1595 try {
1596 session = openSession();
1597
1598 Query q = session.createQuery(sql);
1599
1600 QueryPos qPos = QueryPos.getInstance(q);
1601
1602 qPos.add(companyId);
1603
1604 if (name != null) {
1605 qPos.add(name);
1606 }
1607
1608 List<Group> list = q.list();
1609
1610 result = list;
1611
1612 Group group = null;
1613
1614 if (list.isEmpty()) {
1615 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1616 finderArgs, list);
1617 }
1618 else {
1619 group = list.get(0);
1620
1621 cacheResult(group);
1622
1623 if ((group.getCompanyId() != companyId) ||
1624 (group.getName() == null) ||
1625 !group.getName().equals(name)) {
1626 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
1627 finderArgs, group);
1628 }
1629 }
1630
1631 return group;
1632 }
1633 catch (Exception e) {
1634 throw processException(e);
1635 }
1636 finally {
1637 if (result == null) {
1638 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
1639 finderArgs);
1640 }
1641
1642 closeSession(session);
1643 }
1644 }
1645 else {
1646 if (result instanceof List<?>) {
1647 return null;
1648 }
1649 else {
1650 return (Group)result;
1651 }
1652 }
1653 }
1654
1655
1664 public Group findByC_F(long companyId, String friendlyURL)
1665 throws NoSuchGroupException, SystemException {
1666 Group group = fetchByC_F(companyId, friendlyURL);
1667
1668 if (group == null) {
1669 StringBundler msg = new StringBundler(6);
1670
1671 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1672
1673 msg.append("companyId=");
1674 msg.append(companyId);
1675
1676 msg.append(", friendlyURL=");
1677 msg.append(friendlyURL);
1678
1679 msg.append(StringPool.CLOSE_CURLY_BRACE);
1680
1681 if (_log.isWarnEnabled()) {
1682 _log.warn(msg.toString());
1683 }
1684
1685 throw new NoSuchGroupException(msg.toString());
1686 }
1687
1688 return group;
1689 }
1690
1691
1699 public Group fetchByC_F(long companyId, String friendlyURL)
1700 throws SystemException {
1701 return fetchByC_F(companyId, friendlyURL, true);
1702 }
1703
1704
1713 public Group fetchByC_F(long companyId, String friendlyURL,
1714 boolean retrieveFromCache) throws SystemException {
1715 Object[] finderArgs = new Object[] { companyId, friendlyURL };
1716
1717 Object result = null;
1718
1719 if (retrieveFromCache) {
1720 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_F,
1721 finderArgs, this);
1722 }
1723
1724 if (result instanceof Group) {
1725 Group group = (Group)result;
1726
1727 if ((companyId != group.getCompanyId()) ||
1728 !Validator.equals(friendlyURL, group.getFriendlyURL())) {
1729 result = null;
1730 }
1731 }
1732
1733 if (result == null) {
1734 StringBundler query = new StringBundler(4);
1735
1736 query.append(_SQL_SELECT_GROUP__WHERE);
1737
1738 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
1739
1740 if (friendlyURL == null) {
1741 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
1742 }
1743 else {
1744 if (friendlyURL.equals(StringPool.BLANK)) {
1745 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
1746 }
1747 else {
1748 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
1749 }
1750 }
1751
1752 query.append(GroupModelImpl.ORDER_BY_JPQL);
1753
1754 String sql = query.toString();
1755
1756 Session session = null;
1757
1758 try {
1759 session = openSession();
1760
1761 Query q = session.createQuery(sql);
1762
1763 QueryPos qPos = QueryPos.getInstance(q);
1764
1765 qPos.add(companyId);
1766
1767 if (friendlyURL != null) {
1768 qPos.add(friendlyURL);
1769 }
1770
1771 List<Group> list = q.list();
1772
1773 result = list;
1774
1775 Group group = null;
1776
1777 if (list.isEmpty()) {
1778 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1779 finderArgs, list);
1780 }
1781 else {
1782 group = list.get(0);
1783
1784 cacheResult(group);
1785
1786 if ((group.getCompanyId() != companyId) ||
1787 (group.getFriendlyURL() == null) ||
1788 !group.getFriendlyURL().equals(friendlyURL)) {
1789 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_F,
1790 finderArgs, group);
1791 }
1792 }
1793
1794 return group;
1795 }
1796 catch (Exception e) {
1797 throw processException(e);
1798 }
1799 finally {
1800 if (result == null) {
1801 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_F,
1802 finderArgs);
1803 }
1804
1805 closeSession(session);
1806 }
1807 }
1808 else {
1809 if (result instanceof List<?>) {
1810 return null;
1811 }
1812 else {
1813 return (Group)result;
1814 }
1815 }
1816 }
1817
1818
1826 public List<Group> findByT_A(int type, boolean active)
1827 throws SystemException {
1828 return findByT_A(type, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1829 null);
1830 }
1831
1832
1846 public List<Group> findByT_A(int type, boolean active, int start, int end)
1847 throws SystemException {
1848 return findByT_A(type, active, start, end, null);
1849 }
1850
1851
1866 public List<Group> findByT_A(int type, boolean active, int start, int end,
1867 OrderByComparator orderByComparator) throws SystemException {
1868 FinderPath finderPath = null;
1869 Object[] finderArgs = null;
1870
1871 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1872 (orderByComparator == null)) {
1873 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_A;
1874 finderArgs = new Object[] { type, active };
1875 }
1876 else {
1877 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_A;
1878 finderArgs = new Object[] {
1879 type, active,
1880
1881 start, end, orderByComparator
1882 };
1883 }
1884
1885 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
1886 finderArgs, this);
1887
1888 if ((list != null) && !list.isEmpty()) {
1889 for (Group group : list) {
1890 if ((type != group.getType()) || (active != group.getActive())) {
1891 list = null;
1892
1893 break;
1894 }
1895 }
1896 }
1897
1898 if (list == null) {
1899 StringBundler query = null;
1900
1901 if (orderByComparator != null) {
1902 query = new StringBundler(4 +
1903 (orderByComparator.getOrderByFields().length * 3));
1904 }
1905 else {
1906 query = new StringBundler(4);
1907 }
1908
1909 query.append(_SQL_SELECT_GROUP__WHERE);
1910
1911 query.append(_FINDER_COLUMN_T_A_TYPE_2);
1912
1913 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
1914
1915 if (orderByComparator != null) {
1916 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1917 orderByComparator);
1918 }
1919
1920 else {
1921 query.append(GroupModelImpl.ORDER_BY_JPQL);
1922 }
1923
1924 String sql = query.toString();
1925
1926 Session session = null;
1927
1928 try {
1929 session = openSession();
1930
1931 Query q = session.createQuery(sql);
1932
1933 QueryPos qPos = QueryPos.getInstance(q);
1934
1935 qPos.add(type);
1936
1937 qPos.add(active);
1938
1939 list = (List<Group>)QueryUtil.list(q, getDialect(), start, end);
1940 }
1941 catch (Exception e) {
1942 throw processException(e);
1943 }
1944 finally {
1945 if (list == null) {
1946 FinderCacheUtil.removeResult(finderPath, finderArgs);
1947 }
1948 else {
1949 cacheResult(list);
1950
1951 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1952 }
1953
1954 closeSession(session);
1955 }
1956 }
1957
1958 return list;
1959 }
1960
1961
1971 public Group findByT_A_First(int type, boolean active,
1972 OrderByComparator orderByComparator)
1973 throws NoSuchGroupException, SystemException {
1974 Group group = fetchByT_A_First(type, active, orderByComparator);
1975
1976 if (group != null) {
1977 return group;
1978 }
1979
1980 StringBundler msg = new StringBundler(6);
1981
1982 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1983
1984 msg.append("type=");
1985 msg.append(type);
1986
1987 msg.append(", active=");
1988 msg.append(active);
1989
1990 msg.append(StringPool.CLOSE_CURLY_BRACE);
1991
1992 throw new NoSuchGroupException(msg.toString());
1993 }
1994
1995
2004 public Group fetchByT_A_First(int type, boolean active,
2005 OrderByComparator orderByComparator) throws SystemException {
2006 List<Group> list = findByT_A(type, active, 0, 1, orderByComparator);
2007
2008 if (!list.isEmpty()) {
2009 return list.get(0);
2010 }
2011
2012 return null;
2013 }
2014
2015
2025 public Group findByT_A_Last(int type, boolean active,
2026 OrderByComparator orderByComparator)
2027 throws NoSuchGroupException, SystemException {
2028 Group group = fetchByT_A_Last(type, active, orderByComparator);
2029
2030 if (group != null) {
2031 return group;
2032 }
2033
2034 StringBundler msg = new StringBundler(6);
2035
2036 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2037
2038 msg.append("type=");
2039 msg.append(type);
2040
2041 msg.append(", active=");
2042 msg.append(active);
2043
2044 msg.append(StringPool.CLOSE_CURLY_BRACE);
2045
2046 throw new NoSuchGroupException(msg.toString());
2047 }
2048
2049
2058 public Group fetchByT_A_Last(int type, boolean active,
2059 OrderByComparator orderByComparator) throws SystemException {
2060 int count = countByT_A(type, active);
2061
2062 List<Group> list = findByT_A(type, active, count - 1, count,
2063 orderByComparator);
2064
2065 if (!list.isEmpty()) {
2066 return list.get(0);
2067 }
2068
2069 return null;
2070 }
2071
2072
2083 public Group[] findByT_A_PrevAndNext(long groupId, int type,
2084 boolean active, OrderByComparator orderByComparator)
2085 throws NoSuchGroupException, SystemException {
2086 Group group = findByPrimaryKey(groupId);
2087
2088 Session session = null;
2089
2090 try {
2091 session = openSession();
2092
2093 Group[] array = new GroupImpl[3];
2094
2095 array[0] = getByT_A_PrevAndNext(session, group, type, active,
2096 orderByComparator, true);
2097
2098 array[1] = group;
2099
2100 array[2] = getByT_A_PrevAndNext(session, group, type, active,
2101 orderByComparator, false);
2102
2103 return array;
2104 }
2105 catch (Exception e) {
2106 throw processException(e);
2107 }
2108 finally {
2109 closeSession(session);
2110 }
2111 }
2112
2113 protected Group getByT_A_PrevAndNext(Session session, Group group,
2114 int type, boolean active, OrderByComparator orderByComparator,
2115 boolean previous) {
2116 StringBundler query = null;
2117
2118 if (orderByComparator != null) {
2119 query = new StringBundler(6 +
2120 (orderByComparator.getOrderByFields().length * 6));
2121 }
2122 else {
2123 query = new StringBundler(3);
2124 }
2125
2126 query.append(_SQL_SELECT_GROUP__WHERE);
2127
2128 query.append(_FINDER_COLUMN_T_A_TYPE_2);
2129
2130 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
2131
2132 if (orderByComparator != null) {
2133 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2134
2135 if (orderByConditionFields.length > 0) {
2136 query.append(WHERE_AND);
2137 }
2138
2139 for (int i = 0; i < orderByConditionFields.length; i++) {
2140 query.append(_ORDER_BY_ENTITY_ALIAS);
2141 query.append(orderByConditionFields[i]);
2142
2143 if ((i + 1) < orderByConditionFields.length) {
2144 if (orderByComparator.isAscending() ^ previous) {
2145 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2146 }
2147 else {
2148 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2149 }
2150 }
2151 else {
2152 if (orderByComparator.isAscending() ^ previous) {
2153 query.append(WHERE_GREATER_THAN);
2154 }
2155 else {
2156 query.append(WHERE_LESSER_THAN);
2157 }
2158 }
2159 }
2160
2161 query.append(ORDER_BY_CLAUSE);
2162
2163 String[] orderByFields = orderByComparator.getOrderByFields();
2164
2165 for (int i = 0; i < orderByFields.length; i++) {
2166 query.append(_ORDER_BY_ENTITY_ALIAS);
2167 query.append(orderByFields[i]);
2168
2169 if ((i + 1) < orderByFields.length) {
2170 if (orderByComparator.isAscending() ^ previous) {
2171 query.append(ORDER_BY_ASC_HAS_NEXT);
2172 }
2173 else {
2174 query.append(ORDER_BY_DESC_HAS_NEXT);
2175 }
2176 }
2177 else {
2178 if (orderByComparator.isAscending() ^ previous) {
2179 query.append(ORDER_BY_ASC);
2180 }
2181 else {
2182 query.append(ORDER_BY_DESC);
2183 }
2184 }
2185 }
2186 }
2187
2188 else {
2189 query.append(GroupModelImpl.ORDER_BY_JPQL);
2190 }
2191
2192 String sql = query.toString();
2193
2194 Query q = session.createQuery(sql);
2195
2196 q.setFirstResult(0);
2197 q.setMaxResults(2);
2198
2199 QueryPos qPos = QueryPos.getInstance(q);
2200
2201 qPos.add(type);
2202
2203 qPos.add(active);
2204
2205 if (orderByComparator != null) {
2206 Object[] values = orderByComparator.getOrderByConditionValues(group);
2207
2208 for (Object value : values) {
2209 qPos.add(value);
2210 }
2211 }
2212
2213 List<Group> list = q.list();
2214
2215 if (list.size() == 2) {
2216 return list.get(1);
2217 }
2218 else {
2219 return null;
2220 }
2221 }
2222
2223
2233 public Group findByC_C_C(long companyId, long classNameId, long classPK)
2234 throws NoSuchGroupException, SystemException {
2235 Group group = fetchByC_C_C(companyId, classNameId, classPK);
2236
2237 if (group == null) {
2238 StringBundler msg = new StringBundler(8);
2239
2240 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2241
2242 msg.append("companyId=");
2243 msg.append(companyId);
2244
2245 msg.append(", classNameId=");
2246 msg.append(classNameId);
2247
2248 msg.append(", classPK=");
2249 msg.append(classPK);
2250
2251 msg.append(StringPool.CLOSE_CURLY_BRACE);
2252
2253 if (_log.isWarnEnabled()) {
2254 _log.warn(msg.toString());
2255 }
2256
2257 throw new NoSuchGroupException(msg.toString());
2258 }
2259
2260 return group;
2261 }
2262
2263
2272 public Group fetchByC_C_C(long companyId, long classNameId, long classPK)
2273 throws SystemException {
2274 return fetchByC_C_C(companyId, classNameId, classPK, true);
2275 }
2276
2277
2287 public Group fetchByC_C_C(long companyId, long classNameId, long classPK,
2288 boolean retrieveFromCache) throws SystemException {
2289 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
2290
2291 Object result = null;
2292
2293 if (retrieveFromCache) {
2294 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_C,
2295 finderArgs, this);
2296 }
2297
2298 if (result instanceof Group) {
2299 Group group = (Group)result;
2300
2301 if ((companyId != group.getCompanyId()) ||
2302 (classNameId != group.getClassNameId()) ||
2303 (classPK != group.getClassPK())) {
2304 result = null;
2305 }
2306 }
2307
2308 if (result == null) {
2309 StringBundler query = new StringBundler(5);
2310
2311 query.append(_SQL_SELECT_GROUP__WHERE);
2312
2313 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
2314
2315 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
2316
2317 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
2318
2319 query.append(GroupModelImpl.ORDER_BY_JPQL);
2320
2321 String sql = query.toString();
2322
2323 Session session = null;
2324
2325 try {
2326 session = openSession();
2327
2328 Query q = session.createQuery(sql);
2329
2330 QueryPos qPos = QueryPos.getInstance(q);
2331
2332 qPos.add(companyId);
2333
2334 qPos.add(classNameId);
2335
2336 qPos.add(classPK);
2337
2338 List<Group> list = q.list();
2339
2340 result = list;
2341
2342 Group group = null;
2343
2344 if (list.isEmpty()) {
2345 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2346 finderArgs, list);
2347 }
2348 else {
2349 group = list.get(0);
2350
2351 cacheResult(group);
2352
2353 if ((group.getCompanyId() != companyId) ||
2354 (group.getClassNameId() != classNameId) ||
2355 (group.getClassPK() != classPK)) {
2356 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_C,
2357 finderArgs, group);
2358 }
2359 }
2360
2361 return group;
2362 }
2363 catch (Exception e) {
2364 throw processException(e);
2365 }
2366 finally {
2367 if (result == null) {
2368 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_C,
2369 finderArgs);
2370 }
2371
2372 closeSession(session);
2373 }
2374 }
2375 else {
2376 if (result instanceof List<?>) {
2377 return null;
2378 }
2379 else {
2380 return (Group)result;
2381 }
2382 }
2383 }
2384
2385
2395 public Group findByC_L_N(long companyId, long liveGroupId, String name)
2396 throws NoSuchGroupException, SystemException {
2397 Group group = fetchByC_L_N(companyId, liveGroupId, name);
2398
2399 if (group == null) {
2400 StringBundler msg = new StringBundler(8);
2401
2402 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2403
2404 msg.append("companyId=");
2405 msg.append(companyId);
2406
2407 msg.append(", liveGroupId=");
2408 msg.append(liveGroupId);
2409
2410 msg.append(", name=");
2411 msg.append(name);
2412
2413 msg.append(StringPool.CLOSE_CURLY_BRACE);
2414
2415 if (_log.isWarnEnabled()) {
2416 _log.warn(msg.toString());
2417 }
2418
2419 throw new NoSuchGroupException(msg.toString());
2420 }
2421
2422 return group;
2423 }
2424
2425
2434 public Group fetchByC_L_N(long companyId, long liveGroupId, String name)
2435 throws SystemException {
2436 return fetchByC_L_N(companyId, liveGroupId, name, true);
2437 }
2438
2439
2449 public Group fetchByC_L_N(long companyId, long liveGroupId, String name,
2450 boolean retrieveFromCache) throws SystemException {
2451 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
2452
2453 Object result = null;
2454
2455 if (retrieveFromCache) {
2456 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_L_N,
2457 finderArgs, this);
2458 }
2459
2460 if (result instanceof Group) {
2461 Group group = (Group)result;
2462
2463 if ((companyId != group.getCompanyId()) ||
2464 (liveGroupId != group.getLiveGroupId()) ||
2465 !Validator.equals(name, group.getName())) {
2466 result = null;
2467 }
2468 }
2469
2470 if (result == null) {
2471 StringBundler query = new StringBundler(5);
2472
2473 query.append(_SQL_SELECT_GROUP__WHERE);
2474
2475 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
2476
2477 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
2478
2479 if (name == null) {
2480 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
2481 }
2482 else {
2483 if (name.equals(StringPool.BLANK)) {
2484 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
2485 }
2486 else {
2487 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
2488 }
2489 }
2490
2491 query.append(GroupModelImpl.ORDER_BY_JPQL);
2492
2493 String sql = query.toString();
2494
2495 Session session = null;
2496
2497 try {
2498 session = openSession();
2499
2500 Query q = session.createQuery(sql);
2501
2502 QueryPos qPos = QueryPos.getInstance(q);
2503
2504 qPos.add(companyId);
2505
2506 qPos.add(liveGroupId);
2507
2508 if (name != null) {
2509 qPos.add(name);
2510 }
2511
2512 List<Group> list = q.list();
2513
2514 result = list;
2515
2516 Group group = null;
2517
2518 if (list.isEmpty()) {
2519 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
2520 finderArgs, list);
2521 }
2522 else {
2523 group = list.get(0);
2524
2525 cacheResult(group);
2526
2527 if ((group.getCompanyId() != companyId) ||
2528 (group.getLiveGroupId() != liveGroupId) ||
2529 (group.getName() == null) ||
2530 !group.getName().equals(name)) {
2531 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_L_N,
2532 finderArgs, group);
2533 }
2534 }
2535
2536 return group;
2537 }
2538 catch (Exception e) {
2539 throw processException(e);
2540 }
2541 finally {
2542 if (result == null) {
2543 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_L_N,
2544 finderArgs);
2545 }
2546
2547 closeSession(session);
2548 }
2549 }
2550 else {
2551 if (result instanceof List<?>) {
2552 return null;
2553 }
2554 else {
2555 return (Group)result;
2556 }
2557 }
2558 }
2559
2560
2571 public Group findByC_C_L_N(long companyId, long classNameId,
2572 long liveGroupId, String name)
2573 throws NoSuchGroupException, SystemException {
2574 Group group = fetchByC_C_L_N(companyId, classNameId, liveGroupId, name);
2575
2576 if (group == null) {
2577 StringBundler msg = new StringBundler(10);
2578
2579 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2580
2581 msg.append("companyId=");
2582 msg.append(companyId);
2583
2584 msg.append(", classNameId=");
2585 msg.append(classNameId);
2586
2587 msg.append(", liveGroupId=");
2588 msg.append(liveGroupId);
2589
2590 msg.append(", name=");
2591 msg.append(name);
2592
2593 msg.append(StringPool.CLOSE_CURLY_BRACE);
2594
2595 if (_log.isWarnEnabled()) {
2596 _log.warn(msg.toString());
2597 }
2598
2599 throw new NoSuchGroupException(msg.toString());
2600 }
2601
2602 return group;
2603 }
2604
2605
2615 public Group fetchByC_C_L_N(long companyId, long classNameId,
2616 long liveGroupId, String name) throws SystemException {
2617 return fetchByC_C_L_N(companyId, classNameId, liveGroupId, name, true);
2618 }
2619
2620
2631 public Group fetchByC_C_L_N(long companyId, long classNameId,
2632 long liveGroupId, String name, boolean retrieveFromCache)
2633 throws SystemException {
2634 Object[] finderArgs = new Object[] {
2635 companyId, classNameId, liveGroupId, name
2636 };
2637
2638 Object result = null;
2639
2640 if (retrieveFromCache) {
2641 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2642 finderArgs, this);
2643 }
2644
2645 if (result instanceof Group) {
2646 Group group = (Group)result;
2647
2648 if ((companyId != group.getCompanyId()) ||
2649 (classNameId != group.getClassNameId()) ||
2650 (liveGroupId != group.getLiveGroupId()) ||
2651 !Validator.equals(name, group.getName())) {
2652 result = null;
2653 }
2654 }
2655
2656 if (result == null) {
2657 StringBundler query = new StringBundler(6);
2658
2659 query.append(_SQL_SELECT_GROUP__WHERE);
2660
2661 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
2662
2663 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
2664
2665 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
2666
2667 if (name == null) {
2668 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
2669 }
2670 else {
2671 if (name.equals(StringPool.BLANK)) {
2672 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
2673 }
2674 else {
2675 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
2676 }
2677 }
2678
2679 query.append(GroupModelImpl.ORDER_BY_JPQL);
2680
2681 String sql = query.toString();
2682
2683 Session session = null;
2684
2685 try {
2686 session = openSession();
2687
2688 Query q = session.createQuery(sql);
2689
2690 QueryPos qPos = QueryPos.getInstance(q);
2691
2692 qPos.add(companyId);
2693
2694 qPos.add(classNameId);
2695
2696 qPos.add(liveGroupId);
2697
2698 if (name != null) {
2699 qPos.add(name);
2700 }
2701
2702 List<Group> list = q.list();
2703
2704 result = list;
2705
2706 Group group = null;
2707
2708 if (list.isEmpty()) {
2709 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2710 finderArgs, list);
2711 }
2712 else {
2713 group = list.get(0);
2714
2715 cacheResult(group);
2716
2717 if ((group.getCompanyId() != companyId) ||
2718 (group.getClassNameId() != classNameId) ||
2719 (group.getLiveGroupId() != liveGroupId) ||
2720 (group.getName() == null) ||
2721 !group.getName().equals(name)) {
2722 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2723 finderArgs, group);
2724 }
2725 }
2726
2727 return group;
2728 }
2729 catch (Exception e) {
2730 throw processException(e);
2731 }
2732 finally {
2733 if (result == null) {
2734 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C_L_N,
2735 finderArgs);
2736 }
2737
2738 closeSession(session);
2739 }
2740 }
2741 else {
2742 if (result instanceof List<?>) {
2743 return null;
2744 }
2745 else {
2746 return (Group)result;
2747 }
2748 }
2749 }
2750
2751
2757 public List<Group> findAll() throws SystemException {
2758 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2759 }
2760
2761
2773 public List<Group> findAll(int start, int end) throws SystemException {
2774 return findAll(start, end, null);
2775 }
2776
2777
2790 public List<Group> findAll(int start, int end,
2791 OrderByComparator orderByComparator) throws SystemException {
2792 FinderPath finderPath = null;
2793 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2794
2795 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2796 (orderByComparator == null)) {
2797 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2798 finderArgs = FINDER_ARGS_EMPTY;
2799 }
2800 else {
2801 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2802 finderArgs = new Object[] { start, end, orderByComparator };
2803 }
2804
2805 List<Group> list = (List<Group>)FinderCacheUtil.getResult(finderPath,
2806 finderArgs, this);
2807
2808 if (list == null) {
2809 StringBundler query = null;
2810 String sql = null;
2811
2812 if (orderByComparator != null) {
2813 query = new StringBundler(2 +
2814 (orderByComparator.getOrderByFields().length * 3));
2815
2816 query.append(_SQL_SELECT_GROUP_);
2817
2818 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2819 orderByComparator);
2820
2821 sql = query.toString();
2822 }
2823 else {
2824 sql = _SQL_SELECT_GROUP_.concat(GroupModelImpl.ORDER_BY_JPQL);
2825 }
2826
2827 Session session = null;
2828
2829 try {
2830 session = openSession();
2831
2832 Query q = session.createQuery(sql);
2833
2834 if (orderByComparator == null) {
2835 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2836 end, false);
2837
2838 Collections.sort(list);
2839 }
2840 else {
2841 list = (List<Group>)QueryUtil.list(q, getDialect(), start,
2842 end);
2843 }
2844 }
2845 catch (Exception e) {
2846 throw processException(e);
2847 }
2848 finally {
2849 if (list == null) {
2850 FinderCacheUtil.removeResult(finderPath, finderArgs);
2851 }
2852 else {
2853 cacheResult(list);
2854
2855 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2856 }
2857
2858 closeSession(session);
2859 }
2860 }
2861
2862 return list;
2863 }
2864
2865
2871 public void removeByCompanyId(long companyId) throws SystemException {
2872 for (Group group : findByCompanyId(companyId)) {
2873 remove(group);
2874 }
2875 }
2876
2877
2884 public Group removeByLiveGroupId(long liveGroupId)
2885 throws NoSuchGroupException, SystemException {
2886 Group group = findByLiveGroupId(liveGroupId);
2887
2888 return remove(group);
2889 }
2890
2891
2899 public Group removeByC_N(long companyId, String name)
2900 throws NoSuchGroupException, SystemException {
2901 Group group = findByC_N(companyId, name);
2902
2903 return remove(group);
2904 }
2905
2906
2914 public Group removeByC_F(long companyId, String friendlyURL)
2915 throws NoSuchGroupException, SystemException {
2916 Group group = findByC_F(companyId, friendlyURL);
2917
2918 return remove(group);
2919 }
2920
2921
2928 public void removeByT_A(int type, boolean active) throws SystemException {
2929 for (Group group : findByT_A(type, active)) {
2930 remove(group);
2931 }
2932 }
2933
2934
2943 public Group removeByC_C_C(long companyId, long classNameId, long classPK)
2944 throws NoSuchGroupException, SystemException {
2945 Group group = findByC_C_C(companyId, classNameId, classPK);
2946
2947 return remove(group);
2948 }
2949
2950
2959 public Group removeByC_L_N(long companyId, long liveGroupId, String name)
2960 throws NoSuchGroupException, SystemException {
2961 Group group = findByC_L_N(companyId, liveGroupId, name);
2962
2963 return remove(group);
2964 }
2965
2966
2976 public Group removeByC_C_L_N(long companyId, long classNameId,
2977 long liveGroupId, String name)
2978 throws NoSuchGroupException, SystemException {
2979 Group group = findByC_C_L_N(companyId, classNameId, liveGroupId, name);
2980
2981 return remove(group);
2982 }
2983
2984
2989 public void removeAll() throws SystemException {
2990 for (Group group : findAll()) {
2991 remove(group);
2992 }
2993 }
2994
2995
3002 public int countByCompanyId(long companyId) throws SystemException {
3003 Object[] finderArgs = new Object[] { companyId };
3004
3005 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3006 finderArgs, this);
3007
3008 if (count == null) {
3009 StringBundler query = new StringBundler(2);
3010
3011 query.append(_SQL_COUNT_GROUP__WHERE);
3012
3013 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3014
3015 String sql = query.toString();
3016
3017 Session session = null;
3018
3019 try {
3020 session = openSession();
3021
3022 Query q = session.createQuery(sql);
3023
3024 QueryPos qPos = QueryPos.getInstance(q);
3025
3026 qPos.add(companyId);
3027
3028 count = (Long)q.uniqueResult();
3029 }
3030 catch (Exception e) {
3031 throw processException(e);
3032 }
3033 finally {
3034 if (count == null) {
3035 count = Long.valueOf(0);
3036 }
3037
3038 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3039 finderArgs, count);
3040
3041 closeSession(session);
3042 }
3043 }
3044
3045 return count.intValue();
3046 }
3047
3048
3055 public int countByLiveGroupId(long liveGroupId) throws SystemException {
3056 Object[] finderArgs = new Object[] { liveGroupId };
3057
3058 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
3059 finderArgs, this);
3060
3061 if (count == null) {
3062 StringBundler query = new StringBundler(2);
3063
3064 query.append(_SQL_COUNT_GROUP__WHERE);
3065
3066 query.append(_FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2);
3067
3068 String sql = query.toString();
3069
3070 Session session = null;
3071
3072 try {
3073 session = openSession();
3074
3075 Query q = session.createQuery(sql);
3076
3077 QueryPos qPos = QueryPos.getInstance(q);
3078
3079 qPos.add(liveGroupId);
3080
3081 count = (Long)q.uniqueResult();
3082 }
3083 catch (Exception e) {
3084 throw processException(e);
3085 }
3086 finally {
3087 if (count == null) {
3088 count = Long.valueOf(0);
3089 }
3090
3091 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LIVEGROUPID,
3092 finderArgs, count);
3093
3094 closeSession(session);
3095 }
3096 }
3097
3098 return count.intValue();
3099 }
3100
3101
3109 public int countByC_N(long companyId, String name)
3110 throws SystemException {
3111 Object[] finderArgs = new Object[] { companyId, name };
3112
3113 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
3114 finderArgs, this);
3115
3116 if (count == null) {
3117 StringBundler query = new StringBundler(3);
3118
3119 query.append(_SQL_COUNT_GROUP__WHERE);
3120
3121 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3122
3123 if (name == null) {
3124 query.append(_FINDER_COLUMN_C_N_NAME_1);
3125 }
3126 else {
3127 if (name.equals(StringPool.BLANK)) {
3128 query.append(_FINDER_COLUMN_C_N_NAME_3);
3129 }
3130 else {
3131 query.append(_FINDER_COLUMN_C_N_NAME_2);
3132 }
3133 }
3134
3135 String sql = query.toString();
3136
3137 Session session = null;
3138
3139 try {
3140 session = openSession();
3141
3142 Query q = session.createQuery(sql);
3143
3144 QueryPos qPos = QueryPos.getInstance(q);
3145
3146 qPos.add(companyId);
3147
3148 if (name != null) {
3149 qPos.add(name);
3150 }
3151
3152 count = (Long)q.uniqueResult();
3153 }
3154 catch (Exception e) {
3155 throw processException(e);
3156 }
3157 finally {
3158 if (count == null) {
3159 count = Long.valueOf(0);
3160 }
3161
3162 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
3163 count);
3164
3165 closeSession(session);
3166 }
3167 }
3168
3169 return count.intValue();
3170 }
3171
3172
3180 public int countByC_F(long companyId, String friendlyURL)
3181 throws SystemException {
3182 Object[] finderArgs = new Object[] { companyId, friendlyURL };
3183
3184 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_F,
3185 finderArgs, this);
3186
3187 if (count == null) {
3188 StringBundler query = new StringBundler(3);
3189
3190 query.append(_SQL_COUNT_GROUP__WHERE);
3191
3192 query.append(_FINDER_COLUMN_C_F_COMPANYID_2);
3193
3194 if (friendlyURL == null) {
3195 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_1);
3196 }
3197 else {
3198 if (friendlyURL.equals(StringPool.BLANK)) {
3199 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_3);
3200 }
3201 else {
3202 query.append(_FINDER_COLUMN_C_F_FRIENDLYURL_2);
3203 }
3204 }
3205
3206 String sql = query.toString();
3207
3208 Session session = null;
3209
3210 try {
3211 session = openSession();
3212
3213 Query q = session.createQuery(sql);
3214
3215 QueryPos qPos = QueryPos.getInstance(q);
3216
3217 qPos.add(companyId);
3218
3219 if (friendlyURL != null) {
3220 qPos.add(friendlyURL);
3221 }
3222
3223 count = (Long)q.uniqueResult();
3224 }
3225 catch (Exception e) {
3226 throw processException(e);
3227 }
3228 finally {
3229 if (count == null) {
3230 count = Long.valueOf(0);
3231 }
3232
3233 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_F, finderArgs,
3234 count);
3235
3236 closeSession(session);
3237 }
3238 }
3239
3240 return count.intValue();
3241 }
3242
3243
3251 public int countByT_A(int type, boolean active) throws SystemException {
3252 Object[] finderArgs = new Object[] { type, active };
3253
3254 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_A,
3255 finderArgs, this);
3256
3257 if (count == null) {
3258 StringBundler query = new StringBundler(3);
3259
3260 query.append(_SQL_COUNT_GROUP__WHERE);
3261
3262 query.append(_FINDER_COLUMN_T_A_TYPE_2);
3263
3264 query.append(_FINDER_COLUMN_T_A_ACTIVE_2);
3265
3266 String sql = query.toString();
3267
3268 Session session = null;
3269
3270 try {
3271 session = openSession();
3272
3273 Query q = session.createQuery(sql);
3274
3275 QueryPos qPos = QueryPos.getInstance(q);
3276
3277 qPos.add(type);
3278
3279 qPos.add(active);
3280
3281 count = (Long)q.uniqueResult();
3282 }
3283 catch (Exception e) {
3284 throw processException(e);
3285 }
3286 finally {
3287 if (count == null) {
3288 count = Long.valueOf(0);
3289 }
3290
3291 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_A, finderArgs,
3292 count);
3293
3294 closeSession(session);
3295 }
3296 }
3297
3298 return count.intValue();
3299 }
3300
3301
3310 public int countByC_C_C(long companyId, long classNameId, long classPK)
3311 throws SystemException {
3312 Object[] finderArgs = new Object[] { companyId, classNameId, classPK };
3313
3314 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_C,
3315 finderArgs, this);
3316
3317 if (count == null) {
3318 StringBundler query = new StringBundler(4);
3319
3320 query.append(_SQL_COUNT_GROUP__WHERE);
3321
3322 query.append(_FINDER_COLUMN_C_C_C_COMPANYID_2);
3323
3324 query.append(_FINDER_COLUMN_C_C_C_CLASSNAMEID_2);
3325
3326 query.append(_FINDER_COLUMN_C_C_C_CLASSPK_2);
3327
3328 String sql = query.toString();
3329
3330 Session session = null;
3331
3332 try {
3333 session = openSession();
3334
3335 Query q = session.createQuery(sql);
3336
3337 QueryPos qPos = QueryPos.getInstance(q);
3338
3339 qPos.add(companyId);
3340
3341 qPos.add(classNameId);
3342
3343 qPos.add(classPK);
3344
3345 count = (Long)q.uniqueResult();
3346 }
3347 catch (Exception e) {
3348 throw processException(e);
3349 }
3350 finally {
3351 if (count == null) {
3352 count = Long.valueOf(0);
3353 }
3354
3355 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_C,
3356 finderArgs, count);
3357
3358 closeSession(session);
3359 }
3360 }
3361
3362 return count.intValue();
3363 }
3364
3365
3374 public int countByC_L_N(long companyId, long liveGroupId, String name)
3375 throws SystemException {
3376 Object[] finderArgs = new Object[] { companyId, liveGroupId, name };
3377
3378 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_L_N,
3379 finderArgs, this);
3380
3381 if (count == null) {
3382 StringBundler query = new StringBundler(4);
3383
3384 query.append(_SQL_COUNT_GROUP__WHERE);
3385
3386 query.append(_FINDER_COLUMN_C_L_N_COMPANYID_2);
3387
3388 query.append(_FINDER_COLUMN_C_L_N_LIVEGROUPID_2);
3389
3390 if (name == null) {
3391 query.append(_FINDER_COLUMN_C_L_N_NAME_1);
3392 }
3393 else {
3394 if (name.equals(StringPool.BLANK)) {
3395 query.append(_FINDER_COLUMN_C_L_N_NAME_3);
3396 }
3397 else {
3398 query.append(_FINDER_COLUMN_C_L_N_NAME_2);
3399 }
3400 }
3401
3402 String sql = query.toString();
3403
3404 Session session = null;
3405
3406 try {
3407 session = openSession();
3408
3409 Query q = session.createQuery(sql);
3410
3411 QueryPos qPos = QueryPos.getInstance(q);
3412
3413 qPos.add(companyId);
3414
3415 qPos.add(liveGroupId);
3416
3417 if (name != null) {
3418 qPos.add(name);
3419 }
3420
3421 count = (Long)q.uniqueResult();
3422 }
3423 catch (Exception e) {
3424 throw processException(e);
3425 }
3426 finally {
3427 if (count == null) {
3428 count = Long.valueOf(0);
3429 }
3430
3431 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_L_N,
3432 finderArgs, count);
3433
3434 closeSession(session);
3435 }
3436 }
3437
3438 return count.intValue();
3439 }
3440
3441
3451 public int countByC_C_L_N(long companyId, long classNameId,
3452 long liveGroupId, String name) throws SystemException {
3453 Object[] finderArgs = new Object[] {
3454 companyId, classNameId, liveGroupId, name
3455 };
3456
3457 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C_L_N,
3458 finderArgs, this);
3459
3460 if (count == null) {
3461 StringBundler query = new StringBundler(5);
3462
3463 query.append(_SQL_COUNT_GROUP__WHERE);
3464
3465 query.append(_FINDER_COLUMN_C_C_L_N_COMPANYID_2);
3466
3467 query.append(_FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2);
3468
3469 query.append(_FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2);
3470
3471 if (name == null) {
3472 query.append(_FINDER_COLUMN_C_C_L_N_NAME_1);
3473 }
3474 else {
3475 if (name.equals(StringPool.BLANK)) {
3476 query.append(_FINDER_COLUMN_C_C_L_N_NAME_3);
3477 }
3478 else {
3479 query.append(_FINDER_COLUMN_C_C_L_N_NAME_2);
3480 }
3481 }
3482
3483 String sql = query.toString();
3484
3485 Session session = null;
3486
3487 try {
3488 session = openSession();
3489
3490 Query q = session.createQuery(sql);
3491
3492 QueryPos qPos = QueryPos.getInstance(q);
3493
3494 qPos.add(companyId);
3495
3496 qPos.add(classNameId);
3497
3498 qPos.add(liveGroupId);
3499
3500 if (name != null) {
3501 qPos.add(name);
3502 }
3503
3504 count = (Long)q.uniqueResult();
3505 }
3506 catch (Exception e) {
3507 throw processException(e);
3508 }
3509 finally {
3510 if (count == null) {
3511 count = Long.valueOf(0);
3512 }
3513
3514 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C_L_N,
3515 finderArgs, count);
3516
3517 closeSession(session);
3518 }
3519 }
3520
3521 return count.intValue();
3522 }
3523
3524
3530 public int countAll() throws SystemException {
3531 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3532 FINDER_ARGS_EMPTY, this);
3533
3534 if (count == null) {
3535 Session session = null;
3536
3537 try {
3538 session = openSession();
3539
3540 Query q = session.createQuery(_SQL_COUNT_GROUP_);
3541
3542 count = (Long)q.uniqueResult();
3543 }
3544 catch (Exception e) {
3545 throw processException(e);
3546 }
3547 finally {
3548 if (count == null) {
3549 count = Long.valueOf(0);
3550 }
3551
3552 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3553 FINDER_ARGS_EMPTY, count);
3554
3555 closeSession(session);
3556 }
3557 }
3558
3559 return count.intValue();
3560 }
3561
3562
3569 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
3570 throws SystemException {
3571 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3572 }
3573
3574
3587 public List<com.liferay.portal.model.Organization> getOrganizations(
3588 long pk, int start, int end) throws SystemException {
3589 return getOrganizations(pk, start, end, null);
3590 }
3591
3592 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3593 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3594 com.liferay.portal.model.impl.OrganizationImpl.class,
3595 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getOrganizations",
3596 new String[] {
3597 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3598 "com.liferay.portal.kernel.util.OrderByComparator"
3599 });
3600
3601 static {
3602 FINDER_PATH_GET_ORGANIZATIONS.setCacheKeyGeneratorCacheName(null);
3603 }
3604
3605
3619 public List<com.liferay.portal.model.Organization> getOrganizations(
3620 long pk, int start, int end, OrderByComparator orderByComparator)
3621 throws SystemException {
3622 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3623
3624 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
3625 finderArgs, this);
3626
3627 if (list == null) {
3628 Session session = null;
3629
3630 try {
3631 session = openSession();
3632
3633 String sql = null;
3634
3635 if (orderByComparator != null) {
3636 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
3637 .concat(orderByComparator.getOrderBy());
3638 }
3639 else {
3640 sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
3641 }
3642
3643 SQLQuery q = session.createSQLQuery(sql);
3644
3645 q.addEntity("Organization_",
3646 com.liferay.portal.model.impl.OrganizationImpl.class);
3647
3648 QueryPos qPos = QueryPos.getInstance(q);
3649
3650 qPos.add(pk);
3651
3652 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
3653 getDialect(), start, end);
3654 }
3655 catch (Exception e) {
3656 throw processException(e);
3657 }
3658 finally {
3659 if (list == null) {
3660 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
3661 finderArgs);
3662 }
3663 else {
3664 organizationPersistence.cacheResult(list);
3665
3666 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
3667 finderArgs, list);
3668 }
3669
3670 closeSession(session);
3671 }
3672 }
3673
3674 return list;
3675 }
3676
3677 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3678 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
3679 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3680 "getOrganizationsSize", new String[] { Long.class.getName() });
3681
3682 static {
3683 FINDER_PATH_GET_ORGANIZATIONS_SIZE.setCacheKeyGeneratorCacheName(null);
3684 }
3685
3686
3693 public int getOrganizationsSize(long pk) throws SystemException {
3694 Object[] finderArgs = new Object[] { pk };
3695
3696 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3697 finderArgs, this);
3698
3699 if (count == null) {
3700 Session session = null;
3701
3702 try {
3703 session = openSession();
3704
3705 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
3706
3707 q.addScalar(COUNT_COLUMN_NAME,
3708 com.liferay.portal.kernel.dao.orm.Type.LONG);
3709
3710 QueryPos qPos = QueryPos.getInstance(q);
3711
3712 qPos.add(pk);
3713
3714 count = (Long)q.uniqueResult();
3715 }
3716 catch (Exception e) {
3717 throw processException(e);
3718 }
3719 finally {
3720 if (count == null) {
3721 count = Long.valueOf(0);
3722 }
3723
3724 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3725 finderArgs, count);
3726
3727 closeSession(session);
3728 }
3729 }
3730
3731 return count.intValue();
3732 }
3733
3734 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3735 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Boolean.class,
3736 GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3737 "containsOrganization",
3738 new String[] { Long.class.getName(), Long.class.getName() });
3739
3740
3748 public boolean containsOrganization(long pk, long organizationPK)
3749 throws SystemException {
3750 Object[] finderArgs = new Object[] { pk, organizationPK };
3751
3752 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3753 finderArgs, this);
3754
3755 if (value == null) {
3756 try {
3757 value = Boolean.valueOf(containsOrganization.contains(pk,
3758 organizationPK));
3759 }
3760 catch (Exception e) {
3761 throw processException(e);
3762 }
3763 finally {
3764 if (value == null) {
3765 value = Boolean.FALSE;
3766 }
3767
3768 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3769 finderArgs, value);
3770 }
3771 }
3772
3773 return value.booleanValue();
3774 }
3775
3776
3783 public boolean containsOrganizations(long pk) throws SystemException {
3784 if (getOrganizationsSize(pk) > 0) {
3785 return true;
3786 }
3787 else {
3788 return false;
3789 }
3790 }
3791
3792
3799 public void addOrganization(long pk, long organizationPK)
3800 throws SystemException {
3801 try {
3802 addOrganization.add(pk, organizationPK);
3803 }
3804 catch (Exception e) {
3805 throw processException(e);
3806 }
3807 finally {
3808 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3809 }
3810 }
3811
3812
3819 public void addOrganization(long pk,
3820 com.liferay.portal.model.Organization organization)
3821 throws SystemException {
3822 try {
3823 addOrganization.add(pk, organization.getPrimaryKey());
3824 }
3825 catch (Exception e) {
3826 throw processException(e);
3827 }
3828 finally {
3829 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3830 }
3831 }
3832
3833
3840 public void addOrganizations(long pk, long[] organizationPKs)
3841 throws SystemException {
3842 try {
3843 for (long organizationPK : organizationPKs) {
3844 addOrganization.add(pk, organizationPK);
3845 }
3846 }
3847 catch (Exception e) {
3848 throw processException(e);
3849 }
3850 finally {
3851 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3852 }
3853 }
3854
3855
3862 public void addOrganizations(long pk,
3863 List<com.liferay.portal.model.Organization> organizations)
3864 throws SystemException {
3865 try {
3866 for (com.liferay.portal.model.Organization organization : organizations) {
3867 addOrganization.add(pk, organization.getPrimaryKey());
3868 }
3869 }
3870 catch (Exception e) {
3871 throw processException(e);
3872 }
3873 finally {
3874 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3875 }
3876 }
3877
3878
3884 public void clearOrganizations(long pk) throws SystemException {
3885 try {
3886 clearOrganizations.clear(pk);
3887 }
3888 catch (Exception e) {
3889 throw processException(e);
3890 }
3891 finally {
3892 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3893 }
3894 }
3895
3896
3903 public void removeOrganization(long pk, long organizationPK)
3904 throws SystemException {
3905 try {
3906 removeOrganization.remove(pk, organizationPK);
3907 }
3908 catch (Exception e) {
3909 throw processException(e);
3910 }
3911 finally {
3912 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3913 }
3914 }
3915
3916
3923 public void removeOrganization(long pk,
3924 com.liferay.portal.model.Organization organization)
3925 throws SystemException {
3926 try {
3927 removeOrganization.remove(pk, organization.getPrimaryKey());
3928 }
3929 catch (Exception e) {
3930 throw processException(e);
3931 }
3932 finally {
3933 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3934 }
3935 }
3936
3937
3944 public void removeOrganizations(long pk, long[] organizationPKs)
3945 throws SystemException {
3946 try {
3947 for (long organizationPK : organizationPKs) {
3948 removeOrganization.remove(pk, organizationPK);
3949 }
3950 }
3951 catch (Exception e) {
3952 throw processException(e);
3953 }
3954 finally {
3955 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3956 }
3957 }
3958
3959
3966 public void removeOrganizations(long pk,
3967 List<com.liferay.portal.model.Organization> organizations)
3968 throws SystemException {
3969 try {
3970 for (com.liferay.portal.model.Organization organization : organizations) {
3971 removeOrganization.remove(pk, organization.getPrimaryKey());
3972 }
3973 }
3974 catch (Exception e) {
3975 throw processException(e);
3976 }
3977 finally {
3978 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3979 }
3980 }
3981
3982
3989 public void setOrganizations(long pk, long[] organizationPKs)
3990 throws SystemException {
3991 try {
3992 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
3993
3994 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
3995
3996 for (com.liferay.portal.model.Organization organization : organizations) {
3997 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
3998 removeOrganization.remove(pk, organization.getPrimaryKey());
3999 }
4000 }
4001
4002 for (Long organizationPK : organizationPKSet) {
4003 addOrganization.add(pk, organizationPK);
4004 }
4005 }
4006 catch (Exception e) {
4007 throw processException(e);
4008 }
4009 finally {
4010 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4011 }
4012 }
4013
4014
4021 public void setOrganizations(long pk,
4022 List<com.liferay.portal.model.Organization> organizations)
4023 throws SystemException {
4024 try {
4025 long[] organizationPKs = new long[organizations.size()];
4026
4027 for (int i = 0; i < organizations.size(); i++) {
4028 com.liferay.portal.model.Organization organization = organizations.get(i);
4029
4030 organizationPKs[i] = organization.getPrimaryKey();
4031 }
4032
4033 setOrganizations(pk, organizationPKs);
4034 }
4035 catch (Exception e) {
4036 throw processException(e);
4037 }
4038 finally {
4039 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4040 }
4041 }
4042
4043
4050 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
4051 throws SystemException {
4052 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4053 }
4054
4055
4068 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
4069 int start, int end) throws SystemException {
4070 return getPermissions(pk, start, end, null);
4071 }
4072
4073 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
4074 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
4075 com.liferay.portal.model.impl.PermissionImpl.class,
4076 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
4077 "getPermissions",
4078 new String[] {
4079 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4080 "com.liferay.portal.kernel.util.OrderByComparator"
4081 });
4082
4083 static {
4084 FINDER_PATH_GET_PERMISSIONS.setCacheKeyGeneratorCacheName(null);
4085 }
4086
4087
4101 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
4102 int start, int end, OrderByComparator orderByComparator)
4103 throws SystemException {
4104 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4105
4106 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
4107 finderArgs, this);
4108
4109 if (list == null) {
4110 Session session = null;
4111
4112 try {
4113 session = openSession();
4114
4115 String sql = null;
4116
4117 if (orderByComparator != null) {
4118 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
4119 .concat(orderByComparator.getOrderBy());
4120 }
4121 else {
4122 sql = _SQL_GETPERMISSIONS;
4123 }
4124
4125 SQLQuery q = session.createSQLQuery(sql);
4126
4127 q.addEntity("Permission_",
4128 com.liferay.portal.model.impl.PermissionImpl.class);
4129
4130 QueryPos qPos = QueryPos.getInstance(q);
4131
4132 qPos.add(pk);
4133
4134 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
4135 getDialect(), start, end);
4136 }
4137 catch (Exception e) {
4138 throw processException(e);
4139 }
4140 finally {
4141 if (list == null) {
4142 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
4143 finderArgs);
4144 }
4145 else {
4146 permissionPersistence.cacheResult(list);
4147
4148 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
4149 finderArgs, list);
4150 }
4151
4152 closeSession(session);
4153 }
4154 }
4155
4156 return list;
4157 }
4158
4159 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
4160 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS, Long.class,
4161 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
4162 "getPermissionsSize", new String[] { Long.class.getName() });
4163
4164 static {
4165 FINDER_PATH_GET_PERMISSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
4166 }
4167
4168
4175 public int getPermissionsSize(long pk) throws SystemException {
4176 Object[] finderArgs = new Object[] { pk };
4177
4178 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
4179 finderArgs, this);
4180
4181 if (count == null) {
4182 Session session = null;
4183
4184 try {
4185 session = openSession();
4186
4187 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
4188
4189 q.addScalar(COUNT_COLUMN_NAME,
4190 com.liferay.portal.kernel.dao.orm.Type.LONG);
4191
4192 QueryPos qPos = QueryPos.getInstance(q);
4193
4194 qPos.add(pk);
4195
4196 count = (Long)q.uniqueResult();
4197 }
4198 catch (Exception e) {
4199 throw processException(e);
4200 }
4201 finally {
4202 if (count == null) {
4203 count = Long.valueOf(0);
4204 }
4205
4206 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
4207 finderArgs, count);
4208
4209 closeSession(session);
4210 }
4211 }
4212
4213 return count.intValue();
4214 }
4215
4216 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
4217 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS,
4218 Boolean.class,
4219 GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME,
4220 "containsPermission",
4221 new String[] { Long.class.getName(), Long.class.getName() });
4222
4223
4231 public boolean containsPermission(long pk, long permissionPK)
4232 throws SystemException {
4233 Object[] finderArgs = new Object[] { pk, permissionPK };
4234
4235 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
4236 finderArgs, this);
4237
4238 if (value == null) {
4239 try {
4240 value = Boolean.valueOf(containsPermission.contains(pk,
4241 permissionPK));
4242 }
4243 catch (Exception e) {
4244 throw processException(e);
4245 }
4246 finally {
4247 if (value == null) {
4248 value = Boolean.FALSE;
4249 }
4250
4251 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
4252 finderArgs, value);
4253 }
4254 }
4255
4256 return value.booleanValue();
4257 }
4258
4259
4266 public boolean containsPermissions(long pk) throws SystemException {
4267 if (getPermissionsSize(pk) > 0) {
4268 return true;
4269 }
4270 else {
4271 return false;
4272 }
4273 }
4274
4275
4282 public void addPermission(long pk, long permissionPK)
4283 throws SystemException {
4284 try {
4285 addPermission.add(pk, permissionPK);
4286 }
4287 catch (Exception e) {
4288 throw processException(e);
4289 }
4290 finally {
4291 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4292 }
4293 }
4294
4295
4302 public void addPermission(long pk,
4303 com.liferay.portal.model.Permission permission)
4304 throws SystemException {
4305 try {
4306 addPermission.add(pk, permission.getPrimaryKey());
4307 }
4308 catch (Exception e) {
4309 throw processException(e);
4310 }
4311 finally {
4312 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4313 }
4314 }
4315
4316
4323 public void addPermissions(long pk, long[] permissionPKs)
4324 throws SystemException {
4325 try {
4326 for (long permissionPK : permissionPKs) {
4327 addPermission.add(pk, permissionPK);
4328 }
4329 }
4330 catch (Exception e) {
4331 throw processException(e);
4332 }
4333 finally {
4334 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4335 }
4336 }
4337
4338
4345 public void addPermissions(long pk,
4346 List<com.liferay.portal.model.Permission> permissions)
4347 throws SystemException {
4348 try {
4349 for (com.liferay.portal.model.Permission permission : permissions) {
4350 addPermission.add(pk, permission.getPrimaryKey());
4351 }
4352 }
4353 catch (Exception e) {
4354 throw processException(e);
4355 }
4356 finally {
4357 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4358 }
4359 }
4360
4361
4367 public void clearPermissions(long pk) throws SystemException {
4368 try {
4369 clearPermissions.clear(pk);
4370 }
4371 catch (Exception e) {
4372 throw processException(e);
4373 }
4374 finally {
4375 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4376 }
4377 }
4378
4379
4386 public void removePermission(long pk, long permissionPK)
4387 throws SystemException {
4388 try {
4389 removePermission.remove(pk, permissionPK);
4390 }
4391 catch (Exception e) {
4392 throw processException(e);
4393 }
4394 finally {
4395 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4396 }
4397 }
4398
4399
4406 public void removePermission(long pk,
4407 com.liferay.portal.model.Permission permission)
4408 throws SystemException {
4409 try {
4410 removePermission.remove(pk, permission.getPrimaryKey());
4411 }
4412 catch (Exception e) {
4413 throw processException(e);
4414 }
4415 finally {
4416 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4417 }
4418 }
4419
4420
4427 public void removePermissions(long pk, long[] permissionPKs)
4428 throws SystemException {
4429 try {
4430 for (long permissionPK : permissionPKs) {
4431 removePermission.remove(pk, permissionPK);
4432 }
4433 }
4434 catch (Exception e) {
4435 throw processException(e);
4436 }
4437 finally {
4438 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4439 }
4440 }
4441
4442
4449 public void removePermissions(long pk,
4450 List<com.liferay.portal.model.Permission> permissions)
4451 throws SystemException {
4452 try {
4453 for (com.liferay.portal.model.Permission permission : permissions) {
4454 removePermission.remove(pk, permission.getPrimaryKey());
4455 }
4456 }
4457 catch (Exception e) {
4458 throw processException(e);
4459 }
4460 finally {
4461 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4462 }
4463 }
4464
4465
4472 public void setPermissions(long pk, long[] permissionPKs)
4473 throws SystemException {
4474 try {
4475 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
4476
4477 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
4478
4479 for (com.liferay.portal.model.Permission permission : permissions) {
4480 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
4481 removePermission.remove(pk, permission.getPrimaryKey());
4482 }
4483 }
4484
4485 for (Long permissionPK : permissionPKSet) {
4486 addPermission.add(pk, permissionPK);
4487 }
4488 }
4489 catch (Exception e) {
4490 throw processException(e);
4491 }
4492 finally {
4493 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4494 }
4495 }
4496
4497
4504 public void setPermissions(long pk,
4505 List<com.liferay.portal.model.Permission> permissions)
4506 throws SystemException {
4507 try {
4508 long[] permissionPKs = new long[permissions.size()];
4509
4510 for (int i = 0; i < permissions.size(); i++) {
4511 com.liferay.portal.model.Permission permission = permissions.get(i);
4512
4513 permissionPKs[i] = permission.getPrimaryKey();
4514 }
4515
4516 setPermissions(pk, permissionPKs);
4517 }
4518 catch (Exception e) {
4519 throw processException(e);
4520 }
4521 finally {
4522 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_PERMISSIONS_NAME);
4523 }
4524 }
4525
4526
4533 public List<com.liferay.portal.model.Role> getRoles(long pk)
4534 throws SystemException {
4535 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4536 }
4537
4538
4551 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4552 int end) throws SystemException {
4553 return getRoles(pk, start, end, null);
4554 }
4555
4556 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4557 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES,
4558 com.liferay.portal.model.impl.RoleImpl.class,
4559 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRoles",
4560 new String[] {
4561 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4562 "com.liferay.portal.kernel.util.OrderByComparator"
4563 });
4564
4565 static {
4566 FINDER_PATH_GET_ROLES.setCacheKeyGeneratorCacheName(null);
4567 }
4568
4569
4583 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4584 int end, OrderByComparator orderByComparator) throws SystemException {
4585 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4586
4587 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
4588 finderArgs, this);
4589
4590 if (list == null) {
4591 Session session = null;
4592
4593 try {
4594 session = openSession();
4595
4596 String sql = null;
4597
4598 if (orderByComparator != null) {
4599 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
4600 .concat(orderByComparator.getOrderBy());
4601 }
4602 else {
4603 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
4604 }
4605
4606 SQLQuery q = session.createSQLQuery(sql);
4607
4608 q.addEntity("Role_",
4609 com.liferay.portal.model.impl.RoleImpl.class);
4610
4611 QueryPos qPos = QueryPos.getInstance(q);
4612
4613 qPos.add(pk);
4614
4615 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
4616 getDialect(), start, end);
4617 }
4618 catch (Exception e) {
4619 throw processException(e);
4620 }
4621 finally {
4622 if (list == null) {
4623 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
4624 finderArgs);
4625 }
4626 else {
4627 rolePersistence.cacheResult(list);
4628
4629 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
4630 finderArgs, list);
4631 }
4632
4633 closeSession(session);
4634 }
4635 }
4636
4637 return list;
4638 }
4639
4640 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4641 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Long.class,
4642 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "getRolesSize",
4643 new String[] { Long.class.getName() });
4644
4645 static {
4646 FINDER_PATH_GET_ROLES_SIZE.setCacheKeyGeneratorCacheName(null);
4647 }
4648
4649
4656 public int getRolesSize(long pk) throws SystemException {
4657 Object[] finderArgs = new Object[] { pk };
4658
4659 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
4660 finderArgs, this);
4661
4662 if (count == null) {
4663 Session session = null;
4664
4665 try {
4666 session = openSession();
4667
4668 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
4669
4670 q.addScalar(COUNT_COLUMN_NAME,
4671 com.liferay.portal.kernel.dao.orm.Type.LONG);
4672
4673 QueryPos qPos = QueryPos.getInstance(q);
4674
4675 qPos.add(pk);
4676
4677 count = (Long)q.uniqueResult();
4678 }
4679 catch (Exception e) {
4680 throw processException(e);
4681 }
4682 finally {
4683 if (count == null) {
4684 count = Long.valueOf(0);
4685 }
4686
4687 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
4688 finderArgs, count);
4689
4690 closeSession(session);
4691 }
4692 }
4693
4694 return count.intValue();
4695 }
4696
4697 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4698 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES, Boolean.class,
4699 GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME, "containsRole",
4700 new String[] { Long.class.getName(), Long.class.getName() });
4701
4702
4710 public boolean containsRole(long pk, long rolePK) throws SystemException {
4711 Object[] finderArgs = new Object[] { pk, rolePK };
4712
4713 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
4714 finderArgs, this);
4715
4716 if (value == null) {
4717 try {
4718 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
4719 }
4720 catch (Exception e) {
4721 throw processException(e);
4722 }
4723 finally {
4724 if (value == null) {
4725 value = Boolean.FALSE;
4726 }
4727
4728 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
4729 finderArgs, value);
4730 }
4731 }
4732
4733 return value.booleanValue();
4734 }
4735
4736
4743 public boolean containsRoles(long pk) throws SystemException {
4744 if (getRolesSize(pk) > 0) {
4745 return true;
4746 }
4747 else {
4748 return false;
4749 }
4750 }
4751
4752
4759 public void addRole(long pk, long rolePK) throws SystemException {
4760 try {
4761 addRole.add(pk, rolePK);
4762 }
4763 catch (Exception e) {
4764 throw processException(e);
4765 }
4766 finally {
4767 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4768 }
4769 }
4770
4771
4778 public void addRole(long pk, com.liferay.portal.model.Role role)
4779 throws SystemException {
4780 try {
4781 addRole.add(pk, role.getPrimaryKey());
4782 }
4783 catch (Exception e) {
4784 throw processException(e);
4785 }
4786 finally {
4787 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4788 }
4789 }
4790
4791
4798 public void addRoles(long pk, long[] rolePKs) throws SystemException {
4799 try {
4800 for (long rolePK : rolePKs) {
4801 addRole.add(pk, rolePK);
4802 }
4803 }
4804 catch (Exception e) {
4805 throw processException(e);
4806 }
4807 finally {
4808 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4809 }
4810 }
4811
4812
4819 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
4820 throws SystemException {
4821 try {
4822 for (com.liferay.portal.model.Role role : roles) {
4823 addRole.add(pk, role.getPrimaryKey());
4824 }
4825 }
4826 catch (Exception e) {
4827 throw processException(e);
4828 }
4829 finally {
4830 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4831 }
4832 }
4833
4834
4840 public void clearRoles(long pk) throws SystemException {
4841 try {
4842 clearRoles.clear(pk);
4843 }
4844 catch (Exception e) {
4845 throw processException(e);
4846 }
4847 finally {
4848 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4849 }
4850 }
4851
4852
4859 public void removeRole(long pk, long rolePK) throws SystemException {
4860 try {
4861 removeRole.remove(pk, rolePK);
4862 }
4863 catch (Exception e) {
4864 throw processException(e);
4865 }
4866 finally {
4867 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4868 }
4869 }
4870
4871
4878 public void removeRole(long pk, com.liferay.portal.model.Role role)
4879 throws SystemException {
4880 try {
4881 removeRole.remove(pk, role.getPrimaryKey());
4882 }
4883 catch (Exception e) {
4884 throw processException(e);
4885 }
4886 finally {
4887 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4888 }
4889 }
4890
4891
4898 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
4899 try {
4900 for (long rolePK : rolePKs) {
4901 removeRole.remove(pk, rolePK);
4902 }
4903 }
4904 catch (Exception e) {
4905 throw processException(e);
4906 }
4907 finally {
4908 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4909 }
4910 }
4911
4912
4919 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
4920 throws SystemException {
4921 try {
4922 for (com.liferay.portal.model.Role role : roles) {
4923 removeRole.remove(pk, role.getPrimaryKey());
4924 }
4925 }
4926 catch (Exception e) {
4927 throw processException(e);
4928 }
4929 finally {
4930 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4931 }
4932 }
4933
4934
4941 public void setRoles(long pk, long[] rolePKs) throws SystemException {
4942 try {
4943 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
4944
4945 List<com.liferay.portal.model.Role> roles = getRoles(pk);
4946
4947 for (com.liferay.portal.model.Role role : roles) {
4948 if (!rolePKSet.remove(role.getPrimaryKey())) {
4949 removeRole.remove(pk, role.getPrimaryKey());
4950 }
4951 }
4952
4953 for (Long rolePK : rolePKSet) {
4954 addRole.add(pk, rolePK);
4955 }
4956 }
4957 catch (Exception e) {
4958 throw processException(e);
4959 }
4960 finally {
4961 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4962 }
4963 }
4964
4965
4972 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
4973 throws SystemException {
4974 try {
4975 long[] rolePKs = new long[roles.size()];
4976
4977 for (int i = 0; i < roles.size(); i++) {
4978 com.liferay.portal.model.Role role = roles.get(i);
4979
4980 rolePKs[i] = role.getPrimaryKey();
4981 }
4982
4983 setRoles(pk, rolePKs);
4984 }
4985 catch (Exception e) {
4986 throw processException(e);
4987 }
4988 finally {
4989 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_ROLES_NAME);
4990 }
4991 }
4992
4993
5000 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
5001 throws SystemException {
5002 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5003 }
5004
5005
5018 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
5019 int start, int end) throws SystemException {
5020 return getUserGroups(pk, start, end, null);
5021 }
5022
5023 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
5024 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
5025 com.liferay.portal.model.impl.UserGroupImpl.class,
5026 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
5027 "getUserGroups",
5028 new String[] {
5029 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5030 "com.liferay.portal.kernel.util.OrderByComparator"
5031 });
5032
5033 static {
5034 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
5035 }
5036
5037
5051 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
5052 int start, int end, OrderByComparator orderByComparator)
5053 throws SystemException {
5054 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5055
5056 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
5057 finderArgs, this);
5058
5059 if (list == null) {
5060 Session session = null;
5061
5062 try {
5063 session = openSession();
5064
5065 String sql = null;
5066
5067 if (orderByComparator != null) {
5068 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
5069 .concat(orderByComparator.getOrderBy());
5070 }
5071 else {
5072 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
5073 }
5074
5075 SQLQuery q = session.createSQLQuery(sql);
5076
5077 q.addEntity("UserGroup",
5078 com.liferay.portal.model.impl.UserGroupImpl.class);
5079
5080 QueryPos qPos = QueryPos.getInstance(q);
5081
5082 qPos.add(pk);
5083
5084 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
5085 getDialect(), start, end);
5086 }
5087 catch (Exception e) {
5088 throw processException(e);
5089 }
5090 finally {
5091 if (list == null) {
5092 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
5093 finderArgs);
5094 }
5095 else {
5096 userGroupPersistence.cacheResult(list);
5097
5098 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
5099 finderArgs, list);
5100 }
5101
5102 closeSession(session);
5103 }
5104 }
5105
5106 return list;
5107 }
5108
5109 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
5110 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS, Long.class,
5111 GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
5112 "getUserGroupsSize", new String[] { Long.class.getName() });
5113
5114 static {
5115 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
5116 }
5117
5118
5125 public int getUserGroupsSize(long pk) throws SystemException {
5126 Object[] finderArgs = new Object[] { pk };
5127
5128 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
5129 finderArgs, this);
5130
5131 if (count == null) {
5132 Session session = null;
5133
5134 try {
5135 session = openSession();
5136
5137 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
5138
5139 q.addScalar(COUNT_COLUMN_NAME,
5140 com.liferay.portal.kernel.dao.orm.Type.LONG);
5141
5142 QueryPos qPos = QueryPos.getInstance(q);
5143
5144 qPos.add(pk);
5145
5146 count = (Long)q.uniqueResult();
5147 }
5148 catch (Exception e) {
5149 throw processException(e);
5150 }
5151 finally {
5152 if (count == null) {
5153 count = Long.valueOf(0);
5154 }
5155
5156 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
5157 finderArgs, count);
5158
5159 closeSession(session);
5160 }
5161 }
5162
5163 return count.intValue();
5164 }
5165
5166 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
5167 GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_USERGROUPS,
5168 Boolean.class, GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME,
5169 "containsUserGroup",
5170 new String[] { Long.class.getName(), Long.class.getName() });
5171
5172
5180 public boolean containsUserGroup(long pk, long userGroupPK)
5181 throws SystemException {
5182 Object[] finderArgs = new Object[] { pk, userGroupPK };
5183
5184 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
5185 finderArgs, this);
5186
5187 if (value == null) {
5188 try {
5189 value = Boolean.valueOf(containsUserGroup.contains(pk,
5190 userGroupPK));
5191 }
5192 catch (Exception e) {
5193 throw processException(e);
5194 }
5195 finally {
5196 if (value == null) {
5197 value = Boolean.FALSE;
5198 }
5199
5200 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
5201 finderArgs, value);
5202 }
5203 }
5204
5205 return value.booleanValue();
5206 }
5207
5208
5215 public boolean containsUserGroups(long pk) throws SystemException {
5216 if (getUserGroupsSize(pk) > 0) {
5217 return true;
5218 }
5219 else {
5220 return false;
5221 }
5222 }
5223
5224
5231 public void addUserGroup(long pk, long userGroupPK)
5232 throws SystemException {
5233 try {
5234 addUserGroup.add(pk, userGroupPK);
5235 }
5236 catch (Exception e) {
5237 throw processException(e);
5238 }
5239 finally {
5240 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5241 }
5242 }
5243
5244
5251 public void addUserGroup(long pk,
5252 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5253 try {
5254 addUserGroup.add(pk, userGroup.getPrimaryKey());
5255 }
5256 catch (Exception e) {
5257 throw processException(e);
5258 }
5259 finally {
5260 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5261 }
5262 }
5263
5264
5271 public void addUserGroups(long pk, long[] userGroupPKs)
5272 throws SystemException {
5273 try {
5274 for (long userGroupPK : userGroupPKs) {
5275 addUserGroup.add(pk, userGroupPK);
5276 }
5277 }
5278 catch (Exception e) {
5279 throw processException(e);
5280 }
5281 finally {
5282 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5283 }
5284 }
5285
5286
5293 public void addUserGroups(long pk,
5294 List<com.liferay.portal.model.UserGroup> userGroups)
5295 throws SystemException {
5296 try {
5297 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5298 addUserGroup.add(pk, userGroup.getPrimaryKey());
5299 }
5300 }
5301 catch (Exception e) {
5302 throw processException(e);
5303 }
5304 finally {
5305 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5306 }
5307 }
5308
5309
5315 public void clearUserGroups(long pk) throws SystemException {
5316 try {
5317 clearUserGroups.clear(pk);
5318 }
5319 catch (Exception e) {
5320 throw processException(e);
5321 }
5322 finally {
5323 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5324 }
5325 }
5326
5327
5334 public void removeUserGroup(long pk, long userGroupPK)
5335 throws SystemException {
5336 try {
5337 removeUserGroup.remove(pk, userGroupPK);
5338 }
5339 catch (Exception e) {
5340 throw processException(e);
5341 }
5342 finally {
5343 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5344 }
5345 }
5346
5347
5354 public void removeUserGroup(long pk,
5355 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
5356 try {
5357 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5358 }
5359 catch (Exception e) {
5360 throw processException(e);
5361 }
5362 finally {
5363 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5364 }
5365 }
5366
5367
5374 public void removeUserGroups(long pk, long[] userGroupPKs)
5375 throws SystemException {
5376 try {
5377 for (long userGroupPK : userGroupPKs) {
5378 removeUserGroup.remove(pk, userGroupPK);
5379 }
5380 }
5381 catch (Exception e) {
5382 throw processException(e);
5383 }
5384 finally {
5385 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5386 }
5387 }
5388
5389
5396 public void removeUserGroups(long pk,
5397 List<com.liferay.portal.model.UserGroup> userGroups)
5398 throws SystemException {
5399 try {
5400 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5401 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5402 }
5403 }
5404 catch (Exception e) {
5405 throw processException(e);
5406 }
5407 finally {
5408 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5409 }
5410 }
5411
5412
5419 public void setUserGroups(long pk, long[] userGroupPKs)
5420 throws SystemException {
5421 try {
5422 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
5423
5424 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
5425
5426 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5427 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
5428 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
5429 }
5430 }
5431
5432 for (Long userGroupPK : userGroupPKSet) {
5433 addUserGroup.add(pk, userGroupPK);
5434 }
5435 }
5436 catch (Exception e) {
5437 throw processException(e);
5438 }
5439 finally {
5440 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5441 }
5442 }
5443
5444
5451 public void setUserGroups(long pk,
5452 List<com.liferay.portal.model.UserGroup> userGroups)
5453 throws SystemException {
5454 try {
5455 long[] userGroupPKs = new long[userGroups.size()];
5456
5457 for (int i = 0; i < userGroups.size(); i++) {
5458 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
5459
5460 userGroupPKs[i] = userGroup.getPrimaryKey();
5461 }
5462
5463 setUserGroups(pk, userGroupPKs);
5464 }
5465 catch (Exception e) {
5466 throw processException(e);
5467 }
5468 finally {
5469 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_GROUPS_USERGROUPS_NAME);
5470 }
5471 }
5472
5473
5480 public List<com.liferay.portal.model.User> getUsers(long pk)
5481 throws SystemException {
5482 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5483 }
5484
5485
5498 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5499 int end) throws SystemException {
5500 return getUsers(pk, start, end, null);
5501 }
5502
5503 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5504 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
5505 com.liferay.portal.model.impl.UserImpl.class,
5506 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsers",
5507 new String[] {
5508 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5509 "com.liferay.portal.kernel.util.OrderByComparator"
5510 });
5511
5512 static {
5513 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
5514 }
5515
5516
5530 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5531 int end, OrderByComparator orderByComparator) throws SystemException {
5532 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5533
5534 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
5535 finderArgs, this);
5536
5537 if (list == null) {
5538 Session session = null;
5539
5540 try {
5541 session = openSession();
5542
5543 String sql = null;
5544
5545 if (orderByComparator != null) {
5546 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
5547 .concat(orderByComparator.getOrderBy());
5548 }
5549 else {
5550 sql = _SQL_GETUSERS;
5551 }
5552
5553 SQLQuery q = session.createSQLQuery(sql);
5554
5555 q.addEntity("User_",
5556 com.liferay.portal.model.impl.UserImpl.class);
5557
5558 QueryPos qPos = QueryPos.getInstance(q);
5559
5560 qPos.add(pk);
5561
5562 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
5563 getDialect(), start, end);
5564 }
5565 catch (Exception e) {
5566 throw processException(e);
5567 }
5568 finally {
5569 if (list == null) {
5570 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
5571 finderArgs);
5572 }
5573 else {
5574 userPersistence.cacheResult(list);
5575
5576 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
5577 finderArgs, list);
5578 }
5579
5580 closeSession(session);
5581 }
5582 }
5583
5584 return list;
5585 }
5586
5587 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5588 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
5589 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getUsersSize",
5590 new String[] { Long.class.getName() });
5591
5592 static {
5593 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
5594 }
5595
5596
5603 public int getUsersSize(long pk) throws SystemException {
5604 Object[] finderArgs = new Object[] { pk };
5605
5606 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
5607 finderArgs, this);
5608
5609 if (count == null) {
5610 Session session = null;
5611
5612 try {
5613 session = openSession();
5614
5615 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
5616
5617 q.addScalar(COUNT_COLUMN_NAME,
5618 com.liferay.portal.kernel.dao.orm.Type.LONG);
5619
5620 QueryPos qPos = QueryPos.getInstance(q);
5621
5622 qPos.add(pk);
5623
5624 count = (Long)q.uniqueResult();
5625 }
5626 catch (Exception e) {
5627 throw processException(e);
5628 }
5629 finally {
5630 if (count == null) {
5631 count = Long.valueOf(0);
5632 }
5633
5634 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
5635 finderArgs, count);
5636
5637 closeSession(session);
5638 }
5639 }
5640
5641 return count.intValue();
5642 }
5643
5644 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
5645 GroupModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
5646 GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsUser",
5647 new String[] { Long.class.getName(), Long.class.getName() });
5648
5649
5657 public boolean containsUser(long pk, long userPK) throws SystemException {
5658 Object[] finderArgs = new Object[] { pk, userPK };
5659
5660 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
5661 finderArgs, this);
5662
5663 if (value == null) {
5664 try {
5665 value = Boolean.valueOf(containsUser.contains(pk, userPK));
5666 }
5667 catch (Exception e) {
5668 throw processException(e);
5669 }
5670 finally {
5671 if (value == null) {
5672 value = Boolean.FALSE;
5673 }
5674
5675 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
5676 finderArgs, value);
5677 }
5678 }
5679
5680 return value.booleanValue();
5681 }
5682
5683
5690 public boolean containsUsers(long pk) throws SystemException {
5691 if (getUsersSize(pk) > 0) {
5692 return true;
5693 }
5694 else {
5695 return false;
5696 }
5697 }
5698
5699
5706 public void addUser(long pk, long userPK) throws SystemException {
5707 try {
5708 addUser.add(pk, userPK);
5709 }
5710 catch (Exception e) {
5711 throw processException(e);
5712 }
5713 finally {
5714 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5715 }
5716 }
5717
5718
5725 public void addUser(long pk, com.liferay.portal.model.User user)
5726 throws SystemException {
5727 try {
5728 addUser.add(pk, user.getPrimaryKey());
5729 }
5730 catch (Exception e) {
5731 throw processException(e);
5732 }
5733 finally {
5734 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5735 }
5736 }
5737
5738
5745 public void addUsers(long pk, long[] userPKs) throws SystemException {
5746 try {
5747 for (long userPK : userPKs) {
5748 addUser.add(pk, userPK);
5749 }
5750 }
5751 catch (Exception e) {
5752 throw processException(e);
5753 }
5754 finally {
5755 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5756 }
5757 }
5758
5759
5766 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
5767 throws SystemException {
5768 try {
5769 for (com.liferay.portal.model.User user : users) {
5770 addUser.add(pk, user.getPrimaryKey());
5771 }
5772 }
5773 catch (Exception e) {
5774 throw processException(e);
5775 }
5776 finally {
5777 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5778 }
5779 }
5780
5781
5787 public void clearUsers(long pk) throws SystemException {
5788 try {
5789 clearUsers.clear(pk);
5790 }
5791 catch (Exception e) {
5792 throw processException(e);
5793 }
5794 finally {
5795 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5796 }
5797 }
5798
5799
5806 public void removeUser(long pk, long userPK) throws SystemException {
5807 try {
5808 removeUser.remove(pk, userPK);
5809 }
5810 catch (Exception e) {
5811 throw processException(e);
5812 }
5813 finally {
5814 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5815 }
5816 }
5817
5818
5825 public void removeUser(long pk, com.liferay.portal.model.User user)
5826 throws SystemException {
5827 try {
5828 removeUser.remove(pk, user.getPrimaryKey());
5829 }
5830 catch (Exception e) {
5831 throw processException(e);
5832 }
5833 finally {
5834 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5835 }
5836 }
5837
5838
5845 public void removeUsers(long pk, long[] userPKs) throws SystemException {
5846 try {
5847 for (long userPK : userPKs) {
5848 removeUser.remove(pk, userPK);
5849 }
5850 }
5851 catch (Exception e) {
5852 throw processException(e);
5853 }
5854 finally {
5855 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5856 }
5857 }
5858
5859
5866 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
5867 throws SystemException {
5868 try {
5869 for (com.liferay.portal.model.User user : users) {
5870 removeUser.remove(pk, user.getPrimaryKey());
5871 }
5872 }
5873 catch (Exception e) {
5874 throw processException(e);
5875 }
5876 finally {
5877 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5878 }
5879 }
5880
5881
5888 public void setUsers(long pk, long[] userPKs) throws SystemException {
5889 try {
5890 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
5891
5892 List<com.liferay.portal.model.User> users = getUsers(pk);
5893
5894 for (com.liferay.portal.model.User user : users) {
5895 if (!userPKSet.remove(user.getPrimaryKey())) {
5896 removeUser.remove(pk, user.getPrimaryKey());
5897 }
5898 }
5899
5900 for (Long userPK : userPKSet) {
5901 addUser.add(pk, userPK);
5902 }
5903 }
5904 catch (Exception e) {
5905 throw processException(e);
5906 }
5907 finally {
5908 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5909 }
5910 }
5911
5912
5919 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
5920 throws SystemException {
5921 try {
5922 long[] userPKs = new long[users.size()];
5923
5924 for (int i = 0; i < users.size(); i++) {
5925 com.liferay.portal.model.User user = users.get(i);
5926
5927 userPKs[i] = user.getPrimaryKey();
5928 }
5929
5930 setUsers(pk, userPKs);
5931 }
5932 catch (Exception e) {
5933 throw processException(e);
5934 }
5935 finally {
5936 FinderCacheUtil.clearCache(GroupModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5937 }
5938 }
5939
5940
5943 public void afterPropertiesSet() {
5944 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5945 com.liferay.portal.util.PropsUtil.get(
5946 "value.object.listener.com.liferay.portal.model.Group")));
5947
5948 if (listenerClassNames.length > 0) {
5949 try {
5950 List<ModelListener<Group>> listenersList = new ArrayList<ModelListener<Group>>();
5951
5952 for (String listenerClassName : listenerClassNames) {
5953 Class<?> clazz = getClass();
5954
5955 listenersList.add((ModelListener<Group>)InstanceFactory.newInstance(
5956 clazz.getClassLoader(), listenerClassName));
5957 }
5958
5959 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5960 }
5961 catch (Exception e) {
5962 _log.error(e);
5963 }
5964 }
5965
5966 containsOrganization = new ContainsOrganization();
5967
5968 addOrganization = new AddOrganization();
5969 clearOrganizations = new ClearOrganizations();
5970 removeOrganization = new RemoveOrganization();
5971
5972 containsPermission = new ContainsPermission();
5973
5974 addPermission = new AddPermission();
5975 clearPermissions = new ClearPermissions();
5976 removePermission = new RemovePermission();
5977
5978 containsRole = new ContainsRole();
5979
5980 addRole = new AddRole();
5981 clearRoles = new ClearRoles();
5982 removeRole = new RemoveRole();
5983
5984 containsUserGroup = new ContainsUserGroup();
5985
5986 addUserGroup = new AddUserGroup();
5987 clearUserGroups = new ClearUserGroups();
5988 removeUserGroup = new RemoveUserGroup();
5989
5990 containsUser = new ContainsUser();
5991
5992 addUser = new AddUser();
5993 clearUsers = new ClearUsers();
5994 removeUser = new RemoveUser();
5995 }
5996
5997 public void destroy() {
5998 EntityCacheUtil.removeCache(GroupImpl.class.getName());
5999 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6000 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6001 }
6002
6003 @BeanReference(type = AccountPersistence.class)
6004 protected AccountPersistence accountPersistence;
6005 @BeanReference(type = AddressPersistence.class)
6006 protected AddressPersistence addressPersistence;
6007 @BeanReference(type = BrowserTrackerPersistence.class)
6008 protected BrowserTrackerPersistence browserTrackerPersistence;
6009 @BeanReference(type = ClassNamePersistence.class)
6010 protected ClassNamePersistence classNamePersistence;
6011 @BeanReference(type = ClusterGroupPersistence.class)
6012 protected ClusterGroupPersistence clusterGroupPersistence;
6013 @BeanReference(type = CompanyPersistence.class)
6014 protected CompanyPersistence companyPersistence;
6015 @BeanReference(type = ContactPersistence.class)
6016 protected ContactPersistence contactPersistence;
6017 @BeanReference(type = CountryPersistence.class)
6018 protected CountryPersistence countryPersistence;
6019 @BeanReference(type = EmailAddressPersistence.class)
6020 protected EmailAddressPersistence emailAddressPersistence;
6021 @BeanReference(type = GroupPersistence.class)
6022 protected GroupPersistence groupPersistence;
6023 @BeanReference(type = ImagePersistence.class)
6024 protected ImagePersistence imagePersistence;
6025 @BeanReference(type = LayoutPersistence.class)
6026 protected LayoutPersistence layoutPersistence;
6027 @BeanReference(type = LayoutBranchPersistence.class)
6028 protected LayoutBranchPersistence layoutBranchPersistence;
6029 @BeanReference(type = LayoutPrototypePersistence.class)
6030 protected LayoutPrototypePersistence layoutPrototypePersistence;
6031 @BeanReference(type = LayoutRevisionPersistence.class)
6032 protected LayoutRevisionPersistence layoutRevisionPersistence;
6033 @BeanReference(type = LayoutSetPersistence.class)
6034 protected LayoutSetPersistence layoutSetPersistence;
6035 @BeanReference(type = LayoutSetBranchPersistence.class)
6036 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
6037 @BeanReference(type = LayoutSetPrototypePersistence.class)
6038 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
6039 @BeanReference(type = ListTypePersistence.class)
6040 protected ListTypePersistence listTypePersistence;
6041 @BeanReference(type = LockPersistence.class)
6042 protected LockPersistence lockPersistence;
6043 @BeanReference(type = MembershipRequestPersistence.class)
6044 protected MembershipRequestPersistence membershipRequestPersistence;
6045 @BeanReference(type = OrganizationPersistence.class)
6046 protected OrganizationPersistence organizationPersistence;
6047 @BeanReference(type = OrgGroupPermissionPersistence.class)
6048 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
6049 @BeanReference(type = OrgGroupRolePersistence.class)
6050 protected OrgGroupRolePersistence orgGroupRolePersistence;
6051 @BeanReference(type = OrgLaborPersistence.class)
6052 protected OrgLaborPersistence orgLaborPersistence;
6053 @BeanReference(type = PasswordPolicyPersistence.class)
6054 protected PasswordPolicyPersistence passwordPolicyPersistence;
6055 @BeanReference(type = PasswordPolicyRelPersistence.class)
6056 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
6057 @BeanReference(type = PasswordTrackerPersistence.class)
6058 protected PasswordTrackerPersistence passwordTrackerPersistence;
6059 @BeanReference(type = PermissionPersistence.class)
6060 protected PermissionPersistence permissionPersistence;
6061 @BeanReference(type = PhonePersistence.class)
6062 protected PhonePersistence phonePersistence;
6063 @BeanReference(type = PluginSettingPersistence.class)
6064 protected PluginSettingPersistence pluginSettingPersistence;
6065 @BeanReference(type = PortalPreferencesPersistence.class)
6066 protected PortalPreferencesPersistence portalPreferencesPersistence;
6067 @BeanReference(type = PortletPersistence.class)
6068 protected PortletPersistence portletPersistence;
6069 @BeanReference(type = PortletItemPersistence.class)
6070 protected PortletItemPersistence portletItemPersistence;
6071 @BeanReference(type = PortletPreferencesPersistence.class)
6072 protected PortletPreferencesPersistence portletPreferencesPersistence;
6073 @BeanReference(type = RegionPersistence.class)
6074 protected RegionPersistence regionPersistence;
6075 @BeanReference(type = ReleasePersistence.class)
6076 protected ReleasePersistence releasePersistence;
6077 @BeanReference(type = RepositoryPersistence.class)
6078 protected RepositoryPersistence repositoryPersistence;
6079 @BeanReference(type = RepositoryEntryPersistence.class)
6080 protected RepositoryEntryPersistence repositoryEntryPersistence;
6081 @BeanReference(type = ResourcePersistence.class)
6082 protected ResourcePersistence resourcePersistence;
6083 @BeanReference(type = ResourceActionPersistence.class)
6084 protected ResourceActionPersistence resourceActionPersistence;
6085 @BeanReference(type = ResourceBlockPersistence.class)
6086 protected ResourceBlockPersistence resourceBlockPersistence;
6087 @BeanReference(type = ResourceBlockPermissionPersistence.class)
6088 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
6089 @BeanReference(type = ResourceCodePersistence.class)
6090 protected ResourceCodePersistence resourceCodePersistence;
6091 @BeanReference(type = ResourcePermissionPersistence.class)
6092 protected ResourcePermissionPersistence resourcePermissionPersistence;
6093 @BeanReference(type = ResourceTypePermissionPersistence.class)
6094 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
6095 @BeanReference(type = RolePersistence.class)
6096 protected RolePersistence rolePersistence;
6097 @BeanReference(type = ServiceComponentPersistence.class)
6098 protected ServiceComponentPersistence serviceComponentPersistence;
6099 @BeanReference(type = ShardPersistence.class)
6100 protected ShardPersistence shardPersistence;
6101 @BeanReference(type = SubscriptionPersistence.class)
6102 protected SubscriptionPersistence subscriptionPersistence;
6103 @BeanReference(type = TeamPersistence.class)
6104 protected TeamPersistence teamPersistence;
6105 @BeanReference(type = TicketPersistence.class)
6106 protected TicketPersistence ticketPersistence;
6107 @BeanReference(type = UserPersistence.class)
6108 protected UserPersistence userPersistence;
6109 @BeanReference(type = UserGroupPersistence.class)
6110 protected UserGroupPersistence userGroupPersistence;
6111 @BeanReference(type = UserGroupGroupRolePersistence.class)
6112 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
6113 @BeanReference(type = UserGroupRolePersistence.class)
6114 protected UserGroupRolePersistence userGroupRolePersistence;
6115 @BeanReference(type = UserIdMapperPersistence.class)
6116 protected UserIdMapperPersistence userIdMapperPersistence;
6117 @BeanReference(type = UserNotificationEventPersistence.class)
6118 protected UserNotificationEventPersistence userNotificationEventPersistence;
6119 @BeanReference(type = UserTrackerPersistence.class)
6120 protected UserTrackerPersistence userTrackerPersistence;
6121 @BeanReference(type = UserTrackerPathPersistence.class)
6122 protected UserTrackerPathPersistence userTrackerPathPersistence;
6123 @BeanReference(type = VirtualHostPersistence.class)
6124 protected VirtualHostPersistence virtualHostPersistence;
6125 @BeanReference(type = WebDAVPropsPersistence.class)
6126 protected WebDAVPropsPersistence webDAVPropsPersistence;
6127 @BeanReference(type = WebsitePersistence.class)
6128 protected WebsitePersistence websitePersistence;
6129 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
6130 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
6131 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
6132 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
6133 @BeanReference(type = AssetEntryPersistence.class)
6134 protected AssetEntryPersistence assetEntryPersistence;
6135 @BeanReference(type = AssetVocabularyPersistence.class)
6136 protected AssetVocabularyPersistence assetVocabularyPersistence;
6137 @BeanReference(type = BlogsEntryPersistence.class)
6138 protected BlogsEntryPersistence blogsEntryPersistence;
6139 @BeanReference(type = BlogsStatsUserPersistence.class)
6140 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
6141 @BeanReference(type = BookmarksFolderPersistence.class)
6142 protected BookmarksFolderPersistence bookmarksFolderPersistence;
6143 @BeanReference(type = CalEventPersistence.class)
6144 protected CalEventPersistence calEventPersistence;
6145 @BeanReference(type = DLFileEntryTypePersistence.class)
6146 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
6147 @BeanReference(type = JournalArticlePersistence.class)
6148 protected JournalArticlePersistence journalArticlePersistence;
6149 @BeanReference(type = JournalStructurePersistence.class)
6150 protected JournalStructurePersistence journalStructurePersistence;
6151 @BeanReference(type = JournalTemplatePersistence.class)
6152 protected JournalTemplatePersistence journalTemplatePersistence;
6153 @BeanReference(type = MBBanPersistence.class)
6154 protected MBBanPersistence mbBanPersistence;
6155 @BeanReference(type = MBCategoryPersistence.class)
6156 protected MBCategoryPersistence mbCategoryPersistence;
6157 @BeanReference(type = MBStatsUserPersistence.class)
6158 protected MBStatsUserPersistence mbStatsUserPersistence;
6159 @BeanReference(type = MBThreadPersistence.class)
6160 protected MBThreadPersistence mbThreadPersistence;
6161 @BeanReference(type = PollsQuestionPersistence.class)
6162 protected PollsQuestionPersistence pollsQuestionPersistence;
6163 @BeanReference(type = ShoppingCartPersistence.class)
6164 protected ShoppingCartPersistence shoppingCartPersistence;
6165 @BeanReference(type = ShoppingCategoryPersistence.class)
6166 protected ShoppingCategoryPersistence shoppingCategoryPersistence;
6167 @BeanReference(type = ShoppingCouponPersistence.class)
6168 protected ShoppingCouponPersistence shoppingCouponPersistence;
6169 @BeanReference(type = ShoppingOrderPersistence.class)
6170 protected ShoppingOrderPersistence shoppingOrderPersistence;
6171 @BeanReference(type = SCFrameworkVersionPersistence.class)
6172 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
6173 @BeanReference(type = SCProductEntryPersistence.class)
6174 protected SCProductEntryPersistence scProductEntryPersistence;
6175 @BeanReference(type = WikiNodePersistence.class)
6176 protected WikiNodePersistence wikiNodePersistence;
6177 protected ContainsOrganization containsOrganization;
6178 protected AddOrganization addOrganization;
6179 protected ClearOrganizations clearOrganizations;
6180 protected RemoveOrganization removeOrganization;
6181 protected ContainsPermission containsPermission;
6182 protected AddPermission addPermission;
6183 protected ClearPermissions clearPermissions;
6184 protected RemovePermission removePermission;
6185 protected ContainsRole containsRole;
6186 protected AddRole addRole;
6187 protected ClearRoles clearRoles;
6188 protected RemoveRole removeRole;
6189 protected ContainsUserGroup containsUserGroup;
6190 protected AddUserGroup addUserGroup;
6191 protected ClearUserGroups clearUserGroups;
6192 protected RemoveUserGroup removeUserGroup;
6193 protected ContainsUser containsUser;
6194 protected AddUser addUser;
6195 protected ClearUsers clearUsers;
6196 protected RemoveUser removeUser;
6197
6198 protected class ContainsOrganization {
6199 protected ContainsOrganization() {
6200 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6201 _SQL_CONTAINSORGANIZATION,
6202 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6203 RowMapper.COUNT);
6204 }
6205
6206 protected boolean contains(long groupId, long organizationId) {
6207 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6208 new Long(groupId), new Long(organizationId)
6209 });
6210
6211 if (results.size() > 0) {
6212 Integer count = results.get(0);
6213
6214 if (count.intValue() > 0) {
6215 return true;
6216 }
6217 }
6218
6219 return false;
6220 }
6221
6222 private MappingSqlQuery<Integer> _mappingSqlQuery;
6223 }
6224
6225 protected class AddOrganization {
6226 protected AddOrganization() {
6227 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6228 "INSERT INTO Groups_Orgs (groupId, organizationId) VALUES (?, ?)",
6229 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6230 }
6231
6232 protected void add(long groupId, long organizationId)
6233 throws SystemException {
6234 if (!containsOrganization.contains(groupId, organizationId)) {
6235 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6236 organizationPersistence.getListeners();
6237
6238 for (ModelListener<Group> listener : listeners) {
6239 listener.onBeforeAddAssociation(groupId,
6240 com.liferay.portal.model.Organization.class.getName(),
6241 organizationId);
6242 }
6243
6244 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6245 listener.onBeforeAddAssociation(organizationId,
6246 Group.class.getName(), groupId);
6247 }
6248
6249 _sqlUpdate.update(new Object[] {
6250 new Long(groupId), new Long(organizationId)
6251 });
6252
6253 for (ModelListener<Group> listener : listeners) {
6254 listener.onAfterAddAssociation(groupId,
6255 com.liferay.portal.model.Organization.class.getName(),
6256 organizationId);
6257 }
6258
6259 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6260 listener.onAfterAddAssociation(organizationId,
6261 Group.class.getName(), groupId);
6262 }
6263 }
6264 }
6265
6266 private SqlUpdate _sqlUpdate;
6267 }
6268
6269 protected class ClearOrganizations {
6270 protected ClearOrganizations() {
6271 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6272 "DELETE FROM Groups_Orgs WHERE groupId = ?",
6273 new int[] { java.sql.Types.BIGINT });
6274 }
6275
6276 protected void clear(long groupId) throws SystemException {
6277 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6278 organizationPersistence.getListeners();
6279
6280 List<com.liferay.portal.model.Organization> organizations = null;
6281
6282 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6283 organizations = getOrganizations(groupId);
6284
6285 for (com.liferay.portal.model.Organization organization : organizations) {
6286 for (ModelListener<Group> listener : listeners) {
6287 listener.onBeforeRemoveAssociation(groupId,
6288 com.liferay.portal.model.Organization.class.getName(),
6289 organization.getPrimaryKey());
6290 }
6291
6292 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6293 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
6294 Group.class.getName(), groupId);
6295 }
6296 }
6297 }
6298
6299 _sqlUpdate.update(new Object[] { new Long(groupId) });
6300
6301 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
6302 for (com.liferay.portal.model.Organization organization : organizations) {
6303 for (ModelListener<Group> listener : listeners) {
6304 listener.onAfterRemoveAssociation(groupId,
6305 com.liferay.portal.model.Organization.class.getName(),
6306 organization.getPrimaryKey());
6307 }
6308
6309 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6310 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
6311 Group.class.getName(), groupId);
6312 }
6313 }
6314 }
6315 }
6316
6317 private SqlUpdate _sqlUpdate;
6318 }
6319
6320 protected class RemoveOrganization {
6321 protected RemoveOrganization() {
6322 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6323 "DELETE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?",
6324 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6325 }
6326
6327 protected void remove(long groupId, long organizationId)
6328 throws SystemException {
6329 if (containsOrganization.contains(groupId, organizationId)) {
6330 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
6331 organizationPersistence.getListeners();
6332
6333 for (ModelListener<Group> listener : listeners) {
6334 listener.onBeforeRemoveAssociation(groupId,
6335 com.liferay.portal.model.Organization.class.getName(),
6336 organizationId);
6337 }
6338
6339 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6340 listener.onBeforeRemoveAssociation(organizationId,
6341 Group.class.getName(), groupId);
6342 }
6343
6344 _sqlUpdate.update(new Object[] {
6345 new Long(groupId), new Long(organizationId)
6346 });
6347
6348 for (ModelListener<Group> listener : listeners) {
6349 listener.onAfterRemoveAssociation(groupId,
6350 com.liferay.portal.model.Organization.class.getName(),
6351 organizationId);
6352 }
6353
6354 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
6355 listener.onAfterRemoveAssociation(organizationId,
6356 Group.class.getName(), groupId);
6357 }
6358 }
6359 }
6360
6361 private SqlUpdate _sqlUpdate;
6362 }
6363
6364 protected class ContainsPermission {
6365 protected ContainsPermission() {
6366 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6367 _SQL_CONTAINSPERMISSION,
6368 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6369 RowMapper.COUNT);
6370 }
6371
6372 protected boolean contains(long groupId, long permissionId) {
6373 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6374 new Long(groupId), new Long(permissionId)
6375 });
6376
6377 if (results.size() > 0) {
6378 Integer count = results.get(0);
6379
6380 if (count.intValue() > 0) {
6381 return true;
6382 }
6383 }
6384
6385 return false;
6386 }
6387
6388 private MappingSqlQuery<Integer> _mappingSqlQuery;
6389 }
6390
6391 protected class AddPermission {
6392 protected AddPermission() {
6393 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6394 "INSERT INTO Groups_Permissions (groupId, permissionId) VALUES (?, ?)",
6395 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6396 }
6397
6398 protected void add(long groupId, long permissionId)
6399 throws SystemException {
6400 if (!containsPermission.contains(groupId, permissionId)) {
6401 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6402 permissionPersistence.getListeners();
6403
6404 for (ModelListener<Group> listener : listeners) {
6405 listener.onBeforeAddAssociation(groupId,
6406 com.liferay.portal.model.Permission.class.getName(),
6407 permissionId);
6408 }
6409
6410 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6411 listener.onBeforeAddAssociation(permissionId,
6412 Group.class.getName(), groupId);
6413 }
6414
6415 _sqlUpdate.update(new Object[] {
6416 new Long(groupId), new Long(permissionId)
6417 });
6418
6419 for (ModelListener<Group> listener : listeners) {
6420 listener.onAfterAddAssociation(groupId,
6421 com.liferay.portal.model.Permission.class.getName(),
6422 permissionId);
6423 }
6424
6425 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6426 listener.onAfterAddAssociation(permissionId,
6427 Group.class.getName(), groupId);
6428 }
6429 }
6430 }
6431
6432 private SqlUpdate _sqlUpdate;
6433 }
6434
6435 protected class ClearPermissions {
6436 protected ClearPermissions() {
6437 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6438 "DELETE FROM Groups_Permissions WHERE groupId = ?",
6439 new int[] { java.sql.Types.BIGINT });
6440 }
6441
6442 protected void clear(long groupId) throws SystemException {
6443 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6444 permissionPersistence.getListeners();
6445
6446 List<com.liferay.portal.model.Permission> permissions = null;
6447
6448 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6449 permissions = getPermissions(groupId);
6450
6451 for (com.liferay.portal.model.Permission permission : permissions) {
6452 for (ModelListener<Group> listener : listeners) {
6453 listener.onBeforeRemoveAssociation(groupId,
6454 com.liferay.portal.model.Permission.class.getName(),
6455 permission.getPrimaryKey());
6456 }
6457
6458 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6459 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
6460 Group.class.getName(), groupId);
6461 }
6462 }
6463 }
6464
6465 _sqlUpdate.update(new Object[] { new Long(groupId) });
6466
6467 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
6468 for (com.liferay.portal.model.Permission permission : permissions) {
6469 for (ModelListener<Group> listener : listeners) {
6470 listener.onAfterRemoveAssociation(groupId,
6471 com.liferay.portal.model.Permission.class.getName(),
6472 permission.getPrimaryKey());
6473 }
6474
6475 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6476 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
6477 Group.class.getName(), groupId);
6478 }
6479 }
6480 }
6481 }
6482
6483 private SqlUpdate _sqlUpdate;
6484 }
6485
6486 protected class RemovePermission {
6487 protected RemovePermission() {
6488 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6489 "DELETE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?",
6490 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6491 }
6492
6493 protected void remove(long groupId, long permissionId)
6494 throws SystemException {
6495 if (containsPermission.contains(groupId, permissionId)) {
6496 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
6497 permissionPersistence.getListeners();
6498
6499 for (ModelListener<Group> listener : listeners) {
6500 listener.onBeforeRemoveAssociation(groupId,
6501 com.liferay.portal.model.Permission.class.getName(),
6502 permissionId);
6503 }
6504
6505 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6506 listener.onBeforeRemoveAssociation(permissionId,
6507 Group.class.getName(), groupId);
6508 }
6509
6510 _sqlUpdate.update(new Object[] {
6511 new Long(groupId), new Long(permissionId)
6512 });
6513
6514 for (ModelListener<Group> listener : listeners) {
6515 listener.onAfterRemoveAssociation(groupId,
6516 com.liferay.portal.model.Permission.class.getName(),
6517 permissionId);
6518 }
6519
6520 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
6521 listener.onAfterRemoveAssociation(permissionId,
6522 Group.class.getName(), groupId);
6523 }
6524 }
6525 }
6526
6527 private SqlUpdate _sqlUpdate;
6528 }
6529
6530 protected class ContainsRole {
6531 protected ContainsRole() {
6532 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6533 _SQL_CONTAINSROLE,
6534 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6535 RowMapper.COUNT);
6536 }
6537
6538 protected boolean contains(long groupId, long roleId) {
6539 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6540 new Long(groupId), new Long(roleId)
6541 });
6542
6543 if (results.size() > 0) {
6544 Integer count = results.get(0);
6545
6546 if (count.intValue() > 0) {
6547 return true;
6548 }
6549 }
6550
6551 return false;
6552 }
6553
6554 private MappingSqlQuery<Integer> _mappingSqlQuery;
6555 }
6556
6557 protected class AddRole {
6558 protected AddRole() {
6559 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6560 "INSERT INTO Groups_Roles (groupId, roleId) VALUES (?, ?)",
6561 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6562 }
6563
6564 protected void add(long groupId, long roleId) throws SystemException {
6565 if (!containsRole.contains(groupId, roleId)) {
6566 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6567
6568 for (ModelListener<Group> listener : listeners) {
6569 listener.onBeforeAddAssociation(groupId,
6570 com.liferay.portal.model.Role.class.getName(), roleId);
6571 }
6572
6573 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6574 listener.onBeforeAddAssociation(roleId,
6575 Group.class.getName(), groupId);
6576 }
6577
6578 _sqlUpdate.update(new Object[] {
6579 new Long(groupId), new Long(roleId)
6580 });
6581
6582 for (ModelListener<Group> listener : listeners) {
6583 listener.onAfterAddAssociation(groupId,
6584 com.liferay.portal.model.Role.class.getName(), roleId);
6585 }
6586
6587 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6588 listener.onAfterAddAssociation(roleId,
6589 Group.class.getName(), groupId);
6590 }
6591 }
6592 }
6593
6594 private SqlUpdate _sqlUpdate;
6595 }
6596
6597 protected class ClearRoles {
6598 protected ClearRoles() {
6599 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6600 "DELETE FROM Groups_Roles WHERE groupId = ?",
6601 new int[] { java.sql.Types.BIGINT });
6602 }
6603
6604 protected void clear(long groupId) throws SystemException {
6605 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6606
6607 List<com.liferay.portal.model.Role> roles = null;
6608
6609 if ((listeners.length > 0) || (roleListeners.length > 0)) {
6610 roles = getRoles(groupId);
6611
6612 for (com.liferay.portal.model.Role role : roles) {
6613 for (ModelListener<Group> listener : listeners) {
6614 listener.onBeforeRemoveAssociation(groupId,
6615 com.liferay.portal.model.Role.class.getName(),
6616 role.getPrimaryKey());
6617 }
6618
6619 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6620 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
6621 Group.class.getName(), groupId);
6622 }
6623 }
6624 }
6625
6626 _sqlUpdate.update(new Object[] { new Long(groupId) });
6627
6628 if ((listeners.length > 0) || (roleListeners.length > 0)) {
6629 for (com.liferay.portal.model.Role role : roles) {
6630 for (ModelListener<Group> listener : listeners) {
6631 listener.onAfterRemoveAssociation(groupId,
6632 com.liferay.portal.model.Role.class.getName(),
6633 role.getPrimaryKey());
6634 }
6635
6636 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6637 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
6638 Group.class.getName(), groupId);
6639 }
6640 }
6641 }
6642 }
6643
6644 private SqlUpdate _sqlUpdate;
6645 }
6646
6647 protected class RemoveRole {
6648 protected RemoveRole() {
6649 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6650 "DELETE FROM Groups_Roles WHERE groupId = ? AND roleId = ?",
6651 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6652 }
6653
6654 protected void remove(long groupId, long roleId)
6655 throws SystemException {
6656 if (containsRole.contains(groupId, roleId)) {
6657 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
6658
6659 for (ModelListener<Group> listener : listeners) {
6660 listener.onBeforeRemoveAssociation(groupId,
6661 com.liferay.portal.model.Role.class.getName(), roleId);
6662 }
6663
6664 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6665 listener.onBeforeRemoveAssociation(roleId,
6666 Group.class.getName(), groupId);
6667 }
6668
6669 _sqlUpdate.update(new Object[] {
6670 new Long(groupId), new Long(roleId)
6671 });
6672
6673 for (ModelListener<Group> listener : listeners) {
6674 listener.onAfterRemoveAssociation(groupId,
6675 com.liferay.portal.model.Role.class.getName(), roleId);
6676 }
6677
6678 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
6679 listener.onAfterRemoveAssociation(roleId,
6680 Group.class.getName(), groupId);
6681 }
6682 }
6683 }
6684
6685 private SqlUpdate _sqlUpdate;
6686 }
6687
6688 protected class ContainsUserGroup {
6689 protected ContainsUserGroup() {
6690 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6691 _SQL_CONTAINSUSERGROUP,
6692 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6693 RowMapper.COUNT);
6694 }
6695
6696 protected boolean contains(long groupId, long userGroupId) {
6697 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6698 new Long(groupId), new Long(userGroupId)
6699 });
6700
6701 if (results.size() > 0) {
6702 Integer count = results.get(0);
6703
6704 if (count.intValue() > 0) {
6705 return true;
6706 }
6707 }
6708
6709 return false;
6710 }
6711
6712 private MappingSqlQuery<Integer> _mappingSqlQuery;
6713 }
6714
6715 protected class AddUserGroup {
6716 protected AddUserGroup() {
6717 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6718 "INSERT INTO Groups_UserGroups (groupId, userGroupId) VALUES (?, ?)",
6719 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6720 }
6721
6722 protected void add(long groupId, long userGroupId)
6723 throws SystemException {
6724 if (!containsUserGroup.contains(groupId, userGroupId)) {
6725 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6726 userGroupPersistence.getListeners();
6727
6728 for (ModelListener<Group> listener : listeners) {
6729 listener.onBeforeAddAssociation(groupId,
6730 com.liferay.portal.model.UserGroup.class.getName(),
6731 userGroupId);
6732 }
6733
6734 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6735 listener.onBeforeAddAssociation(userGroupId,
6736 Group.class.getName(), groupId);
6737 }
6738
6739 _sqlUpdate.update(new Object[] {
6740 new Long(groupId), new Long(userGroupId)
6741 });
6742
6743 for (ModelListener<Group> listener : listeners) {
6744 listener.onAfterAddAssociation(groupId,
6745 com.liferay.portal.model.UserGroup.class.getName(),
6746 userGroupId);
6747 }
6748
6749 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6750 listener.onAfterAddAssociation(userGroupId,
6751 Group.class.getName(), groupId);
6752 }
6753 }
6754 }
6755
6756 private SqlUpdate _sqlUpdate;
6757 }
6758
6759 protected class ClearUserGroups {
6760 protected ClearUserGroups() {
6761 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6762 "DELETE FROM Groups_UserGroups WHERE groupId = ?",
6763 new int[] { java.sql.Types.BIGINT });
6764 }
6765
6766 protected void clear(long groupId) throws SystemException {
6767 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6768 userGroupPersistence.getListeners();
6769
6770 List<com.liferay.portal.model.UserGroup> userGroups = null;
6771
6772 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
6773 userGroups = getUserGroups(groupId);
6774
6775 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
6776 for (ModelListener<Group> listener : listeners) {
6777 listener.onBeforeRemoveAssociation(groupId,
6778 com.liferay.portal.model.UserGroup.class.getName(),
6779 userGroup.getPrimaryKey());
6780 }
6781
6782 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6783 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
6784 Group.class.getName(), groupId);
6785 }
6786 }
6787 }
6788
6789 _sqlUpdate.update(new Object[] { new Long(groupId) });
6790
6791 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
6792 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
6793 for (ModelListener<Group> listener : listeners) {
6794 listener.onAfterRemoveAssociation(groupId,
6795 com.liferay.portal.model.UserGroup.class.getName(),
6796 userGroup.getPrimaryKey());
6797 }
6798
6799 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6800 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
6801 Group.class.getName(), groupId);
6802 }
6803 }
6804 }
6805 }
6806
6807 private SqlUpdate _sqlUpdate;
6808 }
6809
6810 protected class RemoveUserGroup {
6811 protected RemoveUserGroup() {
6812 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6813 "DELETE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?",
6814 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6815 }
6816
6817 protected void remove(long groupId, long userGroupId)
6818 throws SystemException {
6819 if (containsUserGroup.contains(groupId, userGroupId)) {
6820 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
6821 userGroupPersistence.getListeners();
6822
6823 for (ModelListener<Group> listener : listeners) {
6824 listener.onBeforeRemoveAssociation(groupId,
6825 com.liferay.portal.model.UserGroup.class.getName(),
6826 userGroupId);
6827 }
6828
6829 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6830 listener.onBeforeRemoveAssociation(userGroupId,
6831 Group.class.getName(), groupId);
6832 }
6833
6834 _sqlUpdate.update(new Object[] {
6835 new Long(groupId), new Long(userGroupId)
6836 });
6837
6838 for (ModelListener<Group> listener : listeners) {
6839 listener.onAfterRemoveAssociation(groupId,
6840 com.liferay.portal.model.UserGroup.class.getName(),
6841 userGroupId);
6842 }
6843
6844 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6845 listener.onAfterRemoveAssociation(userGroupId,
6846 Group.class.getName(), groupId);
6847 }
6848 }
6849 }
6850
6851 private SqlUpdate _sqlUpdate;
6852 }
6853
6854 protected class ContainsUser {
6855 protected ContainsUser() {
6856 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6857 _SQL_CONTAINSUSER,
6858 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6859 RowMapper.COUNT);
6860 }
6861
6862 protected boolean contains(long groupId, long userId) {
6863 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6864 new Long(groupId), new Long(userId)
6865 });
6866
6867 if (results.size() > 0) {
6868 Integer count = results.get(0);
6869
6870 if (count.intValue() > 0) {
6871 return true;
6872 }
6873 }
6874
6875 return false;
6876 }
6877
6878 private MappingSqlQuery<Integer> _mappingSqlQuery;
6879 }
6880
6881 protected class AddUser {
6882 protected AddUser() {
6883 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6884 "INSERT INTO Users_Groups (groupId, userId) VALUES (?, ?)",
6885 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6886 }
6887
6888 protected void add(long groupId, long userId) throws SystemException {
6889 if (!containsUser.contains(groupId, userId)) {
6890 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6891
6892 for (ModelListener<Group> listener : listeners) {
6893 listener.onBeforeAddAssociation(groupId,
6894 com.liferay.portal.model.User.class.getName(), userId);
6895 }
6896
6897 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6898 listener.onBeforeAddAssociation(userId,
6899 Group.class.getName(), groupId);
6900 }
6901
6902 _sqlUpdate.update(new Object[] {
6903 new Long(groupId), new Long(userId)
6904 });
6905
6906 for (ModelListener<Group> listener : listeners) {
6907 listener.onAfterAddAssociation(groupId,
6908 com.liferay.portal.model.User.class.getName(), userId);
6909 }
6910
6911 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6912 listener.onAfterAddAssociation(userId,
6913 Group.class.getName(), groupId);
6914 }
6915 }
6916 }
6917
6918 private SqlUpdate _sqlUpdate;
6919 }
6920
6921 protected class ClearUsers {
6922 protected ClearUsers() {
6923 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6924 "DELETE FROM Users_Groups WHERE groupId = ?",
6925 new int[] { java.sql.Types.BIGINT });
6926 }
6927
6928 protected void clear(long groupId) throws SystemException {
6929 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6930
6931 List<com.liferay.portal.model.User> users = null;
6932
6933 if ((listeners.length > 0) || (userListeners.length > 0)) {
6934 users = getUsers(groupId);
6935
6936 for (com.liferay.portal.model.User user : users) {
6937 for (ModelListener<Group> listener : listeners) {
6938 listener.onBeforeRemoveAssociation(groupId,
6939 com.liferay.portal.model.User.class.getName(),
6940 user.getPrimaryKey());
6941 }
6942
6943 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6944 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
6945 Group.class.getName(), groupId);
6946 }
6947 }
6948 }
6949
6950 _sqlUpdate.update(new Object[] { new Long(groupId) });
6951
6952 if ((listeners.length > 0) || (userListeners.length > 0)) {
6953 for (com.liferay.portal.model.User user : users) {
6954 for (ModelListener<Group> listener : listeners) {
6955 listener.onAfterRemoveAssociation(groupId,
6956 com.liferay.portal.model.User.class.getName(),
6957 user.getPrimaryKey());
6958 }
6959
6960 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6961 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
6962 Group.class.getName(), groupId);
6963 }
6964 }
6965 }
6966 }
6967
6968 private SqlUpdate _sqlUpdate;
6969 }
6970
6971 protected class RemoveUser {
6972 protected RemoveUser() {
6973 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6974 "DELETE FROM Users_Groups WHERE groupId = ? AND userId = ?",
6975 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6976 }
6977
6978 protected void remove(long groupId, long userId)
6979 throws SystemException {
6980 if (containsUser.contains(groupId, userId)) {
6981 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
6982
6983 for (ModelListener<Group> listener : listeners) {
6984 listener.onBeforeRemoveAssociation(groupId,
6985 com.liferay.portal.model.User.class.getName(), userId);
6986 }
6987
6988 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
6989 listener.onBeforeRemoveAssociation(userId,
6990 Group.class.getName(), groupId);
6991 }
6992
6993 _sqlUpdate.update(new Object[] {
6994 new Long(groupId), new Long(userId)
6995 });
6996
6997 for (ModelListener<Group> listener : listeners) {
6998 listener.onAfterRemoveAssociation(groupId,
6999 com.liferay.portal.model.User.class.getName(), userId);
7000 }
7001
7002 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
7003 listener.onAfterRemoveAssociation(userId,
7004 Group.class.getName(), groupId);
7005 }
7006 }
7007 }
7008
7009 private SqlUpdate _sqlUpdate;
7010 }
7011
7012 private static final String _SQL_SELECT_GROUP_ = "SELECT group_ FROM Group group_";
7013 private static final String _SQL_SELECT_GROUP__WHERE = "SELECT group_ FROM Group group_ WHERE ";
7014 private static final String _SQL_COUNT_GROUP_ = "SELECT COUNT(group_) FROM Group group_";
7015 private static final String _SQL_COUNT_GROUP__WHERE = "SELECT COUNT(group_) FROM Group group_ WHERE ";
7016 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Groups_Orgs ON (Groups_Orgs.organizationId = Organization_.organizationId) WHERE (Groups_Orgs.groupId = ?)";
7017 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ?";
7018 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE groupId = ? AND organizationId = ?";
7019 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Groups_Permissions ON (Groups_Permissions.permissionId = Permission_.permissionId) WHERE (Groups_Permissions.groupId = ?)";
7020 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ?";
7021 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Permissions WHERE groupId = ? AND permissionId = ?";
7022 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Groups_Roles ON (Groups_Roles.roleId = Role_.roleId) WHERE (Groups_Roles.groupId = ?)";
7023 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ?";
7024 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Roles WHERE groupId = ? AND roleId = ?";
7025 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Groups_UserGroups ON (Groups_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Groups_UserGroups.groupId = ?)";
7026 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ?";
7027 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_UserGroups WHERE groupId = ? AND userGroupId = ?";
7028 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Groups ON (Users_Groups.userId = User_.userId) WHERE (Users_Groups.groupId = ?)";
7029 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ?";
7030 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE groupId = ? AND userId = ?";
7031 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "group_.companyId = ?";
7032 private static final String _FINDER_COLUMN_LIVEGROUPID_LIVEGROUPID_2 = "group_.liveGroupId = ?";
7033 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "group_.companyId = ? AND ";
7034 private static final String _FINDER_COLUMN_C_N_NAME_1 = "group_.name IS NULL";
7035 private static final String _FINDER_COLUMN_C_N_NAME_2 = "group_.name = ?";
7036 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
7037 private static final String _FINDER_COLUMN_C_F_COMPANYID_2 = "group_.companyId = ? AND ";
7038 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_1 = "group_.friendlyURL IS NULL";
7039 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_2 = "group_.friendlyURL = ?";
7040 private static final String _FINDER_COLUMN_C_F_FRIENDLYURL_3 = "(group_.friendlyURL IS NULL OR group_.friendlyURL = ?)";
7041 private static final String _FINDER_COLUMN_T_A_TYPE_2 = "group_.type = ? AND ";
7042 private static final String _FINDER_COLUMN_T_A_ACTIVE_2 = "group_.active = ?";
7043 private static final String _FINDER_COLUMN_C_C_C_COMPANYID_2 = "group_.companyId = ? AND ";
7044 private static final String _FINDER_COLUMN_C_C_C_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
7045 private static final String _FINDER_COLUMN_C_C_C_CLASSPK_2 = "group_.classPK = ?";
7046 private static final String _FINDER_COLUMN_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
7047 private static final String _FINDER_COLUMN_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
7048 private static final String _FINDER_COLUMN_C_L_N_NAME_1 = "group_.name IS NULL";
7049 private static final String _FINDER_COLUMN_C_L_N_NAME_2 = "group_.name = ?";
7050 private static final String _FINDER_COLUMN_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
7051 private static final String _FINDER_COLUMN_C_C_L_N_COMPANYID_2 = "group_.companyId = ? AND ";
7052 private static final String _FINDER_COLUMN_C_C_L_N_CLASSNAMEID_2 = "group_.classNameId = ? AND ";
7053 private static final String _FINDER_COLUMN_C_C_L_N_LIVEGROUPID_2 = "group_.liveGroupId = ? AND ";
7054 private static final String _FINDER_COLUMN_C_C_L_N_NAME_1 = "group_.name IS NULL";
7055 private static final String _FINDER_COLUMN_C_C_L_N_NAME_2 = "group_.name = ?";
7056 private static final String _FINDER_COLUMN_C_C_L_N_NAME_3 = "(group_.name IS NULL OR group_.name = ?)";
7057 private static final String _ORDER_BY_ENTITY_ALIAS = "group_.";
7058 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Group exists with the primary key ";
7059 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Group exists with the key {";
7060 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
7061 private static Log _log = LogFactoryUtil.getLog(GroupPersistenceImpl.class);
7062 private static Group _nullGroup = new GroupImpl() {
7063 @Override
7064 public Object clone() {
7065 return this;
7066 }
7067
7068 @Override
7069 public CacheModel<Group> toCacheModel() {
7070 return _nullGroupCacheModel;
7071 }
7072 };
7073
7074 private static CacheModel<Group> _nullGroupCacheModel = new CacheModel<Group>() {
7075 public Group toEntityModel() {
7076 return _nullGroup;
7077 }
7078 };
7079 }