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