aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java42
1 files changed, 34 insertions, 8 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 6c1f4e3211..4b8249823e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -82,6 +82,7 @@ import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDef
import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaFunction;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -114,6 +115,7 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
+import org.openecomp.sdc.be.model.tosca.ToscaType;
import org.openecomp.sdc.be.model.tosca.converters.ToscaMapValueConverter;
import org.openecomp.sdc.be.tosca.PropertyConvertor.PropertyType;
import org.openecomp.sdc.be.tosca.builder.ToscaRelationshipBuilder;
@@ -225,14 +227,6 @@ public class ToscaExportHandler {
.forEach(operations -> operations.values().forEach(operation -> operation.setImplementation(null)));
}
- private static Object buildNodeFilterValue(final PropertyFilterConstraintDataDefinition filterConstraint) {
- if (filterConstraint.getValue() instanceof ToscaFunction) {
- return Map.of(filterConstraint.getOperator().getType(), ((ToscaFunction) filterConstraint.getValue()).getJsonObjectValue());
- } else {
- return Map.of(filterConstraint.getOperator().getType(), filterConstraint.getValue());
- }
- }
-
public Either<ToscaRepresentation, ToscaError> exportComponent(Component component) {
return convertToToscaTemplate(component).left().map(this::createToscaRepresentation);
}
@@ -1776,6 +1770,38 @@ public class ToscaExportHandler {
return propertiesCopy;
}
+ private static Object buildNodeFilterValue(final PropertyFilterConstraintDataDefinition filterConstraint) {
+ if (filterConstraint.getValue() instanceof ToscaFunction) {
+ return Map.of(filterConstraint.getOperator().getType(), ((ToscaFunction) filterConstraint.getValue()).getJsonObjectValue());
+ }
+ if (filterConstraint.getValue() instanceof List) {
+ if (((List<?>) filterConstraint.getValue()).get(0) instanceof ToscaFunction) {
+ List<Object> toscaFunctionList = new ArrayList<>();
+ ((List<?>) filterConstraint.getValue()).forEach(toscaFunctionValue -> toscaFunctionList.add(
+ ((ToscaFunction) toscaFunctionValue).getJsonObjectValue()));
+ return Map.of(filterConstraint.getOperator().getType(), toscaFunctionList);
+ }
+ }
+ if (doesTypeNeedConvertingToIntOrFloat(filterConstraint.getOriginalType(), filterConstraint.getValue())) {
+ ToscaType toscaType = ToscaType.getToscaType(
+ filterConstraint.getValue() instanceof List ? ToscaType.LIST.getType() : filterConstraint.getOriginalType());
+ filterConstraint.setValue(toscaType.convert(String.valueOf(filterConstraint.getValue())));
+ }
+ else if (ConstraintType.LENGTH.getType().equals(filterConstraint.getOperator().getType()) ||
+ ConstraintType.MIN_LENGTH.getType().equals(filterConstraint.getOperator().getType()) ||
+ ConstraintType.MAX_LENGTH.getType().equals(filterConstraint.getOperator().getType())) {
+ filterConstraint.setValue(Integer.valueOf(String.valueOf(filterConstraint.getValue())));
+ }
+ return Map.of(filterConstraint.getOperator().getType(), filterConstraint.getValue());
+ }
+
+ private static boolean doesTypeNeedConvertingToIntOrFloat(String propertyType, Object value) {
+ if (value instanceof List && ((List<?>) value).get(0) instanceof LinkedHashMap && ((LinkedHashMap) ((List<?>) value).get(0)).get("type") != null ) {
+ return false;
+ }
+ return ToscaType.INTEGER.getType().equals(propertyType) || ToscaType.FLOAT.getType().equals(propertyType);
+ }
+
private Map<String, String[]> buildSubstitutionMappingPropertyMapping(final Component component) {
if (component == null || CollectionUtils.isEmpty(component.getInputs())) {
return Collections.emptyMap();