扩展的目标
扩展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

6744

被折叠的 条评论
为什么被折叠?



