aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java259
1 files changed, 150 insertions, 109 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
index 6c6bd61041..3a7dd5772f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/UserParamsServiceTraversal.java
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
@@ -58,6 +59,9 @@ public class UserParamsServiceTraversal {
private final CatalogDbClient catalogDbClient;
private final ExceptionBuilder exceptionBuilder;
+ private boolean foundVfModuleOrVG;
+ private String vnfCustomizationUUID;
+ private String vfModuleCustomizationUUID;
UserParamsServiceTraversal(CatalogDbClient catalogDbClient, ExceptionBuilder exceptionBuilder) {
this.catalogDbClient = catalogDbClient;
@@ -67,131 +71,170 @@ public class UserParamsServiceTraversal {
protected List<Resource> getResourceListFromUserParams(DelegateExecution execution,
List<Map<String, Object>> userParams, String serviceModelVersionId, String requestAction)
throws IOException {
- List<Resource> resourceList = new ArrayList<>();
- boolean foundVfModuleOrVG = false;
- String vnfCustomizationUUID = "";
- String vfModuleCustomizationUUID = "";
if (userParams != null) {
for (Map<String, Object> params : userParams) {
if (params.containsKey(USER_PARAM_SERVICE)) {
ObjectMapper obj = new ObjectMapper();
String input = obj.writeValueAsString(params.get(USER_PARAM_SERVICE));
Service validate = obj.readValue(input, Service.class);
- resourceList.add(
- new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
- if (validate.getResources().getVnfs() != null) {
- for (Vnfs vnf : validate.getResources().getVnfs()) {
- resourceList.add(new Resource(WorkflowType.VNF,
- vnf.getModelInfo().getModelCustomizationId(), false));
- if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
- vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
- }
- if (vnf.getVfModules() != null) {
- for (VfModules vfModule : vnf.getVfModules()) {
- VfModuleCustomization vfModuleCustomization =
- catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(
- vfModule.getModelInfo().getModelCustomizationUuid());
- if (vfModuleCustomization != null) {
-
- if (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
- && vfModuleCustomization.getVolumeHeatEnv() != null) {
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP,
- vfModuleCustomization.getModelCustomizationUUID(), false));
- foundVfModuleOrVG = true;
- }
-
- if ((vfModuleCustomization.getVfModule() != null)
- && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
- && vfModuleCustomization.getHeatEnvironment() != null))
- || (vfModuleCustomization.getVfModule() != null
- && vfModuleCustomization.getVfModule().getModelName() != null
- && vfModuleCustomization.getVfModule().getModelName()
- .contains("helm"))) {
- foundVfModuleOrVG = true;
- Resource resource = new Resource(WorkflowType.VFMODULE,
- vfModuleCustomization.getModelCustomizationUUID(), false);
- resource.setBaseVfModule(
- vfModuleCustomization.getVfModule().getIsBase() != null
- && vfModuleCustomization.getVfModule().getIsBase());
- resourceList.add(resource);
- if (vfModule.getModelInfo() != null
- && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
- vfModuleCustomizationUUID =
- vfModule.getModelInfo().getModelCustomizationUuid();
- }
- if (!vnfCustomizationUUID.isEmpty()
- && !vfModuleCustomizationUUID.isEmpty()) {
- List<CvnfcConfigurationCustomization> configs =
- traverseCatalogDbForConfiguration(
- validate.getModelInfo().getModelVersionId(),
- vnfCustomizationUUID, vfModuleCustomizationUUID);
- for (CvnfcConfigurationCustomization config : configs) {
- Resource configResource = new Resource(WorkflowType.CONFIGURATION,
- config.getConfigurationResource().getModelUUID(), false);
- resource.setVnfCustomizationId(
- vnf.getModelInfo().getModelCustomizationId());
- resource.setVfModuleCustomizationId(
- vfModule.getModelInfo().getModelCustomizationId());
- resourceList.add(configResource);
- }
- }
- }
- if (!foundVfModuleOrVG) {
- buildAndThrowException(execution,
- "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
- }
- }
- }
- }
- }
- }
- if (validate.getResources().getPnfs() != null) {
- for (Pnfs pnf : validate.getResources().getPnfs()) {
- resourceList.add(new Resource(WorkflowType.PNF,
- pnf.getModelInfo().getModelCustomizationId(), false));
- }
- }
- if (validate.getResources().getNetworks() != null) {
- for (Networks network : validate.getResources().getNetworks()) {
- resourceList.add(new Resource(WorkflowType.NETWORK,
- network.getModelInfo().getModelCustomizationId(), false));
- }
- if (requestAction.equals(CREATE_INSTANCE)) {
- String networkColCustId =
- queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
- if (networkColCustId != null) {
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
- }
- }
- }
- break;
+ return getResourceList(execution, serviceModelVersionId, requestAction, validate);
}
}
}
+ return Collections.emptyList();
+ }
+
+ private List<Resource> getResourceList(DelegateExecution execution, String serviceModelVersionId,
+ String requestAction, Service validate) {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
+ if (validate.getResources().getVnfs() != null) {
+ setResourceListForVnfs(execution, resourceList, validate);
+ }
+ if (validate.getResources().getPnfs() != null) {
+ setResourceListForPnfs(resourceList, validate);
+ }
+ if (validate.getResources().getNetworks() != null) {
+ setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, validate);
+ }
return resourceList;
}
+ private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Service validate) {
+ for (Vnfs vnf : validate.getResources().getVnfs()) {
+ setVnfCustomizationUUID(vnf);
+ resourceList.add(new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false));
+ setResourceListForVfModules(execution, resourceList, validate, vnf);
+ }
+ }
- private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID,
- String vnfCustomizationUUID, String vfModuleCustomizationUUID) {
- List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
- try {
- List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
- vnfCustomizationUUID, vfModuleCustomizationUUID);
- for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
- for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
- if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
- configurations.add(customization);
+ private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList, Service validate,
+ Vnfs vnf) {
+ if (vnf.getVfModules() != null) {
+ for (VfModules vfModule : vnf.getVfModules()) {
+ setVfModuleCustomizationUUID(vfModule);
+ VfModuleCustomization vfModuleCustomization =
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID);
+ if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null) {
+ setVolumeGroupWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
+ setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule,
+ vfModuleCustomization);
+ if (!foundVfModuleOrVG) {
+ buildAndThrowException(execution,
+ "Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
}
}
}
- logger.debug("found {} fabric configuration(s)", configurations.size());
- return configurations;
+ }
+ }
+
+ private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList,
+ VfModuleCustomization vfModuleCustomization) {
+ if (vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
+ && vfModuleCustomization.getVolumeHeatEnv() != null) {
+ foundVfModuleOrVG = true;
+ resourceList.add(
+ new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), false));
+ }
+ }
+
+ private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate,
+ Vnfs vnf, VfModules vfModule, VfModuleCustomization vfModuleCustomization) {
+ if ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
+ && vfModuleCustomization.getHeatEnvironment() != null)
+ || (vfModuleCustomization.getVfModule().getModelName() != null
+ && vfModuleCustomization.getVfModule().getModelName().contains("helm"))) {
+ foundVfModuleOrVG = true;
+ Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
+ setConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule, resource);
+ }
+ }
+
+ private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList,
+ VfModuleCustomization vfModuleCustomization) {
+ Resource resource =
+ new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), false);
+ resource.setBaseVfModule(vfModuleCustomization.getVfModule().getIsBase() != null
+ && vfModuleCustomization.getVfModule().getIsBase());
+ resourceList.add(resource);
+ return resource;
+ }
+
+ private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate, Vnfs vnf,
+ VfModules vfModule, Resource resource) {
+ if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) {
+ List<CvnfcConfigurationCustomization> configs =
+ traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId());
+ for (CvnfcConfigurationCustomization config : configs) {
+ Resource configResource = new Resource(WorkflowType.CONFIGURATION,
+ config.getConfigurationResource().getModelUUID(), false);
+ resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
+ resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
+ resourceList.add(configResource);
+ }
+ }
+ }
+
+ private void setVfModuleCustomizationUUID(VfModules vfModule) {
+ if (vfModule.getModelInfo() != null && vfModule.getModelInfo().getModelCustomizationUuid() != null) {
+ vfModuleCustomizationUUID = vfModule.getModelInfo().getModelCustomizationUuid();
+ } else {
+ vfModuleCustomizationUUID = "";
+ }
+ }
+
+ private void setVnfCustomizationUUID(Vnfs vnf) {
+ if (vnf.getModelInfo() != null && vnf.getModelInfo().getModelCustomizationUuid() != null) {
+ vnfCustomizationUUID = vnf.getModelInfo().getModelCustomizationUuid();
+ } else {
+ vnfCustomizationUUID = "";
+ }
+ }
+
+ private void setResourceListForPnfs(List<Resource> resourceList, Service validate) {
+ for (Pnfs pnf : validate.getResources().getPnfs()) {
+ resourceList.add(new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false));
+ }
+ }
+
+ private void setResourceListForNetworks(DelegateExecution execution, String serviceModelVersionId,
+ String requestAction, List<Resource> resourceList, Service validate) {
+ for (Networks network : validate.getResources().getNetworks()) {
+ resourceList
+ .add(new Resource(WorkflowType.NETWORK, network.getModelInfo().getModelCustomizationId(), false));
+ }
+ if (requestAction.equals(CREATE_INSTANCE)) {
+ String networkColCustId = queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
+ if (networkColCustId != null) {
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
+ }
+ }
+ }
+
+
+ private List<CvnfcConfigurationCustomization> traverseCatalogDbForConfiguration(String serviceModelUUID) {
+ try {
+ List<CvnfcCustomization> cvnfcCustomizations = catalogDbClient.getCvnfcCustomization(serviceModelUUID,
+ vnfCustomizationUUID, vfModuleCustomizationUUID);
+ return getCvnfcConfigurationCustomizations(cvnfcCustomizations);
} catch (Exception ex) {
logger.error("Error in finding configurations", ex);
- return configurations;
+ return Collections.emptyList();
+ }
+ }
+
+ private List<CvnfcConfigurationCustomization> getCvnfcConfigurationCustomizations(
+ List<CvnfcCustomization> cvnfcCustomizations) {
+ List<CvnfcConfigurationCustomization> configurations = new ArrayList<>();
+ for (CvnfcCustomization cvnfc : cvnfcCustomizations) {
+ for (CvnfcConfigurationCustomization customization : cvnfc.getCvnfcConfigurationCustomization()) {
+ if (customization.getConfigurationResource().getToscaNodeType().contains(FABRIC_CONFIGURATION)) {
+ configurations.add(customization);
+ }
+ }
}
+ logger.debug("found {} fabric configuration(s)", configurations.size());
+ return configurations;
}
private String queryCatalogDbForNetworkCollection(DelegateExecution execution, String serviceModelVersionId) {
@@ -216,9 +259,7 @@ public class UserParamsServiceTraversal {
count++;
}
}
- if (count == 0) {
- return null;
- } else if (count > 1) {
+ if (count > 1) {
buildAndThrowException(execution,
"Found multiple Network Collections in the Service model, only one per Service is supported.");
}