Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

cancel
Showing results for 
Search instead for 
Did you mean: 
ryandawson
Alfresco Employee

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

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.

ksgphellow
Active Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

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.

daisuke-yoshimo
Senior Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

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

ksgphellow
Active Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

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.

ksgphellow
Active Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

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

daisuke-yoshimo
Senior Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

All you can use.

  • programmatically
  • xml file
  • Activiti Editor/Activiti Designer
ksgphellow
Active Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

Hm okay, didnt find it in the editor, strange. Okay I'll have a look again.

Thank you.

daisuke-yoshimo
Senior Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

I'm sorry that Data Object setting diappear from Activiti Editor...

ksgphellow
Active Member

Re: Define Required Process Variables and Get Information on those before instantiating a ProcessDefinition

Jump to solution

Ok, thanks for the info, no worries.

I'll just define the data objects in xml. 

Thanks again.