02-22-2018 06:09 AM
Hello there,
Is there a possibility in Activiti to define certain Process Variables as Required in a Process Definition and request a list of those required variables from a Process Definition?
The Reason I'm asking is, I want to make some sort of Process Repository for Process selection.
Since my Processes more often than not need different variables or different numbers of variables, I want to show form that dynamically adjusts for how many / which variables are needed to my user.
Is there a functionality like that in Activiti or can someone recommend a solution?
thanks in advance
02-25-2018 03:12 AM
If your goal is only to define a list of variables used in the process in the process, I think that Data objects is optimal.
https://www.activiti.org/userguide/#dataobjects
And, you can get that list by the following code.
List<ValuedDataObject> dataObjects = repositoryService.getBpmnModel("processDefinitionId").getProcessById("processDefinitionKey").getDataObjects();
for(ValuedDataObject dataObject: dataObjects){
System.out.println(dataObject.getId());
System.out.println(dataObject.getName());
System.out.println(dataObject.getType());
} ad
02-23-2018 05:49 AM
Actually I looked further and found there are no calls to the getter or setter of variables on ProcessDefinitionEntityImpl in the engine. I thought that if the variables were defined in the process definition xml then they would at least be linked to the process definition entity but now I'm thinking not. The most relevant-looking tests actually just go through the runtimeService to get variables from the running instance after starting (Activiti/VariableScopeTest.java at develop · Activiti/Activiti · GitHub with XML at Activiti/activiti-engine/src/test/resources/org/activiti/engine/test/db at develop · Activiti/Activi... ). My impression is that this is a gap.
02-24-2018 10:10 AM
I've also done a bit of code research and would like to make sure I havent missed anything.
Am I correct in that there is currently no way to get / lookup Process Variables of a ProcessDefinition? (Weither required or not is not important at this time).
Is so, I guess I'll have to find a way to make a database for holding these in parallel to the deployed processDefinitions.
Thanks for your input.
02-25-2018 03:12 AM
If your goal is only to define a list of variables used in the process in the process, I think that Data objects is optimal.
https://www.activiti.org/userguide/#dataobjects
And, you can get that list by the following code.
List<ValuedDataObject> dataObjects = repositoryService.getBpmnModel("processDefinitionId").getProcessById("processDefinitionKey").getDataObjects();
for(ValuedDataObject dataObject: dataObjects){
System.out.println(dataObject.getId());
System.out.println(dataObject.getName());
System.out.println(dataObject.getType());
} ad
02-25-2018 03:36 AM
Ah thanks, tried around a bit with those, hadnt had the idea to get them via the bpmn model.
Yeah getting that far is atleast a good first step for my usecase, I'll be able to build up on top of that.
Thanks alot for your help.
02-27-2018 04:52 AM
Might be a stupid Question, but: Am I correct in that the DataObjects can only be defined programmatically or in the xml file ? and not in the Activiti Editor?
Thanks
02-27-2018 05:03 AM
All you can use.
02-27-2018 05:20 AM
Hm okay, didnt find it in the editor, strange. Okay I'll have a look again.
Thank you.
02-27-2018 05:40 AM
I'm sorry that Data Object setting diappear from Activiti Editor...
02-27-2018 05:42 AM
Ok, thanks for the info, no worries.
I'll just define the data objects in xml.
Thanks again.
Explore our Alfresco products with the links below. Use labels to filter content by product module.