@Override
public ProcessInstance handle(ProcessInstance state, String definitionId, String elementId) throws ExecutionException {
ProcessDefinition pd = state.getDefinition(definitionId);
UserTask task = (UserTask) ProcessDefinitionUtils.findElement(pd, elementId);
FormExtension x = findFormExtension(task.getExtensions());
if (x == null) {
return state;
}
log.debug("handle ['{}', '{}', '{}'] -> found form extension: {}",
state.getBusinessKey(), definitionId, elementId, x);
Map<String, Object> options = getOptions(x, state.getVariables());
FormDefinition fd = getOrCreateFormDefinition(x, options);
if (fd == null) {
throw new ExecutionException("Form definition not found: " + x.getFormId());
}
String pk = state.getBusinessKey();
UUID fId = UUID.randomUUID();
String eventName = UUID.randomUUID().toString();
Map<String, Object> env = state.getVariables().asMap();
formService.create(pk, fId, eventName, fd, options, env);
return StateHelper.push(state, new CreateEventAction(definitionId, elementId, eventName, null, null, null, null));
}