use of org.jbpm.bpmn2.core.CorrelationKey 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.CorrelationKey in project jbpm by kiegroup.
the class ActivityTest method testCallActivityChain.
@RequirePersistence
@Test
public void testCallActivityChain() throws Exception {
try {
System.setProperty("org.jbpm.correlationkey.length", "155");
KieBase kbase = createKnowledgeBase("correlationkey/Process1.bpmn2", "correlationkey/Process2.bpmn2", "correlationkey/Process3.bpmn2", "correlationkey/Process4.bpmn2", "correlationkey/Process5.bpmn2");
ksession = createKnowledgeSession(kbase);
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("src.Process1", params);
assertProcessInstanceCompleted(processInstance);
ProcessInstanceLog log = logService.findProcessInstances("src.Process5").get(0);
assertNotNull(log);
assertNotNull(log.getCorrelationKey());
assertTrue(log.getCorrelationKey().startsWith(processInstance.getId() + ":src.Process2:"));
assertTrue(log.getCorrelationKey().contains(":src.Process4"));
assertTrue(log.getCorrelationKey().length() <= 155);
} finally {
System.clearProperty("org.jbpm.correlationkey.length");
}
}
use of org.jbpm.bpmn2.core.CorrelationKey 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.CorrelationKey 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"));
}
}
}
use of org.jbpm.bpmn2.core.CorrelationKey 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);
}
}
}
Aggregations