1 of 1 people found this helpful
The code in FormProviderServiceImpl calls TaskData.getDocumentContentId() and then Context.getContentById(id) to retrieve the input mappings (similarly using TaskData.getOutputContemtId() for the output values).
I'm curious about why there isn't a function available on the external API to get the input and output variables for a human task. The following code seems to be how you can do it but it is clumsy and uses APIs from the org.kie.internal... packages which I would have thought would be a bad thing to do.
Task t = taskService.getTaskById(tid); ContentMarshallerContext context = contentService.getMarshallerContext(t); long inputId = t.getTaskData().getDocumentContentId(); Content content = contentService.getContentById(inputId); Object input = ContentMarshallerHelper.unmarshall(content.getContent(), context.getEnvironment(), context.getClassloader()); long outputId = t.getTaskData().getOutputContentId(); content = contentService.getContentById(outputId); Object output = ContentMarshallerHelper.unmarshall(content.getContent(), context.getEnvironment(), context.getClassloader());
So, is the above the correct way to get the task input and output parameters?
yes, that is correct way to do so.
However using internal api (especially this from org.kie.internal) does not have to be bad practice. It's part of the internal API because it requires some additional time to settle before being promoted to public API. What is always welcome is feedback from community about missing or vague options in the API that might get improved.