{{#if entityLogic.isEnableBackend}}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:g="http://www.jboss.org/drools/flow/gpd" xmlns:tns="http://www.jboss.org/drools" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.mvel.org/2.0" id="Definition" name="" targetNamespace="http://www.jboss.org/drools" typeLanguage="http://www.java.com/javaTypes">
    <process id="{{packageName}}.core.{{entityLogic.entity.module}}.service.logic.{{lowerCase entityLogic.entity.codeName}}{{lowerCase entityLogic.codeName}}" isClosed="false" isExecutable="true"
             name="{{entityLogic.entity.module}}_{{lowerCase entityLogic.entity.codeName}}_{{lowerCase entityLogic.codeName}}_RuleFlow" processType="Private"
             tns:packageName="{{packageName}}.core.{{entityLogic.entity.module}}.service.logic.{{lowerCase entityLogic.entity.codeName}}{{lowerCase entityLogic.codeName}}">
        <extensionElements>
            <tns:import name="java.util.Map" />
            <tns:import name="org.springframework.util.StringUtils"/>
            <tns:import name="cn.ibizlab.util.helper.RuleUtils"/>
{{#each entityLogic.pSDELogicParams as |logicParam|}}
    {{#if logicParam.isDefault}}
            <tns:metaData express="" name="{{lowerCase logicParam.codeName}}" type="entity"/>
    {{else}}
        {{#if logicParam.paramPSDataEntity}}
            <tns:metaData express="new {{packageName}}.core.{{lowerCase logicParam.paramPSDataEntity.pSSystemModule.codeName}}.domain.{{logicParam.paramPSDataEntity.codeName}}()" name="{{lowerCase logicParam.codeName}}" type="refentity"/>
        {{else}}
            <tns:metaData express="new HashMap()" name="{{lowerCase logicParam.codeName}}" type="refentity"/>
        {{/if}}
    {{/if}}
{{/each}}
{{#each entityLogic.bpmnTnsParams as |bpmnTnsParam|}}
            {{bpmnTnsParam}}
{{/each}}
        </extensionElements>

{{!-- 绘制处理节点 --}}
{{#each entityLogic.logicNodeModels as |logicNodeModel|}}

        <!-- {{logicNodeModel.name}} -->
    {{#if (eq logicNodeModel.getLogicNodeType 'BEGIN')}}
        <startEvent id="{{lowerCase logicNodeModel.codeName}}" isInterrupting="true"/>
    {{else}}
        <businessRuleTask activiti:exclusive="true" g:ruleFlowGroup="{{lowerCase logicNodeModel.codeName}}group" id="{{lowerCase logicNodeModel.codeName}}" implementation="http://www.jboss.org/drools/rule" name="{{lowerCase logicNodeModel.name}}"/>
    {{/if}}
    {{#if logicNodeModel.pSDELogicNode.getPSDELogicLinks}}
    {{else}}
        <!-- 最后结束节点 -->
        <endEvent id="{{lowerCase logicNodeModel.codeName}}_end" name="end"/>

        <sequenceFlow id="{{lowerCase logicNodeModel.codeName}}_end_line" sourceRef="{{lowerCase logicNodeModel.codeName}}" targetRef="{{lowerCase logicNodeModel.codeName}}_end"/>
    {{/if}}
{{/each}}

{{!-- 绘制节点连线 --}}
{{#each entityLogic.logicLinkModels as |logicLinkModel|}}

        <!-- {{logicLinkModel.name}} -->
        <sequenceFlow id="{{logicLinkModel.sourceNodeId}}_{{logicLinkModel.targetNodeId}}" sourceRef="{{logicLinkModel.sourceNodeId}}" targetRef="{{logicLinkModel.targetNodeId}}">
    {{#if logicLinkModel.hasCondtion}}
            <conditionExpression  language="http://www.jboss.org/drools/rule" >
                <![CDATA[
                {{logicLinkModel.conditionExpression}}
                ]]>
            </conditionExpression>
    {{/if}}
        </sequenceFlow>
{{/each}}

{{!-- 生成交互网关节点--}}
{{#each entityLogic.logicLinkModels as |logicLinkModel|}}
    {{#if logicLinkModel.hasCondtion}}
        <exclusiveGateway id="${gatewayId}" name="Gateway" gatewayDirection="Diverging" default="${gatewayId}_end_line"></exclusiveGateway>
        <sequenceFlow id="${sourceNodeId}_${gatewayId}_gatewayline" sourceRef="${sourceNodeId}" targetRef="${gatewayId}"></sequenceFlow>
        <sequenceFlow id="${gatewayId}_end_line" sourceRef="${gatewayId}" targetRef="${gatewayId}_end"/><#comment>生成流程最后一个处理节点与End节点之间的连线</#comment>
        <endEvent id="${gatewayId}_end" name="end"/>
    {{/if}}
{{/each}}
    </process>
</definitions>
{{/if}}