aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-02-18 17:14:40 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-18 17:14:40 +0000
commit2d11a7092c292a3987ad0b105fe31ee8a0390294 (patch)
treedd81ebe972cb7656e09050213d8e8fff19967429 /bpmn/so-bpmn-tasks/src/main
parenta71813fd697298b9a9bddea6eacc9de5fada2de0 (diff)
parent9737ae116859da4548dcd1bf3ba73d339f326c52 (diff)
Merge "Based on Controller Actor calling CDS or APPC(Current Flow)"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java109
1 files changed, 109 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java
new file mode 100644
index 0000000000..86d56005f6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Tech Mahindra
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
+
+import java.util.Optional;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.BBNameSelectionReference;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ControllerExecution {
+ private static final Logger logger = LoggerFactory.getLogger(ControllerExecution.class);
+ private static final String CONTROLLER_ACTOR = "controllerActor";
+ private static final String BUILDING_BLOCK = "buildingBlock";
+ private static final String SCOPE = "scope";
+ private static final String ACTION = "action";
+ private static final String BBNAME = "bbName";
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ /**
+ * Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
+ *
+ * @param execution - BuildingBlockExecution object
+ */
+ public void setControllerActorScopeAction(BuildingBlockExecution execution) {
+ try {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String modleUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
+ VnfResourceCustomization vnfResourceCustomization =
+ catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modleUuid);
+
+ // Fetching Controller Actor at VNF level if null then Controller Actor is set as "APPC"
+ String controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
+ ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
+ BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
+ String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(
+ () -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
+ String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(
+ () -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
+ execution.setVariable(SCOPE, scope);
+ execution.setVariable(ACTION, action);
+ execution.setVariable(CONTROLLER_ACTOR, controllerActor);
+ logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}",
+ controllerActor, scope, action);
+
+ } catch (Exception ex) {
+ logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * Selecting bbName from BBNameSelectionReference and setting the value in a variable of BuildingBlockExecution
+ *
+ * @param execution - BuildingBlockExecution object
+ */
+ public void selectBB(BuildingBlockExecution execution) {
+ try {
+
+ String controllerActor = execution.getVariable(CONTROLLER_ACTOR);
+ String action = Optional.of((String) execution.getVariable(ACTION)).get();
+ String scope = Optional.of((String) execution.getVariable(SCOPE)).get();
+ BBNameSelectionReference bbNameSelectionReference =
+ catalogDbClient.getBBNameSelectionReference(controllerActor, scope, action);
+ String bbName = bbNameSelectionReference.getBbName();
+ execution.setVariable(BBNAME, bbName);
+ logger.debug(" Executing {} BPMN", bbName);
+ } catch (Exception ex) {
+ logger.error("An exception occurred while getting bbname from catalogdb ", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+
+ }
+
+ }
+}