<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
  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:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="urn:getriebe:examples">
  <bpmn:itemDefinition id="Votes" structureRef="xsd:boolean" isCollection="true" />
  <bpmn:itemDefinition id="Approval" structureRef="xsd:boolean" />
  <bpmn:process id="javascriptVote" name="Evaluate votes with JavaScript" isExecutable="true">
    <bpmn:property id="reviewVotes" itemSubjectRef="Votes" />
    <bpmn:property id="approved" itemSubjectRef="Approval" />
    <bpmn:startEvent id="started" />
    <bpmn:scriptTask id="evaluateVotes" name="Evaluate votes" scriptFormat="text/javascript">
      <bpmn:ioSpecification>
        <bpmn:dataInput id="votesIn" name="reviewVotes" itemSubjectRef="Votes" />
        <bpmn:dataOutput id="approvedOut" name="approval" itemSubjectRef="Approval" />
        <bpmn:inputSet><bpmn:dataInputRefs>votesIn</bpmn:dataInputRefs></bpmn:inputSet>
        <bpmn:outputSet><bpmn:dataOutputRefs>approvedOut</bpmn:dataOutputRefs></bpmn:outputSet>
      </bpmn:ioSpecification>
      <bpmn:dataInputAssociation><bpmn:sourceRef>reviewVotes</bpmn:sourceRef><bpmn:targetRef>votesIn</bpmn:targetRef></bpmn:dataInputAssociation>
      <bpmn:dataOutputAssociation><bpmn:sourceRef>approvedOut</bpmn:sourceRef><bpmn:targetRef>approved</bpmn:targetRef></bpmn:dataOutputAssociation>
      <bpmn:script>return inputs.reviewVotes.every(vote => vote === true);</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:endEvent id="finished" />
    <bpmn:sequenceFlow id="evaluate" sourceRef="started" targetRef="evaluateVotes" />
    <bpmn:sequenceFlow id="finish" sourceRef="evaluateVotes" targetRef="finished" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="voteDiagram">
    <bpmndi:BPMNPlane id="votePlane" bpmnElement="javascriptVote">
      <bpmndi:BPMNShape id="started_di" bpmnElement="started"><dc:Bounds x="120" y="172" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="evaluateVotes_di" bpmnElement="evaluateVotes"><dc:Bounds x="210" y="150" width="130" height="80" /></bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="finished_di" bpmnElement="finished"><dc:Bounds x="394" y="172" width="36" height="36" /></bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="evaluate_di" bpmnElement="evaluate"><di:waypoint x="156" y="190" /><di:waypoint x="210" y="190" /></bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="finish_di" bpmnElement="finish"><di:waypoint x="340" y="190" /><di:waypoint x="394" y="190" /></bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
