pedesen
January 18, 2016, 10:50am
4
Hey @ThePasko ,
I figured out, what the problem is. It is not sufficient to just create the data object, it also has to be added to a parent, if it should be included in the XML. I added a test case in bpmn-moddle to demonstrate that case:
// given
var process = result.rootElements[0],
dataObjectReference = process.flowElements[0];
// when
// creating new data object
var dataObject_2 = moddle.create('bpmn:DataObject', { id: 'dataObject_2' });
// adding data object to its parent (makes sure it is contained in the XML)
process.flowElements.push(dataObject_2);
// set reference to the new data object
dataObjectReference.dataObjectRef = dataObject_2;
toXML(result, { format: true }, function(err, xml) {
// then
expect(xml).to.contain('<bpmn:dataObject id="dataObject_2" />');
expect(xml).to.contain('<bpmn:dataObjectReference id="DataObjectReference_1" dataObjectRef="dataObject_2" />');
This file has been truncated. show original
If you want undo/redo support in addition, you also have to take care of this yourself. To find out how that is done, check this post: Update custom BPMN meta data so it can be undone via CTRL+Z
Hope that helps