剖析Activiti源码扩展元素属性

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

扩展的目标

扩展activiti modeler 的元素属性,activiti modeler读取stencilset.json可动态自定义元素属性.

  • 例如需要扩展状态码属性
	{
      "name" : "stateCode",
      "properties" : [ {
        "id" : "stateCode",
        "type" : "String",
        "title" : "状态码",
        "value" : "",
        "description" : "状态码",
        "popular" : true
      } ]
    },
  • 自定义的元素ID为stateCode,则再对应的userTask的propertyPackages下注入
	{
    "type" : "node",
    "id" : "UserTask",
    "title" : "人工任务",
    "description" : "指派给特定人来执行的人工任务",
     "propertyPackages" : ["stateCode" ],
    "hiddenPropertyPackages" : [ ],
    "roles" : [ "Activity", "sequence_start", "sequence_end", "ActivitiesMorph", "all" ]
  }
  • 效果图

在这里插入图片描述

解析扩展属性

第一步已经实现了扩展UI编辑器,但是还需要在部署流程的时候同时解析写进bpm.xml文件,因为Activiti部署的流程最终生成的就是xml文件,并且在流程审核过程中也是动态一个节点一个节点读取文件,为什么这样?因为考虑到性能问题,无须all in memory.

底层源码元素属性的设计图

在这里插入图片描述

  • HasExtensionAttributes :

public interface HasExtensionAttributes {
  /** get element's attributes */
  Map<String, List<ExtensionAttribute>> getAttributes();

  /**
   * return value of the attribute from given namespace with given name.
   *
   * @param namespace
   * @param name
   * @return attribute value or null in case when attribute was not found
   */
  String getAttributeValue(String namespace, String name);

  /** add attribute to the object */
  void addAttribute(ExtensionAttribute attribute);

  /** set all object's attributes */
  void setAttributes(Map<String, List<ExtensionAttribute>> attributes);
}

通过方法名可以大概知道HasExtensionAttributes接口主要是声明了自定义属性的get set 方法.表明Activiti提供给用户扩展的可能性

  • BaseElement

主要代码片段


public abstract class BaseElement implements HasExtensionAtt

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值