From 80c2cf3c70db2605eb9c2e28515a73567f3404ee Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Thu, 2 Jun 2022 16:34:57 +0100 Subject: Support get functions in composition property modal Allow to assign get functions values to properties in the composition properties modal. Change-Id: I470be63e2980994f43be255d8056af7392baab75 Issue-ID: SDC-4031 Signed-off-by: andre.schmid --- .../impl/ComponentInstanceBusinessLogic.java | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'catalog-be') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index 2caa721b5e..ec4535a27d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -1957,8 +1957,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { try { for (ComponentInstanceProperty property : properties) { validateMandatoryFields(property); - ComponentInstanceProperty componentInstanceProperty = validatePropertyExistsOnComponent(property, containerComponent, - foundResourceInstance); + validatePropertyExistsOnComponent(property, containerComponent, foundResourceInstance); String propertyParentUniqueId = property.getParentUniqueId(); if (property.isGetFunction()) { validateToscaGetFunction(property, containerComponent); @@ -1979,12 +1978,10 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { capPropDefinition.get().getName()), Either::right); } else { updatedPropertyValue.bimap( - updatedValue -> { - componentInstanceProperty.setValue(updatedValue); - return updatePropertyOnContainerComponent(property, updatedValue, - containerComponent, foundResourceInstance); - }, Either::right); - updatedProperties.add(componentInstanceProperty); + updatedValue -> updatePropertyOnContainerComponent(property, updatedValue, containerComponent, foundResourceInstance), + Either::right + ); + updatedProperties.add(property); } } @@ -2107,16 +2104,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } } - private ComponentInstanceProperty validatePropertyExistsOnComponent(ComponentInstanceProperty property, Component containerComponent, + private void validatePropertyExistsOnComponent(ComponentInstanceProperty property, Component containerComponent, ComponentInstance foundResourceInstance) { List instanceProperties = containerComponent.getComponentInstancesProperties() .get(foundResourceInstance.getUniqueId()); - Optional instanceProperty = instanceProperties.stream().filter(p -> p.getName().equals(property.getName())) - .findAny(); - if (instanceProperty.isEmpty()) { + final boolean hasProperty = instanceProperties.stream().anyMatch(p -> p.getName().equals(property.getName())); + if (!hasProperty) { throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND, property.getName()); } - return instanceProperty.get(); } private ComponentInstanceAttribute validateAttributeExistsOnComponent(final ComponentInstanceAttribute attribute, -- cgit 1.2.3-korg