add - 添加模型元数据解析的基础函数
This commit is contained in:
parent
e1cff0bebd
commit
0962cca8a9
@ -101,6 +101,21 @@ public final class BpmnMetaParserHelper {
|
||||
return Optional.of(conf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定审批节点的待办消息模板配置内容
|
||||
*
|
||||
* @param userTask
|
||||
* @return
|
||||
*/
|
||||
public static Optional<BpmnPendingProperty> getNodePendingConfig(UserTask userTask) {
|
||||
return defaultValid(userTask, TEMPLATE_PENDING_MESSAGE_ID).map(element -> {
|
||||
BpmnPendingProperty pendingProperty = new BpmnPendingProperty();
|
||||
pendingProperty.setPendingMessageId(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE));
|
||||
pendingProperty.setViewJson(element.getElementText());
|
||||
return pendingProperty;
|
||||
});
|
||||
}
|
||||
|
||||
public static Optional<BpmnButtonConf> getButtonConfig(Process process) {
|
||||
return parseButtonConfig(process.getExtensionElements().getOrDefault(CONFIG_BUTTON, Collections.emptyList()));
|
||||
}
|
||||
@ -195,54 +210,39 @@ public final class BpmnMetaParserHelper {
|
||||
}
|
||||
|
||||
public static Optional<BpmnFlowNodeType> getNodeType(FlowElement flowElement) {
|
||||
if (flowElement instanceof UserTask
|
||||
|| flowElement instanceof ServiceTask
|
||||
|| flowElement instanceof ReceiveTask) {
|
||||
return defaultValid(flowElement, CONFIG_NODE_TYPE)
|
||||
.map(element -> BpmnFlowNodeType.valueOf(element.getElementText()));
|
||||
if (flowElement instanceof UserTask || flowElement instanceof ServiceTask || flowElement instanceof ReceiveTask) {
|
||||
return defaultValid(flowElement, CONFIG_NODE_TYPE).map(element -> BpmnFlowNodeType.valueOf(element.getElementText()));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static Optional<ApprovalMethodEnum> getApprovalMethod(UserTask userTask) {
|
||||
return defaultValid(userTask, CONFIG_APPROVAL_METHOD)
|
||||
.map(element -> ApprovalMethodEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
return defaultValid(userTask, CONFIG_APPROVAL_METHOD).map(element -> ApprovalMethodEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
}
|
||||
|
||||
public static Optional<ApproverScopeEnum> getApproverScope(UserTask userTask) {
|
||||
return defaultValid(userTask, CONFIG_APPROVER_SCOPE)
|
||||
.map(element -> ApproverScopeEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
return defaultValid(userTask, CONFIG_APPROVER_SCOPE).map(element -> ApproverScopeEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
}
|
||||
|
||||
public static Optional<ApproverSpecifyEnum> getApproverSpecify(UserTask userTask) {
|
||||
return defaultValid(userTask, CONFIG_APPROVER_SPECIFY)
|
||||
.map(element -> ApproverSpecifyEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
return defaultValid(userTask, CONFIG_APPROVER_SPECIFY).map(element -> ApproverSpecifyEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
}
|
||||
|
||||
public static Optional<String> getApproverSpecifyValue(UserTask userTask) {
|
||||
return defaultValid(userTask, CONFIG_APPROVER_SPECIFY)
|
||||
.map(element -> StringUtils.hasLength(element.getElementText())
|
||||
? element.getElementText()
|
||||
: "[]");
|
||||
return defaultValid(userTask, CONFIG_APPROVER_SPECIFY).map(element -> StringUtils.hasLength(element.getElementText()) ? element.getElementText() : "[]");
|
||||
}
|
||||
|
||||
public static Optional<ApproverEmptyHandleTypeEnum> getApproverEmptyHandleType(UserTask userTask) {
|
||||
return defaultValid(userTask, CONFIG_APPROVER_EMPTY_HANDLE_TYPE)
|
||||
.map(element -> ApproverEmptyHandleTypeEnum.valueOf(element.getAttributeValue(null,
|
||||
ELEMENT_ATTRIBUTE_VALUE)));
|
||||
return defaultValid(userTask, CONFIG_APPROVER_EMPTY_HANDLE_TYPE).map(element -> ApproverEmptyHandleTypeEnum.valueOf(element.getAttributeValue(null, ELEMENT_ATTRIBUTE_VALUE)));
|
||||
}
|
||||
|
||||
public static Optional<String> getEmptyApproverSpecify(UserTask userTask) {
|
||||
return defaultValid(userTask, CONFIG_APPROVER_EMPTY_HANDLE_TYPE)
|
||||
.map(element -> StringUtils.hasLength(element.getElementText())
|
||||
? element.getElementText()
|
||||
: "[]");
|
||||
return defaultValid(userTask, CONFIG_APPROVER_EMPTY_HANDLE_TYPE).map(element -> StringUtils.hasLength(element.getElementText()) ? element.getElementText() : "[]");
|
||||
}
|
||||
|
||||
|
||||
private static Optional<ExtensionElement> defaultValid(FlowElement flowElement, String elementName) {
|
||||
if (CollectionUtils.isEmpty(flowElement.getExtensionElements())
|
||||
|| !flowElement.getExtensionElements().containsKey(elementName)) {
|
||||
if (CollectionUtils.isEmpty(flowElement.getExtensionElements()) || !flowElement.getExtensionElements().containsKey(elementName)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
List<ExtensionElement> elements = flowElement.getExtensionElements().getOrDefault(elementName,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user