2 * ========================LICENSE_START=================================
5 * Copyright (C) 2023 Nordix Foundation
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===================================
21 package org.oran.pmlog;
23 import com.google.gson.annotations.Expose;
25 import java.util.ArrayList;
26 import java.util.Collection;
28 import lombok.Builder;
32 @Builder(toBuilder = true)
33 public class PmReport {
35 private static com.google.gson.Gson gson = new com.google.gson.GsonBuilder() //
36 .disableHtmlEscaping() //
39 public static PmReport parse(DataFromKafkaTopic data) {
40 return gson.fromJson(data.valueAsString(), PmReport.class);
43 public long lastTimeEpochMili() {
44 return event.commonEventHeader.lastEpochMicrosec / 1000;
47 public String fullDistinguishedName(PmReport.MeasValuesList measValueList) {
48 return event.getPerf3gppFields().getMeasDataCollection().getMeasuredEntityDn() + ","
49 + measValueList.getMeasObjInstId();
55 public static class CommonEventHeader {
57 private String domain;
60 private String eventId;
63 private String eventName;
67 private String sourceName;
70 private String reportingEntityName;
73 private long startEpochMicrosec;
77 private long lastEpochMicrosec;
80 private String timeZoneOffset;
82 /* Not reported elements */
86 String vesEventListenerVersion;
89 public static class MeasInfoId {
91 private String sMeasInfoId = "";
94 public static class MeasTypes {
95 public String getMeasType(int pValue) {
96 if (pValue > sMeasTypesList.size()) {
97 return "MeasTypeIndexOutOfBounds:" + pValue;
99 return sMeasTypesList.get(pValue - 1);
103 protected ArrayList<String> sMeasTypesList = new ArrayList<>();
107 @Builder(toBuilder = true)
108 public static class MeasResult {
115 private String sValue;
118 @Builder(toBuilder = true)
119 public static class MeasValuesList {
122 private String measObjInstId;
126 private String suspectFlag;
130 private Collection<MeasResult> measResults;
132 public boolean isEmpty() {
133 return this.measResults.isEmpty();
136 static MeasValuesList emptyList = MeasValuesList.builder().measResults(new ArrayList<>()).build();
138 public static MeasValuesList empty() {
144 @Builder(toBuilder = true)
145 public static class MeasInfoList {
147 private MeasInfoId measInfoId;
150 private MeasTypes measTypes;
153 private Collection<MeasValuesList> measValuesList;
157 @Builder(toBuilder = true)
159 public static class MeasDataCollection {
161 private int granularityPeriod;
164 private String measuredEntityUserName;
167 private String measuredEntityDn;
170 private String measuredEntitySoftwareVersion;
173 private Collection<MeasInfoList> measInfoList;
176 @Builder(toBuilder = true)
178 public static class Perf3gppFields {
180 private String perf3gppFieldsVersion;
183 private MeasDataCollection measDataCollection;
187 @Builder(toBuilder = true)
188 public static class Event {
190 private CommonEventHeader commonEventHeader;
193 private Perf3gppFields perf3gppFields;