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

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

Introduction

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

Prototype

String CONTEXT_COMPANY_ID

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

Click Source Link

Usage

From source file:com.liferay.portlet.workflowinstances.action.EditWorkflowInstanceAction.java

License:Open Source License

protected void deleteInstance(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long workflowInstanceId = ParamUtil.getLong(actionRequest, "workflowInstanceId");

    WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil
            .getWorkflowInstance(themeDisplay.getCompanyId(), workflowInstanceId);

    Map<String, Serializable> workflowContext = workflowInstance.getWorkflowContext();

    long companyId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
    long groupId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));
    String className = GetterUtil.getString(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME));
    long classPK = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));

    WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler(className);

    workflowHandler.updateStatus(WorkflowConstants.STATUS_DRAFT, workflowContext);

    WorkflowInstanceLinkLocalServiceUtil.deleteWorkflowInstanceLink(companyId, groupId, className, classPK);
}

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

License:Open Source License

/**
 * Add the article to workflow./*w  ww  . j a v a  2 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);
    }
}