use of org.jbpm.bpmn2.core.Collaboration in project jbpm by kiegroup.
the class ProcessHandler method postProcessCollaborations.
private void postProcessCollaborations(RuleFlowProcess process, ExtensibleXmlParser parser) {
// now we wire correlation process subscriptions
CorrelationManager correlationManager = process.getCorrelationManager();
for (Message message : HandlerUtil.messages(parser).values()) {
correlationManager.newMessage(message.getId(), message.getName(), message.getType());
}
// only the ones this process is member of
List<Collaboration> collaborations = HandlerUtil.collaborations(parser).values().stream().filter(c -> c.getProcessesRef().contains(process.getId())).collect(Collectors.toList());
for (Collaboration collaboration : collaborations) {
for (CorrelationKey key : collaboration.getCorrelationKeys()) {
correlationManager.newCorrelation(key.getId(), key.getName());
List<CorrelationProperty> properties = key.getPropertiesRef().stream().map(k -> HandlerUtil.correlationProperties(parser).get(k)).collect(Collectors.toList());
for (CorrelationProperty correlationProperty : properties) {
correlationProperty.getMessageRefs().forEach(messageRef -> {
// for now only MVEL expressions
MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript());
correlationManager.addMessagePropertyExpression(key.getId(), messageRef, correlationProperty.getId(), evaluator);
});
}
}
}
// we create the correlations
for (CorrelationSubscription subscription : HandlerUtil.correlationSuscription(process).values()) {
correlationManager.subscribeTo(subscription.getCorrelationKeyRef());
for (Map.Entry<String, Expression> binding : subscription.getPropertyExpressions().entrySet()) {
MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(binding.getValue().getScript());
correlationManager.addProcessSubscriptionPropertyExpression(subscription.getCorrelationKeyRef(), binding.getKey(), evaluator);
}
}
}
use of org.jbpm.bpmn2.core.Collaboration in project jbpm by kiegroup.
the class CollaborationHandler method end.
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
Element element = parser.endElementBuilder();
Collaboration collaboration = (Collaboration) parser.getCurrent();
buildCorrelationKeys(collaboration, element.getChildNodes());
return null;
}
use of org.jbpm.bpmn2.core.Collaboration in project jbpm by kiegroup.
the class CollaborationHandler method buildCorrelationKeys.
private void buildCorrelationKeys(Collaboration collaboration, NodeList childNodes) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if ("correlationKey".equals(node.getNodeName())) {
Element elementCorrelationKey = (Element) node;
CorrelationKey key = new CorrelationKey();
key.setId(elementCorrelationKey.getAttribute("id"));
key.setName(elementCorrelationKey.getAttribute("name"));
key.getPropertiesRef().addAll(buildPropertiesRef(elementCorrelationKey.getChildNodes()));
collaboration.addCorrelationKey(key);
} else if ("participant".equals(node.getNodeName())) {
Element participant = (Element) node;
collaboration.getProcessesRef().add(participant.getAttribute("processRef"));
}
}
}
use of org.jbpm.bpmn2.core.Collaboration in project kogito-runtimes by kiegroup.
the class CollaborationHandler method start.
@Override
public Object start(String uri, String localName, Attributes attrs, ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String collaborationPropertyId = attrs.getValue("id");
String collaborationPropertyName = attrs.getValue("name");
Collaboration collaboration = new Collaboration();
collaboration.setId(collaborationPropertyId);
collaboration.setName(collaborationPropertyName);
HandlerUtil.collaborations(parser).put(collaborationPropertyId, collaboration);
return collaboration;
}
use of org.jbpm.bpmn2.core.Collaboration in project kogito-runtimes by kiegroup.
the class CollaborationHandler method buildCorrelationKeys.
private void buildCorrelationKeys(Collaboration collaboration, NodeList childNodes) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if ("correlationKey".equals(node.getNodeName())) {
Element elementCorrelationKey = (Element) node;
CorrelationKey key = new CorrelationKey();
key.setId(elementCorrelationKey.getAttribute("id"));
key.setName(elementCorrelationKey.getAttribute("name"));
key.getPropertiesRef().addAll(buildPropertiesRef(elementCorrelationKey.getChildNodes()));
collaboration.addCorrelationKey(key);
} else if ("participant".equals(node.getNodeName())) {
Element participant = (Element) node;
collaboration.getProcessesRef().add(participant.getAttribute("processRef"));
}
}
}
Aggregations