List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS
String OPEN_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.
Click Source Link
From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles where parentResourcePrimKey = any ? and main = ?. * * <p>/*from w ww. j av a 2 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 parentResourcePrimKeies the parent resource prim keies * @param main the main * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles * @throws SystemException if a system exception occurred */ public List<KBArticle> findByP_M(long[] parentResourcePrimKeies, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_M; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { StringUtil.merge(parentResourcePrimKeies), main }; } else { finderArgs = new Object[] { StringUtil.merge(parentResourcePrimKeies), main, start, end, orderByComparator }; } List<KBArticle> list = (List<KBArticle>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (KBArticle kbArticle : list) { if (!ArrayUtil.contains(parentResourcePrimKeies, kbArticle.getParentResourcePrimKey()) || (main != kbArticle.getMain())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_KBARTICLE_WHERE); boolean conjunctionable = false; if ((parentResourcePrimKeies == null) || (parentResourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentResourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_P_M_PARENTRESOURCEPRIMKEY_5); if ((i + 1) < parentResourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_P_M_MAIN_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(KBArticleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (parentResourcePrimKeies != null) { qPos.add(parentResourcePrimKeies); } qPos.add(main); list = (List<KBArticle>) 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.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles where parentResourcePrimKey = any ? and status = ?. * * <p>//from w w w. j av a 2s . 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 parentResourcePrimKeies the parent resource prim keies * @param status the status * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles * @throws SystemException if a system exception occurred */ public List<KBArticle> findByP_S(long[] parentResourcePrimKeies, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_S; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { StringUtil.merge(parentResourcePrimKeies), status }; } else { finderArgs = new Object[] { StringUtil.merge(parentResourcePrimKeies), status, start, end, orderByComparator }; } List<KBArticle> list = (List<KBArticle>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (KBArticle kbArticle : list) { if (!ArrayUtil.contains(parentResourcePrimKeies, kbArticle.getParentResourcePrimKey()) || (status != kbArticle.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_KBARTICLE_WHERE); boolean conjunctionable = false; if ((parentResourcePrimKeies == null) || (parentResourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentResourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_P_S_PARENTRESOURCEPRIMKEY_5); if ((i + 1) < parentResourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_P_S_STATUS_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(KBArticleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (parentResourcePrimKeies != null) { qPos.add(parentResourcePrimKeies); } qPos.add(status); list = (List<KBArticle>) 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.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles where resourcePrimKey = any ? and groupId = ? and latest = ?. * * <p>/*from w w w .java 2s . 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 resourcePrimKeies the resource prim keies * @param groupId the group ID * @param latest the latest * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles * @throws SystemException if a system exception occurred */ public List<KBArticle> findByR_G_L(long[] resourcePrimKeies, long groupId, boolean latest, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_G_L; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), groupId, latest }; } else { finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), groupId, latest, start, end, orderByComparator }; } List<KBArticle> list = (List<KBArticle>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (KBArticle kbArticle : list) { if (!ArrayUtil.contains(resourcePrimKeies, kbArticle.getResourcePrimKey()) || (groupId != kbArticle.getGroupId()) || (latest != kbArticle.getLatest())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_KBARTICLE_WHERE); boolean conjunctionable = false; if ((resourcePrimKeies == null) || (resourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < resourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_R_G_L_RESOURCEPRIMKEY_5); if ((i + 1) < resourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_L_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_L_LATEST_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(KBArticleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (resourcePrimKeies != null) { qPos.add(resourcePrimKeies); } qPos.add(groupId); qPos.add(latest); list = (List<KBArticle>) 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.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles that the user has permission to view where resourcePrimKey = any ? and groupId = ? and latest = ?. * * <p>// w w w . jav a 2 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 resourcePrimKeies the resource prim keies * @param groupId the group ID * @param latest the latest * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles that the user has permission to view * @throws SystemException if a system exception occurred */ public List<KBArticle> filterFindByR_G_L(long[] resourcePrimKeies, long groupId, boolean latest, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByR_G_L(resourcePrimKeies, groupId, latest, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE); } else { query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if ((resourcePrimKeies == null) || (resourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < resourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_R_G_L_RESOURCEPRIMKEY_5); if ((i + 1) < resourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_L_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_L_LATEST_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_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(KBArticleModelImpl.ORDER_BY_JPQL); } else { query.append(KBArticleModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.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, KBArticleImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (resourcePrimKeies != null) { qPos.add(resourcePrimKeies); } qPos.add(groupId); qPos.add(latest); return (List<KBArticle>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles where resourcePrimKey = any ? and groupId = ? and main = ?. * * <p>/* w w w. j av a 2 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 resourcePrimKeies the resource prim keies * @param groupId the group ID * @param main the main * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles * @throws SystemException if a system exception occurred */ public List<KBArticle> findByR_G_M(long[] resourcePrimKeies, long groupId, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_G_M; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), groupId, main }; } else { finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), groupId, main, start, end, orderByComparator }; } List<KBArticle> list = (List<KBArticle>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (KBArticle kbArticle : list) { if (!ArrayUtil.contains(resourcePrimKeies, kbArticle.getResourcePrimKey()) || (groupId != kbArticle.getGroupId()) || (main != kbArticle.getMain())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_KBARTICLE_WHERE); boolean conjunctionable = false; if ((resourcePrimKeies == null) || (resourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < resourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_R_G_M_RESOURCEPRIMKEY_5); if ((i + 1) < resourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_M_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_M_MAIN_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(KBArticleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (resourcePrimKeies != null) { qPos.add(resourcePrimKeies); } qPos.add(groupId); qPos.add(main); list = (List<KBArticle>) 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.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles that the user has permission to view where resourcePrimKey = any ? and groupId = ? and main = ?. * * <p>/*from w w w. j ava2 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 resourcePrimKeies the resource prim keies * @param groupId the group ID * @param main the main * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles that the user has permission to view * @throws SystemException if a system exception occurred */ public List<KBArticle> filterFindByR_G_M(long[] resourcePrimKeies, long groupId, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByR_G_M(resourcePrimKeies, groupId, main, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE); } else { query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if ((resourcePrimKeies == null) || (resourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < resourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_R_G_M_RESOURCEPRIMKEY_5); if ((i + 1) < resourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_M_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_M_MAIN_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_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(KBArticleModelImpl.ORDER_BY_JPQL); } else { query.append(KBArticleModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.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, KBArticleImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (resourcePrimKeies != null) { qPos.add(resourcePrimKeies); } qPos.add(groupId); qPos.add(main); return (List<KBArticle>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles where resourcePrimKey = any ? and groupId = ? and status = ?. * * <p>//from w w w . java 2s .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 resourcePrimKeies the resource prim keies * @param groupId the group ID * @param status the status * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles * @throws SystemException if a system exception occurred */ public List<KBArticle> findByR_G_S(long[] resourcePrimKeies, long groupId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_R_G_S; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), groupId, status }; } else { finderArgs = new Object[] { StringUtil.merge(resourcePrimKeies), groupId, status, start, end, orderByComparator }; } List<KBArticle> list = (List<KBArticle>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (KBArticle kbArticle : list) { if (!ArrayUtil.contains(resourcePrimKeies, kbArticle.getResourcePrimKey()) || (groupId != kbArticle.getGroupId()) || (status != kbArticle.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_KBARTICLE_WHERE); boolean conjunctionable = false; if ((resourcePrimKeies == null) || (resourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < resourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_R_G_S_RESOURCEPRIMKEY_5); if ((i + 1) < resourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_S_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_S_STATUS_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(KBArticleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (resourcePrimKeies != null) { qPos.add(resourcePrimKeies); } qPos.add(groupId); qPos.add(status); list = (List<KBArticle>) 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.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles that the user has permission to view where resourcePrimKey = any ? and groupId = ? and status = ?. * * <p>/*from w w w .j a v a2 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 resourcePrimKeies the resource prim keies * @param groupId the group ID * @param status the status * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles that the user has permission to view * @throws SystemException if a system exception occurred */ public List<KBArticle> filterFindByR_G_S(long[] resourcePrimKeies, long groupId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByR_G_S(resourcePrimKeies, groupId, status, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE); } else { query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if ((resourcePrimKeies == null) || (resourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < resourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_R_G_S_RESOURCEPRIMKEY_5); if ((i + 1) < resourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_S_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_R_G_S_STATUS_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_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(KBArticleModelImpl.ORDER_BY_JPQL); } else { query.append(KBArticleModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.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, KBArticleImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (resourcePrimKeies != null) { qPos.add(resourcePrimKeies); } qPos.add(groupId); qPos.add(status); return (List<KBArticle>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles where groupId = ? and parentResourcePrimKey = any ? and latest = ?. * * <p>/* w ww . j a va2s .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 parentResourcePrimKeies the parent resource prim keies * @param latest the latest * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles * @throws SystemException if a system exception occurred */ public List<KBArticle> findByG_P_L(long groupId, long[] parentResourcePrimKeies, boolean latest, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_L; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { groupId, StringUtil.merge(parentResourcePrimKeies), latest }; } else { finderArgs = new Object[] { groupId, StringUtil.merge(parentResourcePrimKeies), latest, start, end, orderByComparator }; } List<KBArticle> list = (List<KBArticle>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (KBArticle kbArticle : list) { if ((groupId != kbArticle.getGroupId()) || !ArrayUtil.contains(parentResourcePrimKeies, kbArticle.getParentResourcePrimKey()) || (latest != kbArticle.getLatest())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_KBARTICLE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_L_GROUPID_5); conjunctionable = true; if ((parentResourcePrimKeies == null) || (parentResourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentResourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_G_P_L_PARENTRESOURCEPRIMKEY_5); if ((i + 1) < parentResourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_L_LATEST_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(KBArticleModelImpl.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 (parentResourcePrimKeies != null) { qPos.add(parentResourcePrimKeies); } qPos.add(latest); list = (List<KBArticle>) 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.knowledgebase.service.persistence.KBArticlePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the k b articles that the user has permission to view where groupId = ? and parentResourcePrimKey = any ? and latest = ?. * * <p>// w ww . j av a2 s . 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 groupId the group ID * @param parentResourcePrimKeies the parent resource prim keies * @param latest the latest * @param start the lower bound of the range of k b articles * @param end the upper bound of the range of k b articles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching k b articles that the user has permission to view * @throws SystemException if a system exception occurred */ public List<KBArticle> filterFindByG_P_L(long groupId, long[] parentResourcePrimKeies, boolean latest, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_L(groupId, parentResourcePrimKeies, latest, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_WHERE); } else { query.append(_FILTER_SQL_SELECT_KBARTICLE_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_L_GROUPID_5); conjunctionable = true; if ((parentResourcePrimKeies == null) || (parentResourcePrimKeies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < parentResourcePrimKeies.length; i++) { query.append(_FINDER_COLUMN_G_P_L_PARENTRESOURCEPRIMKEY_5); if ((i + 1) < parentResourcePrimKeies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_L_LATEST_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_KBARTICLE_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(KBArticleModelImpl.ORDER_BY_JPQL); } else { query.append(KBArticleModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.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, KBArticleImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, KBArticleImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (parentResourcePrimKeies != null) { qPos.add(parentResourcePrimKeies); } qPos.add(latest); return (List<KBArticle>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }