Complete assignment from plugin gives error
Hi everybody.
I'm developing a very simple AuditPlugin that takes some messages from a JMS queue and have to complete an activity with some values based on the jms messages.
I'm having troubles with the assignmentComplete() method becouse when I try to complete a given activity, joget logs an error like this:
org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed: Activity [Process Id=29_workflow_patient_enrolment_process, Id=138_29_workflow_patient_enrolment_process_enrollmentOnSHC, ba=null, ActDefId=enrollmentOnSHC] - current state is open.not_running.not_started, can't change to state closed.completed!
What I have to do in order to complete an assignment from a plugin?
Here is the method that does the job:
private void compileForm(String source, String correlation_id){
workflowUserManager.setCurrentThreadUser(source);
WorkflowAssignment assignment = workflowManager.getAssignment(correlation_id);
String current_user = workflowUserManager.getCurrentUser().getUsername();
if(assignment!=null){
System.out.println("Assignment " + correlation_id +" trovato per l'utente " + current_user);
HashMap<String,String> workflow_vars = new HashMap<>();
workflow_vars.put("var_shc_patient_created","ok");
try{
System.out.println("Completo assignment :" + assignment.getActivityId());
workflowManager.assignmentComplete(assignment.getActivityId());
}
catch(Exception e){
System.out.println("Errore nel completamento attività");
}
}
else{
System.out.println("Assignment " + correlation_id +" non trovato per l'utente");
}
}
Where source is an existing username in JOGET. For the moment I'm not using the hashmap with workflow variables, so I'm using the simple method assignmentComplete(String activityId)
Thanks in advance