Fix issue of PerfReq for RAN SliceProfile
[so.git] / common / src / main / java / org / onap / so / beans / nsmf / SliceProfileAdapter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.so.beans.nsmf;
22
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import lombok.Data;
25 import lombok.ToString;
26 import org.springframework.beans.BeanUtils;
27 import java.io.Serializable;
28 import java.util.Arrays;
29
30 @Data
31 @ToString
32 public class SliceProfileAdapter implements Serializable {
33
34     private static final long serialVersionUID = -6412175980642584804L;
35
36     @JsonProperty(value = "sliceProfileId")
37     private String sliceProfileId;
38
39     @JsonProperty(value = "sNSSAI")
40     private String sNSSAIList = "";
41
42     @JsonProperty(value = "pLMNIdList")
43     private String pLMNIdList = "";
44
45     @JsonProperty(value = "maxNumberofUEs")
46     private long maxNumberofUEs;
47
48     @JsonProperty(value = "coverageAreaTAList")
49     private String coverageAreaTAList = "";
50
51     @JsonProperty(value = "latency")
52     private int latency;
53
54     @JsonProperty(value = "uEMobilityLevel")
55     private String uEMobilityLevel;
56
57     @JsonProperty(value = "resourceSharingLevel")
58     private String resourceSharingLevel;
59
60     @JsonProperty(value = "maxBandwidth")
61     private String bandwidth;
62
63     @JsonProperty(value = "sST")
64     private String sST;
65
66     @JsonProperty(value = "activityFactor")
67     private String activityFactor;
68
69     @JsonProperty(value = "survivalTime")
70     private String survivalTime;
71
72     public AnSliceProfile trans2AnProfile() {
73         AnSliceProfile anSliceProfile = new AnSliceProfile();
74         BeanUtils.copyProperties(this, anSliceProfile);
75         anSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
76         anSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
77
78         String[] areas = this.coverageAreaTAList.split("\\|");
79         Integer[] areasRes = new Integer[areas.length];
80         for (int i = 0; i < areas.length; i++) {
81             areasRes[i] = str2Code(areas[i]);
82         }
83         anSliceProfile.setCoverageAreaTAList(Arrays.asList(areasRes));
84         anSliceProfile.setUEMobilityLevel(UeMobilityLevel.fromString(this.uEMobilityLevel));
85         anSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
86         PerfReq perfReq = new PerfReq();
87         // todo
88         anSliceProfile.setPerfReq(perfReq);
89         return anSliceProfile;
90     }
91
92     private Integer str2Code(String area) {
93         return area.hashCode() >> 16;
94     }
95
96     public CnSliceProfile trans2CnProfile() {
97         CnSliceProfile cnSliceProfile = new CnSliceProfile();
98         BeanUtils.copyProperties(this, cnSliceProfile);
99         cnSliceProfile.setSnssaiList(Arrays.asList(this.sNSSAIList.split("\\|")));
100         cnSliceProfile.setCoverageAreaTAList(Arrays.asList(this.coverageAreaTAList.split("\\|")));
101         cnSliceProfile.setPlmnIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
102         cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(this.resourceSharingLevel));
103         PerfReq perfReq = new PerfReq();
104         // todo
105         cnSliceProfile.setPerfReq(perfReq);
106         return cnSliceProfile;
107     }
108
109     public TnSliceProfile trans2TnProfile() {
110         TnSliceProfile tnSliceProfile = new TnSliceProfile();
111         BeanUtils.copyProperties(this, tnSliceProfile);
112         tnSliceProfile.setSNSSAIList(Arrays.asList(this.sNSSAIList.split("\\|")));
113         tnSliceProfile.setPLMNIdList(Arrays.asList(this.pLMNIdList.split("\\|")));
114         return tnSliceProfile;
115     }
116 }