Search in sources :

Example 86 with ExecuteBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.

the class WorkflowAction method updateWorkflowResourceIds.

protected void updateWorkflowResourceIds(List<ExecuteBuildingBlock> flowsToExecute, WorkflowType resourceType, Resource resource, String id, String virtualLinkKey, String serviceInstanceId, Map<Resource, String> resourceInstanceIds) {
    String key = resource.getResourceId();
    String resourceId = id;
    if (resourceId == null) {
        resourceId = UUID.randomUUID().toString();
    }
    resourceInstanceIds.put(resource, resourceId);
    Set<String> assignedFlows = new LinkedHashSet<>();
    for (ExecuteBuildingBlock ebb : flowsToExecute) {
        String resourceTypeStr = resourceType.toString();
        String flowName = ebb.getBuildingBlock().getBpmnFlowName();
        String scope = StringUtils.defaultString(ebb.getBuildingBlock().getBpmnScope());
        String action = StringUtils.defaultString(ebb.getBuildingBlock().getBpmnAction());
        if (key != null && key.equalsIgnoreCase(ebb.getBuildingBlock().getKey()) && isFlowAssignable(assignedFlows, ebb, resourceType, flowName + action) && (flowName.contains(resourceTypeStr) || (flowName.contains(CONTROLLER) && resourceTypeStr.equalsIgnoreCase(scope)))) {
            WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
            workflowResourceIds.setServiceInstanceId(serviceInstanceId);
            Resource parent = resource.getParent();
            if (parent != null && resourceInstanceIds.containsKey(parent)) {
                WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, parent.getResourceType(), resourceInstanceIds.get(parent));
            }
            WorkflowResourceIdsUtils.setInstanceNameByWorkflowType(workflowResourceIds, resourceType, resource.getInstanceName());
            WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, resourceType, resourceId);
            ebb.setWorkflowResourceIds(workflowResourceIds);
            assignedFlows.add(flowName + action);
        }
        if (virtualLinkKey != null && ebb.getBuildingBlock().isVirtualLink() && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) {
            WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
            workflowResourceIds.setServiceInstanceId(serviceInstanceId);
            workflowResourceIds.setNetworkId(resourceId);
            ebb.setWorkflowResourceIds(workflowResourceIds);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)

Example 87 with ExecuteBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.

the class WorkflowAction method selectExecutionList.

public void selectExecutionList(DelegateExecution execution) throws Exception {
    try {
        fillExecutionDefault(execution);
        final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
        ServiceInstancesRequest sIRequest = new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
        final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
        String uri = (String) execution.getVariable(BBConstants.G_URI);
        boolean isResume = isUriResume(uri);
        final boolean isALaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
        Resource resource = getResource(bbInputSetupUtils, isResume, isALaCarte, uri, requestId);
        WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
        RequestDetails requestDetails = sIRequest.getRequestDetails();
        String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
        String resourceId = getResourceId(resource, requestAction, requestDetails, workflowResourceIds);
        WorkflowType resourceType = resource.getResourceType();
        String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType);
        fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType);
        List<ExecuteBuildingBlock> flowsToExecute;
        if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
            String errorMessage = "Could not resume Macro flow. Error loading execution path.";
            flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
        } else if (isALaCarte && isResume) {
            String errorMessage = "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found";
            flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
        } else {
            String vnfType = (String) execution.getVariable(VNF_TYPE);
            String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration());
            List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW);
            final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION);
            final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
            if (isALaCarte) {
                flowsToExecute = loadExecuteBuildingBlocksForAlaCarte(orchFlows, execution, requestAction, resourceType, cloudOwner, serviceType, sIRequest, requestId, workflowResourceIds, requestDetails, resourceId, vnfType, apiVersion);
            } else {
                flowsToExecute = loadExecuteBuildingBlocksForMacro(sIRequest, resourceType, requestAction, execution, serviceInstanceId, resourceId, workflowResourceIds, orchFlows, cloudOwner, serviceType, requestId, apiVersion, vnfType, requestDetails);
            }
        }
        // enable it.
        if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
            List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
            for (Map<String, Object> params : userParams) {
                if (params.containsKey(HOMINGSOLUTION)) {
                    execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION)));
                }
            }
        }
        if (CollectionUtils.isEmpty(flowsToExecute)) {
            throw new IllegalStateException("Macro did not come up with a valid execution path.");
        }
        List<String> flowNames = new ArrayList<>();
        logger.info("List of BuildingBlocks to execute:");
        flowsToExecute.forEach(ebb -> {
            logger.info(ebb.getBuildingBlock().getBpmnFlowName());
            flowNames.add(ebb.getBuildingBlock().getBpmnFlowName());
        });
        if (!isResume) {
            bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute);
        }
        setExecutionVariables(execution, flowsToExecute, flowNames);
    } catch (Exception ex) {
        if (!(execution.hasVariable("WorkflowException") || execution.hasVariable("WorkflowExceptionExceptionMessage"))) {
            buildAndThrowException(execution, "Exception while setting execution list. ", ex);
        } else {
            throw ex;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) IOException(java.io.IOException) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 88 with ExecuteBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.

the class WorkflowAction method loadExecuteBuildingBlocksForAlaCarte.

private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForAlaCarte(List<OrchestrationFlow> orchFlows, DelegateExecution execution, String requestAction, WorkflowType resourceType, String cloudOwner, String serviceType, ServiceInstancesRequest sIRequest, String requestId, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, String resourceId, String vnfType, String apiVersion) throws Exception {
    List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
    if (orchFlows == null || orchFlows.isEmpty()) {
        orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner, serviceType);
    }
    Resource resourceKey = getResourceKey(sIRequest, resourceType);
    ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation();
    if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) && resourceType.equals(WorkflowType.VFMODULE)) {
        logger.debug("Build a BB list for replacing BB modules");
        ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
        orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo);
        createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows, apiVersion, resourceKey, replaceInfo);
    } else {
        if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) {
            addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey, replaceInfo, orchFlows);
        }
        orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
        for (OrchestrationFlow orchFlow : orchFlows) {
            ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, requestDetails, false, null, null, false, replaceInfo);
            flowsToExecute.add(ebb);
        }
    }
    return flowsToExecute;
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow)

Example 89 with ExecuteBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.

the class WorkflowAction method loadExecuteBuildingBlocksForMacro.

private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForMacro(ServiceInstancesRequest sIRequest, WorkflowType resourceType, String requestAction, DelegateExecution execution, String serviceInstanceId, String resourceId, WorkflowResourceIds workflowResourceIds, List<OrchestrationFlow> orchFlows, String cloudOwner, String serviceType, String requestId, String apiVersion, String vnfType, RequestDetails requestDetails) throws IOException, VrfBondingServiceException {
    List<ExecuteBuildingBlock> flowsToExecute;
    List<Resource> resourceList = new ArrayList<>();
    List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
    if (resourceType == WorkflowType.SERVICE || isVNFCreate(resourceType, requestAction)) {
        resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution, serviceInstanceId, resourceId, aaiResourceIds);
    } else if (resourceType == WorkflowType.VNF && (DELETE_INSTANCE.equalsIgnoreCase(requestAction) || REPLACEINSTANCE.equalsIgnoreCase(requestAction) || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) {
        vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
    } else if (resourceType == WorkflowType.VNF && UPDATE_INSTANCE.equalsIgnoreCase(requestAction)) {
        vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
    } else if (resourceType == WorkflowType.VNF && HEALTH_CHECK.equalsIgnoreCase(requestAction)) {
        vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
    } else if (resourceType == WorkflowType.VNF && UPGRADE_CNF.equalsIgnoreCase(requestAction)) {
        vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds);
    } else {
        buildAndThrowException(execution, "Current Macro Request is not supported");
    }
    StringBuilder foundObjects = new StringBuilder();
    for (WorkflowType type : WorkflowType.values()) {
        foundObjects.append(type).append(" - ").append((int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count()).append("    ");
    }
    logger.info("Found {}", foundObjects);
    if (orchFlows == null || orchFlows.isEmpty()) {
        orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, false, cloudOwner, serviceType);
    }
    boolean vnfReplace = false;
    if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) {
        vnfReplace = true;
    }
    flowsToExecute = executeBuildingBlockBuilder.buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace);
    if (serviceEBBLoader.isNetworkCollectionInTheResourceList(resourceList)) {
        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)) && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
        execution.setVariable(HOMING, true);
        execution.setVariable("calledHoming", false);
    }
    if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
        generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
    } else {
        updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, serviceInstanceId);
    }
    execution.setVariable("resources", resourceList);
    return flowsToExecute;
}
Also used : WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) Arrays(java.util.Arrays) BBConstants(org.onap.so.bpmn.common.BBConstants) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Vnfc(org.onap.aai.domain.yang.Vnfc) ServiceEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.ServiceEBBLoader) CREATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE) StringUtils(org.apache.commons.lang3.StringUtils) Matcher(java.util.regex.Matcher) ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) Map(java.util.Map) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) VnfEBBLoader(org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.VnfEBBLoader) UPGRADE_CNF(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPGRADE_CNF) BBInputSetupUtils(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) WORKFLOW_ACTION_ERROR_MESSAGE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) FABRIC_CONFIGURATION(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION) BBInputSetup(org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup) Set(java.util.Set) UUID(java.util.UUID) ASSIGN_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE) Collectors(java.util.stream.Collectors) Pair(org.javatuples.Pair) CatalogDbClient(org.onap.so.db.catalog.client.CatalogDbClient) RelatedInstance(org.onap.so.serviceinstancebeans.RelatedInstance) HEALTH_CHECK(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.HEALTH_CHECK) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) RECREATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.RECREATE_INSTANCE) AAIObjectName(org.onap.aaiclient.client.aai.AAIObjectName) Environment(org.springframework.core.env.Environment) CollectionUtils(org.springframework.util.CollectionUtils) ModelType(org.onap.so.serviceinstancebeans.ModelType) Optional(java.util.Optional) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Pattern(java.util.regex.Pattern) WorkflowResourceIdsUtils(org.onap.so.bpmn.infrastructure.workflow.tasks.utils.WorkflowResourceIdsUtils) VolumeGroup(org.onap.aai.domain.yang.VolumeGroup) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) CloudConfiguration(org.onap.so.serviceinstancebeans.CloudConfiguration) DELETE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE) HashMap(java.util.HashMap) SerializationUtils(org.apache.commons.lang3.SerializationUtils) UPDATE_INSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPDATE_INSTANCE) ArrayList(java.util.ArrayList) ExceptionBuilder(org.onap.so.client.exception.ExceptionBuilder) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) LinkedHashSet(java.util.LinkedHashSet) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) REPLACEINSTANCE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE) Logger(org.slf4j.Logger) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) REPLACEINSTANCERETAINASSIGNMENTS(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS) SERVICE(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE) Component(org.springframework.stereotype.Component) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Comparator(java.util.Comparator) CONTROLLER(org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList) Pair(org.javatuples.Pair)

Example 90 with ExecuteBuildingBlock

use of org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock in project so by onap.

the class WorkflowAction method sortExecutionPathByObjectForVlanTagging.

protected List<ExecuteBuildingBlock> sortExecutionPathByObjectForVlanTagging(List<ExecuteBuildingBlock> orchFlows, String requestAction) {
    List<ExecuteBuildingBlock> sortedOrchFlows = new ArrayList<>();
    if (requestAction.equals(CREATE_INSTANCE)) {
        for (ExecuteBuildingBlock ebb : orchFlows) {
            if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) {
                String key = ebb.getBuildingBlock().getKey();
                boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().isVirtualLink());
                String virtualLinkKey = ebb.getBuildingBlock().getVirtualLinkKey();
                sortedOrchFlows.add(ebb);
                for (ExecuteBuildingBlock ebb2 : orchFlows) {
                    if (!isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals(CREATENETWORKBB) && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
                        sortedOrchFlows.add(ebb2);
                        break;
                    }
                    if (isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals(CREATENETWORKBB) && ebb2.getBuildingBlock().getVirtualLinkKey().equalsIgnoreCase(virtualLinkKey)) {
                        sortedOrchFlows.add(ebb2);
                        break;
                    }
                }
                for (ExecuteBuildingBlock ebb2 : orchFlows) {
                    if (!isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals(ACTIVATENETWORKBB) && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
                        sortedOrchFlows.add(ebb2);
                        break;
                    }
                    if (isVirtualLink && ebb2.getBuildingBlock().getBpmnFlowName().equals(ACTIVATENETWORKBB) && ebb2.getBuildingBlock().getVirtualLinkKey().equalsIgnoreCase(virtualLinkKey)) {
                        sortedOrchFlows.add(ebb2);
                        break;
                    }
                }
            } else if (ebb.getBuildingBlock().getBpmnFlowName().equals(CREATENETWORKBB) || ebb.getBuildingBlock().getBpmnFlowName().equals(ACTIVATENETWORKBB)) {
                continue;
            } else if (!"".equals(ebb.getBuildingBlock().getBpmnFlowName())) {
                sortedOrchFlows.add(ebb);
            }
        }
    } else if (requestAction.equals("deleteInstance")) {
        for (ExecuteBuildingBlock ebb : orchFlows) {
            if (ebb.getBuildingBlock().getBpmnFlowName().equals("DeactivateNetworkBB")) {
                sortedOrchFlows.add(ebb);
                String key = ebb.getBuildingBlock().getKey();
                for (ExecuteBuildingBlock ebb2 : orchFlows) {
                    if (ebb2.getBuildingBlock().getBpmnFlowName().equals("DeleteNetworkBB") && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
                        sortedOrchFlows.add(ebb2);
                        break;
                    }
                }
                for (ExecuteBuildingBlock ebb2 : orchFlows) {
                    if (ebb2.getBuildingBlock().getBpmnFlowName().equals("UnassignNetworkBB") && ebb2.getBuildingBlock().getKey().equalsIgnoreCase(key)) {
                        sortedOrchFlows.add(ebb2);
                        break;
                    }
                }
            } else if (ebb.getBuildingBlock().getBpmnFlowName().equals("DeleteNetworkBB") || ebb.getBuildingBlock().getBpmnFlowName().equals("UnassignNetworkBB")) {
                continue;
            } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) {
                sortedOrchFlows.add(ebb);
            }
        }
    }
    return sortedOrchFlows;
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) ArrayList(java.util.ArrayList)

Aggregations

ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)147 Test (org.junit.Test)107 ArrayList (java.util.ArrayList)86 List (java.util.List)65 BuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock)63 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)61 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)49 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)45 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)45 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)41 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)40 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)40 File (java.io.File)38 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)38 RelationshipList (org.onap.aai.domain.yang.RelationshipList)38 OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)37 Service (org.onap.so.db.catalog.beans.Service)35 HashMap (java.util.HashMap)27 VfModule (org.onap.aai.domain.yang.VfModule)25 RelatedInstanceList (org.onap.so.serviceinstancebeans.RelatedInstanceList)24