From d673cb77453ba5f8e269d2b919e3a5a1d577bf53 Mon Sep 17 00:00:00 2001 From: tragait Date: Wed, 24 Feb 2021 17:11:42 +0000 Subject: set default software version value from properties In this commit, default software version value is copied from software versions list[0] property. This input value will being used in pnfcustomization table. Signed-off-by: tragait Issue-ID: SDC-3469 Change-Id: I114b3452e6a2420487029f7e4d04cb72798c61bb --- .../be/components/impl/SoftwareInformationBusinessLogic.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java index 3605856994..d6b17ca604 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/SoftwareInformationBusinessLogic.java @@ -25,6 +25,8 @@ import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException; import org.openecomp.sdc.be.csar.pnf.PnfSoftwareInformation; import org.openecomp.sdc.be.csar.pnf.PnfSoftwareVersion; import org.openecomp.sdc.be.csar.pnf.SoftwareInformationArtifactYamlParser; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; @@ -42,6 +44,7 @@ public class SoftwareInformationBusinessLogic { private final PropertyBusinessLogic propertyBusinessLogic; private static final String SOFTWARE_VERSION_PROPERTY_NAME = "software_versions"; + private static final String DEFAULT_SOFTWARE_VERSION_PROPERTY_NAME = "default_software_version"; @Autowired public SoftwareInformationBusinessLogic(final PropertyBusinessLogic propertyBusinessLogic) { @@ -84,6 +87,15 @@ public class SoftwareInformationBusinessLogic { final PropertyDefinition updatedPropertyDefinition = propertyBusinessLogic.updateComponentProperty(resource.getUniqueId(), propertyDefinition); + + // set default-software-version as first entry of software version list for resource type pnf + if(resource.getResourceType() == ResourceTypeEnum.PNF && !versionList.isEmpty()){ + final String sw_version = versionList.get(0); + Optional default_Sw_Ver_PropertyDefinition = resource.safeGetInputs().stream().filter(s->DEFAULT_SOFTWARE_VERSION_PROPERTY_NAME.equals(s.getName())).findFirst(); + if(default_Sw_Ver_PropertyDefinition.isPresent()) { + default_Sw_Ver_PropertyDefinition.get().setDefaultValue(sw_version); + } + } return Optional.ofNullable(updatedPropertyDefinition); } -- cgit 1.2.3-korg