04b304e93b53ba0aef56b672586d693924ca3af8
[so.git] / adapters / etsi-sol003-adapter / etsi-sol003-package-management / etsi-sol003-package-management-adapter / src / main / java / org / onap / so / adapters / vnfmadapter / converters / etsicatalog / sol003 / PkgChangeNotificationConverter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003;
22
23 import static org.slf4j.LoggerFactory.getLogger;
24 import org.onap.so.adapters.vnfmadapter.etsicatalog.notification.model.PkgChangeNotification;
25 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification;
26 import org.slf4j.Logger;
27 import org.springframework.core.convert.converter.Converter;
28 import org.springframework.stereotype.Service;
29
30 /**
31  * Converter to convert from an Etsi Catalog Manager {@link PkgChangeNotification} Object to its equivalent SOL003
32  * {@link VnfPackageChangeNotification} Object
33  *
34  * @author andrew.a.lamb@est.tech
35  */
36 @Service
37 public class PkgChangeNotificationConverter extends AbstractPkgNotificationConverter
38         implements Converter<PkgChangeNotification, VnfPackageChangeNotification> {
39     private static final Logger logger = getLogger(PkgChangeNotificationConverter.class);
40
41     /**
42      * Convert a {@link PkgChangeNotification} Object to an {@link VnfPackageChangeNotification} Object
43      * 
44      * @param pkgChangeNotification The PkgChangeNotification Object to Convert
45      * @return The Converted VnfPackageChangeNotification Object
46      */
47     @Override
48     public VnfPackageChangeNotification convert(final PkgChangeNotification pkgChangeNotification) {
49         logger.info("Converting PkgChangeNotification\n{}", pkgChangeNotification.toString());
50         final VnfPackageChangeNotification vnfPackageChangeNotification = new VnfPackageChangeNotification();
51         vnfPackageChangeNotification.setId(pkgChangeNotification.getId());
52
53         if (pkgChangeNotification.getNotificationType() != null) {
54             vnfPackageChangeNotification.setNotificationType(VnfPackageChangeNotification.NotificationTypeEnum
55                     .fromValue(pkgChangeNotification.getNotificationType().getValue()));
56         }
57
58         vnfPackageChangeNotification.setSubscriptionId(pkgChangeNotification.getSubscriptionId());
59         vnfPackageChangeNotification.setTimeStamp(pkgChangeNotification.getTimeStamp());
60         vnfPackageChangeNotification.setVnfPkgId(pkgChangeNotification.getVnfPkgId());
61
62         vnfPackageChangeNotification.setVnfdId(pkgChangeNotification.getVnfdId());
63
64         if (pkgChangeNotification.getChangeType() != null) {
65             vnfPackageChangeNotification.setChangeType(VnfPackageChangeNotification.ChangeTypeEnum
66                     .fromValue(pkgChangeNotification.getChangeType().getValue()));
67         }
68
69         if (pkgChangeNotification.getOperationalState() != null) {
70             vnfPackageChangeNotification.setOperationalState(VnfPackageChangeNotification.OperationalStateEnum
71                     .fromValue(pkgChangeNotification.getOperationalState().getValue()));
72         }
73
74         vnfPackageChangeNotification.setLinks(convert((pkgChangeNotification.getLinks())));
75
76         return vnfPackageChangeNotification;
77     }
78
79 }