Added oparent to sdc main
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-software-product-lib / openecomp-sdc-vendor-software-product-core / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / dao / impl / zusammen / convertor / ElementToVSPGeneralConvertor.java
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
21 package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor;
22
23 import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
24 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
25 import com.amdocs.zusammen.datatypes.item.Info;
26 import com.amdocs.zusammen.datatypes.item.Item;
27 import org.openecomp.convertor.ElementConvertor;
28 import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.VendorSoftwareProductInfoDaoZusammenImpl;
29 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
30 import org.openecomp.sdc.versioning.dao.types.Version;
31
32
33 public class ElementToVSPGeneralConvertor extends ElementConvertor {
34   @Override
35   public VspDetails convert(Element element) {
36     if (element == null) {
37       return null;
38     }
39     return mapInfoToVspDetails(element.getInfo());
40
41   }
42
43   @Override
44   public VspDetails convert(Item item) {
45     if (item == null) {
46       return null;
47     }
48     VspDetails vspDetails = mapInfoToVspDetails(item.getInfo());
49     vspDetails.setId(item.getId().getValue());
50     return vspDetails;
51   }
52
53   @Override
54   public VspDetails convert(ElementInfo elementInfo) {
55     if (elementInfo == null) {
56       return null;
57     }
58     return mapInfoToVspDetails(elementInfo.getInfo());
59
60   }
61
62
63   private VspDetails mapInfoToVspDetails(Info info) {
64
65     VspDetails vspDetails = new VspDetails();
66
67     vspDetails.setName(info.getProperty(VendorSoftwareProductInfoDaoZusammenImpl
68         .InfoPropertyName.NAME.getValue()));
69     vspDetails.setDescription(info.getProperty(
70         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.DESCRIPTION.getValue()));
71     vspDetails.setIcon(info.getProperty(
72         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ICON.getValue()));
73     vspDetails.setCategory(info.getProperty(
74         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.CATEGORY.getValue()));
75     vspDetails.setSubCategory(info.getProperty(
76         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.SUB_CATEGORY.getValue()));
77     vspDetails.setVendorId(info.getProperty(
78         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_ID.getValue()));
79     vspDetails.setVendorName(info.getProperty(
80         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_NAME.getValue()));
81     if (info.getProperty(
82         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()) != null) {
83       vspDetails.setVlmVersion(new Version(info.getProperty(
84           VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue())));
85     }
86
87     vspDetails.setLicenseAgreement(info.getProperty(
88         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue()));
89     vspDetails.setFeatureGroups(info.getProperty(
90         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.FEATURE_GROUPS.getValue()));
91     vspDetails.setOnboardingMethod(info.getProperty(
92         VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.ON_BOARDING_METHOD.getValue()));
93
94     return vspDetails;
95   }
96
97
98 }