update iospec to include refs in input/output sets

This commit is contained in:
Elizabeth Esswein 2023-09-01 17:04:18 -04:00
parent 6e17bda372
commit 7743372d29
2 changed files with 21 additions and 4 deletions

View File

@ -30,7 +30,7 @@ export default class IoInterceptor extends CommandInterceptor {
let process = context.parent.businessObject;
let ioSpec = assureIOSpecificationExists(process, bpmnFactory);
let di = context.shape.di;
let generator = new IdGenerator(type_name), ioSpecification = process.get('ioSpecification');
let generator = new IdGenerator(type_name);
let dataIO = bpmnFactory.create(type, { id: generator.next() });
context.shape.businessObject = dataIO;
dataIO.$parent = ioSpec;
@ -40,9 +40,11 @@ export default class IoInterceptor extends CommandInterceptor {
bpmnUpdater.updateBounds(context.shape);
if (type == 'bpmn:DataInput') {
collectionAdd(ioSpecification.get('dataInputs'), dataIO);
collectionAdd(ioSpec.inputSets[0].get('dataInputRefs'), dataIO);
collectionAdd(ioSpec.get('dataInputs'), dataIO);
} else {
collectionAdd(ioSpecification.get('dataOutputs'), dataIO);
collectionAdd(ioSpec.outputSets[0].get('dataOutputRefs'), dataIO);
collectionAdd(ioSpec.get('dataOutputs'), dataIO);
}
}
});
@ -54,8 +56,10 @@ export default class IoInterceptor extends CommandInterceptor {
let process = context.shape.parent.businessObject;
let ioSpec = assureIOSpecificationExists(process, bpmnFactory);
if (type == 'bpmn:DataInput') {
collectionRemove(ioSpec.inputSets[0].get('dataInputRefs'), context.shape.businessObject);
collectionRemove(ioSpec.get('dataInputs'), context.shape.businessObject);
} else {
collectionRemove(ioSpec.outputSets[0].get('dataOutputRefs'), context.shape.businessObject);
collectionRemove(ioSpec.get('dataOutputs'), context.shape.businessObject);
}
if (context.shape.di.$parent) {

View File

@ -33,7 +33,8 @@ describe('Input/Output Interceptor', function() {
// THEN - the process should now have an IO Specification
const iospec = canvas.getRootElement().businessObject.ioSpecification;
expect(iospec).to.not.be.null;
expect(iospec.dataInputs.length).to.equal(1)
expect(iospec.dataInputs.length).to.equal(1);
expect(iospec.inputSets[0].dataInputRefs.length).to.equal(1);
}));
@ -60,4 +61,16 @@ describe('Input/Output Interceptor', function() {
modeling.removeShape(dataInput)
expect(canvas.getRootElement().businessObject.ioSpecification).to.be.null;
}));
it('deleting a data input should remove it from the input set', inject(function(canvas, modeling) {
let rootShape = canvas.getRootElement();
const dataInput = modeling.createShape({type: 'bpmn:DataInput'},
{x: 220, y: 220}, rootShape);
const dataOutput = modeling.createShape({type: 'bpmn:DataOutput'},
{x: 240, y: 220}, rootShape);
modeling.removeShape(dataInput);
const iospec = canvas.getRootElement().businessObject.ioSpecification;
expect(iospec.dataInputs.length).to.equal(0);
expect(iospec.inputSets[0].dataInputRefs.length).to.equal(0);
}));
});