Event for elements being added after XML import

Are there any events that I can combine such that: After I have imported a xml into the modeler, I can listen for new elements being added. I need the element info of the added element, such as if its a gateway or a task.

What do you want to accomplish?

I want to first import a XML from my database and represent it in the canvas. This i’ve accomplished. Then I want to listen to events of shapes being added so that I can insert values into different tables in my database. E.g. A gateway was dragged into the already filled canvas, then I want to listen for the event and add the gateway with properties into my database. Another element, this time a task, is added, then I want to get the type of this one and add it to another table in my database.

So in summary, I want to listen for an event that contains type information about the shape added AFTER the initial import of an existing XML.

Thanks for sharing these additional details. So your users are using the modeler, and you want to record a change stream to persist that to separate storage (you don’t want the BPMN 2.0 XML to contain that information).

For context users can perform complex operations (add/remove/move/update) so I’m not 100% sure such approach will be practically.

Given that disclaimer you can observe/hook into editor changes through change events emitted via the CommandStack. These capture what is going on in the diagram. After a composite change happened (that may have involved many different individual atomic changes (i.e. moving one element, removing another, adding another) then an elements.changed event is being emitted with a list of all changed elements. Probably most practical: You keep your own record of before/after state for each element, and use elements.changed to diff + persist changes.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.