aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-02-10 13:38:31 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-10 13:38:31 +0000
commit0772e8876fa155fd93b7abb5816a6d9a040aa7f6 (patch)
treee2f01064b48ee3d6363e0c2b3a9b639f5801fb35 /bpmn
parent299cf5f3a2a49a6dec927a0fd038762a07d6c272 (diff)
parentfdc8f787e9874f82409cdb2eae0475162d6519aa (diff)
Merge "optimize camunda process instance history"
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java3
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java30
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java24
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java12
4 files changed, 67 insertions, 2 deletions
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<String, Object> 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<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
+ if (preParseListeners == null) {
+ preParseListeners = new ArrayList<>();
+ processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
+ }
+ preParseListeners.add(new CallActivityBusinessKeyParseListener());
+ }
+
+}
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
index 93f98a34a6..0161422b64 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java
@@ -1534,6 +1534,18 @@ public abstract class WorkflowTest {
}
}
+ protected Object getVariableFromHistoryByProcessInstanceId(String processInstanceId, String variableName) {
+ try {
+ HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery()
+ .processInstanceId(processInstanceId).variableName(variableName).singleResult();
+ return v == null ? null : v.getValue();
+ } catch (Exception e) {
+ logger.debug("Error retrieving variable {} from historical process with processInstanceId {}: ",
+ variableName, processInstanceId, e);
+ return null;
+ }
+ }
+
/**
* Gets a variable value from a process instance based on businessKey and process name. Must be used when multiple
* instances exist with the same business key such as when business key is passed to subflows or shared across