Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setProperties(element, values) {
const loopCharacteristics = getLoopCharacteristics(element),
commands = [];
// ensure extensionElements
let extensionElements = loopCharacteristics.get('extensionElements');
if (!extensionElements) {
extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, loopCharacteristics, bpmnFactory);
commands.push(cmdHelper.updateBusinessObject(element, loopCharacteristics, { extensionElements: extensionElements }));
}
// ensure zeebe:LoopCharacteristics
let zeebeLoopCharacteristics = getZeebeLoopCharacteristics(loopCharacteristics);
if (!zeebeLoopCharacteristics) {
zeebeLoopCharacteristics = elementHelper.createElement('zeebe:LoopCharacteristics', { }, extensionElements, bpmnFactory);
commands.push(cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[ zeebeLoopCharacteristics ],
[]
));
}
commands.push(cmdHelper.updateBusinessObject(element, zeebeLoopCharacteristics, values));
return commands;
}
const businessObject = getBusinessObject(element),
commands = [];
// ensure extensionElements
let extensionElements = businessObject.get('extensionElements');
if (!extensionElements) {
extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, businessObject, bpmnFactory);
commands.push(cmdHelper.updateBusinessObject(element, businessObject, { extensionElements: extensionElements }));
}
// ensure zeebe:calledElement
let calledElement = getCalledElement(businessObject);
if (!calledElement) {
calledElement = elementHelper.createElement('zeebe:CalledElement', { }, extensionElements, bpmnFactory);
commands.push(cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[ calledElement ],
[]
));
}
// update properties
commands.push(cmdHelper.updateBusinessObject(element, calledElement, values));
return commands;
}
const bo = getBusinessObject(element);
const commands = [];
// create extensionElements
let extensionElements = bo.get('extensionElements');
if (!extensionElements) {
extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, bo, bpmnFactory);
commands.push(cmdHelper.updateProperties(element, { extensionElements: extensionElements }));
}
// create taskDefinition
let taskDefinition = getTaskDefinition(element);
if (!taskDefinition) {
taskDefinition = elementHelper.createElement('zeebe:TaskDefinition', { }, extensionElements, bpmnFactory);
commands.push(cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[ taskDefinition ],
[]
));
}
commands.push(cmdHelper.updateBusinessObject(element, taskDefinition, values));
return commands;
},
const reference = definition.get(referenceProperty);
const bo = getBusinessObject(reference);
reference.businessObject = bo;
const commands = [];
let extensionElements = bo.get('extensionElements');
if (!extensionElements) {
extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, bo, bpmnFactory);
commands.push(cmdHelper.updateProperties(reference, { extensionElements: extensionElements }));
}
let extensionElement = getExtensionElement(reference);
if (!extensionElement) {
extensionElement = elementHelper.createElement(extensionElementKey, { }, extensionElements, bpmnFactory);
commands.push(cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[ extensionElement ],
[]
));
}
commands.push(cmdHelper.updateBusinessObject(element, extensionElement, values));
return commands;
},
return (element, extensionElements, value) => {
const commands = [];
let inputOutput = getInputOutput(element);
if (!inputOutput) {
const parent = extensionElements;
inputOutput = createInputOutput(parent, bpmnFactory, {
inputParameters: [],
outputParameters: []
});
commands.push(cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[ inputOutput ],
[]
));
}
const newElem = createParameter(type, inputOutput, bpmnFactory, { source: 'sourceValue', target: 'targetValue' });
commands.push(cmdHelper.addElementsTolist(element, inputOutput, prop, [ newElem ]));
return commands;
};
};
var camundaProperties = findExtension(extensionElements, 'camunda:Properties');
if (!camundaProperties) {
camundaProperties = bpmnFactory.create('camunda:Properties');
updates.push(cmdHelper.addElementsTolist(
element, extensionElements, 'values', [ camundaProperties ]
));
}
var existingCamundaProperty = findCamundaProperty(camundaProperties,{'name':propertyName});
if (values != null && values[propertyName] != null) {
values = values[propertyName];
}
var camundaProperty = bpmnFactory.create('camunda:Property', {
name: propertyName,
value: values || ''
});
updates.push(cmdHelper.addAndRemoveElementsFromList(
element,
camundaProperties,
'values',
null,
[ camundaProperty ],
existingCamundaProperty ? [ existingCamundaProperty ] : []
));
return updates;
};
return (element, extensionElements, value) => {
const commands = [];
let payloadMappings = getPayloadMappings(element);
if (!payloadMappings) {
const parent = extensionElements;
payloadMappings = createPayloadMappings(parent, bpmnFactory, {
mapping: []
});
commands.push(cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[payloadMappings],
[]
));
}
const newElem = createMapping(type, payloadMappings, bpmnFactory, { source: 'sourceValue', target: 'targetValue', type: 'PUT' });
commands.push(cmdHelper.addElementsTolist(element, payloadMappings, prop, [newElem]));
return commands;
};
};