2 * ============LICENSE_START=======================================================
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
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=========================================================
22 package org.onap.so.bpmn.moi.util;
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;
32 public class SliceProfileAaiToMoiMapperUtil {
34 public ServiceInstance fillSliceProfileInstanceFromMoiRequest(Attributes moiRequestAttributes,
35 ServiceInstance serviceInstance) {
37 // org.onap.so.moi.SliceProfile moiSliceProfile = null;
39 String serviceInstanceLocationId = null;
40 String environmentContext = null;
41 String serviceType = null;
42 String operationalState = "LOCKED";
43 String orchistrationStatus = "Assigned";
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();
51 serviceInstance.setServiceInstanceLocationId(serviceInstanceLocationId);
52 serviceInstance.setEnvironmentContext(environmentContext);
53 serviceInstance.setServiceType(serviceType);
54 serviceInstance.setOperationalStatus(operationalState);
55 return serviceInstance;
58 String getSnssai(Snssai snssai) {
59 return snssai.getSst() + "-" + snssai.getSd();
62 String getPlmnId(PlmnId plmnId) {
63 return plmnId.getMcc() + "-" + plmnId.getMnc();
66 public SliceProfile extractAaiSliceProfileFromMoiRequest(Attributes moiRequestAttributes) {
68 SliceProfile aaiSLiceProfile = null;
70 for (org.onap.so.moi.SliceProfile sliceProfileMoi : moiRequestAttributes.getSliceProfileList()) {
71 aaiSLiceProfile = mapMoiSliceProfileToAaiSliceProfile(sliceProfileMoi);
74 return aaiSLiceProfile;
77 private SliceProfile mapMoiSliceProfileToAaiSliceProfile(org.onap.so.moi.SliceProfile moiSliceProfile) {
78 SliceProfile aaiSliceProfile = new SliceProfile();
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();
86 aaiSliceProfile.setLatency(latency);
87 aaiSliceProfile.setMaxNumberOfUEs(maxNumberOfUEs);
88 aaiSliceProfile.setResourceSharingLevel(resourceSharingLevel);
89 aaiSliceProfile.setCoverageAreaTAList(String.valueOf(coverageAreaTAList));
90 aaiSliceProfile.setAreaTrafficCapDL(areaTrafficCapDL);
92 return aaiSliceProfile;