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 groupId = ? and parentResourcePrimKey = any ? and main = ?. * * <p>// w w w. jav 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 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> findByG_P_M(long groupId, long[] parentResourcePrimKeies, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_M; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { groupId, StringUtil.merge(parentResourcePrimKeies), main }; } else { finderArgs = new Object[] { groupId, 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 ((groupId != kbArticle.getGroupId()) || !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 (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_M_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_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_G_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); qPos.add(groupId); 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 that the user has permission to view where groupId = ? and parentResourcePrimKey = any ? and main = ?. * * <p>/* w ww . java 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 groupId the group ID * @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 that the user has permission to view * @throws SystemException if a system exception occurred */ public List<KBArticle> filterFindByG_P_M(long groupId, long[] parentResourcePrimKeies, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_M(groupId, parentResourcePrimKeies, 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 (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_M_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_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_G_P_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); qPos.add(groupId); if (parentResourcePrimKeies != null) { qPos.add(parentResourcePrimKeies); } 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 groupId = ? and parentResourcePrimKey = any ? and status = ?. * * <p>//from w ww. 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 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> findByG_P_S(long groupId, long[] parentResourcePrimKeies, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { groupId, StringUtil.merge(parentResourcePrimKeies), status }; } else { finderArgs = new Object[] { groupId, 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 ((groupId != kbArticle.getGroupId()) || !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 (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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_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_G_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); qPos.add(groupId); 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 that the user has permission to view where groupId = ? and parentResourcePrimKey = any ? and status = ?. * * <p>/* www . 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 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 that the user has permission to view * @throws SystemException if a system exception occurred */ public List<KBArticle> filterFindByG_P_S(long groupId, long[] parentResourcePrimKeies, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S(groupId, parentResourcePrimKeies, 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 (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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_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_G_P_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); qPos.add(groupId); if (parentResourcePrimKeies != null) { qPos.add(parentResourcePrimKeies); } 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 = ? and sections LIKE any ? and latest = ?. * * <p>/*from w w w . j a v a 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 groupId the group ID * @param parentResourcePrimKey the parent resource prim key * @param sectionses the sectionses * @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_S_L(long groupId, long parentResourcePrimKey, String[] sectionses, boolean latest, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S_L; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), latest }; } else { finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), 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()) || (parentResourcePrimKey != kbArticle.getParentResourcePrimKey()) || !ArrayUtil.contains(sectionses, kbArticle.getSections()) || (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_S_L_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_L_PARENTRESOURCEPRIMKEY_5); conjunctionable = true; if ((sectionses == null) || (sectionses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < sectionses.length; i++) { String sections = sectionses[i]; if (sections == null) { query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_4); } else { if (sections.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_6); } else { query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_5); } } if ((i + 1) < sectionses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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); qPos.add(parentResourcePrimKey); if (sectionses != null) { qPos.add(sectionses); } 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 = ? and sections LIKE any ? and latest = ?. * * <p>/*w w w .j ava2s . 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 parentResourcePrimKey the parent resource prim key * @param sectionses the sectionses * @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_S_L(long groupId, long parentResourcePrimKey, String[] sectionses, boolean latest, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S_L(groupId, parentResourcePrimKey, sectionses, 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_S_L_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_L_PARENTRESOURCEPRIMKEY_5); conjunctionable = true; if ((sectionses == null) || (sectionses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < sectionses.length; i++) { String sections = sectionses[i]; if (sections == null) { query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_4); } else { if (sections.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_6); } else { query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_5); } } if ((i + 1) < sectionses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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); qPos.add(parentResourcePrimKey); if (sectionses != null) { qPos.add(sectionses); } 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 groupId = ? and parentResourcePrimKey = ? and sections LIKE any ? and main = ?. * * <p>//from w w w . j a v a 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 groupId the group ID * @param parentResourcePrimKey the parent resource prim key * @param sectionses the sectionses * @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> findByG_P_S_M(long groupId, long parentResourcePrimKey, String[] sectionses, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S_M; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), main }; } else { finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), main, 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()) || (parentResourcePrimKey != kbArticle.getParentResourcePrimKey()) || !ArrayUtil.contains(sectionses, kbArticle.getSections()) || (main != kbArticle.getMain())) { 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_S_M_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_M_PARENTRESOURCEPRIMKEY_5); conjunctionable = true; if ((sectionses == null) || (sectionses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < sectionses.length; i++) { String sections = sectionses[i]; if (sections == null) { query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_4); } else { if (sections.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_6); } else { query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_5); } } if ((i + 1) < sectionses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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); qPos.add(groupId); qPos.add(parentResourcePrimKey); if (sectionses != null) { qPos.add(sectionses); } 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 groupId = ? and parentResourcePrimKey = ? and sections LIKE any ? and main = ?. * * <p>//from w w w . j a v 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 groupId the group ID * @param parentResourcePrimKey the parent resource prim key * @param sectionses the sectionses * @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> filterFindByG_P_S_M(long groupId, long parentResourcePrimKey, String[] sectionses, boolean main, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S_M(groupId, parentResourcePrimKey, sectionses, 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 (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_M_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_M_PARENTRESOURCEPRIMKEY_5); conjunctionable = true; if ((sectionses == null) || (sectionses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < sectionses.length; i++) { String sections = sectionses[i]; if (sections == null) { query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_4); } else { if (sections.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_6); } else { query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_5); } } if ((i + 1) < sectionses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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); qPos.add(groupId); qPos.add(parentResourcePrimKey); if (sectionses != null) { qPos.add(sectionses); } 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 groupId = ? and parentResourcePrimKey = ? and sections LIKE any ? and status = ?. * * <p>/* www. ja v a2s. 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 parentResourcePrimKey the parent resource prim key * @param sectionses the sectionses * @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> findByG_P_S_S(long groupId, long parentResourcePrimKey, String[] sectionses, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S_S; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), status }; } else { finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), status, 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()) || (parentResourcePrimKey != kbArticle.getParentResourcePrimKey()) || !ArrayUtil.contains(sectionses, kbArticle.getSections()) || (status != kbArticle.getStatus())) { 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_S_S_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_S_PARENTRESOURCEPRIMKEY_5); conjunctionable = true; if ((sectionses == null) || (sectionses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < sectionses.length; i++) { String sections = sectionses[i]; if (sections == null) { query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_4); } else { if (sections.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_6); } else { query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_5); } } if ((i + 1) < sectionses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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); qPos.add(groupId); qPos.add(parentResourcePrimKey); if (sectionses != null) { qPos.add(sectionses); } 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 groupId = ? and parentResourcePrimKey = ? and sections LIKE any ? and status = ?. * * <p>//from w w w. ja va2s. 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 parentResourcePrimKey the parent resource prim key * @param sectionses the sectionses * @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> filterFindByG_P_S_S(long groupId, long parentResourcePrimKey, String[] sectionses, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_P_S_S(groupId, parentResourcePrimKey, sectionses, 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 (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_S_GROUPID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_S_PARENTRESOURCEPRIMKEY_5); conjunctionable = true; if ((sectionses == null) || (sectionses.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < sectionses.length; i++) { String sections = sectionses[i]; if (sections == null) { query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_4); } else { if (sections.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_6); } else { query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_5); } } if ((i + 1) < sectionses.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_P_S_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); qPos.add(groupId); qPos.add(parentResourcePrimKey); if (sectionses != null) { qPos.add(sectionses); } qPos.add(status); return (List<KBArticle>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }