Example usage for com.liferay.portal.kernel.workflow WorkflowHandler startWorkflowInstance

List of usage examples for com.liferay.portal.kernel.workflow WorkflowHandler startWorkflowInstance

Introduction

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

Prototype

public void startWorkflowInstance(long companyId, long groupId, long userId, long classPK, T model,
            Map<String, Serializable> workflowContext) throws PortalException;

Source Link

Usage

From source file:se.gothiaforum.actorsarticle.util.ActorsServiceUtil.java

License:Open Source License

/**
 * Add the article to workflow./*www  .j a  v a2 s .  c  o m*/
 * 
 * @param article
 * @param userId
 * @param serviceContext
 * @param groupId
 */
public void addWorkFlow(long userId, JournalArticle article, long groupId, ServiceContext serviceContext) {
    try {

        User user = userService.getUser(userId);
        WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil
                .getWorkflowHandler(JournalArticle.class.getName());
        Map<String, Serializable> workflowContext = new HashMap<String, Serializable>();
        workflowContext.put(WorkflowConstants.CONTEXT_COMPANY_ID, String.valueOf(article.getCompanyId()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME,
                String.valueOf(article.getClass().getName()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK, String.valueOf(article.getPrimaryKey()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_TYPE, String.valueOf(article.getType()));
        workflowContext.put(WorkflowConstants.CONTEXT_GROUP_ID, String.valueOf(article.getGroupId()));
        workflowContext.put(WorkflowConstants.CONTEXT_USER_ID, String.valueOf(article.getUserId()));
        workflowContext.put(WorkflowConstants.CONTEXT_SERVICE_CONTEXT, serviceContext);

        workflowHandler.startWorkflowInstance(article.getCompanyId(), groupId, user.getUserId(),
                article.getPrimaryKey(), article.getClass().getName(), workflowContext);
    } catch (PortalException e) {
        throw new RuntimeException("Unable to add workflow", e);
    } catch (SystemException e) {
        throw new RuntimeException("Unable to add workflow", e);
    }
}