cancel
Showing results for 
Search instead for 
Did you mean: 

serviceTask, trying to parse class name programatically

roadtripryan
Champ in-the-making
Champ in-the-making
I'm building a UI for starting a process. I parse the process definition to know what metadata each step will need. I can't figure out how to get the class name for a service task programatically:

for (PvmActivity activity : processDefinition.getActivities()) {
                String type = (String) activity.getProperty("type");
                if (type == "userTask") {
                 ….
                } else if (type == "serviceTask") {
                    System.out.println(activity.getProperty("activiti:class"));
                }
}

Any idea of how to get the serviceTask class name from the process definition? Depending on the service class, I will prompt the user for different metadata to add to the process variables.

Thanks,
Ryan
1 REPLY 1

saig0
Champ in-the-making
Champ in-the-making
Hi Ryan,

you can get the class name of a service task from BpmnModel of the process:

<java>
BpmnModel bpmnModel = repositoryService.getBpmnModel(PROCESS_DEFINITION_ID);
for (Process process : bpmnModel.getProcesses())
        {
            for (FlowElement flowElement : process.getFlowElements())
            {
                if(flowElement instanceof ServiceTask){
                    ServiceTask serviceTask = (ServiceTask) flowElement;
                    String className = serviceTask.getImplementation();
                    // do something…
                }
            }
        }
</java>