diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
3 files changed, 67 insertions, 87 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 0c31dfa16f..533dd89276 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -6,12 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * 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. @@ -151,32 +153,24 @@ public class ExecuteActivity implements JavaDelegate { } protected BuildingBlock buildBuildingBlock(String activityName) { - BuildingBlock buildingBlock = new BuildingBlock(); - buildingBlock.setBpmnFlowName(activityName); - buildingBlock.setMsoId(UUID.randomUUID().toString()); - buildingBlock.setKey(""); - buildingBlock.setIsVirtualLink(false); - buildingBlock.setVirtualLinkKey(""); + BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(activityName) + .setMsoId(UUID.randomUUID().toString()).setKey("").setIsVirtualLink(false).setVirtualLinkKey(""); return buildingBlock; } protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId, BuildingBlock buildingBlock) throws Exception { - ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); - String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); - ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); - RequestDetails requestDetails = sIRequest.getRequestDetails(); - executeBuildingBlock.setaLaCarte(true); - executeBuildingBlock.setRequestAction((String) execution.getVariable(G_ACTION)); - executeBuildingBlock.setResourceId((String) execution.getVariable(VNF_ID)); - executeBuildingBlock.setVnfType((String) execution.getVariable(VNF_TYPE)); WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID)); workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID)); - executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); - executeBuildingBlock.setRequestId(requestId); - executeBuildingBlock.setBuildingBlock(buildingBlock); - executeBuildingBlock.setRequestDetails(requestDetails); + String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); + ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); + RequestDetails requestDetails = sIRequest.getRequestDetails(); + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setaLaCarte(true) + .setRequestAction((String) execution.getVariable(G_ACTION)) + .setResourceId((String) execution.getVariable(VNF_ID)) + .setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds) + .setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails); return executeBuildingBlock; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 356fe8d9a2..8911ebf15d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -6,14 +6,14 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Copyright (C) 2019 Nokia. + * Modifications Copyright (c) 2020 Nokia * ================================================================================ * 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. @@ -75,7 +75,18 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.serviceinstancebeans.*; +import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.Networks; +import org.onap.so.serviceinstancebeans.Pnfs; +import org.onap.so.serviceinstancebeans.RelatedInstance; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; +import org.onap.so.serviceinstancebeans.Service; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.onap.so.serviceinstancebeans.VfModules; +import org.onap.so.serviceinstancebeans.Vnfs; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -274,15 +285,14 @@ public class WorkflowAction { for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, - requestDetails, false, null, false); + requestDetails, false, null, null, false); flowsToExecute.add(ebb); } } else { boolean foundRelated = false; boolean containsService = false; if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) { - // SERVICE-MACRO-ASSIGN will always get user params with - // a + // SERVICE-MACRO-ASSIGN will always get user params with a // service. if (sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { List<Map<String, Object>> userParams = @@ -300,8 +310,7 @@ public class WorkflowAction { "Service-Macro-Assign request details must contain user params with a service"); } } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - // SERVICE-MACRO-CREATE will get user params with a - // service, + // SERVICE-MACRO-CREATE will get user params with a service, // a service with a network, a service with a // networkcollection, OR an empty service. // If user params is just a service or null and macro @@ -330,8 +339,7 @@ public class WorkflowAction { || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and // SERVICE-MACRO-DELETE - // Will never get user params with service, macro will - // have + // Will never get user params with service, macro will have // to query the SI in AAI to find related instances. traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds); } else if (resourceType == WorkflowType.SERVICE @@ -368,8 +376,7 @@ public class WorkflowAction { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } - // By default, enable homing at VNF level for CREATEINSTANCE - // and ASSIGNINSTANCE + // By default, enable homing at VNF level for CREATEINSTANCE and ASSIGNINSTANCE if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())) @@ -386,8 +393,7 @@ public class WorkflowAction { } } } - // If the user set "Homing_Solution" to "none", disable homing, else - // if "Homing_Solution" is specified, + // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, // enable it. if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { @@ -540,17 +546,16 @@ public class WorkflowAction { dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID); - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), - dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), - dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), - dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, true); String vnfcName = getVnfcNameForConfiguration(configuration); if (vnfcName == null || vnfcName.isEmpty()) { buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match")); } - ebb.getConfigurationResourceKeys().setVnfcName(vnfcName); + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), + dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), + dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), + dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, vnfcName, true); flowsToExecuteConfigs.add(ebb); } } @@ -735,7 +740,7 @@ public class WorkflowAction { } ebb.setWorkflowResourceIds(workflowResourceIds); } - if (virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink() + if (virtualLinkKey != null && ebb.getBuildingBlock().isVirtualLink() && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); workflowResourceIds.setServiceInstanceId(serviceInstanceId); @@ -1323,7 +1328,7 @@ public class WorkflowAction { for (ExecuteBuildingBlock ebb : orchFlows) { if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignNetworkBB")) { String key = ebb.getBuildingBlock().getKey(); - boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().getIsVirtualLink()); + boolean isVirtualLink = Boolean.TRUE.equals(ebb.getBuildingBlock().isVirtualLink()); String virtualLinkKey = ebb.getBuildingBlock().getVirtualLinkKey(); sortedOrchFlows.add(ebb); for (ExecuteBuildingBlock ebb2 : orchFlows) { @@ -1396,7 +1401,7 @@ public class WorkflowAction { .filter(resource -> resource.getResourceType().equals(workflowType)).collect(Collectors.toList()); serviceResources.forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - isVirtualLink, resource.getVirtualLinkKey(), isConfiguration))); + isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration))); } protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows, @@ -1428,7 +1433,6 @@ public class WorkflowAction { addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, true, false); - } else if (orchFlow.getFlowName().contains(VFMODULE)) { List<Resource> vfModuleResourcesSorted = null; if (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE) @@ -1442,7 +1446,7 @@ public class WorkflowAction { for (int i = 0; i < vfModuleResourcesSorted.size(); i++) { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, vfModuleResourcesSorted.get(i), apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails, - false, null, false)); + false, null, null, false)); } } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) { if (requestAction.equalsIgnoreCase(REPLACEINSTANCE) @@ -1463,7 +1467,7 @@ public class WorkflowAction { false, true); } else { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, - requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, false)); + requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null, false)); } } return flowsToExecute; @@ -1472,46 +1476,33 @@ public class WorkflowAction { protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId, Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, - boolean isVirtualLink, String virtualLinkKey, boolean isConfiguration) { - ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); - BuildingBlock buildingBlock = new BuildingBlock(); + boolean isVirtualLink, String virtualLinkKey, String vnfcName, boolean isConfiguration) { + BuildingBlock buildingBlock = + new BuildingBlock().setBpmnFlowName(orchFlow.getFlowName()).setMsoId(UUID.randomUUID().toString()) + .setIsVirtualLink(isVirtualLink).setVirtualLinkKey(virtualLinkKey) + .setKey(Optional.ofNullable(resource).map(Resource::getResourceId).orElse("")); Optional.ofNullable(orchFlow.getBpmnAction()).ifPresent(action -> buildingBlock.setBpmnAction(action)); Optional.ofNullable(orchFlow.getBpmnScope()).ifPresent(scope -> buildingBlock.setBpmnScope(scope)); - - buildingBlock.setBpmnFlowName(orchFlow.getFlowName()); - buildingBlock.setMsoId(UUID.randomUUID().toString()); - if (resource == null) { - buildingBlock.setKey(""); - } else { - buildingBlock.setKey(resource.getResourceId()); - } - buildingBlock.setIsVirtualLink(isVirtualLink); - buildingBlock.setVirtualLinkKey(virtualLinkKey); - executeBuildingBlock.setApiVersion(apiVersion); - executeBuildingBlock.setaLaCarte(aLaCarte); - executeBuildingBlock.setRequestAction(requestAction); - if (resource != null && (orchFlow.getFlowName().contains(VOLUMEGROUP) && (requestAction.equalsIgnoreCase(REPLACEINSTANCE) || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)))) { logger.debug("Setting resourceId to volume group id for volume group flow on replace"); resourceId = workflowResourceIds.getVolumeGroupId(); } - executeBuildingBlock.setResourceId(resourceId); - executeBuildingBlock.setVnfType(vnfType); - executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); - executeBuildingBlock.setRequestId(requestId); - executeBuildingBlock.setBuildingBlock(buildingBlock); - executeBuildingBlock.setRequestDetails(requestDetails); + + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion) + .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock) + .setRequestDetails(requestDetails); + if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) { ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); - if (resource != null) { - configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); - configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); - configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); - } + Optional.ofNullable(vnfcName).ifPresent(name -> configurationResourceKeys.setVnfcName(name)); + configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId()); + configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId()); + configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId()); executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys); } return executeBuildingBlock; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 9d45272a60..ba5d283c01 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -453,21 +453,16 @@ public class WorkflowActionBBTasks { protected ExecuteBuildingBlock getExecuteBBForConfig(String bbName, ExecuteBuildingBlock ebb, String configurationId, ConfigurationResourceKeys configurationResourceKeys) { - ExecuteBuildingBlock configBB = new ExecuteBuildingBlock(); - BuildingBlock buildingBlock = new BuildingBlock(); - buildingBlock.setBpmnFlowName(bbName); - buildingBlock.setMsoId(UUID.randomUUID().toString()); - configBB.setaLaCarte(ebb.isaLaCarte()); - configBB.setApiVersion(ebb.getApiVersion()); - configBB.setRequestAction(ebb.getRequestAction()); - configBB.setVnfType(ebb.getVnfType()); - configBB.setRequestId(ebb.getRequestId()); - configBB.setRequestDetails(ebb.getRequestDetails()); - configBB.setBuildingBlock(buildingBlock); + BuildingBlock buildingBlock = + new BuildingBlock().setBpmnFlowName(bbName).setMsoId(UUID.randomUUID().toString()); + WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds(); workflowResourceIds.setConfigurationId(configurationId); - configBB.setWorkflowResourceIds(workflowResourceIds); - configBB.setConfigurationResourceKeys(configurationResourceKeys); + ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()) + .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction()) + .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId()) + .setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock) + .setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys); return configBB; } |