Map<String, Message> messages = (Map<String, Message>)
((ProcessBuildData) parser.getData()).getMetaData("Messages");
if (messages == null) {
throw new IllegalArgumentException("No messages found");
}
Message message = messages.get(messageRef);
if (message == null) {
throw new IllegalArgumentException("Could not find message " + messageRef);
}
String variable = (String) actionNode.getMetaData("MappingVariable");
actionNode.setMetaData("MessageType", message.getType());
actionNode.setAction(new DroolsConsequenceAction("java",
"org.drools.process.instance.impl.WorkItemImpl workItem = new org.drools.process.instance.impl.WorkItemImpl();" + EOL +
"workItem.setName(\"Send Task\");" + EOL +
"workItem.setParameter(\"MessageType\", \"" + message.getType() + "\");" + EOL +
(variable == null ? "" : "workItem.setParameter(\"Message\", " + variable + ");" + EOL) +
"((org.drools.process.instance.WorkItemManager) kcontext.getKnowledgeRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem);"));
}
xmlNode = xmlNode.getNextSibling();
}