summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ConstraintConvertor.java14
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java8
3 files changed, 34 insertions, 3 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
index c1669d18f6..e60ced5cc7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
-import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.impl.utils.CINodeFilterUtils;
@@ -44,6 +43,7 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeFilterConstraintType;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
@@ -156,6 +156,18 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
return Optional.ofNullable(result.left().value());
}
+ private String getComponentInstancePropertyType(Component component, String componentInstanceId, String propertyName) {
+ List<ComponentInstanceProperty> componentInstanceProperties = component.getComponentInstancesProperties().get(componentInstanceId);
+ if (!componentInstanceProperties.isEmpty()) {
+ for (ComponentInstanceProperty componentInstanceProperty : componentInstanceProperties) {
+ if (componentInstanceProperty.getName().equals(propertyName)) {
+ return componentInstanceProperty.getType();
+ }
+ }
+ }
+ return null;
+ }
+
public Optional<CINodeFilterDataDefinition> addNodeFilter(final String componentId, final String componentInstanceId,
final NodeFilterConstraintAction action, final String propertyName,
final String constraint, final boolean shouldLock,
@@ -174,6 +186,7 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
final RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition = new RequirementNodeFilterPropertyDataDefinition();
requirementNodeFilterPropertyDataDefinition.setName(propertyName);
requirementNodeFilterPropertyDataDefinition.setConstraints(Collections.singletonList(constraint));
+ requirementNodeFilterPropertyDataDefinition.setType(getComponentInstancePropertyType(component, componentInstanceId, propertyName));
final Either<CINodeFilterDataDefinition, StorageOperationStatus> result = addNewNodeFilter(componentId, componentInstanceId,
nodeFilterConstraintType, nodeFilterDataDefinition, requirementNodeFilterPropertyDataDefinition, capabilityName);
if (result.isRight()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ConstraintConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ConstraintConvertor.java
index 0fcbdd7768..a2c7aa2502 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ConstraintConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ConstraintConvertor.java
@@ -32,6 +32,7 @@ import org.openecomp.sdc.be.ui.model.UIConstraint;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
public class ConstraintConvertor {
@@ -51,6 +52,10 @@ public class ConstraintConvertor {
.of(ToscaFunctions.GET_INPUT.getFunctionName(), ToscaFunctions.GET_PROPERTY.getFunctionName());
public UIConstraint convert(String inConstraint) {
+ return convert(inConstraint, "");
+ }
+
+ public UIConstraint convert(String inConstraint, String valueType) {
Yaml yamlSource = new Yaml();
UIConstraint uiConstraint = new UIConstraint();
Object content1 = yamlSource.load(inConstraint);
@@ -82,6 +87,15 @@ public class ConstraintConvertor {
uiConstraint.setSourceName(STATIC_CONSTRAINT);
uiConstraint.setValue(list1);
return uiConstraint;
+ } else if (valueType != null && valueType.equals("string")) {
+ uiConstraint.setSourceType(STATIC_CONSTRAINT);
+ uiConstraint.setSourceName(STATIC_CONSTRAINT);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
+ Yaml yaml = new Yaml(options);
+ String yamlString = yaml.dump(content3);
+ uiConstraint.setValue(yamlString);
+ return uiConstraint;
} else if (content3 instanceof Map) {
return handleMap(uiConstraint, content3);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java
index cd1a1c6a55..63093ebd9a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/NodeFilterConverter.java
@@ -38,8 +38,12 @@ public class NodeFilterConverter {
final ConstraintConvertor constraintConvertor = new ConstraintConvertor();
final ListDataDefinition<RequirementNodeFilterPropertyDataDefinition> nodeFilterProperties = inNodeFilter.getProperties();
if (nodeFilterProperties != null && !nodeFilterProperties.isEmpty()) {
- final List<UIConstraint> propertiesConstraint = nodeFilterProperties.getListToscaDataDefinition().stream()
- .map(property -> property.getConstraints().iterator().next()).map(constraintConvertor::convert).collect(Collectors.toList());
+ final List<UIConstraint> propertiesConstraint = nodeFilterProperties.getListToscaDataDefinition().stream().map(property -> {
+ if(property.getType() != null) {
+ return constraintConvertor.convert(property.getConstraints().iterator().next(), property.getType());
+ } else {
+ return constraintConvertor.convert(property.getConstraints().iterator().next());
+ }}).collect(Collectors.toList());
uiNodeFilter.setProperties(propertiesConstraint);
}
final ListDataDefinition<RequirementNodeFilterCapabilityDataDefinition> nodeFilterCapabilities = inNodeFilter.getCapabilities();