1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2022 Wipro Limited.
6 * ==============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 *******************************************************************************/
22 package org.onap.slice.analysis.ms.service;
24 import java.util.List;
26 import java.util.Objects;
28 import org.onap.slice.analysis.ms.aai.AaiInterface;
29 import org.onap.slice.analysis.ms.configdb.IConfigDbService;
30 import org.onap.slice.analysis.ms.cps.CpsInterface;
31 import org.onap.slice.analysis.ms.models.CUModel;
32 import org.onap.slice.analysis.ms.models.Configuration;
33 import org.onap.slice.analysis.ms.models.MLOutputModel;
34 import org.onap.slice.analysis.ms.models.policy.AdditionalProperties;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.context.annotation.Scope;
39 import org.springframework.stereotype.Component;
42 * Process the message sent by ML service and sends notification to policy
46 public class MLMessageProcessor {
47 private static Logger log = LoggerFactory.getLogger(MLMessageProcessor.class);
50 private IConfigDbService configDbService;
53 private PolicyService policyService;
56 private AaiInterface aaiInterface;
59 private CpsInterface cpsInterface;
62 * Process the message sent by ML service and sends notification to policy
64 public void processMLMsg(MLOutputModel mlOutputMsg) {
65 Boolean isConfigDbEnabled = (Objects.isNull(Configuration.getInstance().getConfigDbEnabled())) ? true
66 : Configuration.getInstance().getConfigDbEnabled();
67 Map<String, List<String>> ricToCellMapping = null;
68 Map<String, String> serviceDetails = null;
69 String snssai = mlOutputMsg.getSnssai();
70 List<CUModel> cuData = mlOutputMsg.getData();
71 if (isConfigDbEnabled) {
72 ricToCellMapping = configDbService.fetchRICsOfSnssai(snssai);
74 ricToCellMapping = cpsInterface.fetchRICsOfSnssai(snssai);
76 log.debug("RIC to cell mapping of S-NSSAI {} is {}", snssai, ricToCellMapping);
77 for (CUModel cuModel : cuData) {
78 String cellId = String.valueOf(cuModel.getCellCUList().get(0).getCellLocalId());
79 ricToCellMapping.forEach((ricId, cells) -> {
80 if (cells.contains(cellId)) {
81 cuModel.setNearRTRICId(ricId);
85 AdditionalProperties<MLOutputModel> addProps = new AdditionalProperties<>();
86 addProps.setResourceConfig(mlOutputMsg);
88 if (isConfigDbEnabled) {
89 serviceDetails = configDbService.fetchServiceDetails(snssai);
91 serviceDetails = aaiInterface.fetchServiceDetails(snssai);
94 policyService.sendOnsetMessageToPolicy(snssai, addProps, serviceDetails);