From 205003d9063c2ed0bddf90cf1e9191b104b90be5 Mon Sep 17 00:00:00 2001 From: Philipp Fromme Date: Tue, 27 Nov 2018 20:12:00 +0100 Subject: [PATCH] WIP input-association --- .../behavior/DataInputAssociationBehavior.js | 39 ++++++------------- .../DataInputAssociationBehaviorSpec.js | 5 +++ 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/lib/features/modeling/behavior/DataInputAssociationBehavior.js b/lib/features/modeling/behavior/DataInputAssociationBehavior.js index 8751b035ce..bc4bc5fc6c 100644 --- a/lib/features/modeling/behavior/DataInputAssociationBehavior.js +++ b/lib/features/modeling/behavior/DataInputAssociationBehavior.js @@ -57,7 +57,7 @@ export default function DataInputAssociationBehavior(eventBus, bpmnFactory) { function createDataInput(element) { var ioSpecification = element.get('ioSpecification'); - var inputSet; + var inputSet, outputSet; if (!ioSpecification) { ioSpecification = bpmnFactory.create('bpmn:InputOutputSpecification', { @@ -75,6 +75,15 @@ export default function DataInputAssociationBehavior(eventBus, bpmnFactory) { inputSet.$parent = ioSpecification; collectionAdd(ioSpecification.get('inputSets'), inputSet); + + outputSet = bpmnFactory.create('bpmn:OutputSet', { + dataOutputRefs: [], + name: 'Outputs' + }); + + outputSet.$parent = ioSpecification; + + collectionAdd(ioSpecification.get('outputSets'), outputSet); } var dataInput = bpmnFactory.create('bpmn:DataInput'); @@ -244,34 +253,10 @@ function cleanUpIoSpecification(element) { delete ioSpecification.dataOutputs; } - if (inputSets && inputSets.length) { - forEach(inputSets, function(inputSet) { - if (!inputSet.dataInputRefs.length) { - collectionRemove(inputSets, inputSet); - } - }); - - if (!inputSets.length) { - delete ioSpecification.inputSets; - } - } - - if (outputSets && outputSets.length) { - forEach(outputSets, function(outputSet) { - if (!outputSet.dataOutputRefs.length) { - collectionRemove(outputSets, outputSet); - } - }); - - if (!outputSets.length) { - delete ioSpecification.outputSets; - } - } - if ((!dataInputs || !dataInputs.length) && (!dataOutputs || !dataOutputs.length) && - (!inputSets || !inputSets.length) && - (!outputSets || !outputSets.length)) { + !inputSets[0].dataInputRefs.length && + !outputSets[0].dataOutputRefs.length) { delete element.ioSpecification; } diff --git a/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js b/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js index debdb6947e..05d98929c2 100644 --- a/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js @@ -34,6 +34,11 @@ describe('modeling/behavior - DataInputAssociationBehavior', function() { var dataInputAssociationBo = dataInputAssociation.businessObject; expect(taskBo.ioSpecification).to.exist; + expect(taskBo.ioSpecification.inputSets).to.exist; + expect(taskBo.ioSpecification.inputSets).to.have.length(1); + expect(taskBo.ioSpecification.outputSets).to.exist; + expect(taskBo.ioSpecification.outputSets).to.have.length(1); + expect(dataInputAssociationBo.targetRef).to.exist; expect(dataInputAssociationBo.targetRef).to.eql(getDataInput(taskBo, dataInputAssociationBo.targetRef)); }));