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