12-26-2019 10:26 PM
Hi,
My workflow is something like Service Task createNewAssignment --> TimerCatchingEvent timer1 --> Service Task checkForSubmission.
I'm using Java delegate expression for service tasks.
Below is how I'm starting a process.
AssignmentProcessDTO assignmentProcessDTO = new AssignmentProcessDTO();
assignmentProcessDTO.setAssignmentDTO(assignmentDTO);
assignmentProcessDTO.setDidAnyDoctorOptsIn(true);
assignmentProcessDTO.setNoDoctorSelected(true);
assignmentProcessDTO.setDidDoctorAcknowledge(false);
assignmentProcessDTO.setSecondDoctor(true);
Map<String, Object> variables = new HashMap<>();
variables.put("assignmentProcessDTO", assignmentProcessDTO);
runtimeService.startProcessInstanceByKey("assignmentFlow", variables);
In createNewAssignment, I'm doing below and things work fine.
AssignmentProcessDTO assignmentProcessDTO = execution.getVariable("assignmentProcessDTO", AssignmentProcessDTO.class);
But When i do the same in service task checkForSubmission, which is called after timer, it gives me below error.
2019-12-27 08:48:02.048 ERROR 37424 --- [ecutor-thread-1] o.a.e.impl.interceptor.CommandContext : Error while closing command context org.activiti.engine.ActivitiException: Cannot cast com.fasterxml.jackson.databind.node.ObjectNode to com.sfl.ahoy.service.dto.AssignmentProcessDTO at org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior.execute(ServiceTaskDelegateExpressionActivityBehavior.java:115) at org.activiti.engine.impl.agenda.ContinueProcessOperation.executeActivityBehavior(ContinueProcessOperation.java:210) at org.activiti.engine.impl.agenda.ContinueProcessOperation.executeSynchronous(ContinueProcessOperation.java:146) at org.activiti.engine.impl.agenda.ContinueProcessOperation.continueThroughFlowNode(ContinueProcessOperation.java:101) at org.activiti.engine.impl.agenda.ContinueProcessOperation.run(ContinueProcessOperation.java:66)
Below is the java class where I'm getting exception.
@Component
public class CheckDoctorOptInService implements JavaDelegate {
private final Logger logger = LoggerFactory.getLogger(CheckDoctorOptInService.class);
private final DoctorAssignmentResponseService doctorAssignmentResponseService;
public CheckDoctorOptInService(DoctorAssignmentResponseService doctorAssignmentResponseService) {
this.doctorAssignmentResponseService = doctorAssignmentResponseService;
}
@Override
public void execute(DelegateExecution execution) {
logger.debug("Checking if any doctor has opted in for the assignment or not with execution {}", execution.getVariables());
AssignmentProcessDTO assignmentProcessDTO = execution.getVariable("assignmentProcessDTO", AssignmentProcessDTO.class);
Boolean didAnyDoctorOptedIn = doctorAssignmentResponseService.didDoctorRespondForAssignment(assignmentProcessDTO.getAssignmentDTO().getId());
}
}
Request your help on the same.
01-07-2020 04:01 AM
Hi ash,
Can you provide the AssignmentProcessDTO Class ?
But I think that this should work:
AssignmentProcessDTO assignmentProcessDTO =(AssignmentProcessDTO)execution.getVariable("assignmentProcessDTO");
Explore our Alfresco products with the links below. Use labels to filter content by product module.