summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java/org
diff options
context:
space:
mode:
authorManamohan <MS00534989@techmahindra.com>2020-02-13 11:15:52 +0530
committerManamohan <MS00534989@techmahindra.com>2020-02-13 11:15:52 +0530
commit7955aa1d34f6579eb1a1a6064ceba228f0c70594 (patch)
tree5f7068ac45bf26f816de94d50ac07217b19283dc /bpmn/so-bpmn-tasks/src/main/java/org
parent1980195d94d2208c8f5c8951885cfe345fbc8dd1 (diff)
Skips the VfModule or VNF Configassign/ConfigDeploy action.
Change-Id: Ic34900cc3664944c9ecd3b5636d87deefb178aee Issue-ID: SO-2317 Change-Id: I102d340b248ab67a9801af178e6b76a9a15821be Signed-off-by: Manamohan <MS00534989@techmahindra.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java116
1 files changed, 116 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
new file mode 100644
index 0000000000..682a0471ee
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 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.workflow.tasks.listeners;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.logging.log4j.util.Strings;
+import org.onap.so.bpmn.common.BBConstants;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+@Component
+public class SkipCDSBuildingBlockListener implements FlowManipulator {
+
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ private Set<String> vnfActions =
+ new HashSet<String>(Arrays.asList("config-assign", "config-deploy", "VnfConfigAssign", "VnfConfigDeploy"));
+
+ private Set<String> vFModuleAction =
+ new HashSet<String>(Arrays.asList("VfModuleConfigAssign", "VfModuleConfigDeploy"));
+
+ @Override
+ public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) {
+
+ return "ControllerExecutionBB".equals(currentBBName);
+ }
+
+ /**
+ * Skip the CDS Building block according to the Skip Flag.
+ *
+ * @param flowsToExecute - List of ExecuteBuildingBlock object.
+ * @param execution - BuildingBlockExecution object
+ * @param currentBB - ExecuteBuildingBlock object
+ *
+ */
+ @Override
+ public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB,
+ BuildingBlockExecution execution) {
+ String customizationUUID = currentBB.getBuildingBlock().getKey();
+
+ if (Strings.isEmpty(customizationUUID)) {
+ return;
+ }
+
+ if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF")
+ && containsIgnoreCaseAction(currentBB, vnfActions)) {
+ List<VnfResourceCustomization> vnfResourceCustomizations =
+ catalogDbClient.getVnfResourceCustomizationByModelUuid(
+ currentBB.getRequestDetails().getModelInfo().getModelUuid());
+ if (!CollectionUtils.isEmpty(vnfResourceCustomizations)) {
+ VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(customizationUUID,
+ vnfResourceCustomizations);
+ if (null != vrc) {
+ boolean skipConfigVNF = vrc.isSkipPostInstConf();
+ currentSequenceSkipCheck(execution, skipConfigVNF);
+ }
+
+ }
+ } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule")
+ && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
+
+ VfModuleCustomization vfc =
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(customizationUUID);
+
+ if (null != vfc) {
+ boolean skipVfModule = vfc.isSkipPostInstConf();
+ currentSequenceSkipCheck(execution, skipVfModule);
+ }
+ }
+
+
+ }
+
+ private boolean containsIgnoreCaseAction(ExecuteBuildingBlock currentBB, Set<String> actions) {
+ return actions.stream().filter(action -> action.equalsIgnoreCase(currentBB.getBuildingBlock().getBpmnAction()))
+ .findFirst().isPresent();
+ }
+
+
+ private void currentSequenceSkipCheck(BuildingBlockExecution execution, boolean skipModule) {
+ if (skipModule) {
+ int currentSequence = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1);
+ }
+ }
+
+}