Perform workflow transition programmatically in liferay?

只谈情不闲聊 提交于 2019-12-12 09:57:16

问题


I have two transition named "approved" and "reject" at the lastest step of my workflow, but i want to controll the workflow action from my portlet.

Anybody know How to Perform workflow transition programmatically in liferay ?


回答1:


my current code

  JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticle(id);
            getPermissionChecker().init(u.getUser(), true);

            WorkflowInstanceLink wil= WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink(companyId, journalArticle.getGroupId(), JournalArticle.class.getName(), journalArticle.getId());
            WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId, wil.getWorkflowInstanceId());
            Map<String, Serializable> workflowContext = workflowInstance.getWorkflowContext();

            List<Integer> logTypes_assign = new ArrayList<Integer>();
            logTypes_assign.add(WorkflowLog.TASK_ASSIGN);
            List<WorkflowLog> workflowLogs_assign = WorkflowLogManagerUtil.getWorkflowLogsByWorkflowInstance(companyId, wil.getWorkflowInstanceId(), logTypes_assign, QueryUtil.ALL_POS, QueryUtil.ALL_POS, WorkflowComparatorFactoryUtil.getLogCreateDateComparator(true));
            //WorkflowPermissionUtil.hasPermission(permissionChecker, groupId, className, classPK, actionId);

            if(workflowLogs_assign.size() > 0){             
                long taskId = workflowLogs_assign.get(workflowLogs_assign.size()-1).getWorkflowTaskId();
                WorkflowTask task = WorkflowTaskManagerUtil.getWorkflowTask(companyId, taskId);
                _log.info("task : "+task.getName());
                WorkflowTask nextTask = WorkflowTaskManagerUtil.assignWorkflowTaskToUser(companyId, userId, task.getWorkflowTaskId(), userId, "auto assign", task.getDueDate(), workflowContext);               
                WorkflowTaskManagerUtil.completeWorkflowTask(companyId, userId, nextTask.getWorkflowTaskId(), "next task transition name", "next task name", workflowContext);
            }



回答2:


workflowInstance1 = WorkflowInstanceManagerUtil.signalWorkflowInstance(service.getCompanyId(), user.getUserId(),
            workflowInstanceId, transitionNAME, workflowInstance.getWorkflowContext());


来源:https://stackoverflow.com/questions/15672441/perform-workflow-transition-programmatically-in-liferay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!