2 * ============LICENSE_START=======================================================
3 * Modifications Copyright (C) 2025 OpenInfra Foundation Europe
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.oran.smo.ncmp_to_teiv_adapter.models;
22 import com.fasterxml.jackson.annotation.JsonAnySetter;
23 import com.fasterxml.jackson.databind.ObjectMapper;
25 import lombok.extern.slf4j.Slf4j;
27 import java.util.ArrayList;
28 import java.util.List;
32 public class ManagedElement extends AbstractEntity {
35 private List<AbstractFunction> ranFunctions = new ArrayList<>();
39 public void setAdditionalProperty(String name, Object value) {
40 ObjectMapper mapper = new ObjectMapper();
43 if ("_3gpp-nr-nrm-gnbdufunction:GNBDUFunction".equals(name)) {
44 List<Object> list = (List<Object>) value;
45 for (Object item : list) {
46 GNBDUFunction du = mapper.convertValue(item, GNBDUFunction.class);
49 } else if ("_3gpp-nr-nrm-gnbcucpfunction:GNBCUCPFunction".equals(name)) {
50 List<Object> list = (List<Object>) value;
51 for (Object item : list) {
52 GNBCUCPFunction cu = mapper.convertValue(item, GNBCUCPFunction.class);
56 getAdditionalProperties().put(name, value);
58 } catch (Exception e) {
64 public Map<String, Object> addTeivEntitiesAndRelationships(Map<String, List<Object>> entityMap,
65 Map<String, List<Object>> relationshipMap, String parenId) {
66 for (AbstractFunction ranFunction : getRanFunctions()) {
67 addRanFunctionEntitiesAndRelationships(ranFunction, entityMap, relationshipMap);
68 addRelationshipWithRanFunction(ranFunction, relationshipMap);
70 String managedElementId = "urn:oran:smo:teiv:" + getId();
71 return Map.of("id", managedElementId, "sourceIds", List.of(managedElementId));
74 private void addRanFunctionEntitiesAndRelationships(AbstractFunction ranFunction, Map<String, List<Object>> entityMap,
75 Map<String, List<Object>> relationshipMap) {
76 String ranFunctionType = ranFunction.getTeivEntityType();
77 if (!entityMap.containsKey(ranFunctionType)) {
78 entityMap.put(ranFunctionType, new ArrayList<>());
80 entityMap.get(ranFunctionType).add(ranFunction.addTeivEntitiesAndRelationships(entityMap, relationshipMap,
84 private void addRelationshipWithRanFunction(AbstractFunction ranFunction, Map<String, List<Object>> relationshipMap) {
85 String ranFunctionRelType = ranFunction.getTeivRelationshipWithManagedElement();
86 if (!relationshipMap.containsKey(ranFunctionRelType)) {
87 relationshipMap.put(ranFunctionRelType, new ArrayList<>());
89 relationshipMap.get(ranFunctionRelType).add(ranFunction.createRelationshipWithManagedElement(getId()));
93 public String getTeivEntityType() {
94 return "o-ran-smo-teiv-oam:ManagedElement";