8234eeeaf1fc29c6b4aa68acf05bc2448e07e9bd
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
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 package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
21
22 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
23 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
24 import com.amdocs.zusammen.datatypes.item.Info;
25 import com.amdocs.zusammen.datatypes.item.Item;
26 import org.openecomp.convertor.ElementConvertor;
27 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl;
28 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
29 import org.openecomp.sdc.versioning.dao.types.Version;
30
31 public class ElementToVSPGeneralConvertor extends ElementConvertor {
32
33     @Override
34     public VspDetails convert(Element element) {
35         if (element == null) {
36             return null;
37         }
38         return mapInfoToVspDetails(element.getInfo());
39     }
40
41     @Override
42     public VspDetails convert(Item item) {
43         if (item == null) {
44             return null;
45         }
46         VspDetails vspDetails = mapInfoToVspDetails(item.getInfo());
47         vspDetails.setId(item.getId().getValue());
48         return vspDetails;
49     }
50
51     @Override
52     public VspDetails convert(ElementInfo elementInfo) {
53         if (elementInfo == null) {
54             return null;
55         }
56         return mapInfoToVspDetails(elementInfo.getInfo());
57     }
58
59     private VspDetails mapInfoToVspDetails(Info info) {
60         VspDetails vspDetails = new VspDetails();
61         vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.NAME.getValue()));
62         vspDetails.setDescription(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue()));
63         vspDetails.setIcon(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ICON.getValue()));
64         vspDetails.setCategory(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.CATEGORY.getValue()));
65         vspDetails.setSubCategory(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.SUB_CATEGORY.getValue()));
66         vspDetails.setVendorId(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_ID.getValue()));
67         vspDetails.setVendorName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_NAME.getValue()));
68         if (info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()) != null) {
69             vspDetails
70                 .setVlmVersion(new Version(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue())));
71         }
72         vspDetails.setLicenseType(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_TYPE.getValue()));
73         vspDetails.setLicenseAgreement(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue()));
74         vspDetails.setFeatureGroups(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.FEATURE_GROUPS.getValue()));
75         vspDetails.setOnboardingMethod(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ON_BOARDING_METHOD.getValue()));
76         return vspDetails;
77     }
78 }