summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java15
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/ListValidator.java21
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java24
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UIConstraint.java1
4 files changed, 60 insertions, 1 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java
index b9ceb11276..4800c020d2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/dto/FilterConstraintDto.java
@@ -22,6 +22,8 @@
package org.openecomp.sdc.be.model.dto;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
import lombok.Data;
import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
@@ -38,6 +40,7 @@ public class FilterConstraintDto {
private ConstraintType operator;
private FilterValueType valueType;
private Object value;
+ private String originalType;
public boolean isCapabilityPropertyFilter() {
return capabilityName != null;
@@ -53,6 +56,18 @@ public class FilterConstraintDto {
return Optional.empty();
}
}
+ public Optional<List<ToscaGetFunctionDataDefinition>> getAsListToscaGetFunction() {
+ List<ToscaGetFunctionDataDefinition> toscaGetFunctionDataDefinitionList = new ArrayList<>();
+ if (value instanceof List) {
+ try {
+ ((List<?>) value).forEach(toscaValue -> toscaGetFunctionDataDefinitionList.add(new ObjectMapper().convertValue(toscaValue, ToscaGetFunctionDataDefinition.class)));
+ return Optional.of(toscaGetFunctionDataDefinitionList);
+ } catch (final Exception ignored) {
+ return Optional.empty();
+ }
+ }
+ return Optional.empty();
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/ListValidator.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/ListValidator.java
index 20d927f483..46fd44d786 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/ListValidator.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/validators/ListValidator.java
@@ -72,6 +72,27 @@ public class ListValidator implements PropertyTypeValidator {
case MAP:
innerValidator = ToscaPropertyType.MAP.getValidator();
break;
+ case RANGE:
+ innerValidator = ToscaPropertyType.RANGE.getValidator();
+ break;
+ case SCALAR_UNIT_BITRATE:
+ innerValidator = ToscaPropertyType.SCALAR_UNIT_BITRATE.getValidator();
+ break;
+ case SCALAR_UNIT_FREQUENCY:
+ innerValidator = ToscaPropertyType.SCALAR_UNIT_FREQUENCY.getValidator();
+ break;
+ case SCALAR_UNIT_TIME:
+ innerValidator = ToscaPropertyType.SCALAR_UNIT_TIME.getValidator();
+ break;
+ case SCALAR_UNIT_SIZE:
+ innerValidator = ToscaPropertyType.SCALAR_UNIT_SIZE.getValidator();
+ break;
+ case SCALAR_UNIT:
+ innerValidator = ToscaPropertyType.SCALAR_UNIT.getValidator();
+ break;
+ case TIMESTAMP:
+ innerValidator = ToscaPropertyType.TIMESTAMP.getValidator();
+ break;
default:
log.debug("inner Tosca Type is unknown. {}", innerToscaType);
return false;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java
index 9c1b6c9f48..59d7ef074f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/mapper/FilterConstraintMapper.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.be.ui.mapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -49,6 +50,7 @@ public class FilterConstraintMapper {
filterConstraint.setTargetType(StringUtils.isEmpty(uiConstraint.getCapabilityName()) ? PropertyFilterTargetType.PROPERTY : PropertyFilterTargetType.CAPABILITY);
FilterValueType.findByName(uiConstraint.getSourceType()).ifPresent(filterConstraint::setValueType);
filterConstraint.setValue(mapValueFrom(uiConstraint));
+ filterConstraint.setOriginalType(uiConstraint.getOriginalType());
return filterConstraint;
}
@@ -95,6 +97,7 @@ public class FilterConstraintMapper {
propertyFilterConstraint.setOperator(filterConstraintDto.getOperator());
propertyFilterConstraint.setValueType(filterConstraintDto.getValueType());
propertyFilterConstraint.setValue(filterConstraintDto.getValue());
+ propertyFilterConstraint.setOriginalType(filterConstraintDto.getOriginalType());
return propertyFilterConstraint;
}
@@ -106,13 +109,32 @@ public class FilterConstraintMapper {
uiConstraint.setServicePropertyName(filterConstraintDto.getPropertyName());
uiConstraint.setSourceType(filterConstraintDto.getValueType().getName());
uiConstraint.setSourceName(uiConstraint.getSourceType());
+ uiConstraint.setOriginalType(uiConstraint.getOriginalType());
return uiConstraint;
}
private Object parseValueFromUiConstraint(final Object value) {
- if (!(value instanceof Map || value instanceof String)) {
+ if (!(value instanceof Map || value instanceof List || value instanceof String)) {
return value;
}
+ if (value instanceof List) {
+ List<ToscaFunction> listValue = new ArrayList<>();
+ ToscaFunction valueObject;
+ for (Object obj: (List)value) {
+ try {
+ valueObject = (ToscaFunction) getValueObject(obj);
+ }
+ catch (Exception e) {
+ return value;
+ }
+ listValue.add(valueObject);
+ }
+ return listValue;
+ }
+ return getValueObject(value);
+ }
+
+ private Object getValueObject(Object value) {
final Map<?, ?> valueAsMap;
if (value instanceof String) {
try {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UIConstraint.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UIConstraint.java
index 401de95e71..acb0c81d35 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UIConstraint.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UIConstraint.java
@@ -35,6 +35,7 @@ public class UIConstraint implements Serializable {
private String sourceType;
private String sourceName;
private Object value;
+ private String originalType;
public UIConstraint() {
}