diff options
Diffstat (limited to 'components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java')
-rw-r--r-- | components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java | 144 |
1 files changed, 80 insertions, 64 deletions
diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java index 5798a40f..50a60ac3 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * slice-analysis-ms * ================================================================================ - * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2020-2021 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import org.onap.slice.analysis.ms.models.Configuration; import org.onap.slice.analysis.ms.models.configdb.CellsModel; @@ -35,82 +36,97 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; /** - * + * * Service for config db interfaces * */ @Service public class ConfigDbInterfaceService implements IConfigDbService { - @Autowired - private ConfigDbRestClient restclient; - private String configDbBaseUrl = Configuration.getInstance().getConfigDbService(); + @Autowired + private ConfigDbRestClient restclient; + private String configDbBaseUrl = Configuration.getInstance().getConfigDbService(); + + /** + * Fetches the current configuration of an S-NSSAI from config DB + */ + public Map<String, Integer> fetchCurrentConfigurationOfSlice(String snssai){ + Map<String,Integer> responseMap = null; + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/profile-config/"+snssai; - /** - * Fetches the current configuration of an S-NSSAI from config DB - */ - public Map<String, Integer> fetchCurrentConfigurationOfSlice(String snssai){ - Map<String,Integer> responseMap = null; - String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/profile-config/"+snssai; + ResponseEntity<Map<String,Integer>> response=restclient.sendGetRequest(reqUrl,new ParameterizedTypeReference<Map<String, Integer>>() { + }); + responseMap=response.getBody(); + return responseMap; + } - ResponseEntity<Map<String,Integer>> response=restclient.sendGetRequest(reqUrl,new ParameterizedTypeReference<Map<String, Integer>>() { - }); - responseMap=response.getBody(); - return responseMap; - } + /** + * Fetches the current configuration of RIC from config DB + */ + public Map<String, Map<String, Object>> fetchCurrentConfigurationOfRIC(String snssai) { + String reqUrl = configDbBaseUrl + "/api/sdnc-config-db/v4/slice-config/" + snssai; + Map<String, Map<String, Object>> responseMap = new HashMap<String, Map<String, Object>>(); + ResponseEntity<Map<String, List<Map<String, Object>>>> response = restclient.sendGetRequest(reqUrl, + new ParameterizedTypeReference<Map<String, List<Map<String, Object>>>>() { + }); + if (Objects.nonNull(response)) { + for (Map.Entry<String, List<Map<String, Object>>> entry : response.getBody().entrySet()) { + List<Map<String, Object>> list = entry.getValue(); + if (!list.isEmpty()) { + list.forEach(l -> { + if (l.containsKey("nearRTRICId")) { + responseMap.put(String.valueOf(l.get("nearRTRICId")), l); + } + }); + } - /** - * Fetches the current configuration of RIC from config DB - */ - public Map<String,Map<String,Object>> fetchCurrentConfigurationOfRIC(String snssai){ - String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/slice-config/"+snssai; - ResponseEntity<Map<String,Map<String,Object>>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,Map<String,Object>>>() { - }); - return response.getBody(); - } + } + } + return responseMap; + } - /** - * Fetches all the network functions of an S-NSSAI from config DB - */ - public List<String> fetchNetworkFunctionsOfSnssai(String snssai){ - List<String> responseList=new ArrayList<>(); - String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-list/"+snssai; - ResponseEntity<List<NetworkFunctionModel>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<List<NetworkFunctionModel>>() { - }); - for(NetworkFunctionModel networkFn:response.getBody()) { - responseList.add(networkFn.getgNBDUId()); - } - return responseList; - } + /** + * Fetches all the network functions of an S-NSSAI from config DB + */ + public List<String> fetchNetworkFunctionsOfSnssai(String snssai){ + List<String> responseList=new ArrayList<>(); + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-list/"+snssai; + ResponseEntity<List<NetworkFunctionModel>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<List<NetworkFunctionModel>>() { + }); + for(NetworkFunctionModel networkFn:response.getBody()) { + responseList.add(networkFn.getgNBDUId()); + } + return responseList; + } - /** - * Fetches the RICS of an S-NSSAI from config DB - */ - public Map<String, List<String>> fetchRICsOfSnssai(String snssai){ - Map<String,List<String>> responseMap=new HashMap<>(); - String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-cell-list/"+snssai; - ResponseEntity<Map<String,List<CellsModel>>> response = restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,List<CellsModel>>>() { - }); + /** + * Fetches the RICS of an S-NSSAI from config DB + */ + public Map<String, List<String>> fetchRICsOfSnssai(String snssai){ + Map<String,List<String>> responseMap=new HashMap<>(); + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-cell-list/"+snssai; + ResponseEntity<Map<String,List<CellsModel>>> response = restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,List<CellsModel>>>() { + }); - for (Map.Entry<String, List<CellsModel>> entry : response.getBody().entrySet()) { - List<String> cellslist=new ArrayList<>(); - for(CellsModel cellmodel:entry.getValue()) { - cellslist.add(cellmodel.getCellLocalId()); - } - responseMap.put(entry.getKey(), cellslist); - } - return responseMap; - } + for (Map.Entry<String, List<CellsModel>> entry : response.getBody().entrySet()) { + List<String> cellslist=new ArrayList<>(); + for(CellsModel cellmodel:entry.getValue()) { + cellslist.add(cellmodel.getCellLocalId()); + } + responseMap.put(entry.getKey(), cellslist); + } + return responseMap; + } - /** - * Fetches the details of a service - */ - public Map<String,String> fetchServiceDetails(String snssai){ - String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/subscriber-details/"+snssai; - ResponseEntity<Map<String,String>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,String>>() { - }); - return response.getBody(); - } + /** + * Fetches the details of a service + */ + public Map<String,String> fetchServiceDetails(String snssai){ + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/subscriber-details/"+snssai; + ResponseEntity<Map<String,String>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference<Map<String,String>>() { + }); + return response.getBody(); + } } |