当前位置:网站首页>Flowable process custom attribute
Flowable process custom attribute
2022-07-27 16:25:00 【Tony-devj】
flowable Custom process properties
I wrote before about adding custom extension attributes to nodes , But how to extend custom attributes on the process ? In fact, it is consistent with adding custom attributes to nodes , Only the modified related classes are different .
edit stencilset_bpmn.json file
find stencilset_bpmn.json file , Open it and you will find propertyPackages Properties of , Pictured :
We just need to follow the form created before the process , I define it here as follows :
{
"name": "isbatchapproval_package",
"properties": [
{
"id": "isbatchapproval",
"type": "Boolean", // Set to boolean type
"title": " Allow batch approval ",
"value": "",
"description": " Set whether batch approval is allowed for related nodes ",
"popular": true
}
]
}
After writing , To display related attributes on related nodes , You need to reference the above attributes on the process id The value is isbatchapproval Of , We need to introduce :
{
"type": "node",
"id": "BPMNDiagram",
"title": "BPMN\u56fe\u8868",
"description": "A BPMN 2.0 diagram.",
"view": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\"\n xmlns:oryx=\"http://www.b3mn.org/oryx\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n width=\"800\"\n height=\"600\"\n version=\"1.0\">\n <defs></defs>\n <g pointer-events=\"fill\" >\n <polygon stroke=\"black\" fill=\"black\" stroke-width=\"1\" points=\"0,0 0,590 9,599 799,599 799,9 790,0\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\" />\n <rect id=\"diagramcanvas\" oryx:resize=\"vertical horizontal\" x=\"0\" y=\"0\" width=\"790\" height=\"590\" stroke=\"black\" stroke-width=\"2\" fill=\"white\" />\n \t<text font-size=\"22\" id=\"diagramtext\" x=\"400\" y=\"25\" oryx:align=\"top center\" stroke=\"#373e48\"></text>\n </g>\n</svg>",
"icon": "diagram.png",
"groups": [
" The illustration "
],
"mayBeRoot": true,
"hide": true,
"propertyPackages": [
"process_idpackage",
"namepackage",
"documentationpackage",
"process_authorpackage",
"process_versionpackage",
"process_namespacepackage",
"process_historylevelpackage",
"isexecutablepackage",
"datapropertiespackage",
"executionlistenerspackage",
"eventlistenerspackage",
"signaldefinitionspackage",
"messagedefinitionspackage",
"process_potentialstarteruserpackage",
"process_potentialstartergrouppackage",
"process_iseagerexecutionfetchpackage",
"isbatchapproval_package"
],
"hiddenPropertyPackages": [],
"roles": []
}
After adding, there will be a selection box above the attributes of the process .
In download BPMN.xml Add attributes in
We know that when used on nodes , Need to expand UserTaskJsonConverter, But what classes should the process extend ? Through previous experience , We know that the process expansion is in BaseBpmnJsonConverter.java and BpmnJsonConverter.
edit BaseBpmnJsonConverter.java
find if (baseElement instanceof FlowElement) Change to the following code :PROCESS_IS_BATCHAPPROVAL_KEY = “isbatchapproval”;
if (baseElement instanceof FlowElement) {
FlowElement flowElement = (FlowElement) baseElement;
if (StringUtils.isNotEmpty(flowElement.getName())) {
propertiesNode.put(PROPERTY_NAME, flowElement.getName());
}
if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
propertiesNode.put(PROPERTY_DOCUMENTATION, flowElement.getDocumentation());
}
Map<String, List<ExtensionElement>> extensionElements = flowElement.getExtensionElements();
List<ExtensionElement> elements = extensionElements.get(PROCESS_IS_BATCHAPPROVAL_KEY);
if (CollectionUtils.isNotEmpty(elements)) {
for (ExtensionElement extensionElement : elements) {
if (extensionElement.getName().equals(PROCESS_IS_BATCHAPPROVAL_KEY)) {
propertiesNode.put(PROCESS_IS_BATCHAPPROVAL_KEY, extensionElement.getElementText());
}
}
}
BpmnJsonConverterUtil.convertListenersToJson(((FlowElement) baseElement).getExecutionListeners(), true, propertiesNode);
}
edit BpmnJsonConverter.java
find if (!nonEmptyPoolFound) Add as the following code :
String isbatchapproval = BpmnJsonConverterUtil.getPropertyValueAsString("isbatchapproval", modelNode);
if (StringUtils.isNotEmpty(isbatchapproval)) {
ExtensionElement isbatchapprovalExtensionElement = new ExtensionElement();
isbatchapprovalExtensionElement.setName("isbatchapproval");
isbatchapprovalExtensionElement.setNamespace("http://flowable.org/bpmn");
isbatchapprovalExtensionElement.setNamespacePrefix("flowable");
isbatchapprovalExtensionElement.setElementText(isbatchapproval);
process.addExtensionElement(isbatchapprovalExtensionElement);
}
Then start the project , downloaded xml There will be custom attributes on the process , Pictured :
Be careful
1. If it is source code deployment , Just modify the source code
2. If it is the introduction of jar When , Need to override BaseBpmnJsonConverter.java and BpmnJsonConverter.java, In the project , Create the same package as the package in the source class , Assign notes in the source code , Pay attention to the imported version and the edited version , Don't get it wrong !
边栏推荐
- flink打包程序提交任务示例
- It can carry 100 people! Musk releases the strongest "starship" in history! Go to Mars as early as next year!
- Taking advantage of 5g Dongfeng, does MediaTek want to fight the high-end market again?
- 时间序列——使用tsfresh进行分类任务
- Scratch crawler framework
- Join hands with sifive, Galanz will enter the semiconductor field! Exposure of two self-developed chips
- Servlet基础知识点
- The first week of C language learning - the history of C language
- Common tool classes under JUC package
- Reduce PDF document size (Reprint)
猜你喜欢

Excel提取重复项

matlab legend用法

Leetcode25 question: turn the linked list in a group of K -- detailed explanation of the difficult questions of the linked list

jupyter 创建虚拟环境并安装pytorch(gpu)

Flume incrementally collects MySQL data to Kafka

Axure install Icon Font Catalog

Log management

JSP基础

减小PDF文档大小(转载)

MapReduce instance (I): wordcount
随机推荐
DRF learning notes (IV): DRF view
MySQL索引
C language programming (Third Edition)
DEX and AMMS of DFI security
It can carry 100 people! Musk releases the strongest "starship" in history! Go to Mars as early as next year!
嵌入式面试
Excel extract duplicates
4位数的随机数据
C channel simply implements the publishing and subscription of message queue
Flume incrementally collects MySQL data to Kafka
Thesis reduction
The difference and use between get request and post request
DeFi安全之DEX与AMMs
4-digit random data
excel skill
Pychart imports the existing local installation package
These questions~~
2021-06-02
How PHP changes a two-dimensional array into a one-dimensional array
Rare bitwise operators