bpmn-io / bpmn-js-differ

A diffing utility for BPMN 2.0 documents.
44 stars 16 forks source link

Not find camunda:decisionRef change #2

Open romero83 opened 7 years ago

romero83 commented 7 years ago

Hi!

The differ cannot find camunda:decisionRef changes.

Can it be that differ not works in case of camunda namespace?

nikku commented 6 years ago

May be fixed with latest version of this library.

If that is not the case, add a pull request with a failing test case and we can fix this.

romero83 commented 6 years ago

Hi!

I upgraded to 0.3.0 version, but unfortunately it is still not tracing camunda:decisionRef changes nor input/output parameters.

nikku commented 6 years ago

You'd need to add the camunda-bpmn-moddle extension in order to recognize camunda attributes. See this failing test case I've created.

romero83 commented 6 years ago

Thank you nikku!

Now it trace camunda:decisionRef change indeed.

I Used as following:

var BpmnModdle = require('bpmn-moddle'),
    BpmnCamundaModdleDescriptor = require('camunda-bpmn-moddle/resources/camunda');

new BpmnModdle({
       camunda: BpmnCamundaModdleDescriptor
}).fromXML(xml, function(err, definitions) {
...
}

However it is still not tracing input/output parameter changes.

nikku commented 6 years ago

Make sure you use the latest version of bpmn-moddle, too. We're at 1.1.1 right now.

romero83 commented 6 years ago

Ok, when I call Differ.diff(adefs, bdefs) on the two parsed BPMNs it returns and indicate the input/output parameter "_changed", but I see no old-new values descriptor in the "attrs" property.

nikku commented 6 years ago

Please provide a reproducible test case, including

Cf. this example

romero83 commented 6 years ago

test/fixtures/extension-attributes/before.bpmn

<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.2">
  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:businessRuleTask id="BusinessRuleTask" camunda:resultVariable="foo" camunda:decisionRef="foobar" camunda:mapDecisionResult="collectEntries" camunda:decisionRefTenantId="_0001">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="firstInput">in1</camunda:inputParameter>
          <camunda:outputParameter name="firstOutput">out1</camunda:outputParameter>
          <camunda:outputParameter name="secondOutput">out2</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
    </bpmn:businessRuleTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="BusinessRuleTask_1lqeokr_di" bpmnElement="BusinessRuleTask">
        <dc:Bounds x="396" y="134" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

test/fixtures/extension-attributes/after.bpmn

<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.2">
  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:businessRuleTask id="BusinessRuleTask" camunda:decisionRef="foobar">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="firstInput">in1_modify</camunda:inputParameter>
          <camunda:inputParameter name="secondInput">in2</camunda:inputParameter>
          <camunda:outputParameter name="secondOutput">out2modify</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
    </bpmn:businessRuleTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="BusinessRuleTask_1lqeokr_di" bpmnElement="BusinessRuleTask">
        <dc:Bounds x="396" y="134" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

test/spec/differ.js

it.only('should diff extension attributes', function(done) {

      var aDiagram = fs.readFileSync('test/fixtures/extension-attributes/before.bpmn', 'utf-8');
      var bDiagram = fs.readFileSync('test/fixtures/extension-attributes/after.bpmn', 'utf-8');      

      // when
      diff(aDiagram, bDiagram, function(err, results, aDefinitions, bDefinitions) {

        if (err) {
          return done(err);
        }

        // then
        expect(results._added).to.be.empty;
        expect(results._removed).to.be.empty;
        expect(results._layoutChanged).to.be.empty;
        for (var key in results._changed) {
            console.log("_changed: " + JSON.stringify(results._changed[key], null, '\t'));
        }
        expect(results._changed).to.have.keys([ 'BusinessRuleTask' ]);

        done();
      });
});

I modified also BpmnModdle creation in the top of test/deffer.js to diff camunda specific namespace.

var BpmnModdle = require('bpmn-moddle');
var BpmnCamundaModdleDescriptor = require('camunda-bpmn-moddle/resources/camunda');

var Differ = require('../../lib/differ'),
    SimpleChangeHandler = require('../../lib/change-handler');

function importDiagrams(a, b, done) {

  new BpmnModdle({
      camunda: BpmnCamundaModdleDescriptor
  }).fromXML(a, function(err, adefs) {

    if (err) {
      return done(err);
    }

    new BpmnModdle({
      camunda: BpmnCamundaModdleDescriptor
    }).fromXML(b, function(err, bdefs) {
      if (err) {
        return done(err);
      } else {
        return done(null, adefs, bdefs);
      }
    });
  });
}

When I execute npm run test it prints all changed properties, but no information about input/output parameter changes. However if you look at before/after BPMN files, I also changed input/output parameters but in the "attrs array" they are not found.

Egoplayer commented 2 years ago

Hi, is there any progress on this issue?