Hi there,
i created a custom element with the following json extension:
Summary
{
"name": "MassDataTaskExample",
"uri": "http://example/",
"prefix": "mdt",
"xml": {
"tagAlias": "lowerCase"
},
"types": [
{
"name": "AnalyzedNode",
"extends": [
"bpmn:FlowNode"
],
"properties": [
{
"name": "suitable",
"isAttr": true,
"type": "Integer"
}
]
},
{
"name": "MassDataTask",
"superClass": [
"bpmn:Task"
],
"properties": [
{
"name": "key",
"isAttr": true,
"type": "Integer"
},
{
"name": "keyName",
"isAttr": true,
"type": "String"
},
{
"name": "comments",
"isMany": true,
"type": "Comment"
}
]
},
{
"name": "Comment",
"properties": [
{
"name": "author",
"isAttr": true,
"type": "String"
},
{
"name": "text",
"isBody": true,
"type": "String"
}
]
}
],
"emumerations": [],
"associations": []
}
My needs are: A new custom element, that looks differently and has more custom attributes. This element should be able to be exported and imported by my application. BPMN 2.0 compatibility is not necessary, but if there is an easy way to do this feel free to correct my approach.
I can render this custom element and add certain properties.
I am currently doing this in the following way:
const businessObject = bpmnFactory.create('mdt:MassDataTask');
businessObject.suitable = 70;
businessObject.key = 50;
businessObject.keyName = "test"
This works just fine. I can export and import the xml etc. However i am unable to add a comment to comments.
The XML looks like this:
<mdt:massDataTask id="Activity_0sb0sm0" suitable="70" key="50" keyName="test" />
This is all i need. If it is possible like this i would prefer this or do i absolutly need extensionElements?
I already looked at several posts like:
And the moddle-extension example. There we use superClass āElementā, is this absoluty necessary to add an isMany attribute?
I create comments like this:
let commentOne = moddle.create('mdt:Comment', {
"author": "Klaus",
"text": "Das ist ein Text"
});
And tried stuff like:
let massDataTaskDetails = getExtensionElement(businessObject, 'mdt:MassDataTask');
let comment = massDataTaskDetails ? massDataTaskDetails.get("comments")[0] : null;
console.log("comment author: " + comment);
console.log("comment text: " + comment);
massDataTask.comments.push(commentOne);
comments.splice(1, 1);
comments.push(commentOne);
But most of the stuff is undefined
If anyone could help me creating one or two comments and add them to my custom element i would appreciate it a lot and would gladly share my work with custom elements.
Thanks in advance!