/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portal.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.SQLQuery; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.exception.NoSuchUserGroupException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.model.UserGroup; import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil; import com.liferay.portal.kernel.service.ServiceContext; import com.liferay.portal.kernel.service.ServiceContextThreadLocal; import com.liferay.portal.kernel.service.persistence.CompanyProvider; import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper; import com.liferay.portal.kernel.service.persistence.GroupPersistence; import com.liferay.portal.kernel.service.persistence.TeamPersistence; import com.liferay.portal.kernel.service.persistence.UserGroupPersistence; import com.liferay.portal.kernel.service.persistence.UserPersistence; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.service.persistence.impl.TableMapper; import com.liferay.portal.kernel.service.persistence.impl.TableMapperFactory; import com.liferay.portal.kernel.util.ArrayUtil; import com.liferay.portal.kernel.util.ListUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ReflectionUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.liferay.portal.model.impl.UserGroupImpl; import com.liferay.portal.model.impl.UserGroupModelImpl; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; /** * The persistence implementation for the user group service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see UserGroupPersistence * @see com.liferay.portal.kernel.service.persistence.UserGroupUtil * @generated */ @ProviderType public class UserGroupPersistenceImpl extends BasePersistenceImpl<UserGroup> implements UserGroupPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link UserGroupUtil} to access the user group persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = UserGroupImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, UserGroupModelImpl.UUID_COLUMN_BITMASK | UserGroupModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the user groups where uuid = ?. * * @param uuid the uuid * @return the matching user groups */ @Override public List<UserGroup> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups */ @Override public List<UserGroup> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the user groups where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByUuid(String uuid, int start, int end, OrderByComparator<UserGroup> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the user groups where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByUuid(String uuid, int start, int end, OrderByComparator<UserGroup> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid, start, end, orderByComparator }; } List<UserGroup> list = null; if (retrieveFromCache) { list = (List<UserGroup>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (UserGroup userGroup : list) { if (!Objects.equals(uuid, userGroup.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (!pagination) { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first user group in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByUuid_First(String uuid, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByUuid_First(uuid, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the first user group in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByUuid_First(String uuid, OrderByComparator<UserGroup> orderByComparator) { List<UserGroup> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last user group in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByUuid_Last(String uuid, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByUuid_Last(uuid, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the last user group in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByUuid_Last(String uuid, OrderByComparator<UserGroup> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<UserGroup> list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the user groups before and after the current user group in the ordered set where uuid = ?. * * @param userGroupId the primary key of the current user group * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] findByUuid_PrevAndNext(long userGroupId, String uuid, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = getByUuid_PrevAndNext(session, userGroup, uuid, orderByComparator, true); array[1] = userGroup; array[2] = getByUuid_PrevAndNext(session, userGroup, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup getByUuid_PrevAndNext(Session session, UserGroup userGroup, String uuid, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the user groups that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByUuid(String uuid) { return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups that the user has permission to view where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByUuid(String uuid, int start, int end) { return filterFindByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the user groups that the user has permissions to view where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByUuid(String uuid, int start, int end, OrderByComparator<UserGroup> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid(uuid, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1_SQL); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the user groups before and after the current user group in the ordered set of user groups that the user has permission to view where uuid = ?. * * @param userGroupId the primary key of the current user group * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] filterFindByUuid_PrevAndNext(long userGroupId, String uuid, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid_PrevAndNext(userGroupId, uuid, orderByComparator); } UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = filterGetByUuid_PrevAndNext(session, userGroup, uuid, orderByComparator, true); array[1] = userGroup; array[2] = filterGetByUuid_PrevAndNext(session, userGroup, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup filterGetByUuid_PrevAndNext(Session session, UserGroup userGroup, String uuid, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1_SQL); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the user groups where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (UserGroup userGroup : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(userGroup); } } /** * Returns the number of user groups where uuid = ?. * * @param uuid the uuid * @return the number of matching user groups */ @Override public int countByUuid(String uuid) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID; Object[] finderArgs = new Object[] { uuid }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of user groups that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the number of matching user groups that the user has permission to view */ @Override public int filterCountByUuid(String uuid) { if (!InlineSQLHelperUtil.isEnabled()) { return countByUuid(uuid); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1_SQL); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_UUID_UUID_1 = "userGroup.uuid IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2 = "userGroup.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(userGroup.uuid IS NULL OR userGroup.uuid = '')"; private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "userGroup.uuid_ IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "userGroup.uuid_ = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(userGroup.uuid_ IS NULL OR userGroup.uuid_ = '')"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, UserGroupModelImpl.UUID_COLUMN_BITMASK | UserGroupModelImpl.COMPANYID_COLUMN_BITMASK | UserGroupModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the user groups where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching user groups */ @Override public List<UserGroup> findByUuid_C(String uuid, long companyId) { return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups */ @Override public List<UserGroup> findByUuid_C(String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the user groups where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<UserGroup> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the user groups where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<UserGroup> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<UserGroup> list = null; if (retrieveFromCache) { list = (List<UserGroup>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (UserGroup userGroup : list) { if (!Objects.equals(uuid, userGroup.getUuid()) || (companyId != userGroup.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (!pagination) { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first user group in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByUuid_C_First(String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the first user group in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator) { List<UserGroup> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last user group in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByUuid_C_Last(String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the last user group in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<UserGroup> list = findByUuid_C(uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the user groups before and after the current user group in the ordered set where uuid = ? and companyId = ?. * * @param userGroupId the primary key of the current user group * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] findByUuid_C_PrevAndNext(long userGroupId, String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = getByUuid_C_PrevAndNext(session, userGroup, uuid, companyId, orderByComparator, true); array[1] = userGroup; array[2] = getByUuid_C_PrevAndNext(session, userGroup, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup getByUuid_C_PrevAndNext(Session session, UserGroup userGroup, String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the user groups that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByUuid_C(String uuid, long companyId) { return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups that the user has permission to view where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByUuid_C(String uuid, long companyId, int start, int end) { return filterFindByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the user groups that the user has permissions to view where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<UserGroup> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C(uuid, companyId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the user groups before and after the current user group in the ordered set of user groups that the user has permission to view where uuid = ? and companyId = ?. * * @param userGroupId the primary key of the current user group * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] filterFindByUuid_C_PrevAndNext(long userGroupId, String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C_PrevAndNext(userGroupId, uuid, companyId, orderByComparator); } UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = filterGetByUuid_C_PrevAndNext(session, userGroup, uuid, companyId, orderByComparator, true); array[1] = userGroup; array[2] = filterGetByUuid_C_PrevAndNext(session, userGroup, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup filterGetByUuid_C_PrevAndNext(Session session, UserGroup userGroup, String uuid, long companyId, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the user groups where uuid = ? and companyId = ? from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (UserGroup userGroup : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(userGroup); } } /** * Returns the number of user groups where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching user groups */ @Override public int countByUuid_C(String uuid, long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C; Object[] finderArgs = new Object[] { uuid, companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of user groups that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching user groups that the user has permission to view */ @Override public int filterCountByUuid_C(String uuid, long companyId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByUuid_C(uuid, companyId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "userGroup.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "userGroup.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(userGroup.uuid IS NULL OR userGroup.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "userGroup.uuid_ IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "userGroup.uuid_ = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(userGroup.uuid_ IS NULL OR userGroup.uuid_ = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "userGroup.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] { Long.class.getName() }, UserGroupModelImpl.COMPANYID_COLUMN_BITMASK | UserGroupModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] { Long.class.getName() }); /** * Returns all the user groups where companyId = ?. * * @param companyId the company ID * @return the matching user groups */ @Override public List<UserGroup> findByCompanyId(long companyId) { return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups */ @Override public List<UserGroup> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the user groups where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByCompanyId(long companyId, int start, int end, OrderByComparator<UserGroup> orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the user groups where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByCompanyId(long companyId, int start, int end, OrderByComparator<UserGroup> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId, start, end, orderByComparator }; } List<UserGroup> list = null; if (retrieveFromCache) { list = (List<UserGroup>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (UserGroup userGroup : list) { if ((companyId != userGroup.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (!pagination) { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first user group in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByCompanyId_First(long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByCompanyId_First(companyId, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the first user group in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByCompanyId_First(long companyId, OrderByComparator<UserGroup> orderByComparator) { List<UserGroup> list = findByCompanyId(companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last user group in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByCompanyId_Last(long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByCompanyId_Last(companyId, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the last user group in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByCompanyId_Last(long companyId, OrderByComparator<UserGroup> orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List<UserGroup> list = findByCompanyId(companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the user groups before and after the current user group in the ordered set where companyId = ?. * * @param userGroupId the primary key of the current user group * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] findByCompanyId_PrevAndNext(long userGroupId, long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = getByCompanyId_PrevAndNext(session, userGroup, companyId, orderByComparator, true); array[1] = userGroup; array[2] = getByCompanyId_PrevAndNext(session, userGroup, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup getByCompanyId_PrevAndNext(Session session, UserGroup userGroup, long companyId, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the user groups that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByCompanyId(long companyId) { return filterFindByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups that the user has permission to view where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByCompanyId(long companyId, int start, int end) { return filterFindByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the user groups that the user has permissions to view where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByCompanyId(long companyId, int start, int end, OrderByComparator<UserGroup> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId(companyId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the user groups before and after the current user group in the ordered set of user groups that the user has permission to view where companyId = ?. * * @param userGroupId the primary key of the current user group * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] filterFindByCompanyId_PrevAndNext(long userGroupId, long companyId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId_PrevAndNext(userGroupId, companyId, orderByComparator); } UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = filterGetByCompanyId_PrevAndNext(session, userGroup, companyId, orderByComparator, true); array[1] = userGroup; array[2] = filterGetByCompanyId_PrevAndNext(session, userGroup, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup filterGetByCompanyId_PrevAndNext(Session session, UserGroup userGroup, long companyId, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the user groups where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (UserGroup userGroup : findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(userGroup); } } /** * Returns the number of user groups where companyId = ?. * * @param companyId the company ID * @return the number of matching user groups */ @Override public int countByCompanyId(long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID; Object[] finderArgs = new Object[] { companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of user groups that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the number of matching user groups that the user has permission to view */ @Override public int filterCountByCompanyId(long companyId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByCompanyId(companyId); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "userGroup.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P", new String[] { Long.class.getName(), Long.class.getName() }, UserGroupModelImpl.COMPANYID_COLUMN_BITMASK | UserGroupModelImpl.PARENTUSERGROUPID_COLUMN_BITMASK | UserGroupModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the user groups where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @return the matching user groups */ @Override public List<UserGroup> findByC_P(long companyId, long parentUserGroupId) { return findByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups where companyId = ? and parentUserGroupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups */ @Override public List<UserGroup> findByC_P(long companyId, long parentUserGroupId, int start, int end) { return findByC_P(companyId, parentUserGroupId, start, end, null); } /** * Returns an ordered range of all the user groups where companyId = ? and parentUserGroupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByC_P(long companyId, long parentUserGroupId, int start, int end, OrderByComparator<UserGroup> orderByComparator) { return findByC_P(companyId, parentUserGroupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the user groups where companyId = ? and parentUserGroupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching user groups */ @Override public List<UserGroup> findByC_P(long companyId, long parentUserGroupId, int start, int end, OrderByComparator<UserGroup> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P; finderArgs = new Object[] { companyId, parentUserGroupId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P; finderArgs = new Object[] { companyId, parentUserGroupId, start, end, orderByComparator }; } List<UserGroup> list = null; if (retrieveFromCache) { list = (List<UserGroup>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (UserGroup userGroup : list) { if ((companyId != userGroup.getCompanyId()) || (parentUserGroupId != userGroup.getParentUserGroupId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_C_P_COMPANYID_2); query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(parentUserGroupId); if (!pagination) { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first user group in the ordered set where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByC_P_First(long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByC_P_First(companyId, parentUserGroupId, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", parentUserGroupId="); msg.append(parentUserGroupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the first user group in the ordered set where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByC_P_First(long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator) { List<UserGroup> list = findByC_P(companyId, parentUserGroupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last user group in the ordered set where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByC_P_Last(long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = fetchByC_P_Last(companyId, parentUserGroupId, orderByComparator); if (userGroup != null) { return userGroup; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", parentUserGroupId="); msg.append(parentUserGroupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchUserGroupException(msg.toString()); } /** * Returns the last user group in the ordered set where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByC_P_Last(long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator) { int count = countByC_P(companyId, parentUserGroupId); if (count == 0) { return null; } List<UserGroup> list = findByC_P(companyId, parentUserGroupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the user groups before and after the current user group in the ordered set where companyId = ? and parentUserGroupId = ?. * * @param userGroupId the primary key of the current user group * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] findByC_P_PrevAndNext(long userGroupId, long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = getByC_P_PrevAndNext(session, userGroup, companyId, parentUserGroupId, orderByComparator, true); array[1] = userGroup; array[2] = getByC_P_PrevAndNext(session, userGroup, companyId, parentUserGroupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup getByC_P_PrevAndNext(Session session, UserGroup userGroup, long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_C_P_COMPANYID_2); query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(parentUserGroupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the user groups that the user has permission to view where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @return the matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByC_P(long companyId, long parentUserGroupId) { return filterFindByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups that the user has permission to view where companyId = ? and parentUserGroupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByC_P(long companyId, long parentUserGroupId, int start, int end) { return filterFindByC_P(companyId, parentUserGroupId, start, end, null); } /** * Returns an ordered range of all the user groups that the user has permissions to view where companyId = ? and parentUserGroupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching user groups that the user has permission to view */ @Override public List<UserGroup> filterFindByC_P(long companyId, long parentUserGroupId, int start, int end, OrderByComparator<UserGroup> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_P(companyId, parentUserGroupId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_C_P_COMPANYID_2); query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(parentUserGroupId); return (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the user groups before and after the current user group in the ordered set of user groups that the user has permission to view where companyId = ? and parentUserGroupId = ?. * * @param userGroupId the primary key of the current user group * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup[] filterFindByC_P_PrevAndNext(long userGroupId, long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator) throws NoSuchUserGroupException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByC_P_PrevAndNext(userGroupId, companyId, parentUserGroupId, orderByComparator); } UserGroup userGroup = findByPrimaryKey(userGroupId); Session session = null; try { session = openSession(); UserGroup[] array = new UserGroupImpl[3]; array[0] = filterGetByC_P_PrevAndNext(session, userGroup, companyId, parentUserGroupId, orderByComparator, true); array[1] = userGroup; array[2] = filterGetByC_P_PrevAndNext(session, userGroup, companyId, parentUserGroupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected UserGroup filterGetByC_P_PrevAndNext(Session session, UserGroup userGroup, long companyId, long parentUserGroupId, OrderByComparator<UserGroup> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_WHERE); } else { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_C_P_COMPANYID_2); query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(UserGroupModelImpl.ORDER_BY_JPQL); } else { query.append(UserGroupModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, UserGroupImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, UserGroupImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(parentUserGroupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(userGroup); for (Object value : values) { qPos.add(value); } } List<UserGroup> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the user groups where companyId = ? and parentUserGroupId = ? from the database. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID */ @Override public void removeByC_P(long companyId, long parentUserGroupId) { for (UserGroup userGroup : findByC_P(companyId, parentUserGroupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(userGroup); } } /** * Returns the number of user groups where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @return the number of matching user groups */ @Override public int countByC_P(long companyId, long parentUserGroupId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P; Object[] finderArgs = new Object[] { companyId, parentUserGroupId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_C_P_COMPANYID_2); query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(parentUserGroupId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of user groups that the user has permission to view where companyId = ? and parentUserGroupId = ?. * * @param companyId the company ID * @param parentUserGroupId the parent user group ID * @return the number of matching user groups that the user has permission to view */ @Override public int filterCountByC_P(long companyId, long parentUserGroupId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByC_P(companyId, parentUserGroupId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_C_P_COMPANYID_2); query.append(_FINDER_COLUMN_C_P_PARENTUSERGROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), UserGroup.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(parentUserGroupId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "userGroup.companyId = ? AND "; private static final String _FINDER_COLUMN_C_P_PARENTUSERGROUPID_2 = "userGroup.parentUserGroupId = ?"; public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, UserGroupImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByC_N", new String[] { Long.class.getName(), String.class.getName() }, UserGroupModelImpl.COMPANYID_COLUMN_BITMASK | UserGroupModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N", new String[] { Long.class.getName(), String.class.getName() }); /** * Returns the user group where companyId = ? and name = ? or throws a {@link NoSuchUserGroupException} if it could not be found. * * @param companyId the company ID * @param name the name * @return the matching user group * @throws NoSuchUserGroupException if a matching user group could not be found */ @Override public UserGroup findByC_N(long companyId, String name) throws NoSuchUserGroupException { UserGroup userGroup = fetchByC_N(companyId, name); if (userGroup == null) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", name="); msg.append(name); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchUserGroupException(msg.toString()); } return userGroup; } /** * Returns the user group where companyId = ? and name = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param companyId the company ID * @param name the name * @return the matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByC_N(long companyId, String name) { return fetchByC_N(companyId, name, true); } /** * Returns the user group where companyId = ? and name = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param companyId the company ID * @param name the name * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching user group, or <code>null</code> if a matching user group could not be found */ @Override public UserGroup fetchByC_N(long companyId, String name, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { companyId, name }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_C_N, finderArgs, this); } if (result instanceof UserGroup) { UserGroup userGroup = (UserGroup)result; if ((companyId != userGroup.getCompanyId()) || !Objects.equals(name, userGroup.getName())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_C_N_COMPANYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_C_N_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_C_N_NAME_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } List<UserGroup> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_C_N, finderArgs, list); } else { UserGroup userGroup = list.get(0); result = userGroup; cacheResult(userGroup); if ((userGroup.getCompanyId() != companyId) || (userGroup.getName() == null) || !userGroup.getName().equals(name)) { finderCache.putResult(FINDER_PATH_FETCH_BY_C_N, finderArgs, userGroup); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_C_N, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (UserGroup)result; } } /** * Removes the user group where companyId = ? and name = ? from the database. * * @param companyId the company ID * @param name the name * @return the user group that was removed */ @Override public UserGroup removeByC_N(long companyId, String name) throws NoSuchUserGroupException { UserGroup userGroup = findByC_N(companyId, name); return remove(userGroup); } /** * Returns the number of user groups where companyId = ? and name = ?. * * @param companyId the company ID * @param name the name * @return the number of matching user groups */ @Override public int countByC_N(long companyId, String name) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_N; Object[] finderArgs = new Object[] { companyId, name }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_USERGROUP_WHERE); query.append(_FINDER_COLUMN_C_N_COMPANYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_C_N_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_C_N_NAME_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "userGroup.companyId = ? AND "; private static final String _FINDER_COLUMN_C_N_NAME_1 = "userGroup.name IS NULL"; private static final String _FINDER_COLUMN_C_N_NAME_2 = "lower(userGroup.name) = ?"; private static final String _FINDER_COLUMN_C_N_NAME_3 = "(userGroup.name IS NULL OR userGroup.name = '')"; public UserGroupPersistenceImpl() { setModelClass(UserGroup.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the user group in the entity cache if it is enabled. * * @param userGroup the user group */ @Override public void cacheResult(UserGroup userGroup) { entityCache.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup); finderCache.putResult(FINDER_PATH_FETCH_BY_C_N, new Object[] { userGroup.getCompanyId(), userGroup.getName() }, userGroup); userGroup.resetOriginalValues(); } /** * Caches the user groups in the entity cache if it is enabled. * * @param userGroups the user groups */ @Override public void cacheResult(List<UserGroup> userGroups) { for (UserGroup userGroup : userGroups) { if (entityCache.getResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, userGroup.getPrimaryKey()) == null) { cacheResult(userGroup); } else { userGroup.resetOriginalValues(); } } } /** * Clears the cache for all user groups. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(UserGroupImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the user group. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(UserGroup userGroup) { entityCache.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, userGroup.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((UserGroupModelImpl)userGroup, true); } @Override public void clearCache(List<UserGroup> userGroups) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (UserGroup userGroup : userGroups) { entityCache.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, userGroup.getPrimaryKey()); clearUniqueFindersCache((UserGroupModelImpl)userGroup, true); } } protected void cacheUniqueFindersCache( UserGroupModelImpl userGroupModelImpl) { Object[] args = new Object[] { userGroupModelImpl.getCompanyId(), userGroupModelImpl.getName() }; finderCache.putResult(FINDER_PATH_COUNT_BY_C_N, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_C_N, args, userGroupModelImpl, false); } protected void clearUniqueFindersCache( UserGroupModelImpl userGroupModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { userGroupModelImpl.getCompanyId(), userGroupModelImpl.getName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_N, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_C_N, args); } if ((userGroupModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) { Object[] args = new Object[] { userGroupModelImpl.getOriginalCompanyId(), userGroupModelImpl.getOriginalName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_N, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_C_N, args); } } /** * Creates a new user group with the primary key. Does not add the user group to the database. * * @param userGroupId the primary key for the new user group * @return the new user group */ @Override public UserGroup create(long userGroupId) { UserGroup userGroup = new UserGroupImpl(); userGroup.setNew(true); userGroup.setPrimaryKey(userGroupId); String uuid = PortalUUIDUtil.generate(); userGroup.setUuid(uuid); userGroup.setCompanyId(companyProvider.getCompanyId()); return userGroup; } /** * Removes the user group with the primary key from the database. Also notifies the appropriate model listeners. * * @param userGroupId the primary key of the user group * @return the user group that was removed * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup remove(long userGroupId) throws NoSuchUserGroupException { return remove((Serializable)userGroupId); } /** * Removes the user group with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the user group * @return the user group that was removed * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup remove(Serializable primaryKey) throws NoSuchUserGroupException { Session session = null; try { session = openSession(); UserGroup userGroup = (UserGroup)session.get(UserGroupImpl.class, primaryKey); if (userGroup == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(userGroup); } catch (NoSuchUserGroupException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected UserGroup removeImpl(UserGroup userGroup) { userGroup = toUnwrappedModel(userGroup); userGroupToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(userGroup.getPrimaryKey()); userGroupToTeamTableMapper.deleteLeftPrimaryKeyTableMappings(userGroup.getPrimaryKey()); userGroupToUserTableMapper.deleteLeftPrimaryKeyTableMappings(userGroup.getPrimaryKey()); Session session = null; try { session = openSession(); if (!session.contains(userGroup)) { userGroup = (UserGroup)session.get(UserGroupImpl.class, userGroup.getPrimaryKeyObj()); } if (userGroup != null) { session.delete(userGroup); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (userGroup != null) { clearCache(userGroup); } return userGroup; } @Override public UserGroup updateImpl(UserGroup userGroup) { userGroup = toUnwrappedModel(userGroup); boolean isNew = userGroup.isNew(); UserGroupModelImpl userGroupModelImpl = (UserGroupModelImpl)userGroup; if (Validator.isNull(userGroup.getUuid())) { String uuid = PortalUUIDUtil.generate(); userGroup.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (userGroup.getCreateDate() == null)) { if (serviceContext == null) { userGroup.setCreateDate(now); } else { userGroup.setCreateDate(serviceContext.getCreateDate(now)); } } if (!userGroupModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { userGroup.setModifiedDate(now); } else { userGroup.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (userGroup.isNew()) { session.save(userGroup); userGroup.setNew(false); } else { userGroup = (UserGroup)session.merge(userGroup); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!UserGroupModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { userGroupModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { userGroupModelImpl.getUuid(), userGroupModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { userGroupModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { userGroupModelImpl.getCompanyId(), userGroupModelImpl.getParentUserGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((userGroupModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { userGroupModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { userGroupModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((userGroupModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { userGroupModelImpl.getOriginalUuid(), userGroupModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { userGroupModelImpl.getUuid(), userGroupModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((userGroupModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { userGroupModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { userGroupModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } if ((userGroupModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) { Object[] args = new Object[] { userGroupModelImpl.getOriginalCompanyId(), userGroupModelImpl.getOriginalParentUserGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P, args); args = new Object[] { userGroupModelImpl.getCompanyId(), userGroupModelImpl.getParentUserGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_P, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P, args); } } entityCache.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, userGroup.getPrimaryKey(), userGroup, false); clearUniqueFindersCache(userGroupModelImpl, false); cacheUniqueFindersCache(userGroupModelImpl); userGroup.resetOriginalValues(); return userGroup; } protected UserGroup toUnwrappedModel(UserGroup userGroup) { if (userGroup instanceof UserGroupImpl) { return userGroup; } UserGroupImpl userGroupImpl = new UserGroupImpl(); userGroupImpl.setNew(userGroup.isNew()); userGroupImpl.setPrimaryKey(userGroup.getPrimaryKey()); userGroupImpl.setMvccVersion(userGroup.getMvccVersion()); userGroupImpl.setUuid(userGroup.getUuid()); userGroupImpl.setUserGroupId(userGroup.getUserGroupId()); userGroupImpl.setCompanyId(userGroup.getCompanyId()); userGroupImpl.setUserId(userGroup.getUserId()); userGroupImpl.setUserName(userGroup.getUserName()); userGroupImpl.setCreateDate(userGroup.getCreateDate()); userGroupImpl.setModifiedDate(userGroup.getModifiedDate()); userGroupImpl.setParentUserGroupId(userGroup.getParentUserGroupId()); userGroupImpl.setName(userGroup.getName()); userGroupImpl.setDescription(userGroup.getDescription()); userGroupImpl.setAddedByLDAPImport(userGroup.isAddedByLDAPImport()); return userGroupImpl; } /** * Returns the user group with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the user group * @return the user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup findByPrimaryKey(Serializable primaryKey) throws NoSuchUserGroupException { UserGroup userGroup = fetchByPrimaryKey(primaryKey); if (userGroup == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchUserGroupException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return userGroup; } /** * Returns the user group with the primary key or throws a {@link NoSuchUserGroupException} if it could not be found. * * @param userGroupId the primary key of the user group * @return the user group * @throws NoSuchUserGroupException if a user group with the primary key could not be found */ @Override public UserGroup findByPrimaryKey(long userGroupId) throws NoSuchUserGroupException { return findByPrimaryKey((Serializable)userGroupId); } /** * Returns the user group with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the user group * @return the user group, or <code>null</code> if a user group with the primary key could not be found */ @Override public UserGroup fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, primaryKey); if (serializable == nullModel) { return null; } UserGroup userGroup = (UserGroup)serializable; if (userGroup == null) { Session session = null; try { session = openSession(); userGroup = (UserGroup)session.get(UserGroupImpl.class, primaryKey); if (userGroup != null) { cacheResult(userGroup); } else { entityCache.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return userGroup; } /** * Returns the user group with the primary key or returns <code>null</code> if it could not be found. * * @param userGroupId the primary key of the user group * @return the user group, or <code>null</code> if a user group with the primary key could not be found */ @Override public UserGroup fetchByPrimaryKey(long userGroupId) { return fetchByPrimaryKey((Serializable)userGroupId); } @Override public Map<Serializable, UserGroup> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, UserGroup> map = new HashMap<Serializable, UserGroup>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); UserGroup userGroup = fetchByPrimaryKey(primaryKey); if (userGroup != null) { map.put(primaryKey, userGroup); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (UserGroup)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_USERGROUP_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (UserGroup userGroup : (List<UserGroup>)q.list()) { map.put(userGroup.getPrimaryKeyObj(), userGroup); cacheResult(userGroup); uncachedPrimaryKeys.remove(userGroup.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(UserGroupModelImpl.ENTITY_CACHE_ENABLED, UserGroupImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the user groups. * * @return the user groups */ @Override public List<UserGroup> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the user groups. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of user groups */ @Override public List<UserGroup> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the user groups. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of user groups */ @Override public List<UserGroup> findAll(int start, int end, OrderByComparator<UserGroup> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the user groups. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of user groups */ @Override public List<UserGroup> findAll(int start, int end, OrderByComparator<UserGroup> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<UserGroup> list = null; if (retrieveFromCache) { list = (List<UserGroup>)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_USERGROUP); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_USERGROUP; if (pagination) { sql = sql.concat(UserGroupModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<UserGroup>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the user groups from the database. * */ @Override public void removeAll() { for (UserGroup userGroup : findAll()) { remove(userGroup); } } /** * Returns the number of user groups. * * @return the number of user groups */ @Override public int countAll() { Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_USERGROUP); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the primaryKeys of groups associated with the user group. * * @param pk the primary key of the user group * @return long[] of the primaryKeys of groups associated with the user group */ @Override public long[] getGroupPrimaryKeys(long pk) { long[] pks = userGroupToGroupTableMapper.getRightPrimaryKeys(pk); return pks.clone(); } /** * Returns all the groups associated with the user group. * * @param pk the primary key of the user group * @return the groups associated with the user group */ @Override public List<com.liferay.portal.kernel.model.Group> getGroups(long pk) { return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } /** * Returns a range of all the groups associated with the user group. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the user group * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of groups associated with the user group */ @Override public List<com.liferay.portal.kernel.model.Group> getGroups(long pk, int start, int end) { return getGroups(pk, start, end, null); } /** * Returns an ordered range of all the groups associated with the user group. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the user group * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of groups associated with the user group */ @Override public List<com.liferay.portal.kernel.model.Group> getGroups(long pk, int start, int end, OrderByComparator<com.liferay.portal.kernel.model.Group> orderByComparator) { return userGroupToGroupTableMapper.getRightBaseModels(pk, start, end, orderByComparator); } /** * Returns the number of groups associated with the user group. * * @param pk the primary key of the user group * @return the number of groups associated with the user group */ @Override public int getGroupsSize(long pk) { long[] pks = userGroupToGroupTableMapper.getRightPrimaryKeys(pk); return pks.length; } /** * Returns <code>true</code> if the group is associated with the user group. * * @param pk the primary key of the user group * @param groupPK the primary key of the group * @return <code>true</code> if the group is associated with the user group; <code>false</code> otherwise */ @Override public boolean containsGroup(long pk, long groupPK) { return userGroupToGroupTableMapper.containsTableMapping(pk, groupPK); } /** * Returns <code>true</code> if the user group has any groups associated with it. * * @param pk the primary key of the user group to check for associations with groups * @return <code>true</code> if the user group has any groups associated with it; <code>false</code> otherwise */ @Override public boolean containsGroups(long pk) { if (getGroupsSize(pk) > 0) { return true; } else { return false; } } /** * Adds an association between the user group and the group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groupPK the primary key of the group */ @Override public void addGroup(long pk, long groupPK) { UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { userGroupToGroupTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, groupPK); } else { userGroupToGroupTableMapper.addTableMapping(userGroup.getCompanyId(), pk, groupPK); } } /** * Adds an association between the user group and the group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param group the group */ @Override public void addGroup(long pk, com.liferay.portal.kernel.model.Group group) { UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { userGroupToGroupTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, group.getPrimaryKey()); } else { userGroupToGroupTableMapper.addTableMapping(userGroup.getCompanyId(), pk, group.getPrimaryKey()); } } /** * Adds an association between the user group and the groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groupPKs the primary keys of the groups */ @Override public void addGroups(long pk, long[] groupPKs) { long companyId = 0; UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { companyId = companyProvider.getCompanyId(); } else { companyId = userGroup.getCompanyId(); } userGroupToGroupTableMapper.addTableMappings(companyId, pk, groupPKs); } /** * Adds an association between the user group and the groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groups the groups */ @Override public void addGroups(long pk, List<com.liferay.portal.kernel.model.Group> groups) { addGroups(pk, ListUtil.toLongArray(groups, com.liferay.portal.kernel.model.Group.GROUP_ID_ACCESSOR)); } /** * Clears all associations between the user group and its groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group to clear the associated groups from */ @Override public void clearGroups(long pk) { userGroupToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk); } /** * Removes the association between the user group and the group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groupPK the primary key of the group */ @Override public void removeGroup(long pk, long groupPK) { userGroupToGroupTableMapper.deleteTableMapping(pk, groupPK); } /** * Removes the association between the user group and the group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param group the group */ @Override public void removeGroup(long pk, com.liferay.portal.kernel.model.Group group) { userGroupToGroupTableMapper.deleteTableMapping(pk, group.getPrimaryKey()); } /** * Removes the association between the user group and the groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groupPKs the primary keys of the groups */ @Override public void removeGroups(long pk, long[] groupPKs) { userGroupToGroupTableMapper.deleteTableMappings(pk, groupPKs); } /** * Removes the association between the user group and the groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groups the groups */ @Override public void removeGroups(long pk, List<com.liferay.portal.kernel.model.Group> groups) { removeGroups(pk, ListUtil.toLongArray(groups, com.liferay.portal.kernel.model.Group.GROUP_ID_ACCESSOR)); } /** * Sets the groups associated with the user group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groupPKs the primary keys of the groups to be associated with the user group */ @Override public void setGroups(long pk, long[] groupPKs) { Set<Long> newGroupPKsSet = SetUtil.fromArray(groupPKs); Set<Long> oldGroupPKsSet = SetUtil.fromArray(userGroupToGroupTableMapper.getRightPrimaryKeys( pk)); Set<Long> removeGroupPKsSet = new HashSet<Long>(oldGroupPKsSet); removeGroupPKsSet.removeAll(newGroupPKsSet); userGroupToGroupTableMapper.deleteTableMappings(pk, ArrayUtil.toLongArray(removeGroupPKsSet)); newGroupPKsSet.removeAll(oldGroupPKsSet); long companyId = 0; UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { companyId = companyProvider.getCompanyId(); } else { companyId = userGroup.getCompanyId(); } userGroupToGroupTableMapper.addTableMappings(companyId, pk, ArrayUtil.toLongArray(newGroupPKsSet)); } /** * Sets the groups associated with the user group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param groups the groups to be associated with the user group */ @Override public void setGroups(long pk, List<com.liferay.portal.kernel.model.Group> groups) { try { long[] groupPKs = new long[groups.size()]; for (int i = 0; i < groups.size(); i++) { com.liferay.portal.kernel.model.Group group = groups.get(i); groupPKs[i] = group.getPrimaryKey(); } setGroups(pk, groupPKs); } catch (Exception e) { throw processException(e); } } /** * Returns the primaryKeys of teams associated with the user group. * * @param pk the primary key of the user group * @return long[] of the primaryKeys of teams associated with the user group */ @Override public long[] getTeamPrimaryKeys(long pk) { long[] pks = userGroupToTeamTableMapper.getRightPrimaryKeys(pk); return pks.clone(); } /** * Returns all the teams associated with the user group. * * @param pk the primary key of the user group * @return the teams associated with the user group */ @Override public List<com.liferay.portal.kernel.model.Team> getTeams(long pk) { return getTeams(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } /** * Returns a range of all the teams associated with the user group. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the user group * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of teams associated with the user group */ @Override public List<com.liferay.portal.kernel.model.Team> getTeams(long pk, int start, int end) { return getTeams(pk, start, end, null); } /** * Returns an ordered range of all the teams associated with the user group. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the user group * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of teams associated with the user group */ @Override public List<com.liferay.portal.kernel.model.Team> getTeams(long pk, int start, int end, OrderByComparator<com.liferay.portal.kernel.model.Team> orderByComparator) { return userGroupToTeamTableMapper.getRightBaseModels(pk, start, end, orderByComparator); } /** * Returns the number of teams associated with the user group. * * @param pk the primary key of the user group * @return the number of teams associated with the user group */ @Override public int getTeamsSize(long pk) { long[] pks = userGroupToTeamTableMapper.getRightPrimaryKeys(pk); return pks.length; } /** * Returns <code>true</code> if the team is associated with the user group. * * @param pk the primary key of the user group * @param teamPK the primary key of the team * @return <code>true</code> if the team is associated with the user group; <code>false</code> otherwise */ @Override public boolean containsTeam(long pk, long teamPK) { return userGroupToTeamTableMapper.containsTableMapping(pk, teamPK); } /** * Returns <code>true</code> if the user group has any teams associated with it. * * @param pk the primary key of the user group to check for associations with teams * @return <code>true</code> if the user group has any teams associated with it; <code>false</code> otherwise */ @Override public boolean containsTeams(long pk) { if (getTeamsSize(pk) > 0) { return true; } else { return false; } } /** * Adds an association between the user group and the team. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teamPK the primary key of the team */ @Override public void addTeam(long pk, long teamPK) { UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { userGroupToTeamTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, teamPK); } else { userGroupToTeamTableMapper.addTableMapping(userGroup.getCompanyId(), pk, teamPK); } } /** * Adds an association between the user group and the team. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param team the team */ @Override public void addTeam(long pk, com.liferay.portal.kernel.model.Team team) { UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { userGroupToTeamTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, team.getPrimaryKey()); } else { userGroupToTeamTableMapper.addTableMapping(userGroup.getCompanyId(), pk, team.getPrimaryKey()); } } /** * Adds an association between the user group and the teams. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teamPKs the primary keys of the teams */ @Override public void addTeams(long pk, long[] teamPKs) { long companyId = 0; UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { companyId = companyProvider.getCompanyId(); } else { companyId = userGroup.getCompanyId(); } userGroupToTeamTableMapper.addTableMappings(companyId, pk, teamPKs); } /** * Adds an association between the user group and the teams. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teams the teams */ @Override public void addTeams(long pk, List<com.liferay.portal.kernel.model.Team> teams) { addTeams(pk, ListUtil.toLongArray(teams, com.liferay.portal.kernel.model.Team.TEAM_ID_ACCESSOR)); } /** * Clears all associations between the user group and its teams. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group to clear the associated teams from */ @Override public void clearTeams(long pk) { userGroupToTeamTableMapper.deleteLeftPrimaryKeyTableMappings(pk); } /** * Removes the association between the user group and the team. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teamPK the primary key of the team */ @Override public void removeTeam(long pk, long teamPK) { userGroupToTeamTableMapper.deleteTableMapping(pk, teamPK); } /** * Removes the association between the user group and the team. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param team the team */ @Override public void removeTeam(long pk, com.liferay.portal.kernel.model.Team team) { userGroupToTeamTableMapper.deleteTableMapping(pk, team.getPrimaryKey()); } /** * Removes the association between the user group and the teams. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teamPKs the primary keys of the teams */ @Override public void removeTeams(long pk, long[] teamPKs) { userGroupToTeamTableMapper.deleteTableMappings(pk, teamPKs); } /** * Removes the association between the user group and the teams. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teams the teams */ @Override public void removeTeams(long pk, List<com.liferay.portal.kernel.model.Team> teams) { removeTeams(pk, ListUtil.toLongArray(teams, com.liferay.portal.kernel.model.Team.TEAM_ID_ACCESSOR)); } /** * Sets the teams associated with the user group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teamPKs the primary keys of the teams to be associated with the user group */ @Override public void setTeams(long pk, long[] teamPKs) { Set<Long> newTeamPKsSet = SetUtil.fromArray(teamPKs); Set<Long> oldTeamPKsSet = SetUtil.fromArray(userGroupToTeamTableMapper.getRightPrimaryKeys( pk)); Set<Long> removeTeamPKsSet = new HashSet<Long>(oldTeamPKsSet); removeTeamPKsSet.removeAll(newTeamPKsSet); userGroupToTeamTableMapper.deleteTableMappings(pk, ArrayUtil.toLongArray(removeTeamPKsSet)); newTeamPKsSet.removeAll(oldTeamPKsSet); long companyId = 0; UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { companyId = companyProvider.getCompanyId(); } else { companyId = userGroup.getCompanyId(); } userGroupToTeamTableMapper.addTableMappings(companyId, pk, ArrayUtil.toLongArray(newTeamPKsSet)); } /** * Sets the teams associated with the user group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param teams the teams to be associated with the user group */ @Override public void setTeams(long pk, List<com.liferay.portal.kernel.model.Team> teams) { try { long[] teamPKs = new long[teams.size()]; for (int i = 0; i < teams.size(); i++) { com.liferay.portal.kernel.model.Team team = teams.get(i); teamPKs[i] = team.getPrimaryKey(); } setTeams(pk, teamPKs); } catch (Exception e) { throw processException(e); } } /** * Returns the primaryKeys of users associated with the user group. * * @param pk the primary key of the user group * @return long[] of the primaryKeys of users associated with the user group */ @Override public long[] getUserPrimaryKeys(long pk) { long[] pks = userGroupToUserTableMapper.getRightPrimaryKeys(pk); return pks.clone(); } /** * Returns all the users associated with the user group. * * @param pk the primary key of the user group * @return the users associated with the user group */ @Override public List<com.liferay.portal.kernel.model.User> getUsers(long pk) { return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } /** * Returns a range of all the users associated with the user group. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the user group * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @return the range of users associated with the user group */ @Override public List<com.liferay.portal.kernel.model.User> getUsers(long pk, int start, int end) { return getUsers(pk, start, end, null); } /** * Returns an ordered range of all the users associated with the user group. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link UserGroupModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the user group * @param start the lower bound of the range of user groups * @param end the upper bound of the range of user groups (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of users associated with the user group */ @Override public List<com.liferay.portal.kernel.model.User> getUsers(long pk, int start, int end, OrderByComparator<com.liferay.portal.kernel.model.User> orderByComparator) { return userGroupToUserTableMapper.getRightBaseModels(pk, start, end, orderByComparator); } /** * Returns the number of users associated with the user group. * * @param pk the primary key of the user group * @return the number of users associated with the user group */ @Override public int getUsersSize(long pk) { long[] pks = userGroupToUserTableMapper.getRightPrimaryKeys(pk); return pks.length; } /** * Returns <code>true</code> if the user is associated with the user group. * * @param pk the primary key of the user group * @param userPK the primary key of the user * @return <code>true</code> if the user is associated with the user group; <code>false</code> otherwise */ @Override public boolean containsUser(long pk, long userPK) { return userGroupToUserTableMapper.containsTableMapping(pk, userPK); } /** * Returns <code>true</code> if the user group has any users associated with it. * * @param pk the primary key of the user group to check for associations with users * @return <code>true</code> if the user group has any users associated with it; <code>false</code> otherwise */ @Override public boolean containsUsers(long pk) { if (getUsersSize(pk) > 0) { return true; } else { return false; } } /** * Adds an association between the user group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param userPK the primary key of the user */ @Override public void addUser(long pk, long userPK) { UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { userGroupToUserTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, userPK); } else { userGroupToUserTableMapper.addTableMapping(userGroup.getCompanyId(), pk, userPK); } } /** * Adds an association between the user group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param user the user */ @Override public void addUser(long pk, com.liferay.portal.kernel.model.User user) { UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { userGroupToUserTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, user.getPrimaryKey()); } else { userGroupToUserTableMapper.addTableMapping(userGroup.getCompanyId(), pk, user.getPrimaryKey()); } } /** * Adds an association between the user group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param userPKs the primary keys of the users */ @Override public void addUsers(long pk, long[] userPKs) { long companyId = 0; UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { companyId = companyProvider.getCompanyId(); } else { companyId = userGroup.getCompanyId(); } userGroupToUserTableMapper.addTableMappings(companyId, pk, userPKs); } /** * Adds an association between the user group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param users the users */ @Override public void addUsers(long pk, List<com.liferay.portal.kernel.model.User> users) { addUsers(pk, ListUtil.toLongArray(users, com.liferay.portal.kernel.model.User.USER_ID_ACCESSOR)); } /** * Clears all associations between the user group and its users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group to clear the associated users from */ @Override public void clearUsers(long pk) { userGroupToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk); } /** * Removes the association between the user group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param userPK the primary key of the user */ @Override public void removeUser(long pk, long userPK) { userGroupToUserTableMapper.deleteTableMapping(pk, userPK); } /** * Removes the association between the user group and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param user the user */ @Override public void removeUser(long pk, com.liferay.portal.kernel.model.User user) { userGroupToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey()); } /** * Removes the association between the user group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param userPKs the primary keys of the users */ @Override public void removeUsers(long pk, long[] userPKs) { userGroupToUserTableMapper.deleteTableMappings(pk, userPKs); } /** * Removes the association between the user group and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param users the users */ @Override public void removeUsers(long pk, List<com.liferay.portal.kernel.model.User> users) { removeUsers(pk, ListUtil.toLongArray(users, com.liferay.portal.kernel.model.User.USER_ID_ACCESSOR)); } /** * Sets the users associated with the user group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param userPKs the primary keys of the users to be associated with the user group */ @Override public void setUsers(long pk, long[] userPKs) { Set<Long> newUserPKsSet = SetUtil.fromArray(userPKs); Set<Long> oldUserPKsSet = SetUtil.fromArray(userGroupToUserTableMapper.getRightPrimaryKeys( pk)); Set<Long> removeUserPKsSet = new HashSet<Long>(oldUserPKsSet); removeUserPKsSet.removeAll(newUserPKsSet); userGroupToUserTableMapper.deleteTableMappings(pk, ArrayUtil.toLongArray(removeUserPKsSet)); newUserPKsSet.removeAll(oldUserPKsSet); long companyId = 0; UserGroup userGroup = fetchByPrimaryKey(pk); if (userGroup == null) { companyId = companyProvider.getCompanyId(); } else { companyId = userGroup.getCompanyId(); } userGroupToUserTableMapper.addTableMappings(companyId, pk, ArrayUtil.toLongArray(newUserPKsSet)); } /** * Sets the users associated with the user group, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the user group * @param users the users to be associated with the user group */ @Override public void setUsers(long pk, List<com.liferay.portal.kernel.model.User> users) { try { long[] userPKs = new long[users.size()]; for (int i = 0; i < users.size(); i++) { com.liferay.portal.kernel.model.User user = users.get(i); userPKs[i] = user.getPrimaryKey(); } setUsers(pk, userPKs); } catch (Exception e) { throw processException(e); } } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected Map<String, Integer> getTableColumnsMap() { return UserGroupModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the user group persistence. */ public void afterPropertiesSet() { userGroupToGroupTableMapper = TableMapperFactory.getTableMapper("Groups_UserGroups", "companyId", "userGroupId", "groupId", this, groupPersistence); userGroupToTeamTableMapper = TableMapperFactory.getTableMapper("UserGroups_Teams", "companyId", "userGroupId", "teamId", this, teamPersistence); userGroupToUserTableMapper = TableMapperFactory.getTableMapper("Users_UserGroups", "companyId", "userGroupId", "userId", this, userPersistence); } public void destroy() { entityCache.removeCache(UserGroupImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); TableMapperFactory.removeTableMapper("Groups_UserGroups"); TableMapperFactory.removeTableMapper("UserGroups_Teams"); TableMapperFactory.removeTableMapper("Users_UserGroups"); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; protected EntityCache entityCache = EntityCacheUtil.getEntityCache(); protected FinderCache finderCache = FinderCacheUtil.getFinderCache(); @BeanReference(type = GroupPersistence.class) protected GroupPersistence groupPersistence; protected TableMapper<UserGroup, com.liferay.portal.kernel.model.Group> userGroupToGroupTableMapper; @BeanReference(type = TeamPersistence.class) protected TeamPersistence teamPersistence; protected TableMapper<UserGroup, com.liferay.portal.kernel.model.Team> userGroupToTeamTableMapper; @BeanReference(type = UserPersistence.class) protected UserPersistence userPersistence; protected TableMapper<UserGroup, com.liferay.portal.kernel.model.User> userGroupToUserTableMapper; private static final String _SQL_SELECT_USERGROUP = "SELECT userGroup FROM UserGroup userGroup"; private static final String _SQL_SELECT_USERGROUP_WHERE_PKS_IN = "SELECT userGroup FROM UserGroup userGroup WHERE userGroupId IN ("; private static final String _SQL_SELECT_USERGROUP_WHERE = "SELECT userGroup FROM UserGroup userGroup WHERE "; private static final String _SQL_COUNT_USERGROUP = "SELECT COUNT(userGroup) FROM UserGroup userGroup"; private static final String _SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(userGroup) FROM UserGroup userGroup WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "userGroup.userGroupId"; private static final String _FILTER_SQL_SELECT_USERGROUP_WHERE = "SELECT DISTINCT {userGroup.*} FROM UserGroup userGroup WHERE "; private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {UserGroup.*} FROM (SELECT DISTINCT userGroup.userGroupId FROM UserGroup userGroup WHERE "; private static final String _FILTER_SQL_SELECT_USERGROUP_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN UserGroup ON TEMP_TABLE.userGroupId = UserGroup.userGroupId"; private static final String _FILTER_SQL_COUNT_USERGROUP_WHERE = "SELECT COUNT(DISTINCT userGroup.userGroupId) AS COUNT_VALUE FROM UserGroup userGroup WHERE "; private static final String _FILTER_ENTITY_ALIAS = "userGroup"; private static final String _FILTER_ENTITY_TABLE = "UserGroup"; private static final String _ORDER_BY_ENTITY_ALIAS = "userGroup."; private static final String _ORDER_BY_ENTITY_TABLE = "UserGroup."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No UserGroup exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No UserGroup exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(UserGroupPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid" }); }