Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.

Prototype

int STATUS_ANY

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.

Click Source Link

Usage

From source file:com.liferay.portlet.messageboards.service.impl.MBThreadServiceImpl.java

License:Open Source License

public int getGroupThreadsCount(long groupId, long userId, int status, boolean subscribed,
        boolean includeAnonymous) throws SystemException {

    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return doGetGroupThreadsCount(groupId, userId, status, subscribed, includeAnonymous);
    }/*from w w w  .  j  a v  a  2  s  .  c o m*/

    long[] categoryIds = mbCategoryService.getCategoryIds(groupId,
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    if (categoryIds.length == 0) {
        return 0;
    }

    if (userId <= 0) {
        if (status == WorkflowConstants.STATUS_ANY) {
            return mbThreadPersistence.countByG_C(groupId, categoryIds);
        } else {
            return mbThreadPersistence.countByG_C_S(groupId, categoryIds, status);
        }
    } else {
        if (subscribed) {
            return mbThreadFinder.filterCountByS_G_U_C_S(groupId, userId, categoryIds, status);
        } else {
            if (includeAnonymous) {
                return mbMessageFinder.filterCountByG_U_C_S(groupId, userId, categoryIds, status);
            } else {
                return mbMessageFinder.filterCountByG_U_C_A_S(groupId, userId, categoryIds, false, status);
            }
        }
    }
}

From source file:com.liferay.portlet.messageboards.service.impl.MBThreadServiceImpl.java

License:Open Source License

public List<MBThread> getThreads(long groupId, long categoryId, int status, int start, int end)
        throws SystemException {

    if (status == WorkflowConstants.STATUS_ANY) {
        return mbThreadFinder.filterFindByG_C(groupId, categoryId, start, end);
    } else {/*from  w w  w.  jav  a2 s  .  c  o m*/
        return mbThreadFinder.filterFindByG_C_S(groupId, categoryId, status, start, end);
    }
}

From source file:com.liferay.portlet.messageboards.service.impl.MBThreadServiceImpl.java

License:Open Source License

public int getThreadsCount(long groupId, long categoryId, int status) throws SystemException {

    if (status == WorkflowConstants.STATUS_ANY) {
        return mbThreadFinder.filterCountByG_C(groupId, categoryId);
    } else {/*from   www.j  a  v  a 2s.  c om*/
        return mbThreadFinder.filterCountByG_C_S(groupId, categoryId, status);
    }
}

From source file:com.liferay.portlet.messageboards.service.impl.MBThreadServiceImpl.java

License:Open Source License

protected List<MBThread> doGetGroupThreads(long groupId, long userId, int status, boolean subscribed,
        boolean includeAnonymous, int start, int end) throws SystemException {

    if (userId <= 0) {
        if (status == WorkflowConstants.STATUS_ANY) {
            return mbThreadPersistence.findByGroupId(groupId, start, end);
        } else {/*  w ww. j  av  a 2 s  .  c  o  m*/
            return mbThreadPersistence.findByG_S(groupId, status, start, end);
        }
    } else if (subscribed) {
        return mbThreadFinder.findByS_G_U_S(groupId, userId, status, start, end);
    } else if (includeAnonymous) {
        return mbThreadFinder.findByG_U_S(groupId, userId, status, start, end);
    } else {
        return mbThreadFinder.findByG_U_A_S(groupId, userId, false, status, start, end);
    }
}

From source file:com.liferay.portlet.messageboards.service.impl.MBThreadServiceImpl.java

License:Open Source License

protected int doGetGroupThreadsCount(long groupId, long userId, int status, boolean subscribed,
        boolean includeAnonymous) throws SystemException {

    if (userId <= 0) {
        if (status == WorkflowConstants.STATUS_ANY) {
            return mbThreadPersistence.countByGroupId(groupId);
        } else {/*from  ww w .j  a v  a2s  . c o m*/
            return mbThreadPersistence.countByG_S(groupId, status);
        }
    } else if (subscribed) {
        return mbThreadFinder.countByS_G_U_S(groupId, userId, status);
    } else if (includeAnonymous) {
        return mbThreadFinder.countByG_U_S(groupId, userId, status);
    } else {
        return mbThreadFinder.countByG_U_A_S(groupId, userId, false, status);
    }
}

From source file:com.liferay.portlet.messageboards.service.persistence.MBMessageFinderImpl.java

License:Open Source License

protected int doCountByG_U_C_S(long groupId, long userId, long[] categoryIds, int status,
        boolean inlineSQLHelper) throws SystemException {

    Session session = null;/*from   w ww .  j a va  2  s .c om*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_G_U_C_S);

        if ((categoryIds == null) || (categoryIds.length == 0)) {
            sql = StringUtil.replace(sql, "(currentMessage.categoryId = ?) AND", StringPool.BLANK);
        } else {
            sql = StringUtil.replace(sql, "currentMessage.categoryId = ?", "currentMessage.categoryId = "
                    + StringUtil.merge(categoryIds, " OR currentMessage.categoryId = "));
        }

        if (status != WorkflowConstants.STATUS_ANY) {
            sql = CustomSQLUtil.appendCriteria(sql, "AND (currentMessage.status = ?)");
        }

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, MBMessage.class.getName(),
                    "rootMessage.messageId", groupId);
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);
        qPos.add(userId);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

        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.messageboards.service.persistence.MBMessageFinderImpl.java

License:Open Source License

protected int doCountByG_U_C_A_S(long groupId, long userId, long[] categoryIds, boolean anonymous, int status,
        boolean inlineSQLHelper) throws SystemException {

    Session session = null;/* w  w w  .  j a v  a 2 s .com*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_G_U_C_A_S);

        if ((categoryIds == null) || (categoryIds.length == 0)) {
            sql = StringUtil.replace(sql, "(currentMessage.categoryId = ?) AND", StringPool.BLANK);
        } else {
            sql = StringUtil.replace(sql, "currentMessage.categoryId = ?", "currentMessage.categoryId = "
                    + StringUtil.merge(categoryIds, " OR currentMessage.categoryId = "));
        }

        if (status != WorkflowConstants.STATUS_ANY) {
            sql = CustomSQLUtil.appendCriteria(sql, "AND (currentMessage.status = ?)");
        }

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, MBMessage.class.getName(),
                    "rootMessage.messageId", groupId);
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);
        qPos.add(userId);
        qPos.add(anonymous);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

        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.messageboards.service.persistence.MBMessageFinderImpl.java

License:Open Source License

protected List<Long> doFindByG_U_C_S(long groupId, long userId, long[] categoryIds, int status, int start,
        int end, boolean inlineSQLHelper) throws SystemException {

    Session session = null;/*from w w  w  .  j av a 2s . c  o m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_G_U_C_S);

        if ((categoryIds == null) || (categoryIds.length == 0)) {
            sql = StringUtil.replace(sql, "(currentMessage.categoryId = ?) AND", StringPool.BLANK);
        } else {
            sql = StringUtil.replace(sql, "currentMessage.categoryId = ?", "currentMessage.categoryId = "
                    + StringUtil.merge(categoryIds, " OR currentMessage.categoryId = "));
        }

        if (status != WorkflowConstants.STATUS_ANY) {
            sql = CustomSQLUtil.appendCriteria(sql, "AND (currentMessage.status = ?)");
        }

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, MBMessage.class.getName(),
                    "rootMessage.messageId", groupId);
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar("threadId", Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);
        qPos.add(userId);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

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

From source file:com.liferay.portlet.messageboards.service.persistence.MBMessageFinderImpl.java

License:Open Source License

protected List<Long> doFindByG_U_C_A_S(long groupId, long userId, long[] categoryIds, boolean anonymous,
        int status, int start, int end, boolean inlineSQLHelper) throws SystemException {

    Session session = null;/*from  w ww  .j a va2s.  co  m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_G_U_C_A_S);

        if ((categoryIds == null) || (categoryIds.length == 0)) {
            sql = StringUtil.replace(sql, "(currentMessage.categoryId = ?) AND", StringPool.BLANK);
        } else {
            sql = StringUtil.replace(sql, "currentMessage.categoryId = ?", "currentMessage.categoryId = "
                    + StringUtil.merge(categoryIds, " OR currentMessage.categoryId = "));
        }

        if (status != WorkflowConstants.STATUS_ANY) {
            sql = CustomSQLUtil.appendCriteria(sql, "AND (currentMessage.status = ?)");
        }

        if (inlineSQLHelper) {
            sql = InlineSQLHelperUtil.replacePermissionCheck(sql, MBMessage.class.getName(),
                    "rootMessage.messageId", groupId);
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar("threadId", Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);
        qPos.add(userId);
        qPos.add(anonymous);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

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

From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadFinderImpl.java

License:Open Source License

public int countByG_U_S(long groupId, long userId, int status) throws SystemException {

    Session session = null;/*www. j  a  va2 s.c o  m*/

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(COUNT_BY_G_U_S);

        if (status != WorkflowConstants.STATUS_ANY) {
            sql = CustomSQLUtil.appendCriteria(sql, "AND (MBMessage.status = ?)");
        }

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);
        qPos.add(userId);

        if (status != WorkflowConstants.STATUS_ANY) {
            qPos.add(status);
        }

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