All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.portal.service.persistence.impl.TeamPersistenceImpl Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
/**
 * 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.EntityCacheUtil;
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.NoSuchTeamException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.Team;
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.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.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import com.liferay.portal.model.impl.TeamImpl;
import com.liferay.portal.model.impl.TeamModelImpl;

import java.io.Serializable;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;

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 team service.
 *
 * 

* Caching information and settings can be found in portal.properties *

* * @author Brian Wing Shun Chan * @generated */ @ProviderType public class TeamPersistenceImpl extends BasePersistenceImpl implements TeamPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use TeamUtil to access the team persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = TeamImpl.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"; private FinderPath _finderPathWithPaginationFindAll; private FinderPath _finderPathWithoutPaginationFindAll; private FinderPath _finderPathCountAll; private FinderPath _finderPathWithPaginationFindByUuid; private FinderPath _finderPathWithoutPaginationFindByUuid; private FinderPath _finderPathCountByUuid; /** * Returns all the teams where uuid = ?. * * @param uuid the uuid * @return the matching teams */ @Override public List findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the teams where uuid = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param uuid the uuid * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of matching teams */ @Override public List findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the teams where uuid = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param uuid the uuid * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching teams */ @Override public List findByUuid( String uuid, int start, int end, OrderByComparator orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the teams where uuid = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param uuid the uuid * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching teams */ @Override public List findByUuid( String uuid, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { uuid = Objects.toString(uuid, ""); boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByUuid; finderArgs = new Object[] {uuid}; } else { finderPath = _finderPathWithPaginationFindByUuid; finderArgs = new Object[] {uuid, start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Team team : list) { if (!uuid.equals(team.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_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { 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(TeamModelImpl.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)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first team in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByUuid_First( String uuid, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = fetchByUuid_First(uuid, orderByComparator); if (team != null) { return team; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append("}"); throw new NoSuchTeamException(msg.toString()); } /** * Returns the first team in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching team, or null if a matching team could not be found */ @Override public Team fetchByUuid_First( String uuid, OrderByComparator orderByComparator) { List list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last team in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByUuid_Last( String uuid, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = fetchByUuid_Last(uuid, orderByComparator); if (team != null) { return team; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append("}"); throw new NoSuchTeamException(msg.toString()); } /** * Returns the last team in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching team, or null if a matching team could not be found */ @Override public Team fetchByUuid_Last( String uuid, OrderByComparator orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the teams before and after the current team in the ordered set where uuid = ?. * * @param teamId the primary key of the current team * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next team * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team[] findByUuid_PrevAndNext( long teamId, String uuid, OrderByComparator orderByComparator) throws NoSuchTeamException { uuid = Objects.toString(uuid, ""); Team team = findByPrimaryKey(teamId); Session session = null; try { session = openSession(); Team[] array = new TeamImpl[3]; array[0] = getByUuid_PrevAndNext( session, team, uuid, orderByComparator, true); array[1] = team; array[2] = getByUuid_PrevAndNext( session, team, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Team getByUuid_PrevAndNext( Session session, Team team, String uuid, OrderByComparator 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_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { 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(TeamModelImpl.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) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(team)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the teams where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (Team team : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(team); } } /** * Returns the number of teams where uuid = ?. * * @param uuid the uuid * @return the number of matching teams */ @Override public int countByUuid(String uuid) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid; Object[] finderArgs = new Object[] {uuid}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { 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(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_2 = "team.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(team.uuid IS NULL OR team.uuid = '')"; private FinderPath _finderPathFetchByUUID_G; private FinderPath _finderPathCountByUUID_G; /** * Returns the team where uuid = ? and groupId = ? or throws a NoSuchTeamException if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByUUID_G(String uuid, long groupId) throws NoSuchTeamException { Team team = fetchByUUID_G(uuid, groupId); if (team == null) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", groupId="); msg.append(groupId); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchTeamException(msg.toString()); } return team; } /** * Returns the team where uuid = ? and groupId = ? or returns null if it could not be found. Uses the finder cache. * * @param uuid the uuid * @param groupId the group ID * @return the matching team, or null if a matching team could not be found */ @Override public Team fetchByUUID_G(String uuid, long groupId) { return fetchByUUID_G(uuid, groupId, true); } /** * Returns the team where uuid = ? and groupId = ? or returns null if it could not be found, optionally using the finder cache. * * @param uuid the uuid * @param groupId the group ID * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching team, or null if a matching team could not be found */ @Override public Team fetchByUUID_G( String uuid, long groupId, boolean retrieveFromCache) { uuid = Objects.toString(uuid, ""); Object[] finderArgs = new Object[] {uuid, groupId}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult( _finderPathFetchByUUID_G, finderArgs, this); } if (result instanceof Team) { Team team = (Team)result; if (!Objects.equals(uuid, team.getUuid()) || (groupId != team.getGroupId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { query.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_G_UUID_2); } query.append(_FINDER_COLUMN_UUID_G_GROUPID_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(groupId); List list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult( _finderPathFetchByUUID_G, finderArgs, list); } else { Team team = list.get(0); result = team; cacheResult(team); } } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathFetchByUUID_G, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (Team)result; } } /** * Removes the team where uuid = ? and groupId = ? from the database. * * @param uuid the uuid * @param groupId the group ID * @return the team that was removed */ @Override public Team removeByUUID_G(String uuid, long groupId) throws NoSuchTeamException { Team team = findByUUID_G(uuid, groupId); return remove(team); } /** * Returns the number of teams where uuid = ? and groupId = ?. * * @param uuid the uuid * @param groupId the group ID * @return the number of matching teams */ @Override public int countByUUID_G(String uuid, long groupId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUUID_G; Object[] finderArgs = new Object[] {uuid, groupId}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { query.append(_FINDER_COLUMN_UUID_G_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_G_UUID_2); } query.append(_FINDER_COLUMN_UUID_G_GROUPID_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(groupId); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "team.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(team.uuid IS NULL OR team.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "team.groupId = ?"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the teams where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching teams */ @Override public List findByUuid_C(String uuid, long companyId) { return findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the teams where uuid = ? and companyId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of matching teams */ @Override public List 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 teams where uuid = ? and companyId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching teams */ @Override public List findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator orderByComparator) { return findByUuid_C( uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the teams where uuid = ? and companyId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching teams */ @Override public List findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { uuid = Objects.toString(uuid, ""); boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByUuid_C; finderArgs = new Object[] {uuid, companyId}; } else { finderPath = _finderPathWithPaginationFindByUuid_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Team team : list) { if (!uuid.equals(team.getUuid()) || (companyId != team.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_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { 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(TeamModelImpl.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)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first team 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 null) * @return the first matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (team != null) { return team; } 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("}"); throw new NoSuchTeamException(msg.toString()); } /** * Returns the first team 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 null) * @return the first matching team, or null if a matching team could not be found */ @Override public Team fetchByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) { List list = findByUuid_C( uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last team 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 null) * @return the last matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (team != null) { return team; } 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("}"); throw new NoSuchTeamException(msg.toString()); } /** * Returns the last team 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 null) * @return the last matching team, or null if a matching team could not be found */ @Override public Team fetchByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List list = findByUuid_C( uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the teams before and after the current team in the ordered set where uuid = ? and companyId = ?. * * @param teamId the primary key of the current team * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next team * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team[] findByUuid_C_PrevAndNext( long teamId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchTeamException { uuid = Objects.toString(uuid, ""); Team team = findByPrimaryKey(teamId); Session session = null; try { session = openSession(); Team[] array = new TeamImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, team, uuid, companyId, orderByComparator, true); array[1] = team; array[2] = getByUuid_C_PrevAndNext( session, team, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Team getByUuid_C_PrevAndNext( Session session, Team team, String uuid, long companyId, OrderByComparator 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_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { 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(TeamModelImpl.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) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(team)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the teams 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 (Team team : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(team); } } /** * Returns the number of teams where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching teams */ @Override public int countByUuid_C(String uuid, long companyId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid_C; Object[] finderArgs = new Object[] {uuid, companyId}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_TEAM_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { 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(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "team.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(team.uuid IS NULL OR team.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "team.companyId = ?"; private FinderPath _finderPathWithPaginationFindByGroupId; private FinderPath _finderPathWithoutPaginationFindByGroupId; private FinderPath _finderPathCountByGroupId; /** * Returns all the teams where groupId = ?. * * @param groupId the group ID * @return the matching teams */ @Override public List findByGroupId(long groupId) { return findByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the teams where groupId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param groupId the group ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of matching teams */ @Override public List findByGroupId(long groupId, int start, int end) { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the teams where groupId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param groupId the group ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching teams */ @Override public List findByGroupId( long groupId, int start, int end, OrderByComparator orderByComparator) { return findByGroupId(groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the teams where groupId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param groupId the group ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching teams */ @Override public List findByGroupId( long groupId, int start, int end, OrderByComparator 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 = _finderPathWithoutPaginationFindByGroupId; finderArgs = new Object[] {groupId}; } else { finderPath = _finderPathWithPaginationFindByGroupId; finderArgs = new Object[] {groupId, start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Team team : list) { if ((groupId != team.getGroupId())) { 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_TEAM_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(TeamModelImpl.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(groupId); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first team in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByGroupId_First( long groupId, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = fetchByGroupId_First(groupId, orderByComparator); if (team != null) { return team; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append("}"); throw new NoSuchTeamException(msg.toString()); } /** * Returns the first team in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching team, or null if a matching team could not be found */ @Override public Team fetchByGroupId_First( long groupId, OrderByComparator orderByComparator) { List list = findByGroupId(groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last team in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByGroupId_Last( long groupId, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = fetchByGroupId_Last(groupId, orderByComparator); if (team != null) { return team; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append("}"); throw new NoSuchTeamException(msg.toString()); } /** * Returns the last team in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching team, or null if a matching team could not be found */ @Override public Team fetchByGroupId_Last( long groupId, OrderByComparator orderByComparator) { int count = countByGroupId(groupId); if (count == 0) { return null; } List list = findByGroupId( groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the teams before and after the current team in the ordered set where groupId = ?. * * @param teamId the primary key of the current team * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next team * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team[] findByGroupId_PrevAndNext( long teamId, long groupId, OrderByComparator orderByComparator) throws NoSuchTeamException { Team team = findByPrimaryKey(teamId); Session session = null; try { session = openSession(); Team[] array = new TeamImpl[3]; array[0] = getByGroupId_PrevAndNext( session, team, groupId, orderByComparator, true); array[1] = team; array[2] = getByGroupId_PrevAndNext( session, team, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Team getByGroupId_PrevAndNext( Session session, Team team, long groupId, OrderByComparator 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_TEAM_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_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(TeamModelImpl.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(groupId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(team)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the teams that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the matching teams that the user has permission to view */ @Override public List filterFindByGroupId(long groupId) { return filterFindByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the teams that the user has permission to view where groupId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param groupId the group ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of matching teams that the user has permission to view */ @Override public List filterFindByGroupId(long groupId, int start, int end) { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the teams that the user has permissions to view where groupId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param groupId the group ID * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching teams that the user has permission to view */ @Override public List filterFindByGroupId( long groupId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId(groupId, 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_TEAM_WHERE); } else { query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_TEAM_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(TeamModelImpl.ORDER_BY_JPQL); } else { query.append(TeamModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( query.toString(), Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the teams before and after the current team in the ordered set of teams that the user has permission to view where groupId = ?. * * @param teamId the primary key of the current team * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next team * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team[] filterFindByGroupId_PrevAndNext( long teamId, long groupId, OrderByComparator orderByComparator) throws NoSuchTeamException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext( teamId, groupId, orderByComparator); } Team team = findByPrimaryKey(teamId); Session session = null; try { session = openSession(); Team[] array = new TeamImpl[3]; array[0] = filterGetByGroupId_PrevAndNext( session, team, groupId, orderByComparator, true); array[1] = team; array[2] = filterGetByGroupId_PrevAndNext( session, team, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Team filterGetByGroupId_PrevAndNext( Session session, Team team, long groupId, OrderByComparator 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_TEAM_WHERE); } else { query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_TEAM_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( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { query.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } 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( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { query.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } 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(TeamModelImpl.ORDER_BY_JPQL); } else { query.append(TeamModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( query.toString(), Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(team)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the teams where groupId = ? from the database. * * @param groupId the group ID */ @Override public void removeByGroupId(long groupId) { for (Team team : findByGroupId( groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(team); } } /** * Returns the number of teams where groupId = ?. * * @param groupId the group ID * @return the number of matching teams */ @Override public int countByGroupId(long groupId) { FinderPath finderPath = _finderPathCountByGroupId; Object[] finderArgs = new Object[] {groupId}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_TEAM_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of teams that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the number of matching teams that the user has permission to view */ @Override public int filterCountByGroupId(long groupId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByGroupId(groupId); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_TEAM_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( query.toString(), Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); 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(groupId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?"; private FinderPath _finderPathFetchByG_N; private FinderPath _finderPathCountByG_N; /** * Returns the team where groupId = ? and name = ? or throws a NoSuchTeamException if it could not be found. * * @param groupId the group ID * @param name the name * @return the matching team * @throws NoSuchTeamException if a matching team could not be found */ @Override public Team findByG_N(long groupId, String name) throws NoSuchTeamException { Team team = fetchByG_N(groupId, name); if (team == null) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", name="); msg.append(name); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchTeamException(msg.toString()); } return team; } /** * Returns the team where groupId = ? and name = ? or returns null if it could not be found. Uses the finder cache. * * @param groupId the group ID * @param name the name * @return the matching team, or null if a matching team could not be found */ @Override public Team fetchByG_N(long groupId, String name) { return fetchByG_N(groupId, name, true); } /** * Returns the team where groupId = ? and name = ? or returns null if it could not be found, optionally using the finder cache. * * @param groupId the group ID * @param name the name * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching team, or null if a matching team could not be found */ @Override public Team fetchByG_N( long groupId, String name, boolean retrieveFromCache) { name = Objects.toString(name, ""); Object[] finderArgs = new Object[] {groupId, name}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult( _finderPathFetchByG_N, finderArgs, this); } if (result instanceof Team) { Team team = (Team)result; if ((groupId != team.getGroupId()) || !Objects.equals(name, team.getName())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_TEAM_WHERE); query.append(_FINDER_COLUMN_G_N_GROUPID_2); boolean bindName = false; if (name.isEmpty()) { query.append(_FINDER_COLUMN_G_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_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(groupId); if (bindName) { qPos.add(name); } List list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult( _finderPathFetchByG_N, finderArgs, list); } else { Team team = list.get(0); result = team; cacheResult(team); } } catch (Exception e) { FinderCacheUtil.removeResult(_finderPathFetchByG_N, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (Team)result; } } /** * Removes the team where groupId = ? and name = ? from the database. * * @param groupId the group ID * @param name the name * @return the team that was removed */ @Override public Team removeByG_N(long groupId, String name) throws NoSuchTeamException { Team team = findByG_N(groupId, name); return remove(team); } /** * Returns the number of teams where groupId = ? and name = ?. * * @param groupId the group ID * @param name the name * @return the number of matching teams */ @Override public int countByG_N(long groupId, String name) { name = Objects.toString(name, ""); FinderPath finderPath = _finderPathCountByG_N; Object[] finderArgs = new Object[] {groupId, name}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_TEAM_WHERE); query.append(_FINDER_COLUMN_G_N_GROUPID_2); boolean bindName = false; if (name.isEmpty()) { query.append(_FINDER_COLUMN_G_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_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(groupId); if (bindName) { qPos.add(name); } count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND "; private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?"; private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = '')"; public TeamPersistenceImpl() { setModelClass(Team.class); Map dbColumnNames = new HashMap(); dbColumnNames.put("uuid", "uuid_"); try { Field field = BasePersistenceImpl.class.getDeclaredField( "_dbColumnNames"); field.setAccessible(true); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the team in the entity cache if it is enabled. * * @param team the team */ @Override public void cacheResult(Team team) { EntityCacheUtil.putResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, team.getPrimaryKey(), team); FinderCacheUtil.putResult( _finderPathFetchByUUID_G, new Object[] {team.getUuid(), team.getGroupId()}, team); FinderCacheUtil.putResult( _finderPathFetchByG_N, new Object[] {team.getGroupId(), team.getName()}, team); team.resetOriginalValues(); } /** * Caches the teams in the entity cache if it is enabled. * * @param teams the teams */ @Override public void cacheResult(List teams) { for (Team team : teams) { if (EntityCacheUtil.getResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, team.getPrimaryKey()) == null) { cacheResult(team); } else { team.resetOriginalValues(); } } } /** * Clears the cache for all teams. * *

* The com.liferay.portal.kernel.dao.orm.EntityCache and com.liferay.portal.kernel.dao.orm.FinderCache are both cleared by this method. *

*/ @Override public void clearCache() { EntityCacheUtil.clearCache(TeamImpl.class); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the team. * *

* The com.liferay.portal.kernel.dao.orm.EntityCache and com.liferay.portal.kernel.dao.orm.FinderCache are both cleared by this method. *

*/ @Override public void clearCache(Team team) { EntityCacheUtil.removeResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, team.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((TeamModelImpl)team, true); } @Override public void clearCache(List teams) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (Team team : teams) { EntityCacheUtil.removeResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, team.getPrimaryKey()); clearUniqueFindersCache((TeamModelImpl)team, true); } } protected void cacheUniqueFindersCache(TeamModelImpl teamModelImpl) { Object[] args = new Object[] { teamModelImpl.getUuid(), teamModelImpl.getGroupId() }; FinderCacheUtil.putResult( _finderPathCountByUUID_G, args, Long.valueOf(1), false); FinderCacheUtil.putResult( _finderPathFetchByUUID_G, args, teamModelImpl, false); args = new Object[] { teamModelImpl.getGroupId(), teamModelImpl.getName() }; FinderCacheUtil.putResult( _finderPathCountByG_N, args, Long.valueOf(1), false); FinderCacheUtil.putResult( _finderPathFetchByG_N, args, teamModelImpl, false); } protected void clearUniqueFindersCache( TeamModelImpl teamModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { teamModelImpl.getUuid(), teamModelImpl.getGroupId() }; FinderCacheUtil.removeResult(_finderPathCountByUUID_G, args); FinderCacheUtil.removeResult(_finderPathFetchByUUID_G, args); } if ((teamModelImpl.getColumnBitmask() & _finderPathFetchByUUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { teamModelImpl.getOriginalUuid(), teamModelImpl.getOriginalGroupId() }; FinderCacheUtil.removeResult(_finderPathCountByUUID_G, args); FinderCacheUtil.removeResult(_finderPathFetchByUUID_G, args); } if (clearCurrent) { Object[] args = new Object[] { teamModelImpl.getGroupId(), teamModelImpl.getName() }; FinderCacheUtil.removeResult(_finderPathCountByG_N, args); FinderCacheUtil.removeResult(_finderPathFetchByG_N, args); } if ((teamModelImpl.getColumnBitmask() & _finderPathFetchByG_N.getColumnBitmask()) != 0) { Object[] args = new Object[] { teamModelImpl.getOriginalGroupId(), teamModelImpl.getOriginalName() }; FinderCacheUtil.removeResult(_finderPathCountByG_N, args); FinderCacheUtil.removeResult(_finderPathFetchByG_N, args); } } /** * Creates a new team with the primary key. Does not add the team to the database. * * @param teamId the primary key for the new team * @return the new team */ @Override public Team create(long teamId) { Team team = new TeamImpl(); team.setNew(true); team.setPrimaryKey(teamId); String uuid = PortalUUIDUtil.generate(); team.setUuid(uuid); team.setCompanyId(companyProvider.getCompanyId()); return team; } /** * Removes the team with the primary key from the database. Also notifies the appropriate model listeners. * * @param teamId the primary key of the team * @return the team that was removed * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team remove(long teamId) throws NoSuchTeamException { return remove((Serializable)teamId); } /** * Removes the team with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the team * @return the team that was removed * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team remove(Serializable primaryKey) throws NoSuchTeamException { Session session = null; try { session = openSession(); Team team = (Team)session.get(TeamImpl.class, primaryKey); if (team == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchTeamException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(team); } catch (NoSuchTeamException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected Team removeImpl(Team team) { teamToUserTableMapper.deleteLeftPrimaryKeyTableMappings( team.getPrimaryKey()); teamToUserGroupTableMapper.deleteLeftPrimaryKeyTableMappings( team.getPrimaryKey()); Session session = null; try { session = openSession(); if (!session.contains(team)) { team = (Team)session.get( TeamImpl.class, team.getPrimaryKeyObj()); } if (team != null) { session.delete(team); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (team != null) { clearCache(team); } return team; } @Override public Team updateImpl(Team team) { boolean isNew = team.isNew(); if (!(team instanceof TeamModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(team.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(team); throw new IllegalArgumentException( "Implement ModelWrapper in team proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom Team implementation " + team.getClass()); } TeamModelImpl teamModelImpl = (TeamModelImpl)team; if (Validator.isNull(team.getUuid())) { String uuid = PortalUUIDUtil.generate(); team.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (team.getCreateDate() == null)) { if (serviceContext == null) { team.setCreateDate(now); } else { team.setCreateDate(serviceContext.getCreateDate(now)); } } if (!teamModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { team.setModifiedDate(now); } else { team.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (team.isNew()) { session.save(team); team.setNew(false); } else { team = (Team)session.merge(team); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!TeamModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] {teamModelImpl.getUuid()}; FinderCacheUtil.removeResult(_finderPathCountByUuid, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByUuid, args); args = new Object[] { teamModelImpl.getUuid(), teamModelImpl.getCompanyId() }; FinderCacheUtil.removeResult(_finderPathCountByUuid_C, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); args = new Object[] {teamModelImpl.getGroupId()}; FinderCacheUtil.removeResult(_finderPathCountByGroupId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByGroupId, args); FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } else { if ((teamModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUuid.getColumnBitmask()) != 0) { Object[] args = new Object[] {teamModelImpl.getOriginalUuid()}; FinderCacheUtil.removeResult(_finderPathCountByUuid, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByUuid, args); args = new Object[] {teamModelImpl.getUuid()}; FinderCacheUtil.removeResult(_finderPathCountByUuid, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByUuid, args); } if ((teamModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByUuid_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { teamModelImpl.getOriginalUuid(), teamModelImpl.getOriginalCompanyId() }; FinderCacheUtil.removeResult(_finderPathCountByUuid_C, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); args = new Object[] { teamModelImpl.getUuid(), teamModelImpl.getCompanyId() }; FinderCacheUtil.removeResult(_finderPathCountByUuid_C, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByUuid_C, args); } if ((teamModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByGroupId. getColumnBitmask()) != 0) { Object[] args = new Object[] { teamModelImpl.getOriginalGroupId() }; FinderCacheUtil.removeResult(_finderPathCountByGroupId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByGroupId, args); args = new Object[] {teamModelImpl.getGroupId()}; FinderCacheUtil.removeResult(_finderPathCountByGroupId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByGroupId, args); } } EntityCacheUtil.putResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, team.getPrimaryKey(), team, false); clearUniqueFindersCache(teamModelImpl, false); cacheUniqueFindersCache(teamModelImpl); team.resetOriginalValues(); return team; } /** * Returns the team with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException if it could not be found. * * @param primaryKey the primary key of the team * @return the team * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team findByPrimaryKey(Serializable primaryKey) throws NoSuchTeamException { Team team = fetchByPrimaryKey(primaryKey); if (team == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchTeamException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return team; } /** * Returns the team with the primary key or throws a NoSuchTeamException if it could not be found. * * @param teamId the primary key of the team * @return the team * @throws NoSuchTeamException if a team with the primary key could not be found */ @Override public Team findByPrimaryKey(long teamId) throws NoSuchTeamException { return findByPrimaryKey((Serializable)teamId); } /** * Returns the team with the primary key or returns null if it could not be found. * * @param primaryKey the primary key of the team * @return the team, or null if a team with the primary key could not be found */ @Override public Team fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = EntityCacheUtil.getResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, primaryKey); if (serializable == nullModel) { return null; } Team team = (Team)serializable; if (team == null) { Session session = null; try { session = openSession(); team = (Team)session.get(TeamImpl.class, primaryKey); if (team != null) { cacheResult(team); } else { EntityCacheUtil.putResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, primaryKey, nullModel); } } catch (Exception e) { EntityCacheUtil.removeResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return team; } /** * Returns the team with the primary key or returns null if it could not be found. * * @param teamId the primary key of the team * @return the team, or null if a team with the primary key could not be found */ @Override public Team fetchByPrimaryKey(long teamId) { return fetchByPrimaryKey((Serializable)teamId); } @Override public Map fetchByPrimaryKeys( Set primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map map = new HashMap(); if (primaryKeys.size() == 1) { Iterator iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Team team = fetchByPrimaryKey(primaryKey); if (team != null) { map.put(primaryKey, team); } return map; } Set uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = EntityCacheUtil.getResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Team)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler( uncachedPrimaryKeys.size() * 2 + 1); query.append(_SQL_SELECT_TEAM_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(","); } query.setIndex(query.index() - 1); query.append(")"); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Team team : (List)q.list()) { map.put(team.getPrimaryKeyObj(), team); cacheResult(team); uncachedPrimaryKeys.remove(team.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the teams. * * @return the teams */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the teams. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of teams */ @Override public List findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the teams. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of teams */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the teams. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of teams */ @Override public List findAll( int start, int end, OrderByComparator 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 = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.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_TEAM); appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_TEAM; if (pagination) { sql = sql.concat(TeamModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the teams from the database. * */ @Override public void removeAll() { for (Team team : findAll()) { remove(team); } } /** * Returns the number of teams. * * @return the number of teams */ @Override public int countAll() { Long count = (Long)FinderCacheUtil.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_TEAM); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the primaryKeys of users associated with the team. * * @param pk the primary key of the team * @return long[] of the primaryKeys of users associated with the team */ @Override public long[] getUserPrimaryKeys(long pk) { long[] pks = teamToUserTableMapper.getRightPrimaryKeys(pk); return pks.clone(); } /** * Returns all the users associated with the team. * * @param pk the primary key of the team * @return the users associated with the team */ @Override public List getUsers(long pk) { return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } /** * Returns a range of all the users associated with the team. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param pk the primary key of the team * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of users associated with the team */ @Override public List getUsers( long pk, int start, int end) { return getUsers(pk, start, end, null); } /** * Returns an ordered range of all the users associated with the team. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param pk the primary key of the team * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of users associated with the team */ @Override public List getUsers( long pk, int start, int end, OrderByComparator orderByComparator) { return teamToUserTableMapper.getRightBaseModels( pk, start, end, orderByComparator); } /** * Returns the number of users associated with the team. * * @param pk the primary key of the team * @return the number of users associated with the team */ @Override public int getUsersSize(long pk) { long[] pks = teamToUserTableMapper.getRightPrimaryKeys(pk); return pks.length; } /** * Returns true if the user is associated with the team. * * @param pk the primary key of the team * @param userPK the primary key of the user * @return true if the user is associated with the team; false otherwise */ @Override public boolean containsUser(long pk, long userPK) { return teamToUserTableMapper.containsTableMapping(pk, userPK); } /** * Returns true if the team has any users associated with it. * * @param pk the primary key of the team to check for associations with users * @return true if the team has any users associated with it; false otherwise */ @Override public boolean containsUsers(long pk) { if (getUsersSize(pk) > 0) { return true; } else { return false; } } /** * Adds an association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userPK the primary key of the user */ @Override public void addUser(long pk, long userPK) { Team team = fetchByPrimaryKey(pk); if (team == null) { teamToUserTableMapper.addTableMapping( companyProvider.getCompanyId(), pk, userPK); } else { teamToUserTableMapper.addTableMapping( team.getCompanyId(), pk, userPK); } } /** * Adds an association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param user the user */ @Override public void addUser(long pk, com.liferay.portal.kernel.model.User user) { Team team = fetchByPrimaryKey(pk); if (team == null) { teamToUserTableMapper.addTableMapping( companyProvider.getCompanyId(), pk, user.getPrimaryKey()); } else { teamToUserTableMapper.addTableMapping( team.getCompanyId(), pk, user.getPrimaryKey()); } } /** * Adds an association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userPKs the primary keys of the users */ @Override public void addUsers(long pk, long[] userPKs) { long companyId = 0; Team team = fetchByPrimaryKey(pk); if (team == null) { companyId = companyProvider.getCompanyId(); } else { companyId = team.getCompanyId(); } teamToUserTableMapper.addTableMappings(companyId, pk, userPKs); } /** * Adds an association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param users the users */ @Override public void addUsers( long pk, List users) { addUsers( pk, ListUtil.toLongArray( users, com.liferay.portal.kernel.model.User.USER_ID_ACCESSOR)); } /** * Clears all associations between the team and its users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team to clear the associated users from */ @Override public void clearUsers(long pk) { teamToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk); } /** * Removes the association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userPK the primary key of the user */ @Override public void removeUser(long pk, long userPK) { teamToUserTableMapper.deleteTableMapping(pk, userPK); } /** * Removes the association between the team and the user. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param user the user */ @Override public void removeUser(long pk, com.liferay.portal.kernel.model.User user) { teamToUserTableMapper.deleteTableMapping(pk, user.getPrimaryKey()); } /** * Removes the association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userPKs the primary keys of the users */ @Override public void removeUsers(long pk, long[] userPKs) { teamToUserTableMapper.deleteTableMappings(pk, userPKs); } /** * Removes the association between the team and the users. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param users the users */ @Override public void removeUsers( long pk, List users) { removeUsers( pk, ListUtil.toLongArray( users, com.liferay.portal.kernel.model.User.USER_ID_ACCESSOR)); } /** * Sets the users associated with the team, 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 team * @param userPKs the primary keys of the users to be associated with the team */ @Override public void setUsers(long pk, long[] userPKs) { Set newUserPKsSet = SetUtil.fromArray(userPKs); Set oldUserPKsSet = SetUtil.fromArray( teamToUserTableMapper.getRightPrimaryKeys(pk)); Set removeUserPKsSet = new HashSet(oldUserPKsSet); removeUserPKsSet.removeAll(newUserPKsSet); teamToUserTableMapper.deleteTableMappings( pk, ArrayUtil.toLongArray(removeUserPKsSet)); newUserPKsSet.removeAll(oldUserPKsSet); long companyId = 0; Team team = fetchByPrimaryKey(pk); if (team == null) { companyId = companyProvider.getCompanyId(); } else { companyId = team.getCompanyId(); } teamToUserTableMapper.addTableMappings( companyId, pk, ArrayUtil.toLongArray(newUserPKsSet)); } /** * Sets the users associated with the team, 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 team * @param users the users to be associated with the team */ @Override public void setUsers( long pk, List 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); } } /** * Returns the primaryKeys of user groups associated with the team. * * @param pk the primary key of the team * @return long[] of the primaryKeys of user groups associated with the team */ @Override public long[] getUserGroupPrimaryKeys(long pk) { long[] pks = teamToUserGroupTableMapper.getRightPrimaryKeys(pk); return pks.clone(); } /** * Returns all the user groups associated with the team. * * @param pk the primary key of the team * @return the user groups associated with the team */ @Override public List getUserGroups( long pk) { return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } /** * Returns a range of all the user groups associated with the team. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param pk the primary key of the team * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @return the range of user groups associated with the team */ @Override public List getUserGroups( long pk, int start, int end) { return getUserGroups(pk, start, end, null); } /** * Returns an ordered range of all the user groups associated with the team. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from TeamModelImpl. If both orderByComparator 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. *

* * @param pk the primary key of the team * @param start the lower bound of the range of teams * @param end the upper bound of the range of teams (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of user groups associated with the team */ @Override public List getUserGroups( long pk, int start, int end, OrderByComparator orderByComparator) { return teamToUserGroupTableMapper.getRightBaseModels( pk, start, end, orderByComparator); } /** * Returns the number of user groups associated with the team. * * @param pk the primary key of the team * @return the number of user groups associated with the team */ @Override public int getUserGroupsSize(long pk) { long[] pks = teamToUserGroupTableMapper.getRightPrimaryKeys(pk); return pks.length; } /** * Returns true if the user group is associated with the team. * * @param pk the primary key of the team * @param userGroupPK the primary key of the user group * @return true if the user group is associated with the team; false otherwise */ @Override public boolean containsUserGroup(long pk, long userGroupPK) { return teamToUserGroupTableMapper.containsTableMapping(pk, userGroupPK); } /** * Returns true if the team has any user groups associated with it. * * @param pk the primary key of the team to check for associations with user groups * @return true if the team has any user groups associated with it; false otherwise */ @Override public boolean containsUserGroups(long pk) { if (getUserGroupsSize(pk) > 0) { return true; } else { return false; } } /** * Adds an association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroupPK the primary key of the user group */ @Override public void addUserGroup(long pk, long userGroupPK) { Team team = fetchByPrimaryKey(pk); if (team == null) { teamToUserGroupTableMapper.addTableMapping( companyProvider.getCompanyId(), pk, userGroupPK); } else { teamToUserGroupTableMapper.addTableMapping( team.getCompanyId(), pk, userGroupPK); } } /** * Adds an association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroup the user group */ @Override public void addUserGroup( long pk, com.liferay.portal.kernel.model.UserGroup userGroup) { Team team = fetchByPrimaryKey(pk); if (team == null) { teamToUserGroupTableMapper.addTableMapping( companyProvider.getCompanyId(), pk, userGroup.getPrimaryKey()); } else { teamToUserGroupTableMapper.addTableMapping( team.getCompanyId(), pk, userGroup.getPrimaryKey()); } } /** * Adds an association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroupPKs the primary keys of the user groups */ @Override public void addUserGroups(long pk, long[] userGroupPKs) { long companyId = 0; Team team = fetchByPrimaryKey(pk); if (team == null) { companyId = companyProvider.getCompanyId(); } else { companyId = team.getCompanyId(); } teamToUserGroupTableMapper.addTableMappings( companyId, pk, userGroupPKs); } /** * Adds an association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroups the user groups */ @Override public void addUserGroups( long pk, List userGroups) { addUserGroups( pk, ListUtil.toLongArray( userGroups, com.liferay.portal.kernel.model.UserGroup. USER_GROUP_ID_ACCESSOR)); } /** * Clears all associations between the team and its user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team to clear the associated user groups from */ @Override public void clearUserGroups(long pk) { teamToUserGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk); } /** * Removes the association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroupPK the primary key of the user group */ @Override public void removeUserGroup(long pk, long userGroupPK) { teamToUserGroupTableMapper.deleteTableMapping(pk, userGroupPK); } /** * Removes the association between the team and the user group. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroup the user group */ @Override public void removeUserGroup( long pk, com.liferay.portal.kernel.model.UserGroup userGroup) { teamToUserGroupTableMapper.deleteTableMapping( pk, userGroup.getPrimaryKey()); } /** * Removes the association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroupPKs the primary keys of the user groups */ @Override public void removeUserGroups(long pk, long[] userGroupPKs) { teamToUserGroupTableMapper.deleteTableMappings(pk, userGroupPKs); } /** * Removes the association between the team and the user groups. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the team * @param userGroups the user groups */ @Override public void removeUserGroups( long pk, List userGroups) { removeUserGroups( pk, ListUtil.toLongArray( userGroups, com.liferay.portal.kernel.model.UserGroup. USER_GROUP_ID_ACCESSOR)); } /** * Sets the user groups associated with the team, 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 team * @param userGroupPKs the primary keys of the user groups to be associated with the team */ @Override public void setUserGroups(long pk, long[] userGroupPKs) { Set newUserGroupPKsSet = SetUtil.fromArray(userGroupPKs); Set oldUserGroupPKsSet = SetUtil.fromArray( teamToUserGroupTableMapper.getRightPrimaryKeys(pk)); Set removeUserGroupPKsSet = new HashSet(oldUserGroupPKsSet); removeUserGroupPKsSet.removeAll(newUserGroupPKsSet); teamToUserGroupTableMapper.deleteTableMappings( pk, ArrayUtil.toLongArray(removeUserGroupPKsSet)); newUserGroupPKsSet.removeAll(oldUserGroupPKsSet); long companyId = 0; Team team = fetchByPrimaryKey(pk); if (team == null) { companyId = companyProvider.getCompanyId(); } else { companyId = team.getCompanyId(); } teamToUserGroupTableMapper.addTableMappings( companyId, pk, ArrayUtil.toLongArray(newUserGroupPKsSet)); } /** * Sets the user groups associated with the team, 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 team * @param userGroups the user groups to be associated with the team */ @Override public void setUserGroups( long pk, List userGroups) { try { long[] userGroupPKs = new long[userGroups.size()]; for (int i = 0; i < userGroups.size(); i++) { com.liferay.portal.kernel.model.UserGroup userGroup = userGroups.get(i); userGroupPKs[i] = userGroup.getPrimaryKey(); } setUserGroups(pk, userGroupPKs); } catch (Exception e) { throw processException(e); } } @Override public Set getBadColumnNames() { return _badColumnNames; } @Override protected Map getTableColumnsMap() { return TeamModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the team persistence. */ public void afterPropertiesSet() { teamToUserTableMapper = TableMapperFactory.getTableMapper( "Users_Teams", "companyId", "teamId", "userId", this, userPersistence); teamToUserGroupTableMapper = TableMapperFactory.getTableMapper( "UserGroups_Teams", "companyId", "teamId", "userGroupId", this, userGroupPersistence); _finderPathWithPaginationFindAll = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathWithPaginationFindByUuid = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByUuid = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] {String.class.getName()}, TeamModelImpl.UUID_COLUMN_BITMASK | TeamModelImpl.NAME_COLUMN_BITMASK); _finderPathCountByUuid = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] {String.class.getName()}); _finderPathFetchByUUID_G = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] {String.class.getName(), Long.class.getName()}, TeamModelImpl.UUID_COLUMN_BITMASK | TeamModelImpl.GROUPID_COLUMN_BITMASK); _finderPathCountByUUID_G = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G", new String[] {String.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByUuid_C = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.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() }); _finderPathWithoutPaginationFindByUuid_C = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, TeamModelImpl.UUID_COLUMN_BITMASK | TeamModelImpl.COMPANYID_COLUMN_BITMASK | TeamModelImpl.NAME_COLUMN_BITMASK); _finderPathCountByUuid_C = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] {String.class.getName(), Long.class.getName()}); _finderPathWithPaginationFindByGroupId = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByGroupId = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] {Long.class.getName()}, TeamModelImpl.GROUPID_COLUMN_BITMASK | TeamModelImpl.NAME_COLUMN_BITMASK); _finderPathCountByGroupId = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] {Long.class.getName()}); _finderPathFetchByG_N = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N", new String[] {Long.class.getName(), String.class.getName()}, TeamModelImpl.GROUPID_COLUMN_BITMASK | TeamModelImpl.NAME_COLUMN_BITMASK); _finderPathCountByG_N = new FinderPath( TeamModelImpl.ENTITY_CACHE_ENABLED, TeamModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N", new String[] {Long.class.getName(), String.class.getName()}); } public void destroy() { EntityCacheUtil.removeCache(TeamImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); TableMapperFactory.removeTableMapper("Users_Teams"); TableMapperFactory.removeTableMapper("UserGroups_Teams"); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; @BeanReference(type = UserPersistence.class) protected UserPersistence userPersistence; protected TableMapper teamToUserTableMapper; @BeanReference(type = UserGroupPersistence.class) protected UserGroupPersistence userGroupPersistence; protected TableMapper teamToUserGroupTableMapper; private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team"; private static final String _SQL_SELECT_TEAM_WHERE_PKS_IN = "SELECT team FROM Team team WHERE teamId IN ("; private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE "; private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team"; private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "team.teamId"; private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE "; private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE "; private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId"; private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE "; private static final String _FILTER_ENTITY_ALIAS = "team"; private static final String _FILTER_ENTITY_TABLE = "Team"; private static final String _ORDER_BY_ENTITY_ALIAS = "team."; private static final String _ORDER_BY_ENTITY_TABLE = "Team."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( TeamPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"uuid"}); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy