资源简介

此文件为本人对activit测试的各种demo,符合工作流开发的各种场景,工作中的测试部分尽在这里,包括对在线编辑器的整合

资源截图

代码片段和文件信息

package activitiTest;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.objectMapper;
import org.activiti.bpmn.converter.BpmnxmlConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.editor.language.json.converter.BpmnJsonConverter;
import org.activiti.engine.IdentityService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.form.FormProperty;
import org.activiti.engine.form.StartFormData;
import org.activiti.engine.form.TaskFormData;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.util.json.JSONobject;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.Model;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
import org.junit.Test;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wxt
 * @date 2018/9/19
 * @description:
 */
public class DocTest {
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();


    @Test
    public void model(){

        List resultList =  processEngine.getRepositoryService().createModelQuery().notDeployed().
                orderByCreateTime().desc().list();
        JSONobject resultJson = new JSONobject();
        resultJson.put(“data“ resultList);
        System.out.println( resultJson.toString());
    }

    //部署流程

    /**
     * 流程部署会在流程部署表中存在一封数据(act_re_deploment)
     * 2501 zsyleave 2018-09-19 15:06:10.608
     *
     * 同时资源文件表中也会维护一份数据(act_ge_bytearray)
     * 流程定义表会有数据(act_re_procdef)
     * myleave:1:2504 1 http://www.activiti.org/processdef 请假 myleave 1 2501 zsyleave.bpmn20.xml zsyleave.myleave.png 中顺易员工请假审批流程图 0 1 1
     *
     * @throws IOException
     */
    @Test
    public void deployProcess() throws IOException {

        RepositoryService repositoryService = processEngine.getRepositoryService();
        String id = “37501“;
        try {
            Model modelData = repositoryService.getModel(id);
            if (modelData != null) {
                byte[] bytes = repositoryService.getModelEditorSource(modelData.getId());
                if (bytes != null) {
                    JsonNode modelNode = new objectMapper().readTree(bytes);
                    BpmnModel model = new BpmnJsonConverter().convert

评论

共有 条评论