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.etsisol003adapter.pkgm.converters.etsicatalog.sol003;
 
  23 import static org.slf4j.LoggerFactory.getLogger;
 
  24 import org.onap.so.adapters.etsi.sol003.adapter.common.VnfmAdapterUrlProvider;
 
  25 import org.onap.so.adapters.etsisol003adapter.etsicatalog.notification.model.PkgChangeNotification;
 
  26 import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.vnfm.notification.model.VnfPackageChangeNotification;
 
  27 import org.slf4j.Logger;
 
  28 import org.springframework.core.convert.converter.Converter;
 
  29 import org.springframework.stereotype.Service;
 
  32  * Converter to convert from an Etsi Catalog Manager {@link PkgChangeNotification} Object to its equivalent SOL003
 
  33  * {@link VnfPackageChangeNotification} Object
 
  35  * @author andrew.a.lamb@est.tech
 
  38 public class PkgChangeNotificationConverter extends AbstractPkgNotificationConverter
 
  39         implements Converter<PkgChangeNotification, VnfPackageChangeNotification> {
 
  40     private static final Logger logger = getLogger(PkgChangeNotificationConverter.class);
 
  42     public PkgChangeNotificationConverter(final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) {
 
  43         super(vnfmAdapterUrlProvider);
 
  47      * Convert a {@link PkgChangeNotification} Object to an {@link VnfPackageChangeNotification} Object
 
  49      * @param pkgChangeNotification The PkgChangeNotification Object to Convert
 
  50      * @return The Converted VnfPackageChangeNotification Object
 
  53     public VnfPackageChangeNotification convert(final PkgChangeNotification pkgChangeNotification) {
 
  54         logger.info("Converting PkgChangeNotification\n{}", pkgChangeNotification.toString());
 
  55         final VnfPackageChangeNotification vnfPackageChangeNotification = new VnfPackageChangeNotification();
 
  56         vnfPackageChangeNotification.setId(pkgChangeNotification.getId());
 
  58         if (pkgChangeNotification.getNotificationType() != null) {
 
  59             vnfPackageChangeNotification.setNotificationType(VnfPackageChangeNotification.NotificationTypeEnum
 
  60                     .fromValue(pkgChangeNotification.getNotificationType().getValue()));
 
  63         vnfPackageChangeNotification.setSubscriptionId(pkgChangeNotification.getSubscriptionId());
 
  64         vnfPackageChangeNotification.setTimeStamp(pkgChangeNotification.getTimeStamp());
 
  65         vnfPackageChangeNotification.setVnfPkgId(pkgChangeNotification.getVnfPkgId());
 
  67         vnfPackageChangeNotification.setVnfdId(pkgChangeNotification.getVnfdId());
 
  69         if (pkgChangeNotification.getChangeType() != null) {
 
  70             vnfPackageChangeNotification.setChangeType(VnfPackageChangeNotification.ChangeTypeEnum
 
  71                     .fromValue(pkgChangeNotification.getChangeType().getValue()));
 
  74         if (pkgChangeNotification.getOperationalState() != null) {
 
  75             vnfPackageChangeNotification.setOperationalState(VnfPackageChangeNotification.OperationalStateEnum
 
  76                     .fromValue(pkgChangeNotification.getOperationalState().getValue()));
 
  79         vnfPackageChangeNotification.setLinks(convert(pkgChangeNotification.getLinks(),
 
  80                 pkgChangeNotification.getVnfPkgId(), pkgChangeNotification.getSubscriptionId()));
 
  82         return vnfPackageChangeNotification;