Activiti6--[5] 核心API方法

本文档详细介绍了Activiti6的核心API用法,包括流程模型的创建、查询、删除和部署;流程定义的部署、查询和删除;流程实例的启动、任务办理;流程变量的设置和获取;以及历史流程的相关操作,如查询历史流程实例、活动和任务。
摘要由CSDN通过智能技术生成

API方法说明

流程模型操作

一般先定义一个流程模型,也就是通过界面拖拉拽一个图形流程出来,然后保存。这个数据就是流程模型数据

创建模型

repositoryService.newModel()
....
repositoryService.saveModel()

分页查询模型

repositoryService.createModelQuery().listPage(firstResult,maxResults)
// 查询总数
repositoryService.createModelQuery().count()  

删除模型

repositoryService.deleteModel()

部署模型

repository.createDeployment().name().deploy();

流程定义操作

通过zip部署流程

@Test
public void deployProcessByZip() throws FileNotFoundException {
   
    // 流程部署 参与的表 act_re_procdef  act_ge_bytearry act_re_deployment
    // 加斜杠代表从classpah的根目录里面找文件
    InputStream inputStream = this.getClass().getResourceAsStream("/processes/processes.zip");
    // 部署流程
    ZipInputStream zipInputStream = new ZipInputStream(inputStream);
    // 保存act_re_deployment
    Deployment deployment = repositoryService.createDeployment()
            .name("请假流程009")
            .addZipInputStream(zipInputStream)
            .deploy();

    System.out.println("部署成功,流程部署id:" + deployment.getId());//57501
}

分页查询流程部署信息

@Test
public void queryDeployment(){
   
  List<Deployment> deployments = repositoryService.createDeploymentQuery().listPage(0, 4);
  for (Deployment deployment : deployments) {
   
    System.out.println("部署id:"+deployment.getId());
    System.out.println("部署名称:"+deployment.getName());
    System.out.println("部署时间:"+deployment.getDeploymentTime());
  }
}

分页查询流程定义信息

@Test
public void  queryProcessDef(){
   
  List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().listPage(0, 4);
  for (ProcessDefinition processDefinition : processDefinitions) {
   
    System.out.println("流程定义id:"+processDefinition.getId());
    System.out.println("流程定义名称:"+processDefinition.getName());
    System.out.println("流程定义bmp:"+processDefinition.getResourceName());
    System.out.println("流程定义png:"+processDefinition.getDiagramResourceName());
    System.out.println("部署id:"+processDefinition.getDeploymentId());
    System.out.println("流程定义版本:"+processDefinition.getVersion());
  }
}

删除流程部署信息

同时删除流程定义

@Test
public void deleteDeploy(){
   
  // 根据部署id删除流程定义,如果当前部署id有对应的流程定义运行的流程实例运行,那么会报错
  repositoryService.deleteDeployment("1");
  // 级联删除表,会删除正在执行的流程数据以及act_ru_*和act_hi_*里面的数据
  // repositoryService.deleteDeployment("1",true);
}

查询流程定义图片

@Test
public void queryProcessDragram() throws Exception {
   
    //根据流程定义id查询流程定义的图片
    InputStream processDiagram = repositoryService.getProcessDiagram("helloWorld:1:4");
    File file 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值