use of org.jbpm.bpmn2.core.CorrelationProperty 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.CorrelationProperty in project jbpm by kiegroup.
the class CorrelationPropertyHandler method start.
@Override
public Object start(String uri, String localName, Attributes attrs, ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String correlationPropertyId = attrs.getValue("id");
String correlationPropertyName = attrs.getValue("name");
String type = attrs.getValue("type");
CorrelationProperty correlationProperty = new CorrelationProperty();
correlationProperty.setId(correlationPropertyId);
correlationProperty.setName(correlationPropertyName);
correlationProperty.setType(HandlerUtil.definitions(parser).get(type).getStructureRef());
HandlerUtil.correlationProperties(parser).put(correlationPropertyId, correlationProperty);
return correlationProperty;
}
use of org.jbpm.bpmn2.core.CorrelationProperty in project jbpm by kiegroup.
the class CorrelationPropertyHandler method end.
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
Element element = parser.endElementBuilder();
CorrelationProperty correlationProperty = (CorrelationProperty) parser.getCurrent();
NodeList nodeList = element.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if ("correlationPropertyRetrievalExpression".equals(node.getNodeName())) {
String messageRef = ((Element) node).getAttribute("messageRef");
correlationProperty.setRetrievalExpression(messageRef, buildMessagePathExpression(node.getChildNodes(), parser));
}
}
return null;
}
use of org.jbpm.bpmn2.core.CorrelationProperty in project kogito-runtimes 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.correlationSubscription(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.CorrelationProperty in project kogito-runtimes by kiegroup.
the class CorrelationPropertyHandler method end.
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
Element element = parser.endElementBuilder();
CorrelationProperty correlationProperty = (CorrelationProperty) parser.getCurrent();
NodeList nodeList = element.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if ("correlationPropertyRetrievalExpression".equals(node.getNodeName())) {
String messageRef = ((Element) node).getAttribute("messageRef");
correlationProperty.setRetrievalExpression(messageRef, buildMessagePathExpression(node.getChildNodes(), parser));
}
}
return null;
}
Aggregations