package org.springblade.flow.engine.custom.handler;


import org.flowable.bpmn.model.SequenceFlow;
import org.flowable.engine.impl.bpmn.parser.BpmnParse;
import org.flowable.engine.impl.bpmn.parser.handler.SequenceFlowParseHandler;
import org.springframework.stereotype.Component;

/**
 * @author LoveMyOrange
 * @create 2022-01-30 18:00
 */
@Component
public class CustomSequenceFlowParseHandler extends SequenceFlowParseHandler {

    @Override
    protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) {
        super.executeParse(bpmnParse,sequenceFlow);
//        ScopeImpl scope = bpmnParse.getCurrentScope();
//        //获取连线节点的源
//        ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef());
//        //目的地
//        ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef());
//        //获取连线中的配置 的 跳过表达式
//        Expression skipExpression;
//        if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) {
//            ExpressionManager expressionManager = bpmnParse.getExpressionManager();
//            skipExpression = expressionManager.createExpression(sequenceFlow.getSkipExpression());
//        } else {
//            skipExpression = null;
//        }
//        //实例化TransitionImpl类 ,该对象在PVM 中的最终表示
//        TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId(), skipExpression);
//        //扩展属性添加到PVM
//        String attributeValue = sequenceFlow.getAttributeValue(exActivitiPrefixURL,extensionAttributeName);
//        if(StringUtils.isNotBlank(attributeValue)){
//            transition.setProperty(extensionAttributeName,attributeValue);
//        }
//        //填充 对象属性 name documentation  conditionText, condition
//        bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition);
//        transition.setProperty("name", sequenceFlow.getName());
//        transition.setProperty("documentation", sequenceFlow.getDocumentation());
//        transition.setDestination(destinationActivity);
//
//        if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
//            Condition expressionCondition = new NashornCondition(attributeValue);
//            transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression());
//            transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition);
//        }
//    /*
//      添加连线中配置的 执行监听器
//    * */
//        createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition);
    }



}
