Example usage for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS

List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.

Prototype

String OPEN_PARENTHESIS

To view the source code for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.

Click Source Link

Usage

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 that the user has permission to view where groupId = ? and folderId = any ?.
 *
 * <p>//from   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 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 that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public List<DLFileEntry> 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();

    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
    }

    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 (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_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(DLFileEntryModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
        }
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntry.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, DLFileEntryImpl.class);
        } else {
            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
        }

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        if (folderIds != null) {
            qPos.add(folderIds);
        }

        return (List<DLFileEntry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw processException(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 = &#63; and userId = &#63; and folderId = any &#63;.
 *
 * <p>//from  w ww.j  av  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 userId the user 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_U_F(long groupId, long userId, 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_U_F;
        finderArgs = new Object[] { groupId, userId, StringUtil.merge(folderIds) };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F;
        finderArgs = new Object[] { groupId, userId, 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_U_F_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_U_F_USERID_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_U_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);

            qPos.add(userId);

            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;
}

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 that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
 *
 * <p>//from w w w . j  av  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 userId the user 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 that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public List<DLFileEntry> filterFindByG_U_F(long groupId, long userId, long[] folderIds, int start, int end,
        OrderByComparator orderByComparator) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByG_U_F(groupId, userId, folderIds, start, end, orderByComparator);
    }

    StringBundler query = new StringBundler();

    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
    }

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);

    conjunctionable = true;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_U_F_USERID_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_U_F_FOLDERID_5);

            if ((i + 1) < folderIds.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    if (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_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(DLFileEntryModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
        }
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntry.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, DLFileEntryImpl.class);
        } else {
            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
        }

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        qPos.add(userId);

        if (folderIds != null) {
            qPos.add(folderIds);
        }

        return (List<DLFileEntry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw processException(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 = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
 *
 * <p>/*from  w w w. 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 folderIds the folder IDs
 * @param fileEntryTypeId the file entry type ID
 * @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_F(long groupId, long[] folderIds, long fileEntryTypeId, 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_F;
        finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), fileEntryTypeId };
    } else {
        finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_F;
        finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), fileEntryTypeId,

                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_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_F_FOLDERID_5);

                if ((i + 1) < folderIds.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);

        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);
            }

            qPos.add(fileEntryTypeId);

            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;
}

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 that the user has permission to view where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
 *
 * <p>// w  w  w  .j a  va2  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 fileEntryTypeId the file entry type ID
 * @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 that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public List<DLFileEntry> filterFindByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId, int start,
        int end, OrderByComparator orderByComparator) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByG_F_F(groupId, folderIds, fileEntryTypeId, start, end, orderByComparator);
    }

    StringBundler query = new StringBundler();

    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_NO_INLINE_DISTINCT_WHERE_1);
    }

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_F_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_F_FOLDERID_5);

            if ((i + 1) < folderIds.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5);

    conjunctionable = true;

    if (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_DLFILEENTRY_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(DLFileEntryModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(DLFileEntryModelImpl.ORDER_BY_SQL);
        }
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntry.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, DLFileEntryImpl.class);
        } else {
            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryImpl.class);
        }

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        if (folderIds != null) {
            qPos.add(folderIds);
        }

        qPos.add(fileEntryTypeId);

        return (List<DLFileEntry>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63;.
 *
 * @param groupId the group ID//w  w  w  .  j  a  v  a 2s . c  om
 * @param folderIds the folder IDs
 * @return the number of matching document library file 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_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;
        }

        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.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
 *
 * @param groupId the group ID//  ww w  .  j av  a 2  s .  co  m
 * @param folderIds the folder IDs
 * @return the number of matching document library file 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(_FILTER_SQL_COUNT_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;
    }

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntry.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 (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.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of document library file entries where groupId = &#63; and userId = &#63; and folderId = any &#63;.
 *
 * @param groupId the group ID//  w  w w .  jav a2  s.  c  o m
 * @param userId the user ID
 * @param folderIds the folder IDs
 * @return the number of matching document library file entries
 * @throws SystemException if a system exception occurred
 */
public int countByG_U_F(long groupId, long userId, long[] folderIds) throws SystemException {
    Object[] finderArgs = new Object[] { groupId, userId, StringUtil.merge(folderIds) };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_F, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_DLFILEENTRY_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_U_F_USERID_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_U_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);

            qPos.add(userId);

            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_U_F, finderArgs, count);

            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of document library file entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63;.
 *
 * @param groupId the group ID/*from   ww  w. java  2  s. c o  m*/
 * @param userId the user ID
 * @param folderIds the folder IDs
 * @return the number of matching document library file entries that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountByG_U_F(long groupId, long userId, long[] folderIds) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return countByG_U_F(groupId, userId, folderIds);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE);

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_U_F_GROUPID_5);

    conjunctionable = true;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_U_F_USERID_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_U_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(), DLFileEntry.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);

        qPos.add(userId);

        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.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java

License:Open Source License

/**
 * Returns the number of document library file entries where groupId = &#63; and folderId = any &#63; and fileEntryTypeId = &#63;.
 *
 * @param groupId the group ID//  ww w .j a v  a2 s .c  o  m
 * @param folderIds the folder IDs
 * @param fileEntryTypeId the file entry type ID
 * @return the number of matching document library file entries
 * @throws SystemException if a system exception occurred
 */
public int countByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId) throws SystemException {
    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds), fileEntryTypeId };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F_F, finderArgs, this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_DLFILEENTRY_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_F_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_F_FOLDERID_5);

                if ((i + 1) < folderIds.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_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 (folderIds != null) {
                qPos.add(folderIds);
            }

            qPos.add(fileEntryTypeId);

            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_F, finderArgs, count);

            closeSession(session);
        }
    }

    return count.intValue();
}