List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS
String CLOSE_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.
Click Source Link
From source file:com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the expando columns where tableId = ? and name = any ?. * * <p>//w ww . java 2s. com * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param tableId the table ID * @param names the names * @param start the lower bound of the range of expando columns * @param end the upper bound of the range of expando columns (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching expando columns * @throws SystemException if a system exception occurred */ public List<ExpandoColumn> findByT_N(long tableId, String[] names, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_T_N; finderArgs = new Object[] { tableId, StringUtil.merge(names) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_T_N; finderArgs = new Object[] { tableId, StringUtil.merge(names), start, end, orderByComparator }; } List<ExpandoColumn> list = (List<ExpandoColumn>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_EXPANDOCOLUMN_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_T_N_TABLEID_5); conjunctionable = true; if ((names == null) || (names.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < names.length; i++) { String name = names[i]; if (name == null) { query.append(_FINDER_COLUMN_T_N_NAME_4); } else { if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_T_N_NAME_6); } else { query.append(_FINDER_COLUMN_T_N_NAME_5); } } if ((i + 1) < names.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(ExpandoColumnModelImpl.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(tableId); if (names != null) { qPos.add(names); } list = (List<ExpandoColumn>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; }
From source file:com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the expando columns that the user has permission to view where tableId = ? and name = any ?. * * <p>//from w ww . j a va2 s .c o m * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param tableId the table ID * @param names the names * @param start the lower bound of the range of expando columns * @param end the upper bound of the range of expando columns (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching expando columns that the user has permission to view * @throws SystemException if a system exception occurred */ public List<ExpandoColumn> filterFindByT_N(long tableId, String[] names, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByT_N(tableId, names, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_WHERE); } else { query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_T_N_TABLEID_5); conjunctionable = true; if ((names == null) || (names.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < names.length; i++) { String name = names[i]; if (name == null) { query.append(_FINDER_COLUMN_T_N_NAME_4); } else { if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_T_N_NAME_6); } else { query.append(_FINDER_COLUMN_T_N_NAME_5); } } if ((i + 1) < names.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_EXPANDOCOLUMN_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(ExpandoColumnModelImpl.ORDER_BY_JPQL); } else { query.append(ExpandoColumnModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), ExpandoColumn.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, ExpandoColumnImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, ExpandoColumnImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(tableId); if (names != null) { qPos.add(names); } return (List<ExpandoColumn>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistenceImpl.java
License:Open Source License
/** * Returns the number of expando columns where tableId = ? and name = any ?. * * @param tableId the table ID// ww w . j a va 2 s . co m * @param names the names * @return the number of matching expando columns * @throws SystemException if a system exception occurred */ public int countByT_N(long tableId, String[] names) throws SystemException { Object[] finderArgs = new Object[] { tableId, StringUtil.merge(names) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_T_N, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_EXPANDOCOLUMN_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_T_N_TABLEID_5); conjunctionable = true; if ((names == null) || (names.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < names.length; i++) { String name = names[i]; if (name == null) { query.append(_FINDER_COLUMN_T_N_NAME_4); } else { if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_T_N_NAME_6); } else { query.append(_FINDER_COLUMN_T_N_NAME_5); } } if ((i + 1) < names.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(tableId); if (names != null) { qPos.add(names); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_T_N, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistenceImpl.java
License:Open Source License
/** * Returns the number of expando columns that the user has permission to view where tableId = ? and name = any ?. * * @param tableId the table ID/*from w w w. j av a 2 s. c om*/ * @param names the names * @return the number of matching expando columns that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByT_N(long tableId, String[] names) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return countByT_N(tableId, names); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_EXPANDOCOLUMN_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_T_N_TABLEID_5); conjunctionable = true; if ((names == null) || (names.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < names.length; i++) { String name = names[i]; if (name == null) { query.append(_FINDER_COLUMN_T_N_NAME_4); } else { if (name.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_T_N_NAME_6); } else { query.append(_FINDER_COLUMN_T_N_NAME_5); } } if ((i + 1) < names.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), ExpandoColumn.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(tableId); if (names != null) { qPos.add(names); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the message boards categories where groupId = ? and parentCategoryId = any ?. * * <p>/*w w w . j av a 2 s . co m*/ * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories * @throws SystemException if a system exception occurred */ public List<MBCategory> findByG_P(long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P; finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P; finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds), start, end, orderByComparator }; } List<MBCategory> list = (List<MBCategory>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBCATEGORY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_GROUPID_5); conjunctionable = true; if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentCategoryIds.length; i++) { query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5); if ((i + 1) < parentCategoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBCategoryModelImpl.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 (parentCategoryIds != null) { qPos.add(parentCategoryIds); } list = (List<MBCategory>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; }
From source file:com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ?. * * <p>/*from w w w. j a v a2 s .c o m*/ * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param parentCategoryIds the parent category IDs * @param start the lower bound of the range of message boards categories * @param end the upper bound of the range of message boards categories (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards categories that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBCategory> filterFindByG_P(long groupId, long[] parentCategoryIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P(groupId, parentCategoryIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_GROUPID_5); conjunctionable = true; if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentCategoryIds.length; i++) { query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5); if ((i + 1) < parentCategoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBCATEGORY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBCategoryModelImpl.ORDER_BY_JPQL); } else { query.append(MBCategoryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBCategoryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBCategoryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (parentCategoryIds != null) { qPos.add(parentCategoryIds); } return (List<MBCategory>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistenceImpl.java
License:Open Source License
/** * Returns the number of message boards categories where groupId = ? and parentCategoryId = any ?. * * @param groupId the group ID/*from w w w . j a va 2 s . co m*/ * @param parentCategoryIds the parent category IDs * @return the number of matching message boards categories * @throws SystemException if a system exception occurred */ public int countByG_P(long groupId, long[] parentCategoryIds) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(parentCategoryIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBCATEGORY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_GROUPID_5); conjunctionable = true; if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentCategoryIds.length; i++) { query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5); if ((i + 1) < parentCategoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (parentCategoryIds != null) { qPos.add(parentCategoryIds); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.messageboards.service.persistence.MBCategoryPersistenceImpl.java
License:Open Source License
/** * Returns the number of message boards categories that the user has permission to view where groupId = ? and parentCategoryId = any ?. * * @param groupId the group ID//from w ww . ja v a 2 s. c om * @param parentCategoryIds the parent category IDs * @return the number of matching message boards categories that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_P(long groupId, long[] parentCategoryIds) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_P(groupId, parentCategoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBCATEGORY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_GROUPID_5); conjunctionable = true; if ((parentCategoryIds == null) || (parentCategoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentCategoryIds.length; i++) { query.append(_FINDER_COLUMN_G_P_PARENTCATEGORYID_5); if ((i + 1) < parentCategoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBCategory.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (parentCategoryIds != null) { qPos.add(parentCategoryIds); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the message boards threads where groupId = ? and categoryId = any ?. * * <p>/*from w ww. j a v a 2 s . co m*/ * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C(long groupId, long[] categoryIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.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 (categoryIds != null) { qPos.add(categoryIds); } list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = any ?. * * <p>//from w w w . ja va2 s. c om * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C(long groupId, long[] categoryIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C(groupId, categoryIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }