2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
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=========================================================
21 package org.onap.so.beans.nsmf;
23 import com.fasterxml.jackson.annotation.JsonProperty;
25 import lombok.ToString;
26 import org.springframework.beans.BeanUtils;
27 import java.io.Serializable;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.List;
34 public class SliceProfileAdapter implements Serializable {
36 private static final long serialVersionUID = -6412175980642584804L;
38 @JsonProperty(value = "sliceProfileId")
39 private String sliceProfileId;
41 @JsonProperty(value = "sNSSAI")
42 private String sNSSAIList = "";
44 @JsonProperty(value = "pLMNIdList")
45 private String pLMNIdList = "";
47 @JsonProperty(value = "maxNumberofUEs")
48 private int maxNumberOfUEs;
50 @JsonProperty(value = "coverageAreaTAList")
51 private String coverageAreaTAList = "";
53 @JsonProperty(value = "latency")
56 @JsonProperty(value = "uEMobilityLevel")
57 private String ueMobilityLevel;
59 @JsonProperty(value = "resourceSharingLevel")
60 private String resourceSharingLevel;
62 @JsonProperty(value = "maxBandwidth")
63 private int maxBandwidth;
65 @JsonProperty(value = "sST")
66 private String sST = "embb";
68 @JsonProperty(value = "activityFactor")
69 private int activityFactor;
71 @JsonProperty(value = "survivalTime")
72 private String survivalTime;
74 @JsonProperty(value = "expDataRateUL")
75 private int expDataRateUL;
77 @JsonProperty(value = "expDataRateDL")
78 private int expDataRateDL;
80 @JsonProperty(value = "areaTrafficCapUL")
81 private int areaTrafficCapUL;
83 @JsonProperty(value = "areaTrafficCapDL")
84 private int areaTrafficCapDL;
86 @JsonProperty(value = "jitter")
89 @JsonProperty(value = "csAvailabilityTarget")
90 private float csAvailabilityTarget;
92 @JsonProperty(value = "expDataRate")
93 private int expDataRate;
95 @JsonProperty(value = "maxNumberofPDUSession")
96 private int maxNumberOfPDUSession;
98 @JsonProperty(value = "overallUserDensity")
99 private int overallUserDensity;
101 @JsonProperty(value = "cSReliabilityMeanTime")
102 private String csReliabilityMeanTime;
104 @JsonProperty(value = "msgSizeByte")
105 private String msgSizeByte;
107 @JsonProperty(value = "transferIntervalTarget")
108 private String transferIntervalTarget;
110 @JsonProperty(value = "ipAddress")
111 private String ipAddress;
113 @JsonProperty(value = "logicInterfaceId")
114 private String logicInterfaceId;
116 @JsonProperty(value = "nextHopInfo")
117 private String nextHopInfo;
119 public AnSliceProfile trans2AnProfile() {
120 AnSliceProfile anSliceProfile = new AnSliceProfile();
121 BeanUtils.copyProperties(this, anSliceProfile);
122 anSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
123 anSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
125 String[] areas = this.coverageAreaTAList.split("\\|");
126 Integer[] areasRes = new Integer[areas.length];
127 for (int i = 0; i < areas.length; i++) {
128 areasRes[i] = str2Code(areas[i]);
130 anSliceProfile.setCoverageAreaTAList(Arrays.asList(areasRes));
132 anSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(this.ueMobilityLevel));
133 anSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
134 anSliceProfile.setMaxNumberOfPDUSession(this.maxNumberOfPDUSession);
135 anSliceProfile.setPerfReq(generatePerfReq());
137 return anSliceProfile;
140 private Integer str2Code(String area) {
141 return area.hashCode() >> 16;
144 public CnSliceProfile trans2CnProfile() {
145 CnSliceProfile cnSliceProfile = new CnSliceProfile();
146 BeanUtils.copyProperties(this, cnSliceProfile);
147 cnSliceProfile.setSnssaiList(Arrays.asList(this.sNSSAIList.split("\\|")));
148 cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|")));
149 cnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
150 cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
152 cnSliceProfile.setPerfReq(generatePerfReq());
153 return cnSliceProfile;
156 private PerfReq generatePerfReq() {
157 PerfReq perfReq = new PerfReq();
158 if ("embb".equalsIgnoreCase(sST)) {
159 List<PerfReqEmbb> perfReqEmbbs = new ArrayList<>();
160 PerfReqEmbb perfReqEmbb = new PerfReqEmbb();
161 BeanUtils.copyProperties(this, perfReqEmbb);
162 perfReqEmbbs.add(perfReqEmbb);
163 perfReq.setPerfReqEmbbList(perfReqEmbbs);
164 } else if ("urllc".equalsIgnoreCase(sST)) {
165 List<PerfReqUrllc> perfReqUrllcs = new ArrayList<>();
166 PerfReqUrllc perfReqUrllc = new PerfReqUrllc();
167 BeanUtils.copyProperties(this, perfReqUrllc);
168 perfReqUrllcs.add(perfReqUrllc);
169 perfReq.setPerfReqUrllcList(perfReqUrllcs);
174 public TnSliceProfile trans2TnProfile() {
175 TnSliceProfile tnSliceProfile = new TnSliceProfile();
176 BeanUtils.copyProperties(this, tnSliceProfile);
177 tnSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
178 tnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
179 tnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
180 return tnSliceProfile;