Hallo,
I am setting camunda:inputParameter. This is my example output. As you can see, I additional add an own meta-attribute “type”. The problem is that after reloading/reopening via ElementRegistry, the attribute “type” is lost. But I need this meta-data for further actions… Im exporting the xml in an own database table. The “type” attribute is still avaiable in the xml but as said, the ElementRegistry (BusinessObject) is loosing it.
So what is the best way for storing meta data of input parameters? The plan was like above to set it straight as an attribute cause I easily want to read it.
Now I can do the following:
set the meta data as properties. This has the disadvantage that I need to connect it after reading manual with the input parameter (may over the name). Then I have to read/write - both - inputparameters and properties every time.
set the value and metadata as a list or hashmap. Problem is that I need to split it later manual in my camunda delegate.
set the meta data as described above and read it via xpath or iterate the xml manual. But here I dont know, if this is the right way and if its faster or slower than using the ElementRegistry. I guess that using natual operation with the javascript lib of bpmn is a way better?
May someone have a good advice or can tell me what the best practise is.
var moddle = modeler.get('moddle');
var inputParameter = moddle.create('camunda:InputParameter', {
type: 'atype',
name: 'akey',
value: 'avalue'
});
var inputOutput = moddle.create('camunda:InputOutput', {
inputParameters: [ inputParameter ]
});
This is how we read the parameters
var elementRegistry = modeler.get( 'elementRegistry' );
var elementRegistryEntry = elementRegistry.get( pElement.element.id );
var elementRegistryEntryBO = elementRegistryEntry.businessObject;
var inputPar = elementRegistryEntryBO.extensionElements.values[0].inputParameters
I’d advice you to add your own attributes under your own namespace to avoid collisions with the Camunda Namespace. The meta-model of Camunda is well defined, adding extensions to it is not easily possible outside your own namespace. This is due to the nature of XML and defined extension mechanisms that we enforce.
That said, what you need to end up is something like this:
Because of the fact that the type attribute is unknown (and invalid) in the camunda schema it is added to the el.$attrs holder for generic / unknown properties instead.
You may verify that post import:
bo.$attrs; // { type: 'BAR' }
In the future we’ll improve the model validation to warn if you try to monkey-patch your extension into well-known namespace attributes (cf. moddle-xml issue).