summaryrefslogtreecommitdiffstats
path: root/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
index 4fe3f3ae13..0ef417f8e2 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaGetFunctionDataDefinition.java
@@ -30,6 +30,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.datatypes.enums.PropertySource;
import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType;
@@ -43,6 +44,7 @@ public class ToscaGetFunctionDataDefinition implements ToscaFunction, ToscaFunct
private String sourceName;
private ToscaGetFunctionType functionType;
private List<String> propertyPathFromSource = new ArrayList<>();
+ private Object toscaIndex;
public ToscaGetFunctionDataDefinition() {
//necessary for JSON conversions
@@ -87,6 +89,12 @@ public class ToscaGetFunctionDataDefinition implements ToscaFunction, ToscaFunct
);
}
if (propertySource == PropertySource.SELF) {
+ if (toscaIndex != null) {
+ Object toscaIndexValue = StringUtils.isNumeric(toscaIndex.toString()) ? Integer.parseInt(toscaIndex.toString()) : toscaIndex;
+ return Map.of(functionType.getFunctionName(),
+ Stream.concat(Stream.of(PropertySource.SELF.getName()), Stream.concat(propertyPathFromSource.stream(),Stream.of(toscaIndexValue))).collect(Collectors.toList())
+ );
+ }
return Map.of(functionType.getFunctionName(),
Stream.concat(Stream.of(PropertySource.SELF.getName()), propertyPathFromSource.stream()).collect(Collectors.toList())
);
@@ -97,6 +105,12 @@ public class ToscaGetFunctionDataDefinition implements ToscaFunction, ToscaFunct
String.format("sourceName is required in order to generate the %s from INSTANCE value", functionType.getFunctionName())
);
}
+ if (toscaIndex != null) {
+ Object toscaIndexValue = StringUtils.isNumeric(toscaIndex.toString()) ? Integer.parseInt(toscaIndex.toString()) : toscaIndex;
+ return Map.of(functionType.getFunctionName(),
+ Stream.concat(Stream.of(sourceName), Stream.concat(propertyPathFromSource.stream(),Stream.of(toscaIndexValue))).collect(Collectors.toList())
+ );
+ }
return Map.of(functionType.getFunctionName(),
Stream.concat(Stream.of(sourceName), propertyPathFromSource.stream()).collect(Collectors.toList())
);
@@ -106,10 +120,17 @@ public class ToscaGetFunctionDataDefinition implements ToscaFunction, ToscaFunct
}
private Map<String, Object> buildGetInputFunctionValue() {
+ List<Object> propertySourceCopy = new ArrayList<Object>(this.propertyPathFromSource);
+ List<Object> propertySourceOneCopy = new ArrayList<>();
+ propertySourceOneCopy.add(this.propertyPathFromSource.get(0));
+ if (toscaIndex != null) {
+ propertySourceCopy.add(toscaIndex);
+ propertySourceOneCopy.add(toscaIndex);
+ }
if (this.propertyPathFromSource.size() == 1) {
- return Map.of(this.functionType.getFunctionName(), this.propertyPathFromSource.get(0));
+ return Map.of(this.functionType.getFunctionName(), propertySourceOneCopy);
}
- return Map.of(this.functionType.getFunctionName(), this.propertyPathFromSource);
+ return Map.of(this.functionType.getFunctionName(), propertySourceCopy);
}
@Override