From fdc8f787e9874f82409cdb2eae0475162d6519aa Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Thu, 6 Feb 2020 11:26:19 -0500 Subject: optimize camunda process instance history Set buinessKey to requestId. Added plugin to pass businessKey to subprocesses Updated process-instance and activity-instance lookups to filter response Removed duplicate tests and updated att history lookup Updated businessKey to be set to mso-request-id Updated snapshot version to fix build issues Removed query param from properties. added uribuilder Updated to use uriBuilder.build().toString() Updated unit tests to lookup by procesInstanceId to fix build failure Issue-ID: SO-2650 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I357053c52a75ee5149a56392ce866dbb654b541d --- .../common/workflow/service/WorkflowProcessor.java | 3 +-- .../CallActivityBusinessKeyParseListener.java | 30 ++++++++++++++++++++++ ...CallActivityBusinessKeyParseListenerPlugin.java | 24 +++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java create mode 100644 bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java (limited to 'bpmn/mso-infrastructure-bpmn/src/main/java') diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index 70365b744c..25f7c4b93f 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -75,9 +75,8 @@ public class WorkflowProcessor extends ProcessEngineAwareService { } } - // Note: the business key is used to identify the process in unit tests protected static String getBusinessKey(Map inputVariables) { - return getOrCreate(inputVariables, "mso-business-key"); + return getOrCreate(inputVariables, "mso-request-id"); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java new file mode 100644 index 0000000000..80d86ad009 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java @@ -0,0 +1,30 @@ +package org.onap.so.bpmn.core.plugins; + +import org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior; +import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.model.CallableElement; +import org.camunda.bpm.engine.impl.el.ElValueProvider; +import org.camunda.bpm.engine.impl.el.Expression; +import org.camunda.bpm.engine.impl.el.ExpressionManager; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; +import org.camunda.bpm.engine.impl.util.xml.Element; +import org.springframework.stereotype.Component; + + +@Component +public class CallActivityBusinessKeyParseListener extends AbstractBpmnParseListener { + + @Override + public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { + ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager(); + Expression expression = expressionManager.createExpression("#{execution.processBusinessKey}"); + ElValueProvider p = new ElValueProvider(expression); + CallableElementActivityBehavior callableElementActivityBehavior = + (CallableElementActivityBehavior) activity.getActivityBehavior(); + CallableElement callableElement = (CallableElement) callableElementActivityBehavior.getCallableElement(); + callableElement.setBusinessKeyValueProvider(p); + callableElementActivityBehavior.setCallableElement(callableElement); + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java new file mode 100644 index 0000000000..a2d897e367 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java @@ -0,0 +1,24 @@ +package org.onap.so.bpmn.core.plugins; + +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; +import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.springframework.stereotype.Component; + + +@Component +public class CallActivityBusinessKeyParseListenerPlugin extends AbstractProcessEnginePlugin { + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); + if (preParseListeners == null) { + preParseListeners = new ArrayList<>(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + preParseListeners.add(new CallActivityBusinessKeyParseListener()); + } + +} -- cgit 1.2.3-korg