diff options
author | imamSidero <imam.hussain@est.tech> | 2023-06-15 12:32:37 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-06-16 14:55:01 +0000 |
commit | dee57e7e416bbcbd1fcbcf5acc905a679666af28 (patch) | |
tree | 1b352c154ec815ad020dbbcc00569929c68206a4 | |
parent | 6843db5fbca71b3a30fabb4dd97f818dc4d6b72d (diff) |
Bug fix for the get input tosca function of list of nested complex type
Fixed bug regarding tosca function for list of nested complex type
Issue-ID: SDC-4538
Signed-off-by: Imam hussain <imam.hussain@est.tech>
Change-Id: I41adff984d7b7bb0f968c4ed3a24c895a546a7b9
2 files changed, 22 insertions, 17 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts index 07058ea069..26098b7020 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-get-function/tosca-get-function.component.ts @@ -133,7 +133,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { let tempIndexValue = "0"; let tempIndexProperty = tempSelectedProperty; let subPropertyDropdownList : Array<PropertyDropdownValue> = []; - if (index%2 == 0) { + if (!isNaN(Number(indexValue)) || indexValue.toLowerCase() === 'index') { tempIndexFlag = true; tempIndexValue = indexValue; tempSelectedProperty = null; @@ -143,6 +143,9 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { const dataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, tempIndexProperty.schemaType); this.addPropertiesToDropdown(dataTypeFound.properties, subPropertyDropdownList); tempSelectedProperty = subPropertyDropdownList.find(property => property.propertyName === this.toscaGetFunction.toscaIndexList[index+1]) + if (tempSelectedProperty == null && this.toscaGetFunction.toscaIndexList[index+2]) { + tempSelectedProperty = subPropertyDropdownList.find(property => property.propertyName === this.toscaGetFunction.toscaIndexList[index+2]) + } } } let tempIndexValueMap : ToscaIndexObject = {indexFlag : tempIndexFlag, nestedFlag : tempNestedFlag, indexValue: tempIndexValue, indexProperty: tempSelectedProperty, subPropertyArray: subPropertyDropdownList}; @@ -182,7 +185,7 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { this.indexListValues.forEach((indexObject : ToscaIndexObject) => { indexAndProperty.push(indexObject.indexValue); if(indexObject.nestedFlag && indexObject.indexProperty != null) { - indexAndProperty.push(indexObject.indexProperty.propertyName); + indexAndProperty.push(...indexObject.indexProperty.propertyPath); } }); toscaGetFunction.toscaIndexList = indexAndProperty; @@ -466,6 +469,16 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { if (this.hasSameType(dataTypeProperty)) { returnFlag = true; } + if (!returnFlag && this.isComplexType(dataTypeProperty.type)) { + const nestedDataTypeFound: DataTypeModel = this.dataTypeService.getDataTypeByModelAndTypeName(this.componentMetadata.model, dataTypeProperty.type); + if (nestedDataTypeFound && nestedDataTypeFound.properties) { + nestedDataTypeFound.properties.forEach( nestedDateTypeProperty => { + if (this.hasSameType(nestedDateTypeProperty)) { + returnFlag = true; + } + }); + } + } }); } return returnFlag; diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java index e234a4666f..9671eee217 100644 --- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java +++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java @@ -159,23 +159,15 @@ public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction if (!jsonNode.isArray()) { throw context.instantiationException(ToscaGetFunctionDataDefinition.class, "Expecting an array for toscaIndexList attribute"); } - for (int index = 0; index < jsonNode.size(); index++) { - String textValue = jsonNode.get(index).asText(); - if (index % 2 == 0) { - if (textValue.equalsIgnoreCase("INDEX")) { - toscaIndexList.add(textValue); - } else { - try { - toscaIndexList.add(Integer.parseInt(textValue)); - } catch (Exception e) { - throw context.instantiationException(ToscaGetFunctionDataDefinition.class, - "Expecting a valid value for toscaIndex attribute"); - } - } + + jsonNode.forEach(nodeValue -> { + String indexValue = nodeValue.asText(); + if (StringUtils.isNumeric(indexValue)) { + toscaIndexList.add(Integer.parseInt(indexValue)); } else { - toscaIndexList.add(textValue); + toscaIndexList.add(indexValue); } - } + }); } return toscaIndexList; } |