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;
20 import org.onap.aai.esr.common.SystemType;
21 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
22 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
23 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
24 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
26 public class ThirdpartySdncManagerUtil {
28 public static EsrThirdpartySdncDetail sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
29 EsrThirdpartySdncDetail esrThirdpartySdnc = new EsrThirdpartySdncDetail();
30 sdncRegisterInfo.setThirdpartySdncId(ExtsysUtil.generateId());
31 esrThirdpartySdnc.setThirdpartySdncId(sdncRegisterInfo.getThirdpartySdncId());
32 esrThirdpartySdnc.setLocation(sdncRegisterInfo.getLocation());
33 esrThirdpartySdnc.setProductName(sdncRegisterInfo.getProductName());
34 esrThirdpartySdnc.setEsrSystemInfoList(getEsrSystemInfoList(sdncRegisterInfo));
35 return esrThirdpartySdnc;
38 private static EsrSystemInfoList getEsrSystemInfoList(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
39 EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
40 ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
41 EsrSystemInfo authInfo = new EsrSystemInfo();
42 authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
43 authInfo.setVersion(sdncRegisterInfo.getVersion());
44 authInfo.setSystemName(sdncRegisterInfo.getName());
45 authInfo.setServiceUrl(sdncRegisterInfo.getUrl());
46 authInfo.setVendor(sdncRegisterInfo.getVendor());
47 authInfo.setType(sdncRegisterInfo.getType());
48 authInfo.setUserName(sdncRegisterInfo.getUserName());
49 authInfo.setPassword(sdncRegisterInfo.getPassword());
50 authInfo.setProtocol(sdncRegisterInfo.getProtocol());
51 authInfo.setSystemType(SystemType.thirdparty_SDNC.toString());
52 esrSystemInfo.add(authInfo);
53 esrSystemInfoList.setEsrSystemInfo(esrSystemInfo);
54 return esrSystemInfoList;
57 public static ThirdpartySdncRegisterInfo esrSdnc2SdncRegisterInfo(EsrThirdpartySdncDetail esrSdnc) {
58 ThirdpartySdncRegisterInfo registerSdncInfo = new ThirdpartySdncRegisterInfo();
59 EsrSystemInfo esrSystemInfo = esrSdnc.getEsrSystemInfoList().getEsrSystemInfo().get(0);
60 registerSdncInfo.setThirdpartySdncId(esrSdnc.getThirdpartySdncId());
61 registerSdncInfo.setLocation(esrSdnc.getLocation());
62 registerSdncInfo.setProductName(esrSdnc.getProductName());
63 registerSdncInfo.setName(esrSystemInfo.getSystemName());
64 registerSdncInfo.setPassword(esrSystemInfo.getPassword());
65 registerSdncInfo.setProtocol(esrSystemInfo.getProtocol());
66 registerSdncInfo.setType(esrSystemInfo.getType());
67 registerSdncInfo.setUrl(esrSystemInfo.getServiceUrl());
68 registerSdncInfo.setUserName(esrSystemInfo.getUserName());
69 registerSdncInfo.setVendor(esrSystemInfo.getVendor());
70 registerSdncInfo.setVersion(esrSystemInfo.getVersion());
71 return registerSdncInfo;