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.portlet.calendar.service.persistence.CalEventPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the cal events that the user has permission to view where groupId = ? and type = any ?. * * <p>//from w w w.j a 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. * </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 that the user has permission to view * @throws SystemException if a system exception occurred */ public List<CalEvent> filterFindByG_T(long groupId, String[] types, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_T(groupId, types, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_CALEVENT_WHERE); } else { query.append(_FILTER_SQL_SELECT_CALEVENT_NO_INLINE_DISTINCT_WHERE_1); } 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 (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_CALEVENT_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(CalEventModelImpl.ORDER_BY_JPQL); } else { query.append(CalEventModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), CalEvent.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, CalEventImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, CalEventImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (types != null) { qPos.add(types); } return (List<CalEvent>) QueryUtil.list(q, getDialect(), start, end); } 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 ? and repeating = ?. * * <p>//from ww 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 types the types * @param repeating the repeating * @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_R(long groupId, String[] types, boolean repeating, 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_R; finderArgs = new Object[] { groupId, StringUtil.merge(types), repeating }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T_R; finderArgs = new Object[] { groupId, StringUtil.merge(types), repeating, 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_R_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_R_TYPE_4); } else { if (type.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_T_R_TYPE_6); } else { query.append(_FINDER_COLUMN_G_T_R_TYPE_5); } } if ((i + 1) < types.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_REPEATING_5); 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); } qPos.add(repeating); 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; }
From source file:com.liferay.portlet.calendar.service.persistence.CalEventPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the cal events that the user has permission to view where groupId = ? and type = any ? and repeating = ?. * * <p>// w w w .j av 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. * </p> * * @param groupId the group ID * @param types the types * @param repeating the repeating * @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 that the user has permission to view * @throws SystemException if a system exception occurred */ public List<CalEvent> filterFindByG_T_R(long groupId, String[] types, boolean repeating, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_T_R(groupId, types, repeating, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_CALEVENT_WHERE); } else { query.append(_FILTER_SQL_SELECT_CALEVENT_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_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_R_TYPE_4); } else { if (type.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_T_R_TYPE_6); } else { query.append(_FINDER_COLUMN_G_T_R_TYPE_5); } } if ((i + 1) < types.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_REPEATING_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_CALEVENT_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(CalEventModelImpl.ORDER_BY_JPQL); } else { query.append(CalEventModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), CalEvent.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, CalEventImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, CalEventImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (types != null) { qPos.add(types); } qPos.add(repeating); return (List<CalEvent>) QueryUtil.list(q, getDialect(), start, end); } 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 the number of cal events where groupId = ? and type = any ?. * * @param groupId the group ID//from ww w .ja va2s.c o m * @param types the types * @return the number of matching cal events * @throws SystemException if a system exception occurred */ public int countByG_T(long groupId, String[] types) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(types) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_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; } 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); } 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_T, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.calendar.service.persistence.CalEventPersistenceImpl.java
License:Open Source License
/** * Returns the number of cal events that the user has permission to view where groupId = ? and type = any ?. * * @param groupId the group ID/*from w w w .j a v a2 s . c o m*/ * @param types the types * @return the number of matching cal events that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_T(long groupId, String[] types) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_T(groupId, types); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_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; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), CalEvent.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (types != null) { qPos.add(types); } 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 the number of cal events where groupId = ? and type = any ? and repeating = ?. * * @param groupId the group ID// w w w .jav a 2s .c om * @param types the types * @param repeating the repeating * @return the number of matching cal events * @throws SystemException if a system exception occurred */ public int countByG_T_R(long groupId, String[] types, boolean repeating) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(types), repeating }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_T_R, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_CALEVENT_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_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_R_TYPE_4); } else { if (type.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_T_R_TYPE_6); } else { query.append(_FINDER_COLUMN_G_T_R_TYPE_5); } } if ((i + 1) < types.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_REPEATING_5); 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 (types != null) { qPos.add(types); } qPos.add(repeating); 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_T_R, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.calendar.service.persistence.CalEventPersistenceImpl.java
License:Open Source License
/** * Returns the number of cal events that the user has permission to view where groupId = ? and type = any ? and repeating = ?. * * @param groupId the group ID/* w ww . ja v a 2 s.co m*/ * @param types the types * @param repeating the repeating * @return the number of matching cal events that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_T_R(long groupId, String[] types, boolean repeating) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_T_R(groupId, types, repeating); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_CALEVENT_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_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_R_TYPE_4); } else { if (type.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_G_T_R_TYPE_6); } else { query.append(_FINDER_COLUMN_G_T_R_TYPE_5); } } if ((i + 1) < types.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_T_R_REPEATING_5); conjunctionable = true; String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), CalEvent.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (types != null) { qPos.add(types); } qPos.add(repeating); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryFinderImpl.java
License:Open Source License
public int countByG_U_F_M_S(long groupId, long userId, List<Long> folderIds, String[] mimeTypes, int status) throws SystemException { Session session = null;/*from w w w. j av a 2s .c o m*/ String table = DLFileVersionImpl.TABLE_NAME; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_G_U_F_S); if (userId <= 0) { if (status == WorkflowConstants.STATUS_ANY) { table = DLFileEntryImpl.TABLE_NAME; sql = CustomSQLUtil.get(COUNT_BY_G_F); } else { sql = CustomSQLUtil.get(COUNT_BY_G_F_S); sql = StringUtil.replace(sql, "[$JOIN$]", ""); } } else { if (status == WorkflowConstants.STATUS_ANY) { table = DLFileEntryImpl.TABLE_NAME; sql = CustomSQLUtil.get(COUNT_BY_G_U_F); } } StringBundler sb = new StringBundler(); if (folderIds.size() > 0) { sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getFolderIds(folderIds, table)); sb.append(StringPool.CLOSE_PARENTHESIS); } if ((mimeTypes != null) && (mimeTypes.length > 0)) { sb.append(WHERE_AND); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getMimeTypes(mimeTypes, table)); sb.append(StringPool.CLOSE_PARENTHESIS); } sql = StringUtil.replace(sql, "[$FOLDER_ID$]", sb.toString()); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (userId > 0) { qPos.add(userId); } if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } for (Long folderId : folderIds) { qPos.add(folderId); } if (mimeTypes != null) { qPos.add(mimeTypes); } Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryFinderImpl.java
License:Open Source License
public List<DLFileEntry> findByG_U_F_M_S(long groupId, long userId, List<Long> folderIds, String[] mimeTypes, int status, int start, int end, OrderByComparator obc) throws SystemException { Session session = null;/*from w w w . ja va 2s. co m*/ String table = DLFileVersionImpl.TABLE_NAME; try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_G_U_F_S); if (userId <= 0) { if (status == WorkflowConstants.STATUS_ANY) { table = DLFileEntryImpl.TABLE_NAME; sql = CustomSQLUtil.get(FIND_BY_G_F); } else { sql = CustomSQLUtil.get(FIND_BY_G_F_S); } } else { if (status == WorkflowConstants.STATUS_ANY) { table = DLFileEntryImpl.TABLE_NAME; sql = CustomSQLUtil.get(FIND_BY_G_U_F); } } StringBundler sb = new StringBundler(); if (folderIds.size() > 0) { sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getFolderIds(folderIds, table)); sb.append(StringPool.CLOSE_PARENTHESIS); } if ((mimeTypes != null) && (mimeTypes.length > 0)) { sb.append(WHERE_AND); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getMimeTypes(mimeTypes, table)); sb.append(StringPool.CLOSE_PARENTHESIS); } sql = StringUtil.replace(sql, "[$FOLDER_ID$]", sb.toString()); sql = CustomSQLUtil.replaceOrderBy(sql, obc); SQLQuery q = session.createSQLQuery(sql); q.addEntity("DLFileEntry", DLFileEntryImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (userId > 0) { qPos.add(userId); } if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } for (Long folderId : folderIds) { qPos.add(folderId); } if (mimeTypes != null) { qPos.add(mimeTypes); } return (List<DLFileEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the document library file entries where groupId = ? and folderId = any ?. * * <p>/*w ww . j a va2 s. c o m*/ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param folderIds the folder IDs * @param start the lower bound of the range of document library file entries * @param end the upper bound of the range of document library file entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching document library file entries * @throws SystemException if a system exception occurred */ public List<DLFileEntry> 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<DLFileEntry> list = (List<DLFileEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_DLFILEENTRY_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(DLFileEntryModelImpl.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<DLFileEntry>) 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; }