Code changes in BPMN infra for RAN Slice Use case
[so.git] / bpmn / so-bpmn-moi / src / main / java / org / onap / so / bpmn / moi / util / SliceProfileAaiToMoiMapperUtil.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (c) 2022 Deutsche telekom
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
22 package org.onap.so.bpmn.moi.util;
23
24 import org.onap.aai.domain.yang.ServiceInstance;
25 import org.onap.aai.domain.yang.SliceProfile;
26 import org.onap.so.moi.Attributes;
27 import org.onap.so.moi.PlmnId;
28 import org.onap.so.moi.Snssai;
29 import org.springframework.stereotype.Component;
30
31 @Component
32 public class SliceProfileAaiToMoiMapperUtil {
33
34     public ServiceInstance fillSliceProfileInstanceFromMoiRequest(Attributes moiRequestAttributes,
35             ServiceInstance serviceInstance) {
36
37         // org.onap.so.moi.SliceProfile moiSliceProfile = null;
38
39         String serviceInstanceLocationId = null;
40         String environmentContext = null;
41         String serviceType = null;
42         String operationalState = "LOCKED";
43         String orchistrationStatus = "Assigned";
44
45         for (org.onap.so.moi.SliceProfile moiSliceProfile : moiRequestAttributes.getSliceProfileList()) {
46             serviceInstanceLocationId = getPlmnId(moiSliceProfile.getPlmnInfoList().get(0).getPlmnId());
47             environmentContext = getSnssai(moiSliceProfile.getPlmnInfoList().get(0).getSnssai());
48             serviceType = moiSliceProfile.getRANSliceSubnetProfile().getServiceType();
49         }
50
51         serviceInstance.setServiceInstanceLocationId(serviceInstanceLocationId);
52         serviceInstance.setEnvironmentContext(environmentContext);
53         serviceInstance.setServiceType(serviceType);
54         serviceInstance.setOperationalStatus(operationalState);
55         return serviceInstance;
56     }
57
58     String getSnssai(Snssai snssai) {
59         return snssai.getSst() + "-" + snssai.getSd();
60     }
61
62     String getPlmnId(PlmnId plmnId) {
63         return plmnId.getMcc() + "-" + plmnId.getMnc();
64     }
65
66     public SliceProfile extractAaiSliceProfileFromMoiRequest(Attributes moiRequestAttributes) {
67
68         SliceProfile aaiSLiceProfile = null;
69
70         for (org.onap.so.moi.SliceProfile sliceProfileMoi : moiRequestAttributes.getSliceProfileList()) {
71             aaiSLiceProfile = mapMoiSliceProfileToAaiSliceProfile(sliceProfileMoi);
72         }
73
74         return aaiSLiceProfile;
75     }
76
77     private SliceProfile mapMoiSliceProfileToAaiSliceProfile(org.onap.so.moi.SliceProfile moiSliceProfile) {
78         SliceProfile aaiSliceProfile = new SliceProfile();
79
80         Integer latency = moiSliceProfile.getRANSliceSubnetProfile().getLatency();
81         Integer areaTrafficCapDL = moiSliceProfile.getRANSliceSubnetProfile().getAreaTrafficCapDL();
82         Integer maxNumberOfUEs = moiSliceProfile.getRANSliceSubnetProfile().getMaxNumberofUEs();
83         String resourceSharingLevel = moiSliceProfile.getRANSliceSubnetProfile().getResourceSharingLevel();
84         Integer coverageAreaTAList = moiSliceProfile.getRANSliceSubnetProfile().getCoverageAreaTAList();
85
86         aaiSliceProfile.setLatency(latency);
87         aaiSliceProfile.setMaxNumberOfUEs(maxNumberOfUEs);
88         aaiSliceProfile.setResourceSharingLevel(resourceSharingLevel);
89         aaiSliceProfile.setCoverageAreaTAList(String.valueOf(coverageAreaTAList));
90         aaiSliceProfile.setAreaTrafficCapDL(areaTrafficCapDL);
91
92         return aaiSliceProfile;
93     }
94 }