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 GNBCUCPFunction extends AbstractFunction {
32 @JsonProperty("attributes")
33 private GNBCUCPAttributes attributes;
35 @JsonProperty("_3gpp-nr-nrm-nrcellcu:NRCellCU")
36 private List<NRCellCU> nrCellCUs;
39 public Map<String, Object> addTeivEntitiesAndRelationships(Map<String, List<Object>> entityMap,
40 Map<String, List<Object>> relationshipMap, String parentId) {
41 createRelationshipWithSmo(relationshipMap);
42 String gnbcucpFunctionFdn = "urn:oran:smo:teiv:" + getId();
44 for (NRCellCU nrCellCU : getNrCellCUs()) {
45 addNrcellcuEntitiesAndRelationships(nrCellCU, entityMap, relationshipMap);
46 addRelationshipWithNrcellcu(nrCellCU, relationshipMap);
49 return Map.of("id", gnbcucpFunctionFdn, "attributes", attributes.createEntityAttributes(), "sourceIds", List.of(
50 gnbcucpFunctionFdn, "urn:oran:smo:teiv:" + parentId));
53 private void addNrcellcuEntitiesAndRelationships(NRCellCU nrCellCU, Map<String, List<Object>> entityMap,
54 Map<String, List<Object>> relationshipMap) {
55 String type = "o-ran-smo-teiv-ran:NRCellCU";
56 if (!entityMap.containsKey(type)) {
57 entityMap.put(type, new ArrayList<>());
59 entityMap.get(type).add(nrCellCU.addTeivEntitiesAndRelationships(entityMap, relationshipMap, getId()));
62 private void addRelationshipWithNrcellcu(NRCellCU nrCellCU, Map<String, List<Object>> relationshipMap) {
63 String relType = "o-ran-smo-teiv-ran:OCUCPFUNCTION_PROVIDES_NRCELLCU";
64 if (!relationshipMap.containsKey(relType)) {
65 relationshipMap.put(relType, new ArrayList<>());
67 relationshipMap.get(relType).add(nrCellCU.createRelationshipWithGnbcucpFunction(getId()));
71 public Map<String, Object> createRelationshipWithManagedElement(String managedElementId) {
72 String gnbcucpFunctionFdn = "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", gnbcucpFunctionFdn, "sourceIds", List.of(managedElementFdn, gnbcucpFunctionFdn));
79 public String getTeivEntityType() {
80 return "o-ran-smo-teiv-ran:OCUCPFunction";
84 public String getTeivRelationshipWithManagedElement() {
85 return "o-ran-smo-teiv-rel-oam-ran:MANAGEDELEMENT_MANAGES_OCUCPFUNCTION";
89 public void createRelationshipWithSmo(Map<String, List<Object>> relationshipMap) {
90 String ranFunctionRelType = "o-ran-smo-teiv-ran:OCUCPFUNCTION_O1LINK_SMO";
91 if (!relationshipMap.containsKey(ranFunctionRelType)) {
92 relationshipMap.put(ranFunctionRelType, new ArrayList<>());
94 String gnbcucpFunctionId = getId();
96 Map<String, Object> test = Map.of("id", String.format("urn:oran:smo:teiv:%s_O1LINK_%s", gnbcucpFunctionId, smoId),
97 "bSide", "urn:oran:smo:teiv:" + smoId, "aSide", "urn:oran:smo:teiv:" + gnbcucpFunctionId, "sourceIds", List
98 .of(smoId, gnbcucpFunctionId));
99 relationshipMap.get(ranFunctionRelType).add(test);