/** * 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.portlet.asset.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.asset.kernel.exception.NoSuchCategoryException; import com.liferay.asset.kernel.model.AssetCategory; import com.liferay.asset.kernel.service.persistence.AssetCategoryPersistence; import com.liferay.asset.kernel.service.persistence.AssetEntryPersistence; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.SQLQuery; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; 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.impl.BasePersistenceImpl; import com.liferay.portal.kernel.service.persistence.impl.NestedSetsTreeManager; import com.liferay.portal.kernel.service.persistence.impl.PersistenceNestedSetsTreeManager; 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.CharPool; import com.liferay.portal.kernel.util.ListUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ReflectionUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.StringUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.liferay.portlet.asset.model.impl.AssetCategoryImpl; import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Arrays; 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 asset category service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see AssetCategoryPersistence * @see com.liferay.asset.kernel.service.persistence.AssetCategoryUtil * @generated */ @ProviderType public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory> implements AssetCategoryPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link AssetCategoryUtil} to access the asset category persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countAncestors", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countDescendants", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "getAncestors", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "getDescendants", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, AssetCategoryModelImpl.UUID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the asset categories where uuid = ?. * * @param uuid the uuid * @return the matching asset categories */ @Override public List<AssetCategory> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the asset categories where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByUuid(String uuid, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByUuid(String uuid, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if (!Objects.equals(uuid, assetCategory.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_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByUuid_First(String uuid, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByUuid_First(String uuid, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByUuid_Last(String uuid, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByUuid_Last(String uuid, OrderByComparator<AssetCategory> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<AssetCategory> list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where uuid = ?. * * @param categoryId the primary key of the current asset category * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid, orderByComparator, true); array[1] = assetCategory; array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByUuid_PrevAndNext(Session session, AssetCategory assetCategory, String uuid, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where uuid = ?. * * @param uuid the uuid * @return the number of matching asset categories */ @Override public int countByUuid(String uuid) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID; Object[] finderArgs = new Object[] { uuid }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')"; public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G", new String[] { String.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.UUID_COLUMN_BITMASK | AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns the asset category where uuid = ? and groupId = ? or throws a {@link NoSuchCategoryException} if it could not be found. * * @param uuid the uuid * @param groupId the group ID * @return the matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByUUID_G(String uuid, long groupId) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByUUID_G(uuid, groupId); if (assetCategory == 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(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchCategoryException(msg.toString()); } return assetCategory; } /** * Returns the asset category where uuid = ? and groupId = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param uuid the uuid * @param groupId the group ID * @return the matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByUUID_G(String uuid, long groupId) { return fetchByUUID_G(uuid, groupId, true); } /** * Returns the asset category where uuid = ? and groupId = ? or returns <code>null</code> 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 asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByUUID_G(String uuid, long groupId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { uuid, groupId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, this); } if (result instanceof AssetCategory) { AssetCategory assetCategory = (AssetCategory)result; if (!Objects.equals(uuid, assetCategory.getUuid()) || (groupId != assetCategory.getGroupId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_G_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { 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<AssetCategory> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, list); } else { AssetCategory assetCategory = list.get(0); result = assetCategory; cacheResult(assetCategory); if ((assetCategory.getUuid() == null) || !assetCategory.getUuid().equals(uuid) || (assetCategory.getGroupId() != groupId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs, assetCategory); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (AssetCategory)result; } } /** * Removes the asset category where uuid = ? and groupId = ? from the database. * * @param uuid the uuid * @param groupId the group ID * @return the asset category that was removed */ @Override public AssetCategory removeByUUID_G(String uuid, long groupId) throws NoSuchCategoryException { AssetCategory assetCategory = findByUUID_G(uuid, groupId); return remove(assetCategory); } /** * Returns the number of asset categories where uuid = ? and groupId = ?. * * @param uuid the uuid * @param groupId the group ID * @return the number of matching asset categories */ @Override public int countByUUID_G(String uuid, long groupId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G; Object[] finderArgs = new Object[] { uuid, groupId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_G_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { 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(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.UUID_COLUMN_BITMASK | AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching asset categories */ @Override public List<AssetCategory> findByUuid_C(String uuid, long companyId) { return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> 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 asset categories where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if (!Objects.equals(uuid, assetCategory.getUuid()) || (companyId != assetCategory.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_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByUuid_C_First(String uuid, long companyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByUuid_C_Last(String uuid, long companyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where uuid = ? and companyId = ?. * * @param categoryId the primary key of the current asset category * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId, String uuid, long companyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid, companyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByUuid_C_PrevAndNext(Session session, AssetCategory assetCategory, String uuid, long companyId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories 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 (AssetCategory assetCategory : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching asset categories */ @Override public int countByUuid_C(String uuid, long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C; Object[] finderArgs = new Object[] { uuid, companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId", new String[] { Long.class.getName() }, AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId", new String[] { Long.class.getName() }); /** * Returns all the asset categories where groupId = ?. * * @param groupId the group ID * @return the matching asset categories */ @Override public List<AssetCategory> findByGroupId(long groupId) { return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByGroupId(long groupId, int start, int end) { return findByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByGroupId(long groupId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByGroupId(groupId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByGroupId(long groupId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { groupId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { groupId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByGroupId_First(long groupId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByGroupId_First(groupId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByGroupId_First(long groupId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByGroupId(groupId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByGroupId_Last(long groupId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByGroupId_Last(groupId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where groupId = ?. * * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByGroupId_Last(long groupId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByGroupId(groupId); if (count == 0) { return null; } List<AssetCategory> list = findByGroupId(groupId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where groupId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByGroupId_PrevAndNext(long categoryId, long groupId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByGroupId_PrevAndNext(session, assetCategory, groupId, orderByComparator, true); array[1] = assetCategory; array[2] = getByGroupId_PrevAndNext(session, assetCategory, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByGroupId_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_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(AssetCategoryModelImpl.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) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByGroupId(long groupId) { return filterFindByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByGroupId(long groupId, int start, int end) { return filterFindByGroupId(groupId, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByGroupId(long groupId, int start, int end, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId, long groupId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByGroupId_PrevAndNext(categoryId, groupId, orderByComparator); } AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory, groupId, orderByComparator, true); array[1] = assetCategory; array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory, groupId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory filterGetByGroupId_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where groupId = ? from the database. * * @param groupId the group ID */ @Override public void removeByGroupId(long groupId) { for (AssetCategory assetCategory : findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where groupId = ?. * * @param groupId the group ID * @return the number of matching asset categories */ @Override public int countByGroupId(long groupId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID; Object[] finderArgs = new Object[] { groupId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_ASSETCATEGORY_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(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories that the user has permission to view where groupId = ?. * * @param groupId the group ID * @return the number of matching asset categories 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_GROUPID_GROUPID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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 = "assetCategory.groupId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByParentCategoryId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByParentCategoryId", new String[] { Long.class.getName() }, AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByParentCategoryId", new String[] { Long.class.getName() }); /** * Returns all the asset categories where parentCategoryId = ?. * * @param parentCategoryId the parent category ID * @return the matching asset categories */ @Override public List<AssetCategory> findByParentCategoryId(long parentCategoryId) { return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByParentCategoryId(long parentCategoryId, int start, int end) { return findByParentCategoryId(parentCategoryId, start, end, null); } /** * Returns an ordered range of all the asset categories where parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByParentCategoryId(long parentCategoryId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByParentCategoryId(parentCategoryId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where parentCategoryId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByParentCategoryId(long parentCategoryId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID; finderArgs = new Object[] { parentCategoryId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID; finderArgs = new Object[] { parentCategoryId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((parentCategoryId != assetCategory.getParentCategoryId())) { 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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(parentCategoryId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where parentCategoryId = ?. * * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByParentCategoryId_First(long parentCategoryId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where parentCategoryId = ?. * * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByParentCategoryId_First(long parentCategoryId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where parentCategoryId = ?. * * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByParentCategoryId_Last(long parentCategoryId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where parentCategoryId = ?. * * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByParentCategoryId(parentCategoryId); if (count == 0) { return null; } List<AssetCategory> list = findByParentCategoryId(parentCategoryId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = ?. * * @param categoryId the primary key of the current asset category * @param parentCategoryId the parent category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId, long parentCategoryId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByParentCategoryId_PrevAndNext(session, assetCategory, parentCategoryId, orderByComparator, true); array[1] = assetCategory; array[2] = getByParentCategoryId_PrevAndNext(session, assetCategory, parentCategoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByParentCategoryId_PrevAndNext(Session session, AssetCategory assetCategory, long parentCategoryId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_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(AssetCategoryModelImpl.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(parentCategoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where parentCategoryId = ? from the database. * * @param parentCategoryId the parent category ID */ @Override public void removeByParentCategoryId(long parentCategoryId) { for (AssetCategory assetCategory : findByParentCategoryId( parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where parentCategoryId = ?. * * @param parentCategoryId the parent category ID * @return the number of matching asset categories */ @Override public int countByParentCategoryId(long parentCategoryId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID; Object[] finderArgs = new Object[] { parentCategoryId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(parentCategoryId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByVocabularyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByVocabularyId", new String[] { Long.class.getName() }, AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId", new String[] { Long.class.getName() }); /** * Returns all the asset categories where vocabularyId = ?. * * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByVocabularyId(long vocabularyId) { return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByVocabularyId(long vocabularyId, int start, int end) { return findByVocabularyId(vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByVocabularyId(long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByVocabularyId(vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByVocabularyId(long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID; finderArgs = new Object[] { vocabularyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID; finderArgs = new Object[] { vocabularyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((vocabularyId != assetCategory.getVocabularyId())) { 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where vocabularyId = ?. * * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByVocabularyId_First(long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where vocabularyId = ?. * * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByVocabularyId_First(long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where vocabularyId = ?. * * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByVocabularyId_Last(long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where vocabularyId = ?. * * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByVocabularyId_Last(long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByVocabularyId(vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByVocabularyId_PrevAndNext(session, assetCategory, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByVocabularyId_PrevAndNext(session, assetCategory, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByVocabularyId_PrevAndNext(Session session, AssetCategory assetCategory, long vocabularyId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_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(AssetCategoryModelImpl.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(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where vocabularyId = ? from the database. * * @param vocabularyId the vocabulary ID */ @Override public void removeByVocabularyId(long vocabularyId) { for (AssetCategory assetCategory : findByVocabularyId(vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where vocabularyId = ?. * * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByVocabularyId(long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID; Object[] finderArgs = new Object[] { vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_V", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_V", new String[] { Long.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK | AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V", new String[] { Long.class.getName(), Long.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long vocabularyId) { return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long vocabularyId, int start, int end) { return findByG_V(groupId, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByG_V(groupId, vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V; finderArgs = new Object[] { groupId, vocabularyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V; finderArgs = new Object[] { groupId, vocabularyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.getGroupId()) || (vocabularyId != assetCategory.getVocabularyId())) { 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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); qPos.add(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_V_First(long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_V_First(long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_V_Last(long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByG_V(groupId, vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where groupId = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByG_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, long vocabularyId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_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(AssetCategoryModelImpl.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); qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId) { return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId, int start, int end) { return filterFindByG_V(groupId, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_V(groupId, vocabularyId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_V_GROUPID_2); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(vocabularyId); return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId, long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId, orderByComparator); } AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = filterGetByG_V_PrevAndNext(session, assetCategory, groupId, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = filterGetByG_V_PrevAndNext(session, assetCategory, groupId, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory filterGetByG_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_V_GROUPID_2); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ? and vocabularyId = any ?. * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_V(long groupId, long[] vocabularyIds) { return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_V(long groupId, long[] vocabularyIds, int start, int end) { return filterFindByG_V(groupId, vocabularyIds, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permission to view where groupId = ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_V(long groupId, long[] vocabularyIds, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_V(groupId, vocabularyIds, start, end, orderByComparator); } if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_V_GROUPID_2); if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the asset categories where groupId = ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @return the matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds) { return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds, int start, int end) { return findByG_V(groupId, vocabularyIds, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByG_V(groupId, vocabularyIds, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ? and vocabularyId = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } if (vocabularyIds.length == 1) { return findByG_V(groupId, vocabularyIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds), start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.getGroupId()) || !ArrayUtil.contains(vocabularyIds, assetCategory.getVocabularyId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the asset categories where groupId = ? and vocabularyId = ? from the database. * * @param groupId the group ID * @param vocabularyId the vocabulary ID */ @Override public void removeByG_V(long groupId, long vocabularyId) { for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByG_V(long groupId, long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V; Object[] finderArgs = new Object[] { groupId, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories where groupId = ? and vocabularyId = any ?. * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @return the number of matching asset categories */ @Override public int countByG_V(long groupId, long[] vocabularyIds) { if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } Object[] finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); 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(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories that the user has permission to view where groupId = ? and vocabularyId = ?. * * @param groupId the group ID * @param vocabularyId the vocabulary ID * @return the number of matching asset categories that the user has permission to view */ @Override public int filterCountByG_V(long groupId, long vocabularyId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_V(groupId, vocabularyId); } StringBundler query = new StringBundler(3); query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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); qPos.add(vocabularyId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of asset categories that the user has permission to view where groupId = ? and vocabularyId = any ?. * * @param groupId the group ID * @param vocabularyIds the vocabulary IDs * @return the number of matching asset categories that the user has permission to view */ @Override public int filterCountByG_V(long groupId, long[] vocabularyIds) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_V(groupId, vocabularyIds); } if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_V_GROUPID_2); if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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_G_V_GROUPID_2 = "assetCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; private static final String _FINDER_COLUMN_G_V_VOCABULARYID_7 = "assetCategory.vocabularyId IN ("; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_N", new String[] { Long.class.getName(), String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_N", new String[] { Long.class.getName(), String.class.getName() }, AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N", new String[] { Long.class.getName(), String.class.getName() }); /** * Returns all the asset categories where parentCategoryId = ? and name = ?. * * @param parentCategoryId the parent category ID * @param name the name * @return the matching asset categories */ @Override public List<AssetCategory> findByP_N(long parentCategoryId, String name) { return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where parentCategoryId = ? and name = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param name the name * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByP_N(long parentCategoryId, String name, int start, int end) { return findByP_N(parentCategoryId, name, start, end, null); } /** * Returns an ordered range of all the asset categories where parentCategoryId = ? and name = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param name the name * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByP_N(long parentCategoryId, String name, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByP_N(parentCategoryId, name, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where parentCategoryId = ? and name = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param name the name * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByP_N(long parentCategoryId, String name, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N; finderArgs = new Object[] { parentCategoryId, name }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N; finderArgs = new Object[] { parentCategoryId, name, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((parentCategoryId != assetCategory.getParentCategoryId()) || !Objects.equals(name, assetCategory.getName())) { 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_P_N_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_P_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_P_N_NAME_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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(parentCategoryId); if (bindName) { qPos.add(name); } if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where parentCategoryId = ? and name = ?. * * @param parentCategoryId the parent category ID * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByP_N_First(long parentCategoryId, String name, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(", name="); msg.append(name); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where parentCategoryId = ? and name = ?. * * @param parentCategoryId the parent category ID * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByP_N_First(long parentCategoryId, String name, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where parentCategoryId = ? and name = ?. * * @param parentCategoryId the parent category ID * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByP_N_Last(long parentCategoryId, String name, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(", name="); msg.append(name); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where parentCategoryId = ? and name = ?. * * @param parentCategoryId the parent category ID * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByP_N_Last(long parentCategoryId, String name, OrderByComparator<AssetCategory> orderByComparator) { int count = countByP_N(parentCategoryId, name); if (count == 0) { return null; } List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = ? and name = ?. * * @param categoryId the primary key of the current asset category * @param parentCategoryId the parent category ID * @param name the name * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByP_N_PrevAndNext(long categoryId, long parentCategoryId, String name, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByP_N_PrevAndNext(session, assetCategory, parentCategoryId, name, orderByComparator, true); array[1] = assetCategory; array[2] = getByP_N_PrevAndNext(session, assetCategory, parentCategoryId, name, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByP_N_PrevAndNext(Session session, AssetCategory assetCategory, long parentCategoryId, String name, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_P_N_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_P_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_P_N_NAME_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(AssetCategoryModelImpl.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(parentCategoryId); if (bindName) { qPos.add(name); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where parentCategoryId = ? and name = ? from the database. * * @param parentCategoryId the parent category ID * @param name the name */ @Override public void removeByP_N(long parentCategoryId, String name) { for (AssetCategory assetCategory : findByP_N(parentCategoryId, name, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where parentCategoryId = ? and name = ?. * * @param parentCategoryId the parent category ID * @param name the name * @return the number of matching asset categories */ @Override public int countByP_N(long parentCategoryId, String name) { FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N; Object[] finderArgs = new Object[] { parentCategoryId, name }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_P_N_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_P_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_P_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(parentCategoryId); if (bindName) { qPos.add(name); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL"; private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?"; private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_V", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_V", new String[] { Long.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where parentCategoryId = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByP_V(long parentCategoryId, long vocabularyId) { return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByP_V(long parentCategoryId, long vocabularyId, int start, int end) { return findByP_V(parentCategoryId, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByP_V(long parentCategoryId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByP_V(parentCategoryId, vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByP_V(long parentCategoryId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V; finderArgs = new Object[] { parentCategoryId, vocabularyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V; finderArgs = new Object[] { parentCategoryId, vocabularyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((parentCategoryId != assetCategory.getParentCategoryId()) || (vocabularyId != assetCategory.getVocabularyId())) { 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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(parentCategoryId); qPos.add(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where parentCategoryId = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByP_V_First(long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByP_V_First(parentCategoryId, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where parentCategoryId = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByP_V_First(long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where parentCategoryId = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByP_V_Last(long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where parentCategoryId = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByP_V_Last(long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByP_V(parentCategoryId, vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByP_V_PrevAndNext(long categoryId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByP_V_PrevAndNext(session, assetCategory, parentCategoryId, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByP_V_PrevAndNext(session, assetCategory, parentCategoryId, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByP_V_PrevAndNext(Session session, AssetCategory assetCategory, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_P_V_VOCABULARYID_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(AssetCategoryModelImpl.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(parentCategoryId); qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where parentCategoryId = ? and vocabularyId = ? from the database. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID */ @Override public void removeByP_V(long parentCategoryId, long vocabularyId) { for (AssetCategory assetCategory : findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where parentCategoryId = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByP_V(long parentCategoryId, long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V; Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(parentCategoryId); qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByN_V", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByN_V", new String[] { String.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.NAME_COLUMN_BITMASK | AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where name = ? and vocabularyId = ?. * * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByN_V(String name, long vocabularyId) { return findByN_V(name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByN_V(String name, long vocabularyId, int start, int end) { return findByN_V(name, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByN_V(String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByN_V(name, vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByN_V(String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V; finderArgs = new Object[] { name, vocabularyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V; finderArgs = new Object[] { name, vocabularyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if (!Objects.equals(name, assetCategory.getName()) || (vocabularyId != assetCategory.getVocabularyId())) { 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_ASSETCATEGORY_WHERE); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_N_V_NAME_2); } query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where name = ? and vocabularyId = ?. * * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByN_V_First(String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where name = ? and vocabularyId = ?. * * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByN_V_First(String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where name = ? and vocabularyId = ?. * * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByN_V_Last(String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where name = ? and vocabularyId = ?. * * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByN_V_Last(String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByN_V(name, vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where name = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByN_V_PrevAndNext(session, assetCategory, name, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByN_V_PrevAndNext(session, assetCategory, name, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByN_V_PrevAndNext(Session session, AssetCategory assetCategory, String name, long vocabularyId, OrderByComparator<AssetCategory> 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_ASSETCATEGORY_WHERE); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_N_V_NAME_2); } query.append(_FINDER_COLUMN_N_V_VOCABULARYID_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where name = ? and vocabularyId = ? from the database. * * @param name the name * @param vocabularyId the vocabulary ID */ @Override public void removeByN_V(String name, long vocabularyId) { for (AssetCategory assetCategory : findByN_V(name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where name = ? and vocabularyId = ?. * * @param name the name * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByN_V(String name, long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V; Object[] finderArgs = new Object[] { name, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_N_V_NAME_2); } query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND "; private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND "; private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND "; private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_V", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_V", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK | AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V", new String[] { Long.class.getName(), Long.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId, long vocabularyId) { return findByG_P_V(groupId, parentCategoryId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId, long vocabularyId, int start, int end) { return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V; finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V; finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.getGroupId()) || (parentCategoryId != assetCategory.getParentCategoryId()) || (vocabularyId != assetCategory.getVocabularyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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); qPos.add(parentCategoryId); qPos.add(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_P_V_First(groupId, parentCategoryId, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_P_V_First(long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId, vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_P_V_Last(groupId, parentCategoryId, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByG_P_V(groupId, parentCategoryId, vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId, vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId, long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByG_P_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_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(AssetCategoryModelImpl.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); qPos.add(parentCategoryId); qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_P_V(long groupId, long parentCategoryId, long vocabularyId) { return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_P_V(long groupId, long parentCategoryId, long vocabularyId, int start, int end) { return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_P_V(long groupId, long parentCategoryId, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(vocabularyId); return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId, long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_V_PrevAndNext(categoryId, groupId, parentCategoryId, vocabularyId, orderByComparator); } AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, long parentCategoryId, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where groupId = ? and parentCategoryId = ? and vocabularyId = ? from the database. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID */ @Override public void removeByG_P_V(long groupId, long parentCategoryId, long vocabularyId) { for (AssetCategory assetCategory : findByG_P_V(groupId, parentCategoryId, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByG_P_V(long groupId, long parentCategoryId, long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V; Object[] finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param vocabularyId the vocabulary ID * @return the number of matching asset categories that the user has permission to view */ @Override public int filterCountByG_P_V(long groupId, long parentCategoryId, long vocabularyId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P_V(groupId, parentCategoryId, vocabularyId); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2); query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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); qPos.add(parentCategoryId); qPos.add(vocabularyId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LikeN_V", new String[] { Long.class.getName(), String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V", new String[] { Long.class.getName(), String.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long vocabularyId) { return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ? and name LIKE ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long vocabularyId, int start, int end) { return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ? and name LIKE ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByG_LikeN_V(groupId, name, vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ? and name LIKE ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V; finderArgs = new Object[] { groupId, name, vocabularyId, start, end, orderByComparator }; List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.getGroupId()) || !StringUtil.wildcardMatches( assetCategory.getName(), name, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, false) || (vocabularyId != assetCategory.getVocabularyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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 (bindName) { qPos.add(StringUtil.toLowerCase(name)); } qPos.add(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_LikeN_V_First(long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_LikeN_V_First(long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_LikeN_V_Last(long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByG_LikeN_V(groupId, name, vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId, long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory, groupId, name, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory, groupId, name, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_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(AssetCategoryModelImpl.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 (bindName) { qPos.add(StringUtil.toLowerCase(name)); } qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name, long vocabularyId) { return filterFindByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name, long vocabularyId, int start, int end) { return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = ? and name LIKE ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_LikeN_V(groupId, name, vocabularyId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } qPos.add(vocabularyId); return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId, long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name, vocabularyId, orderByComparator); } AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory, groupId, name, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory, groupId, name, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(6); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = any ?. * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name, long[] vocabularyIds) { return filterFindByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name, long[] vocabularyIds, int start, int end) { return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name, long[] vocabularyIds, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, orderByComparator); } if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns all the asset categories where groupId = ? and name LIKE ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @return the matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long[] vocabularyIds) { return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ? and name LIKE ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long[] vocabularyIds, int start, int end) { return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ? and name LIKE ? and vocabularyId = any ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long[] vocabularyIds, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ? and name LIKE ? and vocabularyId = ?, optionally using the finder cache. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_LikeN_V(long groupId, String name, long[] vocabularyIds, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } if (vocabularyIds.length == 1) { return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, name, StringUtil.merge(vocabularyIds) }; } else { finderArgs = new Object[] { groupId, name, StringUtil.merge(vocabularyIds), start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.getGroupId()) || !StringUtil.wildcardMatches( assetCategory.getName(), name, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, false) || !ArrayUtil.contains(vocabularyIds, assetCategory.getVocabularyId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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 (bindName) { qPos.add(StringUtil.toLowerCase(name)); } if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the asset categories where groupId = ? and name LIKE ? and vocabularyId = ? from the database. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID */ @Override public void removeByG_LikeN_V(long groupId, String name, long vocabularyId) { for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByG_LikeN_V(long groupId, String name, long vocabularyId) { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V; Object[] finderArgs = new Object[] { groupId, name, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_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(StringUtil.toLowerCase(name)); } qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories where groupId = ? and name LIKE ? and vocabularyId = any ?. * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @return the number of matching asset categories */ @Override public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds) { if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } Object[] finderArgs = new Object[] { groupId, name, StringUtil.merge(vocabularyIds) }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); 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(StringUtil.toLowerCase(name)); } count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = ?. * * @param groupId the group ID * @param name the name * @param vocabularyId the vocabulary ID * @return the number of matching asset categories that the user has permission to view */ @Override public int filterCountByG_LikeN_V(long groupId, String name, long vocabularyId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_LikeN_V(groupId, name, vocabularyId); } StringBundler query = new StringBundler(4); query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } qPos.add(vocabularyId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of asset categories that the user has permission to view where groupId = ? and name LIKE ? and vocabularyId = any ?. * * @param groupId the group ID * @param name the name * @param vocabularyIds the vocabulary IDs * @return the number of matching asset categories that the user has permission to view */ @Override public int filterCountByG_LikeN_V(long groupId, String name, long[] vocabularyIds) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_LikeN_V(groupId, name, vocabularyIds); } if (vocabularyIds == null) { vocabularyIds = new long[0]; } else if (vocabularyIds.length > 1) { vocabularyIds = ArrayUtil.unique(vocabularyIds); Arrays.sort(vocabularyIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2); } if (vocabularyIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7); query.append(StringUtil.merge(vocabularyIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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); if (bindName) { qPos.add(StringUtil.toLowerCase(name)); } Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name IS NULL AND "; private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "lower(assetCategory.name) LIKE ? AND "; private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND "; private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_7 = "assetCategory.vocabularyId IN ("; public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V", new String[] { Long.class.getName(), String.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK | AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V", new String[] { Long.class.getName(), String.class.getName(), Long.class.getName() }); /** * Returns the asset category where parentCategoryId = ? and name = ? and vocabularyId = ? or throws a {@link NoSuchCategoryException} if it could not be found. * * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByP_N_V(long parentCategoryId, String name, long vocabularyId) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name, vocabularyId); if (assetCategory == null) { StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("parentCategoryId="); msg.append(parentCategoryId); msg.append(", name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchCategoryException(msg.toString()); } return assetCategory; } /** * Returns the asset category where parentCategoryId = ? and name = ? and vocabularyId = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByP_N_V(long parentCategoryId, String name, long vocabularyId) { return fetchByP_N_V(parentCategoryId, name, vocabularyId, true); } /** * Returns the asset category where parentCategoryId = ? and name = ? and vocabularyId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByP_N_V(long parentCategoryId, String name, long vocabularyId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_P_N_V, finderArgs, this); } if (result instanceof AssetCategory) { AssetCategory assetCategory = (AssetCategory)result; if ((parentCategoryId != assetCategory.getParentCategoryId()) || !Objects.equals(name, assetCategory.getName()) || (vocabularyId != assetCategory.getVocabularyId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(5); query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); List<AssetCategory> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V, finderArgs, list); } else { AssetCategory assetCategory = list.get(0); result = assetCategory; cacheResult(assetCategory); if ((assetCategory.getParentCategoryId() != parentCategoryId) || (assetCategory.getName() == null) || !assetCategory.getName().equals(name) || (assetCategory.getVocabularyId() != vocabularyId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V, finderArgs, assetCategory); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_P_N_V, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (AssetCategory)result; } } /** * Removes the asset category where parentCategoryId = ? and name = ? and vocabularyId = ? from the database. * * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the asset category that was removed */ @Override public AssetCategory removeByP_N_V(long parentCategoryId, String name, long vocabularyId) throws NoSuchCategoryException { AssetCategory assetCategory = findByP_N_V(parentCategoryId, name, vocabularyId); return remove(assetCategory); } /** * Returns the number of asset categories where parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByP_N_V(long parentCategoryId, String name, long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V; Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND "; private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND "; private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND "; private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_N_V", new String[] { Long.class.getName(), Long.class.getName(), String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_N_V", new String[] { Long.class.getName(), Long.class.getName(), String.class.getName(), Long.class.getName() }, AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK | AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK | AssetCategoryModelImpl.NAME_COLUMN_BITMASK | AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V", new String[] { Long.class.getName(), Long.class.getName(), String.class.getName(), Long.class.getName() }); /** * Returns all the asset categories where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset categories */ @Override public List<AssetCategory> findByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId) { return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories */ @Override public List<AssetCategory> findByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId, int start, int end) { return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching asset categories */ @Override public List<AssetCategory> findByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V; finderArgs = new Object[] { groupId, parentCategoryId, name, vocabularyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V; finderArgs = new Object[] { groupId, parentCategoryId, name, vocabularyId, start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory assetCategory : list) { if ((groupId != assetCategory.getGroupId()) || (parentCategoryId != assetCategory.getParentCategoryId()) || !Objects.equals(name, assetCategory.getName()) || (vocabularyId != assetCategory.getVocabularyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryModelImpl.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); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first asset category in the ordered set where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_P_N_V_First(long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_P_N_V_First(groupId, parentCategoryId, name, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the first asset category in the ordered set where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_P_N_V_First(long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category in the ordered set where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category * @throws NoSuchCategoryException if a matching asset category could not be found */ @Override public AssetCategory findByG_P_N_V_Last(long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId, parentCategoryId, name, vocabularyId, orderByComparator); if (assetCategory != null) { return assetCategory; } StringBundler msg = new StringBundler(10); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("groupId="); msg.append(groupId); msg.append(", parentCategoryId="); msg.append(parentCategoryId); msg.append(", name="); msg.append(name); msg.append(", vocabularyId="); msg.append(vocabularyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryException(msg.toString()); } /** * Returns the last asset category in the ordered set where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found */ @Override public AssetCategory fetchByG_P_N_V_Last(long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) { int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId); if (count == 0) { return null; } List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset categories before and after the current asset category in the ordered set where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId, long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, name, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, name, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory getByG_P_N_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(7 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(6); } query.append(_SQL_SELECT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_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(AssetCategoryModelImpl.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); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId) { return filterFindByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId, int start, int end) { return filterFindByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, start, end, null); } /** * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset categories that the user has permission to view */ @Override public List<AssetCategory> filterFindByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId, int start, int end, OrderByComparator<AssetCategory> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(7); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_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(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param categoryId the primary key of the current asset category * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId, long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator) throws NoSuchCategoryException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_N_V_PrevAndNext(categoryId, groupId, parentCategoryId, name, vocabularyId, orderByComparator); } AssetCategory assetCategory = findByPrimaryKey(categoryId); Session session = null; try { session = openSession(); AssetCategory[] array = new AssetCategoryImpl[3]; array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, name, vocabularyId, orderByComparator, true); array[1] = assetCategory; array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory, groupId, parentCategoryId, name, vocabularyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session, AssetCategory assetCategory, long groupId, long parentCategoryId, String name, long vocabularyId, OrderByComparator<AssetCategory> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(8 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(7); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(AssetCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(AssetCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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, AssetCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategory); for (Object value : values) { qPos.add(value); } } List<AssetCategory> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset categories where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ? from the database. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID */ @Override public void removeByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId) { for (AssetCategory assetCategory : findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategory); } } /** * Returns the number of asset categories where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the number of matching asset categories */ @Override public int countByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V; Object[] finderArgs = new Object[] { groupId, parentCategoryId, name, vocabularyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(5); query.append(_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of asset categories that the user has permission to view where groupId = ? and parentCategoryId = ? and name = ? and vocabularyId = ?. * * @param groupId the group ID * @param parentCategoryId the parent category ID * @param name the name * @param vocabularyId the vocabulary ID * @return the number of matching asset categories that the user has permission to view */ @Override public int filterCountByG_P_N_V(long groupId, long parentCategoryId, String name, long vocabularyId) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId); } StringBundler query = new StringBundler(5); query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE); query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2); query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2); boolean bindName = false; if (name == null) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_1); } else if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_N_V_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_G_P_N_V_NAME_2); } query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), AssetCategory.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); qPos.add(parentCategoryId); if (bindName) { qPos.add(name); } qPos.add(vocabularyId); Long count = (Long)q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND "; private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND "; private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND "; private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND "; private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND "; private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?"; public AssetCategoryPersistenceImpl() { setModelClass(AssetCategory.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the asset category in the entity cache if it is enabled. * * @param assetCategory the asset category */ @Override public void cacheResult(AssetCategory assetCategory) { entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, assetCategory.getPrimaryKey(), assetCategory); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() }, assetCategory); finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V, new Object[] { assetCategory.getParentCategoryId(), assetCategory.getName(), assetCategory.getVocabularyId() }, assetCategory); assetCategory.resetOriginalValues(); } /** * Caches the asset categories in the entity cache if it is enabled. * * @param assetCategories the asset categories */ @Override public void cacheResult(List<AssetCategory> assetCategories) { for (AssetCategory assetCategory : assetCategories) { if (entityCache.getResult( AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) { cacheResult(assetCategory); } else { assetCategory.resetOriginalValues(); } } } /** * Clears the cache for all asset categories. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(AssetCategoryImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the asset category. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(AssetCategory assetCategory) { entityCache.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, assetCategory.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((AssetCategoryModelImpl)assetCategory, true); } @Override public void clearCache(List<AssetCategory> assetCategories) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (AssetCategory assetCategory : assetCategories) { entityCache.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, assetCategory.getPrimaryKey()); clearUniqueFindersCache((AssetCategoryModelImpl)assetCategory, true); } } protected void cacheUniqueFindersCache( AssetCategoryModelImpl assetCategoryModelImpl) { Object[] args = new Object[] { assetCategoryModelImpl.getUuid(), assetCategoryModelImpl.getGroupId() }; finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args, assetCategoryModelImpl, false); args = new Object[] { assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getName(), assetCategoryModelImpl.getVocabularyId() }; finderCache.putResult(FINDER_PATH_COUNT_BY_P_N_V, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_P_N_V, args, assetCategoryModelImpl, false); } protected void clearUniqueFindersCache( AssetCategoryModelImpl assetCategoryModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { assetCategoryModelImpl.getUuid(), assetCategoryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalUuid(), assetCategoryModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args); } if (clearCurrent) { Object[] args = new Object[] { assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getName(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalParentCategoryId(), assetCategoryModelImpl.getOriginalName(), assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args); } } /** * Creates a new asset category with the primary key. Does not add the asset category to the database. * * @param categoryId the primary key for the new asset category * @return the new asset category */ @Override public AssetCategory create(long categoryId) { AssetCategory assetCategory = new AssetCategoryImpl(); assetCategory.setNew(true); assetCategory.setPrimaryKey(categoryId); String uuid = PortalUUIDUtil.generate(); assetCategory.setUuid(uuid); assetCategory.setCompanyId(companyProvider.getCompanyId()); return assetCategory; } /** * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners. * * @param categoryId the primary key of the asset category * @return the asset category that was removed * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory remove(long categoryId) throws NoSuchCategoryException { return remove((Serializable)categoryId); } /** * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the asset category * @return the asset category that was removed * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory remove(Serializable primaryKey) throws NoSuchCategoryException { Session session = null; try { session = openSession(); AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class, primaryKey); if (assetCategory == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(assetCategory); } catch (NoSuchCategoryException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected AssetCategory removeImpl(AssetCategory assetCategory) { assetCategory = toUnwrappedModel(assetCategory); assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(assetCategory.getPrimaryKey()); Session session = null; try { session = openSession(); if (rebuildTreeEnabled) { if (session.isDirty()) { session.flush(); } nestedSetsTreeManager.delete(assetCategory); clearCache(); session.clear(); } if (!session.contains(assetCategory)) { assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class, assetCategory.getPrimaryKeyObj()); } if (assetCategory != null) { session.delete(assetCategory); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (assetCategory != null) { clearCache(assetCategory); } return assetCategory; } @Override public AssetCategory updateImpl(AssetCategory assetCategory) { assetCategory = toUnwrappedModel(assetCategory); boolean isNew = assetCategory.isNew(); AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory; if (Validator.isNull(assetCategory.getUuid())) { String uuid = PortalUUIDUtil.generate(); assetCategory.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (assetCategory.getCreateDate() == null)) { if (serviceContext == null) { assetCategory.setCreateDate(now); } else { assetCategory.setCreateDate(serviceContext.getCreateDate(now)); } } if (!assetCategoryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { assetCategory.setModifiedDate(now); } else { assetCategory.setModifiedDate(serviceContext.getModifiedDate( now)); } } Session session = null; try { session = openSession(); if (rebuildTreeEnabled) { if (session.isDirty()) { session.flush(); } if (isNew) { nestedSetsTreeManager.insert(assetCategory, fetchByPrimaryKey(assetCategory.getParentCategoryId())); } else if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) { nestedSetsTreeManager.move(assetCategory, fetchByPrimaryKey( assetCategoryModelImpl.getOriginalParentCategoryId()), fetchByPrimaryKey(assetCategory.getParentCategoryId())); } clearCache(); session.clear(); } if (assetCategory.isNew()) { session.save(assetCategory); assetCategory.setNew(false); } else { assetCategory = (AssetCategory)session.merge(assetCategory); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { assetCategoryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { assetCategoryModelImpl.getUuid(), assetCategoryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { assetCategoryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { assetCategoryModelImpl.getParentCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID, args); args = new Object[] { assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID, args); args = new Object[] { assetCategoryModelImpl.getGroupId(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V, args); args = new Object[] { assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N, args); args = new Object[] { assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V, args); args = new Object[] { assetCategoryModelImpl.getName(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_N_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V, args); args = new Object[] { assetCategoryModelImpl.getGroupId(), assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V, args); args = new Object[] { assetCategoryModelImpl.getGroupId(), assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getName(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { assetCategoryModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalUuid(), assetCategoryModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { assetCategoryModelImpl.getUuid(), assetCategoryModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { assetCategoryModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalParentCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID, args); args = new Object[] { assetCategoryModelImpl.getParentCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID, args); args = new Object[] { assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalGroupId(), assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V, args); args = new Object[] { assetCategoryModelImpl.getGroupId(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalParentCategoryId(), assetCategoryModelImpl.getOriginalName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N, args); args = new Object[] { assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_N, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalParentCategoryId(), assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V, args); args = new Object[] { assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_P_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalName(), assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_N_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V, args); args = new Object[] { assetCategoryModelImpl.getName(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_N_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalGroupId(), assetCategoryModelImpl.getOriginalParentCategoryId(), assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V, args); args = new Object[] { assetCategoryModelImpl.getGroupId(), assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V, args); } if ((assetCategoryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryModelImpl.getOriginalGroupId(), assetCategoryModelImpl.getOriginalParentCategoryId(), assetCategoryModelImpl.getOriginalName(), assetCategoryModelImpl.getOriginalVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V, args); args = new Object[] { assetCategoryModelImpl.getGroupId(), assetCategoryModelImpl.getParentCategoryId(), assetCategoryModelImpl.getName(), assetCategoryModelImpl.getVocabularyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V, args); } } entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, assetCategory.getPrimaryKey(), assetCategory, false); clearUniqueFindersCache(assetCategoryModelImpl, false); cacheUniqueFindersCache(assetCategoryModelImpl); assetCategory.resetOriginalValues(); return assetCategory; } protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) { if (assetCategory instanceof AssetCategoryImpl) { return assetCategory; } AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl(); assetCategoryImpl.setNew(assetCategory.isNew()); assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey()); assetCategoryImpl.setUuid(assetCategory.getUuid()); assetCategoryImpl.setCategoryId(assetCategory.getCategoryId()); assetCategoryImpl.setGroupId(assetCategory.getGroupId()); assetCategoryImpl.setCompanyId(assetCategory.getCompanyId()); assetCategoryImpl.setUserId(assetCategory.getUserId()); assetCategoryImpl.setUserName(assetCategory.getUserName()); assetCategoryImpl.setCreateDate(assetCategory.getCreateDate()); assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate()); assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId()); assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId()); assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId()); assetCategoryImpl.setName(assetCategory.getName()); assetCategoryImpl.setTitle(assetCategory.getTitle()); assetCategoryImpl.setDescription(assetCategory.getDescription()); assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId()); assetCategoryImpl.setLastPublishDate(assetCategory.getLastPublishDate()); return assetCategoryImpl; } /** * Returns the asset category with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the asset category * @return the asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory findByPrimaryKey(Serializable primaryKey) throws NoSuchCategoryException { AssetCategory assetCategory = fetchByPrimaryKey(primaryKey); if (assetCategory == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return assetCategory; } /** * Returns the asset category with the primary key or throws a {@link NoSuchCategoryException} if it could not be found. * * @param categoryId the primary key of the asset category * @return the asset category * @throws NoSuchCategoryException if a asset category with the primary key could not be found */ @Override public AssetCategory findByPrimaryKey(long categoryId) throws NoSuchCategoryException { return findByPrimaryKey((Serializable)categoryId); } /** * Returns the asset category with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the asset category * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found */ @Override public AssetCategory fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, primaryKey); if (serializable == nullModel) { return null; } AssetCategory assetCategory = (AssetCategory)serializable; if (assetCategory == null) { Session session = null; try { session = openSession(); assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class, primaryKey); if (assetCategory != null) { cacheResult(assetCategory); } else { entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return assetCategory; } /** * Returns the asset category with the primary key or returns <code>null</code> if it could not be found. * * @param categoryId the primary key of the asset category * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found */ @Override public AssetCategory fetchByPrimaryKey(long categoryId) { return fetchByPrimaryKey((Serializable)categoryId); } @Override public Map<Serializable, AssetCategory> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, AssetCategory> map = new HashMap<Serializable, AssetCategory>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); AssetCategory assetCategory = fetchByPrimaryKey(primaryKey); if (assetCategory != null) { map.put(primaryKey, assetCategory); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (AssetCategory)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_ASSETCATEGORY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (AssetCategory assetCategory : (List<AssetCategory>)q.list()) { map.put(assetCategory.getPrimaryKeyObj(), assetCategory); cacheResult(assetCategory); uncachedPrimaryKeys.remove(assetCategory.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the asset categories. * * @return the asset categories */ @Override public List<AssetCategory> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset categories. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of asset categories */ @Override public List<AssetCategory> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the asset categories. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of asset categories */ @Override public List<AssetCategory> findAll(int start, int end, OrderByComparator<AssetCategory> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset categories. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of asset categories */ @Override public List<AssetCategory> findAll(int start, int end, OrderByComparator<AssetCategory> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<AssetCategory> list = null; if (retrieveFromCache) { list = (List<AssetCategory>)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_ASSETCATEGORY); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_ASSETCATEGORY; if (pagination) { sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategory>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the asset categories from the database. * */ @Override public void removeAll() { for (AssetCategory assetCategory : findAll()) { remove(assetCategory); } } /** * Returns the number of asset categories. * * @return the number of asset categories */ @Override public int countAll() { Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the primaryKeys of asset entries associated with the asset category. * * @param pk the primary key of the asset category * @return long[] of the primaryKeys of asset entries associated with the asset category */ @Override public long[] getAssetEntryPrimaryKeys(long pk) { long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk); return pks.clone(); } /** * Returns all the asset entries associated with the asset category. * * @param pk the primary key of the asset category * @return the asset entries associated with the asset category */ @Override public List<com.liferay.asset.kernel.model.AssetEntry> getAssetEntries( long pk) { return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS); } /** * Returns a range of all the asset entries associated with the asset category. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the asset category * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @return the range of asset entries associated with the asset category */ @Override public List<com.liferay.asset.kernel.model.AssetEntry> getAssetEntries( long pk, int start, int end) { return getAssetEntries(pk, start, end, null); } /** * Returns an ordered range of all the asset entries associated with the asset category. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param pk the primary key of the asset category * @param start the lower bound of the range of asset categories * @param end the upper bound of the range of asset categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of asset entries associated with the asset category */ @Override public List<com.liferay.asset.kernel.model.AssetEntry> getAssetEntries( long pk, int start, int end, OrderByComparator<com.liferay.asset.kernel.model.AssetEntry> orderByComparator) { return assetCategoryToAssetEntryTableMapper.getRightBaseModels(pk, start, end, orderByComparator); } /** * Returns the number of asset entries associated with the asset category. * * @param pk the primary key of the asset category * @return the number of asset entries associated with the asset category */ @Override public int getAssetEntriesSize(long pk) { long[] pks = assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys(pk); return pks.length; } /** * Returns <code>true</code> if the asset entry is associated with the asset category. * * @param pk the primary key of the asset category * @param assetEntryPK the primary key of the asset entry * @return <code>true</code> if the asset entry is associated with the asset category; <code>false</code> otherwise */ @Override public boolean containsAssetEntry(long pk, long assetEntryPK) { return assetCategoryToAssetEntryTableMapper.containsTableMapping(pk, assetEntryPK); } /** * Returns <code>true</code> if the asset category has any asset entries associated with it. * * @param pk the primary key of the asset category to check for associations with asset entries * @return <code>true</code> if the asset category has any asset entries associated with it; <code>false</code> otherwise */ @Override public boolean containsAssetEntries(long pk) { if (getAssetEntriesSize(pk) > 0) { return true; } else { return false; } } /** * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntryPK the primary key of the asset entry */ @Override public void addAssetEntry(long pk, long assetEntryPK) { AssetCategory assetCategory = fetchByPrimaryKey(pk); if (assetCategory == null) { assetCategoryToAssetEntryTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, assetEntryPK); } else { assetCategoryToAssetEntryTableMapper.addTableMapping(assetCategory.getCompanyId(), pk, assetEntryPK); } } /** * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntry the asset entry */ @Override public void addAssetEntry(long pk, com.liferay.asset.kernel.model.AssetEntry assetEntry) { AssetCategory assetCategory = fetchByPrimaryKey(pk); if (assetCategory == null) { assetCategoryToAssetEntryTableMapper.addTableMapping(companyProvider.getCompanyId(), pk, assetEntry.getPrimaryKey()); } else { assetCategoryToAssetEntryTableMapper.addTableMapping(assetCategory.getCompanyId(), pk, assetEntry.getPrimaryKey()); } } /** * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntryPKs the primary keys of the asset entries */ @Override public void addAssetEntries(long pk, long[] assetEntryPKs) { long companyId = 0; AssetCategory assetCategory = fetchByPrimaryKey(pk); if (assetCategory == null) { companyId = companyProvider.getCompanyId(); } else { companyId = assetCategory.getCompanyId(); } assetCategoryToAssetEntryTableMapper.addTableMappings(companyId, pk, assetEntryPKs); } /** * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntries the asset entries */ @Override public void addAssetEntries(long pk, List<com.liferay.asset.kernel.model.AssetEntry> assetEntries) { addAssetEntries(pk, ListUtil.toLongArray(assetEntries, com.liferay.asset.kernel.model.AssetEntry.ENTRY_ID_ACCESSOR)); } /** * Clears all associations between the asset category and its asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category to clear the associated asset entries from */ @Override public void clearAssetEntries(long pk) { assetCategoryToAssetEntryTableMapper.deleteLeftPrimaryKeyTableMappings(pk); } /** * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntryPK the primary key of the asset entry */ @Override public void removeAssetEntry(long pk, long assetEntryPK) { assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk, assetEntryPK); } /** * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntry the asset entry */ @Override public void removeAssetEntry(long pk, com.liferay.asset.kernel.model.AssetEntry assetEntry) { assetCategoryToAssetEntryTableMapper.deleteTableMapping(pk, assetEntry.getPrimaryKey()); } /** * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntryPKs the primary keys of the asset entries */ @Override public void removeAssetEntries(long pk, long[] assetEntryPKs) { assetCategoryToAssetEntryTableMapper.deleteTableMappings(pk, assetEntryPKs); } /** * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the asset category * @param assetEntries the asset entries */ @Override public void removeAssetEntries(long pk, List<com.liferay.asset.kernel.model.AssetEntry> assetEntries) { removeAssetEntries(pk, ListUtil.toLongArray(assetEntries, com.liferay.asset.kernel.model.AssetEntry.ENTRY_ID_ACCESSOR)); } /** * Sets the asset entries associated with the asset category, 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 asset category * @param assetEntryPKs the primary keys of the asset entries to be associated with the asset category */ @Override public void setAssetEntries(long pk, long[] assetEntryPKs) { Set<Long> newAssetEntryPKsSet = SetUtil.fromArray(assetEntryPKs); Set<Long> oldAssetEntryPKsSet = SetUtil.fromArray(assetCategoryToAssetEntryTableMapper.getRightPrimaryKeys( pk)); Set<Long> removeAssetEntryPKsSet = new HashSet<Long>(oldAssetEntryPKsSet); removeAssetEntryPKsSet.removeAll(newAssetEntryPKsSet); assetCategoryToAssetEntryTableMapper.deleteTableMappings(pk, ArrayUtil.toLongArray(removeAssetEntryPKsSet)); newAssetEntryPKsSet.removeAll(oldAssetEntryPKsSet); long companyId = 0; AssetCategory assetCategory = fetchByPrimaryKey(pk); if (assetCategory == null) { companyId = companyProvider.getCompanyId(); } else { companyId = assetCategory.getCompanyId(); } assetCategoryToAssetEntryTableMapper.addTableMappings(companyId, pk, ArrayUtil.toLongArray(newAssetEntryPKsSet)); } /** * Sets the asset entries associated with the asset category, 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 asset category * @param assetEntries the asset entries to be associated with the asset category */ @Override public void setAssetEntries(long pk, List<com.liferay.asset.kernel.model.AssetEntry> assetEntries) { try { long[] assetEntryPKs = new long[assetEntries.size()]; for (int i = 0; i < assetEntries.size(); i++) { com.liferay.asset.kernel.model.AssetEntry assetEntry = assetEntries.get(i); assetEntryPKs[i] = assetEntry.getPrimaryKey(); } setAssetEntries(pk, assetEntryPKs); } catch (Exception e) { throw processException(e); } } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected Map<String, Integer> getTableColumnsMap() { return AssetCategoryModelImpl.TABLE_COLUMNS_MAP; } @Override public long countAncestors(AssetCategory assetCategory) { Object[] finderArgs = new Object[] { assetCategory.getGroupId(), assetCategory.getLeftCategoryId(), assetCategory.getRightCategoryId() }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS, finderArgs, this); if (count == null) { try { count = nestedSetsTreeManager.countAncestors(assetCategory); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS, finderArgs, count); } catch (SystemException se) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_ANCESTORS, finderArgs); throw se; } } return count.intValue(); } @Override public long countDescendants(AssetCategory assetCategory) { Object[] finderArgs = new Object[] { assetCategory.getGroupId(), assetCategory.getLeftCategoryId(), assetCategory.getRightCategoryId() }; Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS, finderArgs, this); if (count == null) { try { count = nestedSetsTreeManager.countDescendants(assetCategory); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS, finderArgs, count); } catch (SystemException se) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_DESCENDANTS, finderArgs); throw se; } } return count.intValue(); } @Override public List<AssetCategory> getAncestors(AssetCategory assetCategory) { Object[] finderArgs = new Object[] { assetCategory.getGroupId(), assetCategory.getLeftCategoryId(), assetCategory.getRightCategoryId() }; List<AssetCategory> list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory tempAssetCategory : list) { if ((assetCategory.getLeftCategoryId() < tempAssetCategory.getLeftCategoryId()) || (assetCategory.getRightCategoryId() > tempAssetCategory.getRightCategoryId())) { list = null; break; } } } if (list == null) { try { list = nestedSetsTreeManager.getAncestors(assetCategory); cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS, finderArgs, list); } catch (SystemException se) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_GET_ANCESTORS, finderArgs); throw se; } } return list; } @Override public List<AssetCategory> getDescendants(AssetCategory assetCategory) { Object[] finderArgs = new Object[] { assetCategory.getGroupId(), assetCategory.getLeftCategoryId(), assetCategory.getRightCategoryId() }; List<AssetCategory> list = (List<AssetCategory>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategory tempAssetCategory : list) { if ((assetCategory.getLeftCategoryId() > tempAssetCategory.getLeftCategoryId()) || (assetCategory.getRightCategoryId() < tempAssetCategory.getRightCategoryId())) { list = null; break; } } } if (list == null) { try { list = nestedSetsTreeManager.getDescendants(assetCategory); cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS, finderArgs, list); } catch (SystemException se) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_GET_DESCENDANTS, finderArgs); throw se; } } return list; } /** * Rebuilds the asset categories tree for the scope using the modified pre-order tree traversal algorithm. * * <p> * Only call this method if the tree has become stale through operations other than normal CRUD. Under normal circumstances the tree is automatically rebuilt whenver necessary. * </p> * * @param groupId the ID of the scope * @param force whether to force the rebuild even if the tree is not stale */ @Override public void rebuildTree(long groupId, boolean force) { if (!rebuildTreeEnabled) { return; } if (force || (countOrphanTreeNodes(groupId) > 0)) { Session session = null; try { session = openSession(); if (session.isDirty()) { session.flush(); } SQLQuery selectQuery = session.createSQLQuery( "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC"); selectQuery.addScalar("categoryId", com.liferay.portal.kernel.dao.orm.Type.LONG); SQLQuery updateQuery = session.createSQLQuery( "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?"); rebuildTree(session, selectQuery, updateQuery, groupId, 0, 0); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } clearCache(); } } @Override public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) { this.rebuildTreeEnabled = rebuildTreeEnabled; } protected long countOrphanTreeNodes(long groupId) { Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery( "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)"); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (Long)q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected long rebuildTree(Session session, SQLQuery selectQuery, SQLQuery updateQuery, long groupId, long parentCategoryId, long leftCategoryId) { long rightCategoryId = leftCategoryId + 1; QueryPos qPos = QueryPos.getInstance(selectQuery); qPos.add(groupId); qPos.add(parentCategoryId); List<Long> categoryIds = selectQuery.list(); for (long categoryId : categoryIds) { rightCategoryId = rebuildTree(session, selectQuery, updateQuery, groupId, categoryId, rightCategoryId); } if (parentCategoryId > 0) { qPos = QueryPos.getInstance(updateQuery); qPos.add(leftCategoryId); qPos.add(rightCategoryId); qPos.add(parentCategoryId); updateQuery.executeUpdate(); } return rightCategoryId + 1; } /** * Initializes the asset category persistence. */ public void afterPropertiesSet() { assetCategoryToAssetEntryTableMapper = TableMapperFactory.getTableMapper("AssetEntries_AssetCategories", "companyId", "categoryId", "entryId", this, assetEntryPersistence); } public void destroy() { entityCache.removeCache(AssetCategoryImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); TableMapperFactory.removeTableMapper("AssetEntries_AssetCategories"); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; protected EntityCache entityCache = EntityCacheUtil.getEntityCache(); protected FinderCache finderCache = FinderCacheUtil.getFinderCache(); @BeanReference(type = AssetEntryPersistence.class) protected AssetEntryPersistence assetEntryPersistence; protected TableMapper<AssetCategory, com.liferay.asset.kernel.model.AssetEntry> assetCategoryToAssetEntryTableMapper; protected NestedSetsTreeManager<AssetCategory> nestedSetsTreeManager = new PersistenceNestedSetsTreeManager<AssetCategory>(this, "AssetCategory", "AssetCategory", AssetCategoryImpl.class, "categoryId", "groupId", "leftCategoryId", "rightCategoryId"); protected boolean rebuildTreeEnabled = true; private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory"; private static final String _SQL_SELECT_ASSETCATEGORY_WHERE_PKS_IN = "SELECT assetCategory FROM AssetCategory assetCategory WHERE categoryId IN ("; private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE "; private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory"; private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId"; private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE "; private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE "; private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId"; private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE "; private static final String _FILTER_ENTITY_ALIAS = "assetCategory"; private static final String _FILTER_ENTITY_TABLE = "AssetCategory"; private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory."; private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid" }); }