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.service.persistence.StudentPersistenceImpl.java
License:Open Source License
/** * Returns the number of students where firstName LIKE all ? and studentGender = ?. * * @param firstNames the first names//from w w w . ja v a2s .c om * @param studentGender the student gender * @return the number of matching students * @throws SystemException if a system exception occurred */ @Override public int countByFirstNameAndGender(String[] firstNames, int studentGender) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(firstNames), studentGender }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_FIRSTNAMEANDGENDER, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_STUDENT_WHERE); boolean conjunctionable = false; if ((firstNames == null) || (firstNames.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < firstNames.length; i++) { String firstName = firstNames[i]; if (firstName == null) { query.append(_FINDER_COLUMN_FIRSTNAMEANDGENDER_FIRSTNAME_4); } else if (firstName.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_FIRSTNAMEANDGENDER_FIRSTNAME_6); } else { query.append(_FINDER_COLUMN_FIRSTNAMEANDGENDER_FIRSTNAME_5); } if ((i + 1) < firstNames.length) { query.append(WHERE_AND); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_FIRSTNAMEANDGENDER_STUDENTGENDER_5); conjunctionable = true; String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (firstNames != null) { qPos.add(firstNames); } qPos.add(studentGender); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_FIRSTNAMEANDGENDER, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_FIRSTNAMEANDGENDER, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the tasks entries where userId = ? and status = any ?. * * <p>//from www. j a v a 2 s . co m * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.tasks.model.impl.TasksEntryModelImpl}. 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 userId the user ID * @param statuses the statuses * @param start the lower bound of the range of tasks entries * @param end the upper bound of the range of tasks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching tasks entries */ @Override public List<TasksEntry> findByU_S(long userId, int[] statuses, int start, int end, OrderByComparator<TasksEntry> orderByComparator) { if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } if (statuses.length == 1) { return findByU_S(userId, statuses[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { userId, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { userId, StringUtil.merge(statuses), start, end, orderByComparator }; } List<TasksEntry> list = (List<TasksEntry>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (TasksEntry tasksEntry : list) { if ((userId != tasksEntry.getUserId()) || !ArrayUtil.contains(statuses, tasksEntry.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_U_S_USERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_U_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(TasksEntryModelImpl.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(userId); if (!pagination) { list = (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_S, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_U_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of tasks entries where userId = ? and status = any ?. * * @param userId the user ID//from w ww . j a v a2 s.c o m * @param statuses the statuses * @return the number of matching tasks entries */ @Override public int countByU_S(long userId, int[] statuses) { if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } Object[] finderArgs = new Object[] { userId, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_U_S_USERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_U_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_S, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_U_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the tasks entries where assigneeUserId = ? and status = any ?. * * <p>//from w w w.ja va2 s . c o m * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.tasks.model.impl.TasksEntryModelImpl}. 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 assigneeUserId the assignee user ID * @param statuses the statuses * @param start the lower bound of the range of tasks entries * @param end the upper bound of the range of tasks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching tasks entries */ @Override public List<TasksEntry> findByA_S(long assigneeUserId, int[] statuses, int start, int end, OrderByComparator<TasksEntry> orderByComparator) { if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } if (statuses.length == 1) { return findByA_S(assigneeUserId, statuses[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { assigneeUserId, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { assigneeUserId, StringUtil.merge(statuses), start, end, orderByComparator }; } List<TasksEntry> list = (List<TasksEntry>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_A_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (TasksEntry tasksEntry : list) { if ((assigneeUserId != tasksEntry.getAssigneeUserId()) || !ArrayUtil.contains(statuses, tasksEntry.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_A_S_ASSIGNEEUSERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_A_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(TasksEntryModelImpl.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(assigneeUserId); if (!pagination) { list = (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_A_S, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_A_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of tasks entries where assigneeUserId = ? and status = any ?. * * @param assigneeUserId the assignee user ID * @param statuses the statuses//from w w w .j a v a2s. co m * @return the number of matching tasks entries */ @Override public int countByA_S(long assigneeUserId, int[] statuses) { if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } Object[] finderArgs = new Object[] { assigneeUserId, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_A_S_ASSIGNEEUSERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_A_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(assigneeUserId); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_S, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_A_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the tasks entries that the user has permission to view where groupId = ? and userId = ? and status = any ?. * * <p>/* ww w . j a v a 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. 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.tasks.model.impl.TasksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user ID * @param statuses the statuses * @param start the lower bound of the range of tasks entries * @param end the upper bound of the range of tasks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching tasks entries that the user has permission to view */ @Override public List<TasksEntry> filterFindByG_U_S(long groupId, long userId, int[] statuses, int start, int end, OrderByComparator<TasksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_U_S(groupId, userId, statuses, start, end, orderByComparator); } if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_TASKSENTRY_WHERE); } else { query.append(_FILTER_SQL_SELECT_TASKSENTRY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_TASKSENTRY_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(TasksEntryModelImpl.ORDER_BY_JPQL); } else { query.append(TasksEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), TasksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, TasksEntryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, TasksEntryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); return (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the tasks entries where groupId = ? and userId = ? and status = any ?. * * <p>/*from w w w .ja v a2 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. 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.tasks.model.impl.TasksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param userId the user ID * @param statuses the statuses * @param start the lower bound of the range of tasks entries * @param end the upper bound of the range of tasks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching tasks entries */ @Override public List<TasksEntry> findByG_U_S(long groupId, long userId, int[] statuses, int start, int end, OrderByComparator<TasksEntry> orderByComparator) { if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } if (statuses.length == 1) { return findByG_U_S(groupId, userId, statuses[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { groupId, userId, StringUtil.merge(statuses) }; } else { finderArgs = new Object[] { groupId, userId, StringUtil.merge(statuses), start, end, orderByComparator }; } List<TasksEntry> list = (List<TasksEntry>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (TasksEntry tasksEntry : list) { if ((groupId != tasksEntry.getGroupId()) || (userId != tasksEntry.getUserId()) || !ArrayUtil.contains(statuses, tasksEntry.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(TasksEntryModelImpl.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(userId); if (!pagination) { list = (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of tasks entries where groupId = ? and userId = ? and status = any ?. * * @param groupId the group ID/*from www . jav a2 s . c o m*/ * @param userId the user ID * @param statuses the statuses * @return the number of matching tasks entries */ @Override public int countByG_U_S(long groupId, long userId, int[] statuses) { if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } Object[] finderArgs = new Object[] { groupId, userId, StringUtil.merge(statuses) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of tasks entries that the user has permission to view where groupId = ? and userId = ? and status = any ?. * * @param groupId the group ID//from w ww . j a v a2s.c om * @param userId the user ID * @param statuses the statuses * @return the number of matching tasks entries that the user has permission to view */ @Override public int filterCountByG_U_S(long groupId, long userId, int[] statuses) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_U_S(groupId, userId, statuses); } if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_TASKSENTRY_WHERE); query.append(_FINDER_COLUMN_G_U_S_GROUPID_2); query.append(_FINDER_COLUMN_G_U_S_USERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_U_S_STATUS_7); query.append(StringUtil.merge(statuses)); 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(), TasksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(userId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the tasks entries that the user has permission to view where groupId = ? and assigneeUserId = ? and status = any ?. * * <p>/*ww w . j a va2 s. c o m*/ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.tasks.model.impl.TasksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param groupId the group ID * @param assigneeUserId the assignee user ID * @param statuses the statuses * @param start the lower bound of the range of tasks entries * @param end the upper bound of the range of tasks entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching tasks entries that the user has permission to view */ @Override public List<TasksEntry> filterFindByG_A_S(long groupId, long assigneeUserId, int[] statuses, int start, int end, OrderByComparator<TasksEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_A_S(groupId, assigneeUserId, statuses, start, end, orderByComparator); } if (statuses == null) { statuses = new int[0]; } else { statuses = ArrayUtil.unique(statuses); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_TASKSENTRY_WHERE); } else { query.append(_FILTER_SQL_SELECT_TASKSENTRY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_G_A_S_GROUPID_2); query.append(_FINDER_COLUMN_G_A_S_ASSIGNEEUSERID_2); if (statuses.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_G_A_S_STATUS_7); query.append(StringUtil.merge(statuses)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_TASKSENTRY_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(TasksEntryModelImpl.ORDER_BY_JPQL); } else { query.append(TasksEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), TasksEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, TasksEntryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, TasksEntryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(assigneeUserId); return (List<TasksEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }