Quick parsing of BDM objects from external data sources (e.g. XML, JSON)


We're looking to use Bonitasoft as engine to model workflows for a project for a client, and we have come across the following problem:

1) We obtain a response from a server formatted as XML according to a given specification (the specification might change, but we will probably be notified of this in advance). The structures can be represented as objects with some kind of defined inheritance relation - for example, imagine an inventory for an automobile business, where we get a list of Manufacturers with the Models of cars they are selling.
2) We wish to map this XML structure into a Bonitasoft Business Data Model. As far as I have been able to find out, this is easy (can be done with Groovy's slurpers and POGO mapping) as long as the XML object model is "flat" - i.e. does not contain any child objects with data. However, sticking with our car example, if you are trying to populate your list of Manufacturers, the array of Models does not get populated with the parsed data, even if the Model in the BDM has the same data types as the source XML.

Is there any way to do this sort of translation mapping quickly with Groovy?

1 answer



So if I understand correctly you want to convert XML to POJO (BDM objects are actually POJO).

For that you probably want to use Groovy XmlSlurper class. Lots of example are available such as this one.