<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
	xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
	xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="me.kafeitu.demo.activiti.webservice"
	xmlns:leave="http://webservice.kafeitu.me/" typeLanguage="http://www.w3.org/2001/XMLSchema"
	expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="me.kafeitu.demo.activiti.webservice">

	<import importType="http://schemas.xmlsoap.org/wsdl/" location="http://localhost:8080/kft-activiti-demo/services/leave?wsdl"
		namespace="http://webservice.kafeitu.me/" />

	<!-- interface: implementationRef属性的值要与WSDL（wsdl:portType）中的保持一致，即@WebService中的serviceName属性 -->
	<interface name="Leave Audit Interface" implementationRef="leave:LeaveWebservice">
		<!-- operation: implementationRef属性的值也要与WSDL中保持一致（wsdl:operation） -->
		<operation id="auditOperation" name="General Manager Audit Operation"
			implementationRef="leave:generalManagerAudit">
			<inMessageRef>tns:generalManagerAuditRequestMessage</inMessageRef>
			<outMessageRef>tns:generalManagerAuditResponseMessage</outMessageRef>
		</operation>
	</interface>

	<!-- 定义message，参考wsdl文件中的wsdl:message的定义 -->
	<message id="generalManagerAuditRequestMessage" itemRef="tns:generalManagerAuditRequestItem"></message>
	<message id="generalManagerAuditResponseMessage" itemRef="tns:generalManagerAuditResponseItem"></message>

	<!-- 定义变量 -->
	<itemDefinition id="needed" structureRef="boolean" />
	<itemDefinition id="startDate" structureRef="string" />
	<itemDefinition id="endDate" structureRef="string" />

	<!-- 参考wsdl:input -->
	<itemDefinition id="generalManagerAuditRequestItem"
		structureRef="leave:generalManagerAudit" />
	<!-- 参考wsdl:output -->
	<itemDefinition id="generalManagerAuditResponseItem"
		structureRef="leave:generalManagerAuditResponse" />

	<process id="leave-webservice" name="请假流程-动态表单-Webservice"
		isExecutable="true">
		<documentation>请假流程演示-动态表单-Webservice</documentation>
		<startEvent id="startevent1" name="Start"
			activiti:initiator="applyUserId">
			<extensionElements>
				<activiti:formProperty id="startDate" name="请假开始日期"
					required="true" type="date" datePattern="yyyy-MM-dd"></activiti:formProperty>
				<activiti:formProperty id="endDate" name="请假结束日期"
					required="true" type="date" datePattern="yyyy-MM-dd"></activiti:formProperty>
				<activiti:formProperty id="reason" name="请假原因"
					type="string" required="true"></activiti:formProperty>
			</extensionElements>
		</startEvent>
		<userTask id="deptLeaderAudit" name="部门领导审批"
			activiti:candidateGroups="deptLeader">
			<extensionElements>
				<activiti:formProperty id="startDate" name="请假开始日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="endDate" name="请假结束日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="reason" name="请假原因"
					type="string" writable="false"></activiti:formProperty>
				<activiti:formProperty id="deptLeaderApproved"
					name="审批意见" type="enum" required="true">
					<activiti:value id="true" name="同意"></activiti:value>
					<activiti:value id="false" name="拒绝"></activiti:value>
				</activiti:formProperty>
			</extensionElements>
		</userTask>
		<exclusiveGateway id="exclusivegateway5" name="Exclusive Gateway"></exclusiveGateway>
		<userTask id="modifyApply" name="调整申请" activiti:assignee="${applyUserId}">
			<extensionElements>
				<activiti:formProperty id="startDate" name="请假开始日期"
					type="date" datePattern="yyyy-MM-dd" required="true"></activiti:formProperty>
				<activiti:formProperty id="endDate" name="请假结束日期"
					type="date" datePattern="yyyy-MM-dd" required="true"></activiti:formProperty>
				<activiti:formProperty id="reason" name="请假原因"
					type="string" required="true"></activiti:formProperty>
				<activiti:formProperty id="reApply" name="重新申请"
					type="enum" required="true">
					<activiti:value id="true" name="重新申请"></activiti:value>
					<activiti:value id="false" name="取消申请"></activiti:value>
				</activiti:formProperty>
			</extensionElements>
		</userTask>
		<userTask id="hrAudit" name="人事审批" activiti:candidateGroups="hr">
			<extensionElements>
				<activiti:formProperty id="startDate" name="请假开始日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="endDate" name="请假结束日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="reason" name="请假原因"
					type="string" writable="false"></activiti:formProperty>
				<activiti:formProperty id="hrApproved" name="审批意见"
					type="enum" required="true">
					<activiti:value id="true" name="同意"></activiti:value>
					<activiti:value id="false" name="拒绝"></activiti:value>
				</activiti:formProperty>
			</extensionElements>
		</userTask>
		<exclusiveGateway id="exclusivegateway6" name="Exclusive Gateway"></exclusiveGateway>
		<userTask id="reportBack" name="销假" activiti:assignee="${applyUserId}">
			<extensionElements>
				<activiti:formProperty id="startDate" name="请假开始日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="endDate" name="请假结束日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="reason" name="请假原因"
					type="string" writable="false"></activiti:formProperty>
				<activiti:formProperty id="reportBackDate"
					name="销假日期" required="true" type="date" datePattern="yyyy-MM-dd"></activiti:formProperty>
				<activiti:taskListener event="complete"
					expression="${execution.setVariable('result', 'ok')}"></activiti:taskListener>
			</extensionElements>
		</userTask>
		<endEvent id="endevent1" name="End"></endEvent>
		<exclusiveGateway id="exclusivegateway7" name="Exclusive Gateway"></exclusiveGateway>
		<sequenceFlow id="flow2" sourceRef="startevent1"
			targetRef="deptLeaderAudit"></sequenceFlow>
		<sequenceFlow id="flow3" sourceRef="deptLeaderAudit"
			targetRef="exclusivegateway5"></sequenceFlow>
		<sequenceFlow id="flow4" name="拒绝" sourceRef="exclusivegateway5"
			targetRef="modifyApply">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${deptLeaderApproved == 'false'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow5" name="同意" sourceRef="exclusivegateway5"
			targetRef="hrAudit">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${deptLeaderApproved == 'true'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow6" sourceRef="hrAudit" targetRef="exclusivegateway6"></sequenceFlow>
		<sequenceFlow id="flow7" name="同意" sourceRef="exclusivegateway6"
			targetRef="checkGeneralManagerAudit">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${hrApproved == 'true'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow9" name="拒绝" sourceRef="exclusivegateway6"
			targetRef="modifyApply">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${hrApproved == 'false'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow10" name="重新申请" sourceRef="exclusivegateway7"
			targetRef="deptLeaderAudit">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${reApply == 'true'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow11" sourceRef="modifyApply"
			targetRef="exclusivegateway7"></sequenceFlow>
		<sequenceFlow id="flow12" name="结束流程" sourceRef="exclusivegateway7"
			targetRef="endevent1">
			<extensionElements>
				<activiti:executionListener event="take"
					expression="${execution.setVariable('result', 'canceled')}"></activiti:executionListener>
			</extensionElements>
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${reApply == 'false'}]]></conditionExpression>
		</sequenceFlow>
		<serviceTask id="checkGeneralManagerAudit" name="是否需要总经理审批"
			implementation="##WebService" operationRef="tns:auditOperation">
			<ioSpecification>
				<dataInput itemSubjectRef="tns:generalManagerAuditRequestItem"
					id="dataInput" />
				<dataOutput itemSubjectRef="tns:generalManagerAuditResponseItem"
					id="dataOutput" />
				<inputSet>
					<dataInputRefs>dataInput</dataInputRefs>
				</inputSet>
				<outputSet>
					<dataOutputRefs>dataOutput</dataOutputRefs>
				</outputSet>
			</ioSpecification>
			<!-- 属性名称必须映射，否则报异常 https://gist.github.com/5994803 -->
			<dataInputAssociation>
				<sourceRef>startDate</sourceRef>
				<targetRef>startDate</targetRef>
			</dataInputAssociation>
			<dataInputAssociation>
				<sourceRef>endDate</sourceRef>
				<targetRef>endDate</targetRef>
			</dataInputAssociation>
			<dataOutputAssociation>
				<sourceRef>needed</sourceRef>
				<targetRef>needed</targetRef>
			</dataOutputAssociation>
		</serviceTask>
		<userTask id="generalManagerAudit" name="总经理审批"
			activiti:candidateGroups="generalManager">
			<extensionElements>
				<activiti:formProperty id="startDate" name="请假开始日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="endDate" name="请假结束日期"
					type="date" datePattern="yyyy-MM-dd" writable="false"></activiti:formProperty>
				<activiti:formProperty id="reason" name="请假原因"
					type="string" writable="false"></activiti:formProperty>
				<activiti:formProperty id="generalManagerApproved"
					name="审批意见" type="enum" required="true">
					<activiti:value id="true" name="同意"></activiti:value>
					<activiti:value id="false" name="拒绝"></activiti:value>
				</activiti:formProperty>
			</extensionElements>
		</userTask>
		<sequenceFlow id="flow16" name="拒绝" sourceRef="generalManagerAudit"
			targetRef="modifyApply">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${generalManagerApproved == 'false'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow17" name="同意" sourceRef="generalManagerAudit"
			targetRef="reportBack">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${generalManagerApproved == 'true'}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow18" name="需要" sourceRef="checkGeneralManagerAudit"
			targetRef="generalManagerAudit">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${needed}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow19" name="不需要" sourceRef="checkGeneralManagerAudit"
			targetRef="reportBack">
			<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!needed}]]></conditionExpression>
		</sequenceFlow>
		<sequenceFlow id="flow20" sourceRef="reportBack"
			targetRef="endevent1">
			<extensionElements>
				<activiti:executionListener event="take"
					expression="${execution.setVariable('result', 'ok')}"></activiti:executionListener>
			</extensionElements>
		</sequenceFlow>
		<textAnnotation id="textannotation1" textFormat="text/plain">
			<text>请求被驳回后员工可以选择继续申请，或者取消本次申请</text>
		</textAnnotation>
		<association id="association1" sourceRef="modifyApply"
			targetRef="textannotation1"></association>
		<textAnnotation id="textannotation2">
			<text>请假天数大于3天</text>
		</textAnnotation>
		<association id="association2" sourceRef="textannotation2"
			targetRef="checkGeneralManagerAudit"></association>
	</process>
	<bpmndi:BPMNDiagram id="BPMNDiagram_leave-webservice">
		<bpmndi:BPMNPlane bpmnElement="leave-webservice"
			id="BPMNPlane_leave-webservice">
			<bpmndi:BPMNShape bpmnElement="startevent1"
				id="BPMNShape_startevent1">
				<omgdc:Bounds height="35.0" width="35.0" x="10.0" y="30.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="deptLeaderAudit"
				id="BPMNShape_deptLeaderAudit">
				<omgdc:Bounds height="55.0" width="105.0" x="90.0" y="20.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="exclusivegateway5"
				id="BPMNShape_exclusivegateway5">
				<omgdc:Bounds height="40.0" width="40.0" x="250.0" y="27.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="modifyApply"
				id="BPMNShape_modifyApply">
				<omgdc:Bounds height="55.0" width="105.0" x="218.0" y="108.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="hrAudit" id="BPMNShape_hrAudit">
				<omgdc:Bounds height="55.0" width="105.0" x="358.0" y="20.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="exclusivegateway6"
				id="BPMNShape_exclusivegateway6">
				<omgdc:Bounds height="40.0" width="40.0" x="495.0" y="27.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="reportBack" id="BPMNShape_reportBack">
				<omgdc:Bounds height="55.0" width="105.0" x="659.0" y="176.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
				<omgdc:Bounds height="35.0" width="35.0" x="472.0" y="243.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="exclusivegateway7"
				id="BPMNShape_exclusivegateway7">
				<omgdc:Bounds height="40.0" width="40.0" x="250.0" y="240.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="checkGeneralManagerAudit"
				id="BPMNShape_checkGeneralManagerAudit">
				<omgdc:Bounds height="55.0" width="105.0" x="580.0" y="20.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="generalManagerAudit"
				id="BPMNShape_generalManagerAudit">
				<omgdc:Bounds height="55.0" width="105.0" x="470.0" y="174.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="textannotation1"
				id="BPMNShape_textannotation1">
				<omgdc:Bounds height="57.0" width="120.0" x="301.0" y="198.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNShape bpmnElement="textannotation2"
				id="BPMNShape_textannotation2">
				<omgdc:Bounds height="50.0" width="100.0" x="752.0" y="100.0"></omgdc:Bounds>
			</bpmndi:BPMNShape>
			<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
				<omgdi:waypoint x="45.0" y="47.0"></omgdi:waypoint>
				<omgdi:waypoint x="90.0" y="47.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
				<omgdi:waypoint x="195.0" y="47.0"></omgdi:waypoint>
				<omgdi:waypoint x="250.0" y="47.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
				<omgdi:waypoint x="270.0" y="67.0"></omgdi:waypoint>
				<omgdi:waypoint x="270.0" y="108.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="280.0" y="67.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
				<omgdi:waypoint x="290.0" y="47.0"></omgdi:waypoint>
				<omgdi:waypoint x="358.0" y="47.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="311.0" y="30.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
				<omgdi:waypoint x="463.0" y="47.0"></omgdi:waypoint>
				<omgdi:waypoint x="495.0" y="47.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
				<omgdi:waypoint x="535.0" y="47.0"></omgdi:waypoint>
				<omgdi:waypoint x="580.0" y="47.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="534.0" y="30.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
				<omgdi:waypoint x="515.0" y="67.0"></omgdi:waypoint>
				<omgdi:waypoint x="514.0" y="135.0"></omgdi:waypoint>
				<omgdi:waypoint x="323.0" y="135.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="525.0" y="67.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
				<omgdi:waypoint x="250.0" y="260.0"></omgdi:waypoint>
				<omgdi:waypoint x="142.0" y="259.0"></omgdi:waypoint>
				<omgdi:waypoint x="142.0" y="75.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="44.0" x="163.0" y="244.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
				<omgdi:waypoint x="270.0" y="163.0"></omgdi:waypoint>
				<omgdi:waypoint x="270.0" y="240.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
				<omgdi:waypoint x="290.0" y="260.0"></omgdi:waypoint>
				<omgdi:waypoint x="472.0" y="260.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="44.0" x="300.0" y="267.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
				<omgdi:waypoint x="470.0" y="201.0"></omgdi:waypoint>
				<omgdi:waypoint x="270.0" y="163.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="441.0" y="178.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
				<omgdi:waypoint x="575.0" y="201.0"></omgdi:waypoint>
				<omgdi:waypoint x="659.0" y="203.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="576.0" y="208.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
				<omgdi:waypoint x="632.0" y="75.0"></omgdi:waypoint>
				<omgdi:waypoint x="522.0" y="174.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="22.0" x="617.0" y="108.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow19" id="BPMNEdge_flow19">
				<omgdi:waypoint x="685.0" y="47.0"></omgdi:waypoint>
				<omgdi:waypoint x="711.0" y="48.0"></omgdi:waypoint>
				<omgdi:waypoint x="711.0" y="176.0"></omgdi:waypoint>
				<bpmndi:BPMNLabel>
					<omgdc:Bounds height="11.0" width="33.0" x="719.0" y="74.0"></omgdc:Bounds>
				</bpmndi:BPMNLabel>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="flow20" id="BPMNEdge_flow20">
				<omgdi:waypoint x="711.0" y="231.0"></omgdi:waypoint>
				<omgdi:waypoint x="711.0" y="260.0"></omgdi:waypoint>
				<omgdi:waypoint x="507.0" y="260.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="association1" id="BPMNEdge_association1">
				<omgdi:waypoint x="270.0" y="163.0"></omgdi:waypoint>
				<omgdi:waypoint x="361.0" y="198.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
			<bpmndi:BPMNEdge bpmnElement="association2" id="BPMNEdge_association2">
				<omgdi:waypoint x="802.0" y="100.0"></omgdi:waypoint>
				<omgdi:waypoint x="632.0" y="75.0"></omgdi:waypoint>
			</bpmndi:BPMNEdge>
		</bpmndi:BPMNPlane>
	</bpmndi:BPMNDiagram>
</definitions>