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
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  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.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003;
 
  23 import static org.slf4j.LoggerFactory.getLogger;
 
  24 import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgChangeNotification;
 
  25 import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageChangeNotification;
 
  26 import org.slf4j.Logger;
 
  27 import org.springframework.core.convert.converter.Converter;
 
  28 import org.springframework.stereotype.Service;
 
  31  * Converter to convert from an Etsi Catalog Manager {@link PkgChangeNotification} Object to its equivalent SOL003
 
  32  * {@link VnfPackageChangeNotification} Object
 
  34  * @author andrew.a.lamb@est.tech
 
  37 public class PkgChangeNotificationConverter extends AbstractPkgNotificationConverter
 
  38         implements Converter<PkgChangeNotification, VnfPackageChangeNotification> {
 
  39     private static final Logger logger = getLogger(PkgChangeNotificationConverter.class);
 
  42      * Convert a {@link PkgChangeNotification} Object to an {@link VnfPackageChangeNotification} Object
 
  44      * @param pkgChangeNotification The PkgChangeNotification Object to Convert
 
  45      * @return The Converted VnfPackageChangeNotification Object
 
  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());
 
  53         if (pkgChangeNotification.getNotificationType() != null) {
 
  54             vnfPackageChangeNotification.setNotificationType(VnfPackageChangeNotification.NotificationTypeEnum
 
  55                     .fromValue(pkgChangeNotification.getNotificationType().getValue()));
 
  58         vnfPackageChangeNotification.setSubscriptionId(pkgChangeNotification.getSubscriptionId());
 
  59         vnfPackageChangeNotification.setTimeStamp(pkgChangeNotification.getTimeStamp());
 
  60         vnfPackageChangeNotification.setVnfPkgId(pkgChangeNotification.getVnfPkgId());
 
  62         vnfPackageChangeNotification.setVnfdId(pkgChangeNotification.getVnfdId());
 
  64         if (pkgChangeNotification.getChangeType() != null) {
 
  65             vnfPackageChangeNotification.setChangeType(VnfPackageChangeNotification.ChangeTypeEnum
 
  66                     .fromValue(pkgChangeNotification.getChangeType().getValue()));
 
  69         if (pkgChangeNotification.getOperationalState() != null) {
 
  70             vnfPackageChangeNotification.setOperationalState(VnfPackageChangeNotification.OperationalStateEnum
 
  71                     .fromValue(pkgChangeNotification.getOperationalState().getValue()));
 
  74         vnfPackageChangeNotification.setLinks(convert((pkgChangeNotification.getLinks())));
 
  76         return vnfPackageChangeNotification;