Fix macro flow resource blocks processing order
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / workflow / tasks / WorkflowAction.java
index 8a92899..ce775af 100644 (file)
@@ -10,6 +10,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2020 Tech Mahindra
  * ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
  * 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
@@ -318,6 +320,24 @@ public class WorkflowAction {
             logger.info("Sorting for Vlan Tagging");
             flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
         }
+        logger.info("Building Block Execution Order");
+        for (ExecuteBuildingBlock block : flowsToExecute) {
+            Resource res = resourceList.stream()
+                    .filter(resource -> resource.getResourceId() == block.getBuildingBlock().getKey()).findAny()
+                    .orElse(null);
+            String log = "Block: " + block.getBuildingBlock().getBpmnFlowName();
+            if (res != null) {
+                log += ", Resource: " + res.getResourceType() + "[" + res.getResourceId() + "]";
+                log += ", Priority: " + res.getProcessingPriority();
+                if (res.getResourceType() == WorkflowType.VFMODULE)
+                    log += ", Base: " + res.isBaseVfModule();
+            }
+            if (block.getBuildingBlock().getBpmnScope() != null)
+                log += ", Scope: " + block.getBuildingBlock().getBpmnScope();
+            if (block.getBuildingBlock().getBpmnAction() != null)
+                log += ", Action: " + block.getBuildingBlock().getBpmnAction();
+            logger.info(log);
+        }
         // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
         if (resourceType == WorkflowType.SERVICE
                 && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE))
@@ -417,7 +437,7 @@ public class WorkflowAction {
                 resourceId = modelInfo.getModelCustomizationId();
             }
         }
-        return new Resource(resourceType, resourceId, true);
+        return new Resource(resourceType, resourceId, true, null);
     }
 
     private String getCloudOwner(CloudConfiguration cloudConfiguration) {
@@ -732,7 +752,7 @@ public class WorkflowAction {
                     type = action;
                 }
             }
-            return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
+            return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated, null);
         } else {
             throw new IllegalArgumentException("Uri could not be parsed: " + uri);
         }