activiti

Posted yangyang12138

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了activiti相关的知识,希望对你有一定的参考价值。

1.获取服务列表

  

ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

        List tasks = engine.getTaskService().createTaskQuery().taskAssignee("oo").list();
        
        for(Object task:tasks){
            System.out.println(task.toString());
        }

 

2.完成任务

ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

engine.getTaskService().complete("100");

3.部署工作流

ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

engine.getRepositoryService().createDeployment().name("oo").addClasspathResource("*.bnmp").deploy();

4.启动任务

ProcessInstance processInstance = processRuntime.start(ProcessPayloadBuilder
.start()
.withProcessDefinitionKey("pid")
.withName("Processing Content: " + content)
.withVariable("content", content)
.build());
pid是在bnmp中定义的id
5.完成指定任务
public void checkAndWorkOnTasksWhenAvailable() {
        securityUtil.logInAs("bob");

        Page<Task> tasks = taskRuntime.tasks(Pageable.of(0, 10));
        if (tasks.getTotalItems() > 0) {
            for (Task t : tasks.getContent()) {

                logger.info("> Claiming task: " + t.getId());
                taskRuntime.claim(TaskPayloadBuilder.claim().withTaskId(t.getId()).build());

                List<VariableInstance> variables = taskRuntime.variables(TaskPayloadBuilder.variables().withTaskId(t.getId()).build());
                VariableInstance variableInstance = variables.get(0);
                if (variableInstance.getName().equals("content")) {
                    Content contentToProcess = variableInstance.getValue();
                    logger.info("> Content received inside the task to approve: " + contentToProcess);

                    if (contentToProcess.getBody().contains("activiti")) {
                        logger.info("> User Approving content");
                        contentToProcess.setApproved(true);
                    } else {
                        logger.info("> User Discarding content");
                        contentToProcess.setApproved(false);
                    }
                    taskRuntime.complete(TaskPayloadBuilder.complete()
                            .withTaskId(t.getId()).withVariable("content", contentToProcess).build());
                }


            }

        } else {
            logger.info("> There are no task for me to work on.");
        }

    }

 

以上是关于activiti的主要内容,如果未能解决你的问题,请参考以下文章

片段 MyFragment 未附加到 Activity

将字符串数据从Activity发送到片段[关闭]

如何在 ViewPager 中从 Activity 移动到 Fragment?未找到片段 ID 的视图

如何将片段中的 ListView 对象的数据传递给 Activity?

片段 - 您是不是必须在包含整个 Activity 的片段周围使用 Activity Wrapper?

add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段