Example usage for com.liferay.portal.kernel.workflow WorkflowTaskManagerUtil getWorkflowTaskCountByUser

List of usage examples for com.liferay.portal.kernel.workflow WorkflowTaskManagerUtil getWorkflowTaskCountByUser

Introduction

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

Prototype

public static int getWorkflowTaskCountByUser(long companyId, long userId, Boolean completed)
            throws WorkflowException 

Source Link

Usage

From source file:it.tref.liferay.statusworkflow.portlet.StatusWorkflowPortlet.java

License:Open Source License

@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws IOException, PortletException {

    String id = resourceRequest.getResourceID();

    try {//  www.jav a 2 s  . c  o  m

        ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);

        long companyId = serviceContext.getCompanyId();
        long userId = serviceContext.getUserId();

        int count = 0;

        if ("countTasksUser".equals(id)) {
            try {
                count = WorkflowTaskManagerUtil.getWorkflowTaskCountByUser(companyId, userId, false);
            } catch (WorkflowException e) {
            }
        } else if ("countTasksUserRoles".equals(id)) {
            try {
                count = WorkflowTaskManagerUtil.getWorkflowTaskCountByUserRoles(companyId, userId, false);
            } catch (WorkflowException e) {
            }
        }

        writeJSON(resourceRequest, resourceResponse, JSONFactoryUtil.createJSONObject().put("count", count));

    } catch (PortalException e) {
        _log.error("Error", e);
        throw new PortletException(e);
    } catch (SystemException e) {
        _log.error("Error", e);
        throw new PortletException(e);
    }
}