we are using JSON with Spin to store our process variables during process execution. Now we wanted to use the camunca:candidateGroups and camunda:candidateUsers attribute in a User Task.
To give them a list of candidates, we tried the following snippet:
camunda:candidateGroups=“${S(responsible).prop("candidate_groups").elements()}”
This, of course, raised an exeption, since we get a SpinList, but a string or List of Strings is expected.
Since we can use here only expression language, I unfortunately don’t know how to convert this expression into a list of strings. Moreover, JSP 2.1 doesn’t support stream-like expressions (like JSP 3.0). As workaround, I can transform the data to the correct format upfront, but it would be interesting to know how to do it in an expression.
Taking a quick a look at the doc, I’m surprised it doesn’t do the trick as SpinList extends List. What does your exception look like (maybe can you post it)? Is it because the list itself isn’t a list of strings? Hard to say without knowing what your data looks like.
I just noticed that my title isn’t describtive enough. I have a SpinList of JacksonJsonNode, while a String or List of Strings is required in the expression, which results in a ClassCastException. The JacksonJsonNode have a String value inside.
What is already working is to fetch the first element of the list:
camunda:candidateGroups="${S(responsible).prop(“candidate_groups”).elements().get(9).stringValue()}"
In Java, I would have done the following for the expression:
((JacksonJsonNode) exp.getValue(delegateExecution)).elements().stream().filter(s -> s.isString()).map(spin -> spin.stringValue()).collect(java.util.stream.Collectors.toList())
Unfortunately, I cannot translate this to JSP 2.1.