diff --git a/lib/features/modeling/behavior/DataOutputAssociationBehavior.js b/lib/features/modeling/behavior/DataOutputAssociationBehavior.js index 53f9b60a1c..8b477dd4d7 100644 --- a/lib/features/modeling/behavior/DataOutputAssociationBehavior.js +++ b/lib/features/modeling/behavior/DataOutputAssociationBehavior.js @@ -57,7 +57,7 @@ export default function DataOutputAssociationBehavior(eventBus, bpmnFactory) { function createDataOutput(element) { var ioSpecification = element.get('ioSpecification'); - var outputSet; + var inputSet, outputSet; if (!ioSpecification) { ioSpecification = bpmnFactory.create('bpmn:InputOutputSpecification', { @@ -67,6 +67,15 @@ export default function DataOutputAssociationBehavior(eventBus, bpmnFactory) { element.ioSpecification = ioSpecification; + inputSet = bpmnFactory.create('bpmn:InputSet', { + dataInputRefs: [], + name: 'Inputs' + }); + + inputSet.$parent = ioSpecification; + + collectionAdd(ioSpecification.get('inputSets'), inputSet); + outputSet = bpmnFactory.create('bpmn:OutputSet', { dataOutputRefs: [], name: 'Outputs' @@ -245,34 +254,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/DataOutputAssociationBehaviorSpec.js b/test/spec/features/modeling/behavior/DataOutputAssociationBehaviorSpec.js index 85b99abeaf..8fc1f0a87f 100644 --- a/test/spec/features/modeling/behavior/DataOutputAssociationBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/DataOutputAssociationBehaviorSpec.js @@ -34,6 +34,11 @@ describe('modeling/behavior - DataOutputAssociationBehavior', function() { var dataOutputAssociationBo = dataOutputAssociation.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(dataOutputAssociationBo.get('sourceRef')[0]).to.exist; expect(dataOutputAssociationBo.get('sourceRef')[0]).to.eql(getDataOutput(taskBo, dataOutputAssociationBo.get('sourceRef')[0])); }));