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.JsonProperty;
25 import java.util.ArrayList;
26 import java.util.List;
29 public class GNBDUFunction extends AbstractFunction {
32 @JsonProperty("attributes")
33 private GNBDUAttributes attributes;
35 @JsonProperty("_3gpp-nr-nrm-nrcelldu:NRCellDU")
36 private List<NRCellDU> nrCellDUs;
39 public Map<String, Object> addTeivEntitiesAndRelationships(Map<String, List<Object>> entityMap,
40 Map<String, List<Object>> relationshipMap, String parentId) {
41 createRelationshipWithSmo(relationshipMap);
42 String gnbduFunctionFdn = "urn:oran:smo:teiv:" + getId();
44 for (NRCellDU nrCellDU : getNrCellDUs()) {
45 addNrcellduEntitiesAndRelationships(nrCellDU, entityMap, relationshipMap);
46 addRelationshipWithNrcelldu(nrCellDU, relationshipMap);
49 return Map.of("id", gnbduFunctionFdn, "attributes", attributes.createEntityAttributes(), "sourceIds", List.of(
50 gnbduFunctionFdn, "urn:oran:smo:teiv:" + parentId));
53 private void addNrcellduEntitiesAndRelationships(NRCellDU nrCellDU, Map<String, List<Object>> entityMap,
54 Map<String, List<Object>> relationshipMap) {
55 String type = "o-ran-smo-teiv-ran:NRCellDU";
56 if (!entityMap.containsKey(type)) {
57 entityMap.put(type, new ArrayList<>());
59 entityMap.get(type).add(nrCellDU.addTeivEntitiesAndRelationships(entityMap, relationshipMap, getId()));
62 private void addRelationshipWithNrcelldu(NRCellDU nrCellDU, Map<String, List<Object>> relationshipMap) {
63 String relType = "o-ran-smo-teiv-ran:ODUFUNCTION_PROVIDES_NRCELLDU";
64 if (!relationshipMap.containsKey(relType)) {
65 relationshipMap.put(relType, new ArrayList<>());
67 relationshipMap.get(relType).add(nrCellDU.createRelationshipWithGnbduFunction(getId()));
71 public Map<String, Object> createRelationshipWithManagedElement(String managedElementId) {
72 String gnbduFunctionFdn = "urn:oran:smo:teiv:" + getId();
73 String managedElementFdn = "urn:oran:smo:teiv:" + managedElementId;
74 return Map.of("id", String.format("urn:oran:smo:teiv:%s_MANAGES_%s", managedElementId, getId()), "aSide",
75 managedElementFdn, "bSide", gnbduFunctionFdn, "sourceIds", List.of(managedElementFdn, gnbduFunctionFdn));
79 public String getTeivEntityType() {
80 return "o-ran-smo-teiv-ran:ODUFunction";
84 public String getTeivRelationshipWithManagedElement() {
85 return "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_ODUFUNCTION";
89 public void createRelationshipWithSmo(Map<String, List<Object>> relationshipMap) {
90 String ranFunctionRelType = "o-ran-smo-teiv-ran:ODUFUNCTION_O1LINK_SMO";
91 if (!relationshipMap.containsKey(ranFunctionRelType)) {
92 relationshipMap.put(ranFunctionRelType, new ArrayList<>());
94 String gnbduFunctionId = getId();
96 Map<String, Object> test = Map.of("id", String.format("urn:oran:smo:teiv:%s_O1LINK_%s", gnbduFunctionId, smoId),
97 "bSide", "urn:oran:smo:teiv:" + smoId, "aSide", "urn:oran:smo:teiv:" + gnbduFunctionId, "sourceIds", List
98 .of(smoId, gnbduFunctionId));
99 relationshipMap.get(ranFunctionRelType).add(test);