5d6050a7f097ce5a78f69def895a43b8f0792840
[sdc.git] /
1 package org.openecomp.sdc.healing.healers;
2
3
4 import org.openecomp.sdc.common.utils.SdcCommon;
5 import org.openecomp.sdc.healing.interfaces.Healer;
6 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
7 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
8 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
9 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
10 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
11 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
12 import org.openecomp.sdc.versioning.dao.types.Version;
13
14 import java.util.Map;
15 import java.util.Objects;
16
17 public class VspOnboardingMethodHealer implements Healer {
18   /*private static final VendorSoftwareProductDao vendorSoftwareProductDao =
19       VendorSoftwareProductDaoFactory.getInstance().createInterface();*/
20   private static final VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao =
21       VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
22   private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
23
24   public VspOnboardingMethodHealer(){
25
26   }
27   @Override
28   public Object heal(Map<String, Object> healingParams) throws Exception {
29     mdcDataDebugMessage.debugEntryMessage(null, null);
30
31     String onboardingMethod=null;
32     String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
33     Version version = (Version) healingParams.get(SdcCommon.VERSION);
34     VspDetails vendorSoftwareProductInfo =
35         vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
36     vendorSoftwareProductInfo.getOnboardingMethod();
37
38     if(Objects.isNull(vendorSoftwareProductInfo.getOnboardingMethod())) {
39       onboardingMethod="HEAT";
40       vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
41       vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
42       //vendorSoftwareProductDao.updateVendorSoftwareProductInfo(vendorSoftwareProductInfo);
43     }
44     return onboardingMethod;
45   }
46 }