aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-moi/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-moi/src/main/java/org')
-rw-r--r--bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java335
-rw-r--r--bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java73
-rw-r--r--bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java208
-rw-r--r--bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java186
-rw-r--r--bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java279
-rw-r--r--bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java94
6 files changed, 1175 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java
new file mode 100644
index 0000000000..1ef073ca68
--- /dev/null
+++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasks.java
@@ -0,0 +1,335 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2022 Deutsche telekom
+ * ================================================================================
+ * 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.moi.tasks;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.aai.domain.yang.*;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.moi.util.AAISliceProfileUtil;
+import org.onap.so.bpmn.moi.util.SliceProfileAaiToMoiMapperUtil;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.moi.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+public class AssignRANNssiBBTasks {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AssignRANNssiBBTasks.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
+
+ @Autowired
+ AAISliceProfileUtil aaiSliceProfileUtil;
+
+ @Autowired
+ private SliceProfileAaiToMoiMapperUtil mapperUtil;
+
+ public void createNssi(BuildingBlockExecution execution) throws Exception {
+
+
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+
+ ModelInfoServiceInstance modelInfoServiceInstance = gBB.getServiceInstance().getModelInfoServiceInstance();
+
+ // for NON-SHARED check if its Already present
+ if (checkNSSI(execution)) {
+ if (aaiSliceProfileUtil.getServiceInstance(execution).isPresent()) {
+ throw new RuntimeException("Invalid NSSI, Slice subnet already exists");
+ }
+ }
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId(serviceInstanceId);
+ serviceInstance.setServiceInstanceName("ran_" + serviceInstanceId);
+ serviceInstance.setOrchestrationStatus("Assigned");
+ serviceInstance.setServiceType("nssi");
+ serviceInstance.setModelInvariantId(modelInfoServiceInstance.getModelInvariantUuid());
+ serviceInstance.setModelVersionId(modelInfoServiceInstance.getModelUuid());
+ serviceInstance.setOperationalStatus("LOCKED");
+
+ Customer customer = getCustomer(execution);
+
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(serviceInstance.getServiceInstanceId()));
+
+ injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(serviceInstance));
+
+ }
+
+ private boolean checkNSSI(BuildingBlockExecution execution) {
+
+ Optional<ServiceInstance> serviceInstance = aaiSliceProfileUtil.getServiceInstance(execution);
+
+
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+
+ List<Map<String, Object>> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams();
+
+
+ Attributes attributes = null;
+
+ for (Map<String, Object> userParamData : mapUserParams) {
+ if (userParamData.get("nssi") != null) {
+ Map<String, Object> mapParam = (Map<String, Object>) userParamData.get("nssi");
+ attributes = mapper.convertValue(mapParam, Attributes.class);
+ }
+ }
+ if (attributes.getSliceProfileList().get(0).getRANSliceSubnetProfile().getResourceSharingLevel()
+ .equalsIgnoreCase("NON-SHARED"))
+ return true;
+ else
+ return false;
+ }
+
+
+ public void createSliceProfileInstance(BuildingBlockExecution execution) {
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+
+ Customer customer = getCustomer(execution);
+
+ List<Map<String, Object>> mapUserParams = gBB.getRequestContext().getRequestParameters().getUserParams();
+
+
+ Attributes attributes = null;
+
+ for (Map<String, Object> userParamData : mapUserParams) {
+ if (userParamData.get("nssi") != null) {
+ Map<String, Object> mapParam = (Map<String, Object>) userParamData.get("nssi");
+ attributes = mapper.convertValue(mapParam, Attributes.class);
+ }
+ }
+ // Create SliceProfile Instance
+ ServiceInstance sliceProfileServiceInstance = new ServiceInstance();
+ String sliceProfileInstanceId = UUID.randomUUID().toString();
+ sliceProfileServiceInstance.setServiceInstanceId(sliceProfileInstanceId);
+ sliceProfileServiceInstance.setServiceInstanceName("slice-profile-" + serviceInstanceId);
+ sliceProfileServiceInstance.setServiceRole("slice-profile");
+
+ sliceProfileServiceInstance =
+ mapperUtil.fillSliceProfileInstanceFromMoiRequest(attributes, sliceProfileServiceInstance);
+
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(sliceProfileServiceInstance.getServiceInstanceId()));
+
+ injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(sliceProfileServiceInstance));
+
+ List<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams();
+
+ // sliceProfile
+ SliceProfile sliceProfile = mapperUtil.extractAaiSliceProfileFromMoiRequest(attributes);
+ String sliceProfileId = UUID.randomUUID().toString();
+ sliceProfile.setProfileId(sliceProfileId);
+
+ AAIResourceUri sliceProfileURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(sliceProfileInstanceId).sliceProfile(sliceProfile.getProfileId()));
+
+ injectionHelper.getAaiClient().createIfNotExists(sliceProfileURI, Optional.of(sliceProfile));
+
+ execution.setVariable("sliceProfileServiceInstanceId", sliceProfileServiceInstance.getServiceInstanceId());
+ }
+
+ public void allotResources(BuildingBlockExecution execution) {
+
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String sliceProfileServiceInstanceId = execution.getVariable("sliceProfileServiceInstanceId");
+
+ LOGGER.debug("sliceProfileServiceInstanceId: {}", sliceProfileServiceInstanceId);
+
+ Customer customer = getCustomer(execution);
+
+ org.onap.aai.domain.yang.v23.AllottedResource allottedResource =
+ new org.onap.aai.domain.yang.v23.AllottedResource();
+
+ UUID allottedResourceUuid = UUID.randomUUID();
+ allottedResource.setId(allottedResourceUuid.toString());
+
+ AAIResourceUri allotedResourceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(sliceProfileServiceInstanceId).allottedResource(allottedResource.getId()));
+
+ injectionHelper.getAaiClient().createIfNotExists(allotedResourceURI, Optional.of(allottedResource));
+
+ execution.setVariable("allottedResourceUuid", allottedResource.getId());
+
+ }
+
+
+ public void addSliceProfileToNssi(BuildingBlockExecution execution) {
+ LOGGER.info("Entering into addSliceProfileToNssi");
+
+ String sliceProfileServiceInstanceId = execution.getVariable("sliceProfileServiceInstanceId");
+ String allottedResourceUuid = execution.getVariable("allottedResourceUuid");
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+
+ Customer customer = getCustomer(execution);
+
+
+ AAIResourceUri nssiUri =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(serviceInstanceId));
+
+ AAIResourceUri allotedResourceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(sliceProfileServiceInstanceId).allottedResource(allottedResourceUuid));
+
+ try {
+ injectionHelper.getAaiClient().connect(allotedResourceURI, nssiUri);
+ } catch (Exception e) {
+ LOGGER.error(">>>>> Error in creating Relationship: {} ", e);
+ }
+ }
+
+ public void activateNssi(BuildingBlockExecution execution) {
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+
+ Customer customer = getCustomer(execution);
+
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(serviceInstanceId));
+
+ Optional<ServiceInstance> serviceInstanceReturned =
+ injectionHelper.getAaiClient().get(ServiceInstance.class, serviceInstanceURI);
+
+ ServiceInstance serviceInstance = null;
+ if (serviceInstanceReturned.isPresent()) {
+ serviceInstance = serviceInstanceReturned.get();
+ serviceInstance.setOperationalStatus("UNLOCKED");
+ serviceInstance.setOrchestrationStatus("Active");
+
+ try {
+ injectionHelper.getAaiClient().update(serviceInstanceURI, serviceInstance);
+ } catch (Exception e) {
+ LOGGER.error("Nssi couldnot be activated: {}", e);
+ }
+ } else {
+ LOGGER.debug("Service Instance not present with Id: {}", serviceInstanceId);
+ }
+
+ // SliceProfile
+ List<org.onap.so.moi.SliceProfile> sliceProfileList = new ArrayList<org.onap.so.moi.SliceProfile>();
+ ServiceInstance serviceInstanceObj;
+ List<Relationship> listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship();
+
+ List<Relationship> listOfNssiRelationshipAR = listOfNssiRelationship.stream()
+ .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource"))
+ .collect(Collectors.toList());
+
+ for (Relationship relationship : listOfNssiRelationshipAR) {
+ org.onap.so.moi.SliceProfile sliceProfile = new org.onap.so.moi.SliceProfile();
+ for (RelationshipData relationshipData : relationship.getRelationshipData()) {
+ if (relationshipData.getRelationshipKey().equalsIgnoreCase("service-instance.service-instance-id")) {
+ String sliceProfileInstanceId = relationshipData.getRelationshipValue();
+
+ Optional<ServiceInstance> sliceProfileServiceInstance =
+ aaiRestClient.getServiceInstanceById(sliceProfileInstanceId, "5G", "5GCustomer");
+ if (sliceProfileServiceInstance.isPresent()) {
+ ServiceInstance sliceProflieInstance = sliceProfileServiceInstance.get();
+ sliceProflieInstance.setOperationalStatus("UNLOCKED");
+ sliceProflieInstance.setOrchestrationStatus("ACTIVE");
+
+ AAIResourceUri sliceProfileInstanceURI = AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(customer.getServiceSubscriptions().getServiceSubscription()
+ .get(0).getServiceType())
+ .serviceInstance(sliceProflieInstance.getServiceInstanceId()));
+ try {
+ injectionHelper.getAaiClient().update(sliceProfileInstanceURI, sliceProflieInstance);
+ } catch (Exception e) {
+ LOGGER.error("SliceProfile couldnot be activated: {}", e);
+ }
+ } else {
+ LOGGER.debug("Slice Profile Instance not present with Id: {}", serviceInstanceId);
+ }
+
+
+ }
+ }
+
+ }
+ }
+
+
+ private Customer getCustomer(BuildingBlockExecution execution) {
+
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String serviceType = gBB.getCustomer().getServiceSubscription().getServiceType();
+
+ String globalCustomerId = gBB.getCustomer().getGlobalCustomerId();
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType(serviceType);
+
+ ServiceSubscriptions serviceSubscriptions = new ServiceSubscriptions();
+ serviceSubscriptions.getServiceSubscription().add(serviceSubscription);
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId(globalCustomerId);
+ customer.setServiceSubscriptions(serviceSubscriptions);
+
+ return customer;
+
+ }
+
+}
diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java
new file mode 100644
index 0000000000..f464ed23f3
--- /dev/null
+++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTask.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2022 Deutsche telekom
+ * ================================================================================
+ * 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.moi.tasks;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.moi.util.AAISliceProfileUtil;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+@Component
+public class DeleteRANNssiBBTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(DeleteRANNssiBBTask.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ AAISliceProfileUtil aaiSliceProfileUtil;
+
+ private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+
+ public void deleteNssi(BuildingBlockExecution execution) throws JsonProcessingException {
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+ List<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams();
+ String sliceProfileIdFromRequest = mapUserParamsToSliceProfile(sliceProfilesData);
+ aaiSliceProfileUtil.deleteSliceProfile(execution, sliceProfileIdFromRequest);
+ }
+
+
+
+ private String mapUserParamsToSliceProfile(List<Map<String, Object>> sliceProfilesData)
+ throws JsonProcessingException {
+ Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi");
+ List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList");
+ Map<String, Object> idMap = (Map<String, Object>) list.get(0);
+ String sliceProfileId = (String) idMap.get("sliceProfileId");
+ return sliceProfileId;
+ }
+
+}
diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java
new file mode 100644
index 0000000000..4247b242bf
--- /dev/null
+++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTask.java
@@ -0,0 +1,208 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2022 Deutsche telekom
+ * ================================================================================
+ * 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.moi.tasks;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.common.InjectExecution;
+import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.onap.so.bpmn.common.scripts.OofUtils;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.moi.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class EnrichGBBTask {
+
+ private static final String EXECUTE_BB_VAR_NAME = "buildingBlock";
+ private static final String GBB_INPUT_VAR_NAME = "gBBInput";
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil();
+ JsonUtils jsonUtil = new JsonUtils();
+
+ @Autowired
+ CatalogDbClient catalogDbClient;
+
+ InjectExecution injectExecution = new InjectExecution();
+
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(EnrichGBBTask.class);
+ private static final ObjectMapper mapper = new ObjectMapper();
+ OofUtils oofUtils = new OofUtils(null);
+
+ public void prepareOofRequest(DelegateExecution execution) throws Exception {
+
+ String msoReqId = (String) execution.getVariable("mso-request-id");
+
+
+ BuildingBlockExecution gBuildingBlockExecution =
+ (BuildingBlockExecution) execution.getVariable("gBuildingBlockExecution");
+
+ DelegateExecutionImpl gbbEx = injectExecution.execute(execution,
+ (DelegateExecutionImpl) execution.getVariable("gBuildingBlockExecution"));
+
+
+ GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput");
+
+ List<Map<String, Object>> mapUserParams =
+ generalBuildingBlock.getRequestContext().getRequestParameters().getUserParams();
+
+ Attributes attributes = null;
+
+ for (Map<String, Object> userParamData : mapUserParams) {
+ if (userParamData.get("nssi") != null) {
+ Map<String, Object> mapParam = (Map<String, Object>) userParamData.get("nssi");
+ LOGGER.info(">>> mapParam: {}", mapParam);
+ attributes = mapper.convertValue(mapParam, Attributes.class);
+ }
+ }
+ // Attributes attributes = new ObjectMapper().convertValue(attrMap, Attributes.class);
+ Integer latency = attributes.getSliceProfileList().get(0).getRANSliceSubnetProfile().getLatency();
+ Integer areaTrafficCapDL =
+ attributes.getSliceProfileList().get(0).getRANSliceSubnetProfile().getAreaTrafficCapDL();
+
+
+ String requestId = generalBuildingBlock.getRequestContext().getMsoRequestId();
+
+ // API Path
+ String apiPath = "/api/oof/v1/selection/nsst";
+ LOGGER.debug("API path for NSST Selection: " + apiPath);
+ execution.setVariable("NSST_apiPath", apiPath);
+
+ // Setting correlator as requestId
+ execution.setVariable("NSST_correlator", requestId);
+
+ // Setting messageType for all Core slice as an
+ String messageType = "an";
+ execution.setVariable("NSST_messageType", messageType);
+
+ String timeout = "PT30M";
+ execution.setVariable("NSST_timeout", timeout);
+
+ Map<String, Object> profileInfo = new HashMap<>();
+ profileInfo.put("latency", latency);
+ profileInfo.put("areaTrafficCapDL", areaTrafficCapDL);
+
+ String oofRequest = oofUtils.buildSelectNSTRequest(requestId, messageType, profileInfo);
+ LOGGER.debug("**** OOfRequest for NSST Selection: " + oofRequest);
+ execution.setVariable("NSST_oofRequest", oofRequest);
+ }
+
+
+ public void processOOFAsyncResponse(DelegateExecution execution) {
+ GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput");
+
+ LOGGER.debug(">>>> generalBuildingBlock Initial: {}", generalBuildingBlock);
+
+ LOGGER.debug(" **** Enter EnrichGBB ::: processOOFAsyncResponse ****");
+ String OOFResponse = (String) execution.getVariable("NSST_asyncCallbackResponse");
+ String requestStatus = jsonUtil.getJsonValue(OOFResponse, "requestStatus");
+ LOGGER.debug("NSST OOFResponse is: " + OOFResponse);
+ execution.setVariable("OOFResponse", OOFResponse);
+ String solutions = "";
+ if (requestStatus.equals("completed")) {
+ List solutionsList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(OOFResponse, "solutions"));
+ if (solutionsList != null && !solutionsList.isEmpty()) {
+ solutions = (String) solutionsList.get(0);
+ }
+ } else {
+ String statusMessage = jsonUtil.getJsonValue(OOFResponse, "statusMessage");
+ LOGGER.error("received failed status from oof " + statusMessage);
+ LOGGER.debug("received failed status from oof " + statusMessage);
+ }
+
+ LOGGER.debug(">>>>>> solutions: {}", solutions);
+
+ String nsstId = jsonUtil.getJsonValue(solutions, "UUID");
+ LOGGER.info(">>> nsstId:{} ", nsstId);
+
+ Service service = catalogDbClient.getServiceByModelUUID(nsstId);
+
+ LOGGER.info("Service from CatalogDB: {}", service);
+
+ LOGGER.debug(">>> Map Incoming Values to GBB");
+
+ ServiceInstance serviceInstance = generalBuildingBlock.getServiceInstance();
+
+ ModelInfoServiceInstance modelInfoServiceInstanceFromGBB = serviceInstance.getModelInfoServiceInstance();
+
+ if (modelInfoServiceInstanceFromGBB == null) {
+ String modelInvariantId = service.getModelInvariantUUID();
+ String modelVersion = service.getModelVersion();
+ String serviceType = service.getServiceType();
+ String serviceRole = service.getServiceRole();
+ String controllerActor = service.getControllerActor();
+ String blueprintName = service.getBlueprintName();
+ String blueprintVersion = service.getBlueprintVersion();
+
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelUuid("ad2233a2-6e3f-42cf-8c60-04e614031383");
+ modelInfoServiceInstance.setModelInvariantUuid("38730fb9-bfbb-4a78-88f8-b4f6823197b6");
+ modelInfoServiceInstance.setModelVersion("1.0");
+ modelInfoServiceInstance.setServiceRole("AN");
+ modelInfoServiceInstance.setServiceType("eMBB");
+ modelInfoServiceInstance.setBlueprintVersion("1.0.0");
+ modelInfoServiceInstance.setControllerActor("CDS");
+ modelInfoServiceInstance.setBlueprintName("Hello_World_CBA");
+ modelInfoServiceInstance.setServiceType(serviceType);
+ modelInfoServiceInstance.setServiceRole(serviceRole);
+ modelInfoServiceInstance.setControllerActor(controllerActor);
+ modelInfoServiceInstance.setBlueprintName(blueprintName);
+ modelInfoServiceInstance.setBlueprintVersion(blueprintVersion);
+ modelInfoServiceInstance.setModelInvariantUuid(modelInvariantId);
+ modelInfoServiceInstance.setModelUuid(nsstId);
+ modelInfoServiceInstance.setModelVersion(modelVersion);
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+
+
+ }
+
+ LOGGER.info(">>> ServiceInstance: {}", serviceInstance);
+
+ generalBuildingBlock.setServiceInstance(serviceInstance);
+
+ LOGGER.debug("generalBuildingBlock: {}", generalBuildingBlock);
+
+ execution.setVariable(GBB_INPUT_VAR_NAME, generalBuildingBlock);
+ BuildingBlockExecution gBuildingBlockExecution1 = new DelegateExecutionImpl(execution);
+ execution.setVariable("gBuildingBlockExecution", gBuildingBlockExecution1);
+
+ // execution.setVariable("gBuildingBlockExecution", gBBExecution);
+ LOGGER.debug(" **** Exit EnrichBB ::: processOOFAsyncResponse ****");
+ }
+}
diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java
new file mode 100644
index 0000000000..eba35673e1
--- /dev/null
+++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTask.java
@@ -0,0 +1,186 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2022 Deutsche telekom
+ * ================================================================================
+ * 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.moi.tasks;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.SliceProfile;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.moi.util.AAISliceProfileUtil;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.moi.PlmnInfo;
+import org.onap.so.moi.RANSliceSubnetProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+
+@Component
+public class ModifyRANNssiBBTask {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModifyRANNssiBBTask.class);
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAISliceProfileUtil aaiSliceProfileUtil;
+
+ private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+
+ public void modifyNssi(BuildingBlockExecution execution) throws JsonProcessingException {
+ LOGGER.info("Modify NSSI");
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+ List<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams();
+
+ SliceProfile updatedSliceProfile = mapUserParamsToSliceProfile(sliceProfilesData);
+ String sliceProfileIdFromRequest = getSliceProfileIdFromReq(sliceProfilesData);
+ aaiSliceProfileUtil.updateSliceProfile(execution, sliceProfileIdFromRequest, updatedSliceProfile);
+
+
+
+ }
+
+ private ServiceInstance mapUserParamsToServiceInstance(ServiceInstance sliceProfileServiceInstanceObj,
+ List<Map<String, Object>> sliceProfilesData) {
+ Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi");
+ LOGGER.info(">>> mapParam: {}", mapParam);
+
+ // update administrative State
+ String administrativeState = (String) mapParam.get("administrativeState");
+ LOGGER.info(">>> administrativeState: {}", administrativeState);
+ sliceProfileServiceInstanceObj.setOperationalStatus(administrativeState);
+
+ List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList");
+ LOGGER.info(">>> sliceProfile List: {}", list);
+ Map<String, Object> idMap = (Map<String, Object>) list.get(0);
+ LOGGER.info("Keys of Id Map {} ", idMap.keySet());
+
+ // PlmnInfoList
+ for (String key : idMap.keySet()) {
+ if (key.equalsIgnoreCase("plmnInfoList")) {
+ PlmnInfo plmnInfo = mapper.convertValue(mapParam, PlmnInfo.class);
+ LOGGER.info("PlmnInfo {}", plmnInfo.getPlmnId().getMcc() + "-" + plmnInfo.getPlmnId().getMnc());
+ LOGGER.info("Snssai {} ", plmnInfo.getSnssai().getSst() + "-" + plmnInfo.getSnssai().getSd());
+ sliceProfileServiceInstanceObj.setServiceInstanceLocationId(
+ plmnInfo.getPlmnId().getMcc() + "-" + plmnInfo.getPlmnId().getMnc());
+ sliceProfileServiceInstanceObj
+ .setEnvironmentContext(plmnInfo.getSnssai().getSst() + "-" + plmnInfo.getSnssai().getSd());
+ }
+ }
+ return sliceProfileServiceInstanceObj;
+ }
+
+ SliceProfile mapUserParamsToSliceProfile(List<Map<String, Object>> sliceProfilesData)
+ throws JsonProcessingException {
+ SliceProfile sliceProfile = new SliceProfile();
+ Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi");
+ LOGGER.info(">>> mapParam in map: {}", mapParam);
+
+ List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList");
+
+ Map<String, Object> idMap = (Map<String, Object>) list.get(0);
+
+ String sliceProfileId = (String) idMap.get("sliceProfileId");
+
+ sliceProfile.setProfileId(sliceProfileId);
+ RANSliceSubnetProfile ranSliceSubnetProfile = mapper.convertValue(mapParam, RANSliceSubnetProfile.class);
+
+
+ for (String key : idMap.keySet()) {
+ if (key.equalsIgnoreCase("RANSliceSubnetProfile")) {
+ RANSliceSubnetProfile RANSliceSubnetProfile =
+ mapper.convertValue(mapParam, RANSliceSubnetProfile.class);
+ LOGGER.info("RANSliceSubnetProfile inside {}", RANSliceSubnetProfile);
+ Map<String, Object> ranMap = (Map<String, Object>) idMap.get(key);
+ ranMap.forEach((k, v) -> {
+ LOGGER.info("Key : {}", k);
+ switch (k) {
+ case "coverageAreaTAList":
+ Integer coverageAreaTAList = (Integer) ranMap.get(k);
+ LOGGER.info("coverageAreaTAList {}", coverageAreaTAList);
+ sliceProfile.setCoverageAreaTAList(coverageAreaTAList.toString());
+ break;
+
+ case "latency":
+ Integer latency = (Integer) ranMap.get(k);
+ LOGGER.info("latency {}", latency);
+ sliceProfile.setLatency(latency);
+ break;
+
+ case "dLLatency":
+ Integer dLLatency = (Integer) ranMap.get(k);
+ LOGGER.info("dLLatency {}", dLLatency);
+ sliceProfile.setLatency(dLLatency);
+ break;
+
+ case "areaTrafficCapDL":
+ Integer areaTrafficCapDL = (Integer) ranMap.get(k);
+ LOGGER.info("areaTrafficCapDL {}", areaTrafficCapDL);
+ sliceProfile.setAreaTrafficCapDL(areaTrafficCapDL);
+ break;
+
+ case "resourceSharingLevel":
+ String resourceSharingLevel = (String) ranMap.get(k);
+ LOGGER.info("resourceSharingLevel {}", resourceSharingLevel);
+ sliceProfile.setResourceSharingLevel(resourceSharingLevel);
+ break;
+
+ case "maxNumberofUEs":
+ Integer maxNumberofUEs = (Integer) ranMap.get(k);
+ LOGGER.info("maxNumberofUEs {}", maxNumberofUEs);
+ sliceProfile.setMaxNumberOfUEs(maxNumberofUEs);
+ break;
+
+ }
+ });
+ }
+ }
+ return sliceProfile;
+ }
+
+ private String getSliceProfileIdFromReq(List<Map<String, Object>> sliceProfilesData)
+ throws JsonProcessingException {
+ Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi");
+
+ List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList");
+
+ Map<String, Object> idMap = (Map<String, Object>) list.get(0);
+ String sliceProfileId = (String) idMap.get("sliceProfileId");
+
+ return sliceProfileId;
+ }
+
+
+}
diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java
new file mode 100644
index 0000000000..a23fec8cc7
--- /dev/null
+++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/AAISliceProfileUtil.java
@@ -0,0 +1,279 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2022 Deutsche telekom
+ * ================================================================================
+ * 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.moi.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.aai.domain.yang.*;
+import org.onap.aaiclient.client.aai.AAIRestClientImpl;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+@Component
+public class AAISliceProfileUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AAISliceProfileUtil.class);
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
+
+
+ public Optional<ServiceInstance> getServiceInstance(BuildingBlockExecution execution) {
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+ String serviceInstanceId = gBB.getServiceInstance().getServiceInstanceId();
+ Customer customer = getCustomer(execution);
+
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(serviceInstanceId));
+ return injectionHelper.getAaiClient().get(ServiceInstance.class, serviceInstanceURI);
+ }
+
+ public void deleteSliceProfile(BuildingBlockExecution execution, String profileId) {
+ Optional<ServiceInstance> getServiceInstance = getServiceInstance(execution);
+ if (getServiceInstance.isPresent()) {
+ ServiceInstance serviceInstance = getServiceInstance.get();
+ String NssiId = serviceInstance.getServiceInstanceId();
+ LOGGER.info("NSSID {}", NssiId);
+ List<Relationship> listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship();
+
+ List<Relationship> listOfNssiRelationshipAR = listOfNssiRelationship.stream()
+ .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource"))
+ .collect(Collectors.toList());
+ int size = listOfNssiRelationshipAR.size();
+
+ List<SliceProfile> sliceProfileList;
+ LOGGER.info("ProfileID from Request: {}", profileId);
+ boolean isDeleted = false;
+ for (Relationship relationship : listOfNssiRelationshipAR) {
+ for (RelationshipData relationshipData : relationship.getRelationshipData()) {
+ if (relationshipData.getRelationshipKey()
+ .equalsIgnoreCase("service-instance.service-instance-id")) {
+ String sliceProfileInstanceId = relationshipData.getRelationshipValue();
+ LOGGER.debug(">>> sliceProfileInstance: {}", sliceProfileInstanceId);
+ Optional<ServiceInstance> sliceProfile1 = aaiRestClient
+ .getServiceInstanceByIdWithDepth(sliceProfileInstanceId, "5G", "5GCustomer");
+ if (sliceProfile1.isPresent()) {
+ sliceProfileList = sliceProfile1.get().getSliceProfiles().getSliceProfile();
+ LOGGER.info("sliceProfileList {}", sliceProfileList);
+ for (SliceProfile slice : sliceProfileList) {
+ if (slice.getProfileId().equalsIgnoreCase(profileId)) {
+ LOGGER.info("ProfileID matched Deleting slice profile");
+ deleteSliceProfileFromAAI(sliceProfileInstanceId, size, execution, NssiId);
+ isDeleted = true;
+ break;
+ }
+ }
+ }
+ }
+ if (isDeleted)
+ break;
+ }
+ if (isDeleted)
+ break;
+ }
+ }
+ }
+
+ public void updateSliceProfile(BuildingBlockExecution execution, String profileId, SliceProfile updatedSlice) {
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+ List<Map<String, Object>> sliceProfilesData = gBB.getRequestContext().getRequestParameters().getUserParams();
+ LOGGER.info(">>> mapParam: {}", sliceProfilesData);
+
+ Optional<ServiceInstance> getServiceInstance = getServiceInstance(execution);
+ if (getServiceInstance.isPresent()) {
+ ServiceInstance serviceInstance = getServiceInstance.get();
+ List<Relationship> listOfNssiRelationship = serviceInstance.getRelationshipList().getRelationship();
+
+ List<Relationship> listOfNssiRelationshipAR = listOfNssiRelationship.stream()
+ .filter(relationship -> relationship.getRelatedTo().equalsIgnoreCase("allotted-resource"))
+ .collect(Collectors.toList());
+
+ List<SliceProfile> sliceProfileList;
+ LOGGER.info("ProfileID : {}", profileId);
+ for (Relationship relationship : listOfNssiRelationshipAR) {
+ for (RelationshipData relationshipData : relationship.getRelationshipData()) {
+ if (relationshipData.getRelationshipKey()
+ .equalsIgnoreCase("service-instance.service-instance-id")) {
+ String sliceProfileInstanceId = relationshipData.getRelationshipValue();
+ LOGGER.debug(">>> sliceProfileInstance: {}", sliceProfileInstanceId);
+
+ Optional<ServiceInstance> sliceProfile1 = aaiRestClient
+ .getServiceInstanceByIdWithDepth(sliceProfileInstanceId, "5G", "5GCustomer");
+
+ Optional<ServiceInstance> sliceProfileInstanceNodepth =
+ aaiRestClient.getServiceInstanceById(sliceProfileInstanceId, "5G", "5GCustomer");
+
+ if (sliceProfile1.isPresent()) {
+ sliceProfileList = sliceProfile1.get().getSliceProfiles().getSliceProfile();
+ int size = sliceProfileList.size();
+ ServiceInstance updatedSliceInstance = sliceProfileInstanceNodepth.get();
+
+ for (SliceProfile slice : sliceProfileList) {
+ if (slice.getProfileId().equalsIgnoreCase(profileId)) {
+ LOGGER.info("Profile ID matched... updating slice profile");
+ updateSliceProfileInAAI(execution, sliceProfileInstanceId, updatedSlice);
+
+ // for update in administrativeState
+ updatedSliceInstance =
+ mapUserParamsToServiceInstance(updatedSliceInstance, sliceProfilesData);
+ LOGGER.info(("Updating Slice-profile Instance"));
+ updateSliceProfileInstance(execution, updatedSliceInstance);
+ }
+
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ public void updateSliceProfileInAAI(BuildingBlockExecution execution, String sliceProfileInstanceId,
+ SliceProfile sliceProfile1) {
+ Customer customer = getCustomer(execution);
+ AAIResourceUri updateSliceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(sliceProfileInstanceId).sliceProfile(sliceProfile1.getProfileId()));
+ try {
+ injectionHelper.getAaiClient().update(updateSliceURI, sliceProfile1);
+ } catch (Exception e) {
+ LOGGER.info("Error in updating Slice Profile {}", e);
+ }
+ }
+
+ public void updateSliceProfileInstance(BuildingBlockExecution execution, ServiceInstance sliceProfileinstance) {
+ Customer customer = getCustomer(execution);
+ AAIResourceUri updateSliceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(sliceProfileinstance.getServiceInstanceId()));
+ try {
+ injectionHelper.getAaiClient().update(updateSliceURI, sliceProfileinstance);
+ } catch (Exception e) {
+ LOGGER.info("Error in updating Slice Profile instance {}", e);
+ }
+ }
+
+ public void deleteSliceProfileFromAAI(String serviceInstanceID, int size, BuildingBlockExecution execution,
+ String NssiId) {
+ Customer customer = getCustomer(execution);
+
+ AAIResourceUri deleteInstanceURI =
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(serviceInstanceID));
+ try {
+ injectionHelper.getAaiClient().delete(deleteInstanceURI);
+ LOGGER.info("Slice Profile Instance with ID {} deleted", serviceInstanceID);
+ } catch (Exception e) {
+ LOGGER.info("Error in deleting Slice Profile instace {}", e);
+ }
+ LOGGER.info(">>>> Size : {}", size);
+ if (size == 1) {
+ AAIResourceUri serviceInstanceURI = AAIUriFactory
+ .createResourceUri(AAIFluentTypeBuilder.business().customer(customer.getGlobalCustomerId())
+ .serviceSubscription(
+ customer.getServiceSubscriptions().getServiceSubscription().get(0).getServiceType())
+ .serviceInstance(NssiId));
+ // Delete NSSI
+ try {
+ injectionHelper.getAaiClient().delete(serviceInstanceURI);
+ LOGGER.info("deleted Slice Prfile as well ass NSSI {}", NssiId);
+ } catch (Exception e) {
+ LOGGER.info("Error in deleting NSSI {}", e);
+ }
+
+ }
+
+ }
+
+ private Customer getCustomer(BuildingBlockExecution execution) {
+
+ GeneralBuildingBlock gBB = execution.getGeneralBuildingBlock();
+
+ String serviceType = gBB.getCustomer().getServiceSubscription().getServiceType();
+
+ String globalCustomerId = gBB.getCustomer().getGlobalCustomerId();
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType(serviceType);
+
+ ServiceSubscriptions serviceSubscriptions = new ServiceSubscriptions();
+ serviceSubscriptions.getServiceSubscription().add(serviceSubscription);
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId(globalCustomerId);
+ customer.setServiceSubscriptions(serviceSubscriptions);
+
+ return customer;
+
+ }
+
+ private ServiceInstance mapUserParamsToServiceInstance(ServiceInstance sliceProfileServiceInstanceObj,
+ List<Map<String, Object>> sliceProfilesData) {
+ Map<String, Object> mapParam = (Map<String, Object>) sliceProfilesData.get(0).get("nssi");
+ LOGGER.info(">>> mapParam: {}", mapParam);
+
+ // update administrative State
+ String administrativeState = (String) mapParam.get("administrativeState");
+ if (administrativeState != null) {
+ LOGGER.info(">>> administrativeState: {}", administrativeState);
+ sliceProfileServiceInstanceObj.setOperationalStatus(administrativeState);
+ }
+
+ String operationalState = (String) mapParam.get("operationalState");
+ if (operationalState != null) {
+ LOGGER.info(">>> operationalState: {}", operationalState);
+ sliceProfileServiceInstanceObj.setOrchestrationStatus(operationalState);
+ }
+ List<Object> list = (ArrayList<Object>) mapParam.get("sliceProfileList");
+ LOGGER.info(">>> sliceProfile List: {}", list);
+ Map<String, Object> idMap = (Map<String, Object>) list.get(0);
+ LOGGER.info("Keys of Id Map {} ", idMap.keySet());
+
+ return sliceProfileServiceInstanceObj;
+ }
+}
diff --git a/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java
new file mode 100644
index 0000000000..1cbdabf9c4
--- /dev/null
+++ b/bpmn/so-bpmn-moi/src/main/java/org/onap/so/bpmn/moi/util/SliceProfileAaiToMoiMapperUtil.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2022 Deutsche telekom
+ * ================================================================================
+ * 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.moi.util;
+
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.SliceProfile;
+import org.onap.so.moi.Attributes;
+import org.onap.so.moi.PlmnId;
+import org.onap.so.moi.Snssai;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SliceProfileAaiToMoiMapperUtil {
+
+ public ServiceInstance fillSliceProfileInstanceFromMoiRequest(Attributes moiRequestAttributes,
+ ServiceInstance serviceInstance) {
+
+ // org.onap.so.moi.SliceProfile moiSliceProfile = null;
+
+ String serviceInstanceLocationId = null;
+ String environmentContext = null;
+ String serviceType = null;
+ String operationalState = "LOCKED";
+ String orchistrationStatus = "Assigned";
+
+ for (org.onap.so.moi.SliceProfile moiSliceProfile : moiRequestAttributes.getSliceProfileList()) {
+ serviceInstanceLocationId = getPlmnId(moiSliceProfile.getPlmnInfoList().get(0).getPlmnId());
+ environmentContext = getSnssai(moiSliceProfile.getPlmnInfoList().get(0).getSnssai());
+ serviceType = moiSliceProfile.getRANSliceSubnetProfile().getServiceType();
+ }
+
+ serviceInstance.setServiceInstanceLocationId(serviceInstanceLocationId);
+ serviceInstance.setEnvironmentContext(environmentContext);
+ serviceInstance.setServiceType(serviceType);
+ serviceInstance.setOperationalStatus(operationalState);
+ return serviceInstance;
+ }
+
+ String getSnssai(Snssai snssai) {
+ return snssai.getSst() + "-" + snssai.getSd();
+ }
+
+ String getPlmnId(PlmnId plmnId) {
+ return plmnId.getMcc() + "-" + plmnId.getMnc();
+ }
+
+ public SliceProfile extractAaiSliceProfileFromMoiRequest(Attributes moiRequestAttributes) {
+
+ SliceProfile aaiSLiceProfile = null;
+
+ for (org.onap.so.moi.SliceProfile sliceProfileMoi : moiRequestAttributes.getSliceProfileList()) {
+ aaiSLiceProfile = mapMoiSliceProfileToAaiSliceProfile(sliceProfileMoi);
+ }
+
+ return aaiSLiceProfile;
+ }
+
+ private SliceProfile mapMoiSliceProfileToAaiSliceProfile(org.onap.so.moi.SliceProfile moiSliceProfile) {
+ SliceProfile aaiSliceProfile = new SliceProfile();
+
+ Integer latency = moiSliceProfile.getRANSliceSubnetProfile().getLatency();
+ Integer areaTrafficCapDL = moiSliceProfile.getRANSliceSubnetProfile().getAreaTrafficCapDL();
+ Integer maxNumberOfUEs = moiSliceProfile.getRANSliceSubnetProfile().getMaxNumberofUEs();
+ String resourceSharingLevel = moiSliceProfile.getRANSliceSubnetProfile().getResourceSharingLevel();
+ Integer coverageAreaTAList = moiSliceProfile.getRANSliceSubnetProfile().getCoverageAreaTAList();
+
+ aaiSliceProfile.setLatency(latency);
+ aaiSliceProfile.setMaxNumberOfUEs(maxNumberOfUEs);
+ aaiSliceProfile.setResourceSharingLevel(resourceSharingLevel);
+ aaiSliceProfile.setCoverageAreaTAList(String.valueOf(coverageAreaTAList));
+ aaiSliceProfile.setAreaTrafficCapDL(areaTrafficCapDL);
+
+ return aaiSliceProfile;
+ }
+}