paed01 / bpmn-engine

BPMN 2.0 execution engine. Open source javascript workflow engine.
MIT License
892 stars 167 forks source link

http://www.javascript.com/javascript is unsupported or was not registered #166

Closed TerenYeung closed 1 year ago

TerenYeung commented 1 year ago

when I use scriptFormat like: http://www.javascript.com/javascript, it reports error like this: ActivityError: Script format http://www.javascript.com/javascript is unsupported or was not registered for <_E58A0F41-D28E-4275-B3FE-F0AB97EF09DC>. And my bpmn is generate by bpmn editor, a vscode plugin. The whole file is:


<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" xmlns:xsi="xsi" id="_ePRJ4KbREDu_aaATrQhJrg" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd http://www.omg.org/spec/DD/20100524/DC DC.xsd http://www.omg.org/spec/DD/20100524/DI DI.xsd " exporter="jBPM Process Modeler" exporterVersion="2.0" targetNamespace="http://www.omg.org/bpmn20">
  <bpmn2:collaboration id="_133BE1CA-C5CB-4C8E-9D10-C47299FBC775" name="Default Collaboration">
    <bpmn2:participant id="_89592AC4-941D-4DBF-8FCF-2A5D7FF590B0" name="Pool Participant" processRef="demo"/>
  </bpmn2:collaboration>
  <bpmn2:process id="demo" drools:packageName="com.example" drools:version="1.0" drools:adHoc="false" name="demo" isExecutable="true" processType="Public">
    <bpmn2:sequenceFlow id="_16F73655-8F51-468E-840B-605CE00D52D8" sourceRef="_E58A0F41-D28E-4275-B3FE-F0AB97EF09DC" targetRef="_079C73A3-A1A3-4320-B088-2FA47604E42D"/>
    <bpmn2:sequenceFlow id="_4A47626D-33B0-4EF3-846B-FDAF960C2E9B" sourceRef="_001CAA81-42A8-4E74-A7ED-F81015ED4360" targetRef="_E58A0F41-D28E-4275-B3FE-F0AB97EF09DC">
      <bpmn2:extensionElements>
        <drools:metaData name="isAutoConnection.target">
          <drools:metaValue><![CDATA[true]]></drools:metaValue>
        </drools:metaData>
      </bpmn2:extensionElements>
    </bpmn2:sequenceFlow>
    <bpmn2:endEvent id="_079C73A3-A1A3-4320-B088-2FA47604E42D">
      <bpmn2:incoming>_16F73655-8F51-468E-840B-605CE00D52D8</bpmn2:incoming>
    </bpmn2:endEvent>
    <bpmn2:scriptTask id="_E58A0F41-D28E-4275-B3FE-F0AB97EF09DC" name="Task" scriptFormat="http://www.javascript.com/javascript">
      <bpmn2:extensionElements>
        <drools:metaData name="elementname">
          <drools:metaValue><![CDATA[Task]]></drools:metaValue>
        </drools:metaData>
      </bpmn2:extensionElements>
      <bpmn2:incoming>_4A47626D-33B0-4EF3-846B-FDAF960C2E9B</bpmn2:incoming>
      <bpmn2:outgoing>_16F73655-8F51-468E-840B-605CE00D52D8</bpmn2:outgoing>
      <bpmn2:script>const self = this;
self.environment.output.status = 200;
next(null, {status: 200});</bpmn2:script>
    </bpmn2:scriptTask>
    <bpmn2:startEvent id="_001CAA81-42A8-4E74-A7ED-F81015ED4360">
      <bpmn2:outgoing>_4A47626D-33B0-4EF3-846B-FDAF960C2E9B</bpmn2:outgoing>
    </bpmn2:startEvent>
  </bpmn2:process>
  <bpmndi:BPMNDiagram>
    <bpmndi:BPMNPlane bpmnElement="demo">
      <bpmndi:BPMNShape id="shape__001CAA81-42A8-4E74-A7ED-F81015ED4360" bpmnElement="_001CAA81-42A8-4E74-A7ED-F81015ED4360">
        <dc:Bounds height="56" width="56" x="129" y="102"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape__E58A0F41-D28E-4275-B3FE-F0AB97EF09DC" bpmnElement="_E58A0F41-D28E-4275-B3FE-F0AB97EF09DC">
        <dc:Bounds height="102" width="154" x="251" y="79"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape__079C73A3-A1A3-4320-B088-2FA47604E42D" bpmnElement="_079C73A3-A1A3-4320-B088-2FA47604E42D">
        <dc:Bounds height="56" width="56" x="485" y="102"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="edge_shape__001CAA81-42A8-4E74-A7ED-F81015ED4360_to_shape__E58A0F41-D28E-4275-B3FE-F0AB97EF09DC" bpmnElement="_4A47626D-33B0-4EF3-846B-FDAF960C2E9B">
        <di:waypoint x="157" y="130"/>
        <di:waypoint x="251" y="130"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge_shape__E58A0F41-D28E-4275-B3FE-F0AB97EF09DC_to_shape__079C73A3-A1A3-4320-B088-2FA47604E42D" bpmnElement="_16F73655-8F51-468E-840B-605CE00D52D8">
        <di:waypoint x="328" y="130"/>
        <di:waypoint x="513" y="130"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
  <bpmn2:relationship type="BPSimData">
    <bpmn2:extensionElements>
      <bpsim:BPSimData>
        <bpsim:Scenario id="default" name="Simulationscenario">
          <bpsim:ScenarioParameters/>
          <bpsim:ElementParameters elementRef="_001CAA81-42A8-4E74-A7ED-F81015ED4360">
            <bpsim:TimeParameters>
              <bpsim:ProcessingTime>
                <bpsim:NormalDistribution mean="0" standardDeviation="0"/>
              </bpsim:ProcessingTime>
            </bpsim:TimeParameters>
          </bpsim:ElementParameters>
          <bpsim:ElementParameters elementRef="_E58A0F41-D28E-4275-B3FE-F0AB97EF09DC">
            <bpsim:TimeParameters>
              <bpsim:ProcessingTime>
                <bpsim:NormalDistribution mean="0" standardDeviation="0"/>
              </bpsim:ProcessingTime>
            </bpsim:TimeParameters>
            <bpsim:ResourceParameters>
              <bpsim:Availability>
                <bpsim:FloatingParameter value="0"/>
              </bpsim:Availability>
              <bpsim:Quantity>
                <bpsim:FloatingParameter value="0"/>
              </bpsim:Quantity>
            </bpsim:ResourceParameters>
            <bpsim:CostParameters>
              <bpsim:UnitCost>
                <bpsim:FloatingParameter value="0"/>
              </bpsim:UnitCost>
            </bpsim:CostParameters>
          </bpsim:ElementParameters>
        </bpsim:Scenario>
      </bpsim:BPSimData>
    </bpmn2:extensionElements>
    <bpmn2:source>_ePRJ4KbREDu_aaATrQhJrg</bpmn2:source>
    <bpmn2:target>_ePRJ4KbREDu_aaATrQhJrg</bpmn2:target>
  </bpmn2:relationship>
</bpmn2:definitions>
paed01 commented 1 year ago

If you look at the default implementation of scripts at JavaScript it looks for javascript explicitely. Make a copy of that file, change it to match your needs, and supply as your script handler to engine:

const Scripts = require('./scripts.js');
const engine = new Engine({ scripts: new Scripts() });
TerenYeung commented 1 year ago

However,if I change this format to "Javascript", it works.

paed01 commented 1 year ago

Yes, thats what the regexp pattern is matching.