2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.aai.esr.util;
18 import java.util.ArrayList;
19 import java.util.List;
21 import org.onap.aai.esr.common.SystemType;
22 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
23 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
24 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
25 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
27 public class ThirdpartySdncManagerUtil {
28 private static ExtsysUtil extsysUtil = new ExtsysUtil();
30 public EsrThirdpartySdncDetail sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
31 EsrThirdpartySdncDetail esrThirdpartySdnc = new EsrThirdpartySdncDetail();
32 sdncRegisterInfo.setThirdpartySdncId(extsysUtil.generateId());
33 esrThirdpartySdnc.setThirdpartySdncId(sdncRegisterInfo.getThirdpartySdncId());
34 esrThirdpartySdnc.setLocation(sdncRegisterInfo.getLocation());
35 esrThirdpartySdnc.setProductName(sdncRegisterInfo.getProductName());
36 esrThirdpartySdnc.setEsrSystemInfoList(getEsrSystemInfoList(sdncRegisterInfo));
37 return esrThirdpartySdnc;
40 private EsrSystemInfoList getEsrSystemInfoList(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
41 EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
42 List<EsrSystemInfo> esrSystemInfo = new ArrayList<>();
43 EsrSystemInfo authInfo = new EsrSystemInfo();
44 authInfo.setEsrSystemInfoId(extsysUtil.generateId());
45 authInfo.setVersion(sdncRegisterInfo.getVersion());
46 authInfo.setSystemName(sdncRegisterInfo.getName());
47 authInfo.setServiceUrl(sdncRegisterInfo.getUrl());
48 authInfo.setVendor(sdncRegisterInfo.getVendor());
49 authInfo.setType(sdncRegisterInfo.getType());
50 authInfo.setUserName(sdncRegisterInfo.getUserName());
51 authInfo.setPassword(sdncRegisterInfo.getPassword());
52 authInfo.setProtocol(sdncRegisterInfo.getProtocol());
53 authInfo.setSystemType(SystemType.thirdparty_SDNC.toString());
54 esrSystemInfo.add(authInfo);
55 esrSystemInfoList.setEsrSystemInfo(esrSystemInfo);
56 return esrSystemInfoList;
59 public ThirdpartySdncRegisterInfo esrSdnc2SdncRegisterInfo(EsrThirdpartySdncDetail esrSdnc) {
60 ThirdpartySdncRegisterInfo registerSdncInfo = new ThirdpartySdncRegisterInfo();
61 EsrSystemInfo esrSystemInfo = esrSdnc.getEsrSystemInfoList().getEsrSystemInfo().get(0);
62 registerSdncInfo.setThirdpartySdncId(esrSdnc.getThirdpartySdncId());
63 registerSdncInfo.setLocation(esrSdnc.getLocation());
64 registerSdncInfo.setProductName(esrSdnc.getProductName());
65 registerSdncInfo.setName(esrSystemInfo.getSystemName());
66 registerSdncInfo.setPassword(esrSystemInfo.getPassword());
67 registerSdncInfo.setProtocol(esrSystemInfo.getProtocol());
68 registerSdncInfo.setType(esrSystemInfo.getType());
69 registerSdncInfo.setUrl(esrSystemInfo.getServiceUrl());
70 registerSdncInfo.setUserName(esrSystemInfo.getUserName());
71 registerSdncInfo.setVendor(esrSystemInfo.getVendor());
72 registerSdncInfo.setVersion(esrSystemInfo.getVersion());
73 return registerSdncInfo;