- private static Map<String, List<String>> createMappedInputPropertyDefaultValue(String propertyName) {
- Map<String, List<String>> getPropertyMap = new HashMap<>();
- List<String> values = new ArrayList<>();
- values.add(SELF);
- if (Objects.nonNull(propertyName) && !propertyName.isEmpty()) {
- values.addAll(Arrays.asList(propertyName.split("\\.")));
- }
-
- getPropertyMap.put(GET_PROPERTY, values);
-
- return getPropertyMap;
- }
-
- /**
- * Create the value for operation input mapped to an operation output.
- * @param propertyName the mapped other operation output full name
- * @return input map for tosca
- */
- private static Map<String, List<String>> createMappedOutputDefaultValue(String propertyName) {
- Map<String, List<String>> getOperationOutputMap = new HashMap<>();
- //For operation input mapped to other operation output parameter, the mapped property value
- // should be of the format <interface name>.<operation name>.<output parameter name>
- // Operation name and output param name should not contain "."
- List<String> defaultMappedOperationOutputValue = new ArrayList<>();
- String[] tokens = propertyName.split("\\.");
- if (tokens.length > 2) {
- defaultMappedOperationOutputValue.add(SELF);
- String outputPropertyName = tokens[tokens.length - 1];
- String operationName = tokens[tokens.length - 2];
- String mappedPropertyInterfaceType =
- propertyName.substring(0, propertyName.indexOf(operationName + '.' + outputPropertyName) - 1);
- String interfaceName =
- mappedPropertyInterfaceType.substring(mappedPropertyInterfaceType.lastIndexOf('.') + 1);
- defaultMappedOperationOutputValue.addAll(Arrays.asList(interfaceName, operationName, outputPropertyName));
- getOperationOutputMap.put(GET_OPERATION_OUTPUT, defaultMappedOperationOutputValue);
+ private static String getInputValue(String inputValue) {
+ String toscaInputValue = inputValue;
+ if (Objects.nonNull(inputValue) && inputValue.contains(ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName())) {
+ Gson gson = new Gson();
+ Map<String, List<String>> consumptionValue = gson.fromJson(inputValue, Map.class);
+ List<String> mappedOutputValue =
+ consumptionValue.get(ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName());
+ //Extract the interface name from the interface type
+ String interfaceType = mappedOutputValue.get(1);
+ String interfaceName = interfaceType.substring(interfaceType.lastIndexOf('.') + 1);
+ mappedOutputValue.remove(1);
+ mappedOutputValue.add(1, interfaceName);
+ toscaInputValue = gson.toJson(consumptionValue);