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.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of microblogs entries that the user has permission to view where creatorClassNameId = ? and creatorClassPK = any ?. * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @return the number of matching microblogs entries that the user has permission to view *///from ww w . j a v a 2s . com @Override public int filterCountByCCNI_CCPK(long creatorClassNameId, long[] creatorClassPKs) { if (!InlineSQLHelperUtil.isEnabled()) { return countByCCNI_CCPK(creatorClassNameId, creatorClassPKs); } if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MicroblogsEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the microblogs entries that the user has permission to view where creatorClassNameId = ? and creatorClassPK = any ? and type = ?. * * <p>//from 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.microblogs.model.impl.MicroblogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param type the type * @param start the lower bound of the range of microblogs entries * @param end the upper bound of the range of microblogs entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching microblogs entries that the user has permission to view */ @Override public List<MicroblogsEntry> filterFindByCCNI_CCPK_T(long creatorClassNameId, long[] creatorClassPKs, int type, int start, int end, OrderByComparator<MicroblogsEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs, type, start, end, orderByComparator); } if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2_SQL); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MicroblogsEntryModelImpl.ORDER_BY_JPQL); } else { query.append(MicroblogsEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MicroblogsEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MicroblogsEntryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MicroblogsEntryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); qPos.add(type); return (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?. * * <p>// w w w .j a va 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.microblogs.model.impl.MicroblogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param type the type * @param start the lower bound of the range of microblogs entries * @param end the upper bound of the range of microblogs entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching microblogs entries */ @Override public List<MicroblogsEntry> findByCCNI_CCPK_T(long creatorClassNameId, long[] creatorClassPKs, int type, int start, int end, OrderByComparator<MicroblogsEntry> orderByComparator) { if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } if (creatorClassPKs.length == 1) { return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs[0], type, start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { creatorClassNameId, StringUtil.merge(creatorClassPKs), type }; } else { finderArgs = new Object[] { creatorClassNameId, StringUtil.merge(creatorClassPKs), type, start, end, orderByComparator }; } List<MicroblogsEntry> list = (List<MicroblogsEntry>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MicroblogsEntry microblogsEntry : list) { if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) || !ArrayUtil.contains(creatorClassPKs, microblogsEntry.getCreatorClassPK()) || (type != microblogsEntry.getType())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(MicroblogsEntryModelImpl.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(creatorClassNameId); qPos.add(type); if (!pagination) { list = (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?. * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param type the type/*www . j av a 2s. c om*/ * @return the number of matching microblogs entries */ @Override public int countByCCNI_CCPK_T(long creatorClassNameId, long[] creatorClassPKs, int type) { if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } Object[] finderArgs = new Object[] { creatorClassNameId, StringUtil.merge(creatorClassPKs), type }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); qPos.add(type); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK_T, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of microblogs entries that the user has permission to view where creatorClassNameId = ? and creatorClassPK = any ? and type = ?. * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param type the type/* ww w.ja va 2s. c o m*/ * @return the number of matching microblogs entries that the user has permission to view */ @Override public int filterCountByCCNI_CCPK_T(long creatorClassNameId, long[] creatorClassPKs, int type) { if (!InlineSQLHelperUtil.isEnabled()) { return countByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs, type); } if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2_SQL); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MicroblogsEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); qPos.add(type); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the bookmarks entries where groupId = ? and folderId = any ?. * * <p>//from ww w .j a v 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 groupId the group ID * @param folderIds the folder IDs * @param start the lower bound of the range of bookmarks entries * @param end the upper bound of the range of bookmarks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching bookmarks entries * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds, 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_F; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F; finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), start, end, orderByComparator }; } List<BookmarksEntry> list = (List<BookmarksEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.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(BookmarksEntryModelImpl.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 (folderIds != null) { qPos.add(folderIds); } list = (List<BookmarksEntry>) 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.bookmarks.service.persistence.BookmarksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = ? and folderId = any ?. * * <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 folderIds the folder IDs * @param start the lower bound of the range of bookmarks entries * @param end the upper bound of the range of bookmarks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching bookmarks entries that the user has permission to view * @throws SystemException if a system exception occurred */ public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_F(groupId, folderIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.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(BookmarksEntryModelImpl.ORDER_BY_JPQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (folderIds != null) { qPos.add(folderIds); } return (List<BookmarksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of bookmarks entries where groupId = ? and folderId = any ?. * * @param groupId the group ID//ww w . j ava 2 s. co m * @param folderIds the folder IDs * @return the number of matching bookmarks entries * @throws SystemException if a system exception occurred */ public int countByG_F(long groupId, long[] folderIds) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.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 (folderIds != null) { qPos.add(folderIds); } 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_F, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of bookmarks entries that the user has permission to view where groupId = ? and folderId = any ?. * * @param groupId the group ID/*from www . jav a 2 s.c o m*/ * @param folderIds the folder IDs * @return the number of matching bookmarks entries that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_F(long groupId, long[] folderIds) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F(groupId, folderIds); } StringBundler query = new StringBundler(); query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_FOLDERID_5); if ((i + 1) < folderIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), BookmarksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (folderIds != null) { qPos.add(folderIds); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.calendar.service.persistence.CalEventPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the cal events where groupId = ? and type = any ?. * * <p>//ww w. ja 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 types the types * @param start the lower bound of the range of cal events * @param end the upper bound of the range of cal events (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching cal events * @throws SystemException if a system exception occurred */ public List<CalEvent> findByG_T(long groupId, String[] types, 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_T; finderArgs = new Object[] { groupId, StringUtil.merge(types) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T; finderArgs = new Object[] { groupId, StringUtil.merge(types), start, end, orderByComparator }; } List<CalEvent> list = (List<CalEvent>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_CALEVENT_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_GROUPID_5); conjunctionable = true; if ((types == null) || (types.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < types.length; i++) { String type = types[i]; if (type == null) { query.append(_FINDER_COLUMN_G_T_TYPE_4); } else { if (type.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_T_TYPE_6); } else { query.append(_FINDER_COLUMN_G_T_TYPE_5); } } if ((i + 1) < types.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(CalEventModelImpl.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 (types != null) { qPos.add(types); } list = (List<CalEvent>) 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; }