Skip to content

Commit

Permalink
WIP output-association
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Nov 27, 2018
1 parent 205003d commit d279fa9
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/DataOutputAssociationBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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'
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}));
Expand Down

0 comments on commit d279fa9

Please sign in to comment.