workItem = new WorkItemImpl();
((WorkItem) workItem).setName(work.getName());
((WorkItem) workItem).setProcessInstanceId(getProcessInstance().getId());
((WorkItem) workItem).setParameters(new HashMap<String, Object>(work.getParameters()));
for (Iterator<DataAssociation> iterator = workItemNode.getInAssociations().iterator(); iterator.hasNext(); ) {
DataAssociation association = iterator.next();
if (association.getAssignments() == null || association.getAssignments().isEmpty()) {
Object parameterValue = null;
VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
resolveContextInstance(VariableScope.VARIABLE_SCOPE, association.getSources().get(0));
if (variableScopeInstance != null) {
parameterValue = variableScopeInstance.getVariable(association.getSources().get(0));
} else {
try {
parameterValue = MVEL.eval(association.getSources().get(0), new NodeInstanceResolverFactory(this));
} catch (Throwable t) {
System.err.println("Could not find variable scope for variable " + association.getSources().get(0));
System.err.println("when trying to execute Work Item " + work.getName());
System.err.println("Continuing without setting parameter.");
}
}
if (parameterValue != null) {
((WorkItem) workItem).setParameter(association.getTarget(), parameterValue);
}
} else {
for(Iterator<Assignment> it = association.getAssignments().iterator(); it.hasNext(); ) {
handleAssignment(it.next());
}
}
}