Skip to content

Commit

Permalink
WIP input-association
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Nov 27, 2018
1 parent f2d4870 commit 205003d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
39 changes: 12 additions & 27 deletions lib/features/modeling/behavior/DataInputAssociationBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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');
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}));
Expand Down

0 comments on commit 205003d

Please sign in to comment.