diff options
author | 2023-03-23 11:25:23 +0000 | |
---|---|---|
committer | 2023-04-03 11:13:18 +0000 | |
commit | 7565f810f9fa50c8140843b2f81e8fb428815154 (patch) | |
tree | 5ff3ef43bd7434db7c0bd462db295a2726052c61 /catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function | |
parent | 3dff1c221e58de6a81cf6bbdfb84fdf97665e484 (diff) |
Provide tosca function capability to all nested levels
Tosca function capability is provided to all nested levels of list, map and custom types
Issue-ID: SDC-4445
Signed-off-by: Imam hussain <imam.hussain@est.tech>
Change-Id: I29907bdac83d3cadf90aa0a2ed538002132b4789
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function')
2 files changed, 27 insertions, 19 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts index 9ea0c8f214..d46ac2eb10 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/tosca-function/tosca-function.component.ts @@ -114,16 +114,7 @@ export class ToscaFunctionComponent implements OnInit, OnChanges { if (this.property instanceof PropertyDeclareAPIModel && this.property.subPropertyToscaFunctions && (<PropertyDeclareAPIModel> this.property).propertiesName){ let propertiesPath = (<PropertyDeclareAPIModel> this.property).propertiesName.split("#"); if (propertiesPath.length > 1){ - let keyToFind = []; - if (this.property.type == PROPERTY_TYPES.MAP || this.property.type == PROPERTY_TYPES.LIST) { - if (this.property.type == PROPERTY_TYPES.LIST && this.property.schemaType == PROPERTY_TYPES.MAP) { - keyToFind.push((<DerivedFEProperty>this.property.input).parentMapKey); - } - keyToFind.push((<DerivedFEProperty>this.property.input).mapKey); - if (this.property.schemaType != PROPERTY_TYPES.MAP && PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.property.schemaType) === -1) { - keyToFind.push(propertiesPath.reverse()[0]); - } - } + let keyToFind = (<DerivedFEProperty>this.property.input).toscaPath; let subPropertyToscaFunction = this.property.subPropertyToscaFunctions.find(subPropertyToscaFunction => this.areEqual(subPropertyToscaFunction.subPropertyPath, keyToFind.length > 0 ? keyToFind : propertiesPath.slice(1))); if (subPropertyToscaFunction){ 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 b0146cc1cf..656d7d6d71 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 @@ -264,11 +264,21 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { private propertyTypeToString() { if (this.isSubProperty()){ - if ((this.typeHasSchema(this.property.type) && this.property instanceof PropertyDeclareAPIModel && - (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty) || this.compositionMap) { + if ((this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty) + || this.compositionMap) { if(this.isComplexType(this.property.schemaType) && !this.compositionMap){ - let propertySchemaType = (<PropertyDeclareAPIModel> this.property).input.type; - return propertySchemaType == PROPERTY_TYPES.MAP ? PROPERTY_TYPES.STRING : propertySchemaType; + let mapChildProp : DerivedFEProperty = (<DerivedFEProperty> (<PropertyDeclareAPIModel> this.property).input); + let propertySchemaType = mapChildProp.type; + if (this.property.type == PROPERTY_TYPES.MAP || propertySchemaType == PROPERTY_TYPES.MAP) { + if (mapChildProp.mapKey != '' && mapChildProp.mapKey != null && mapChildProp.schema.property.type != null) { + propertySchemaType = mapChildProp.schema.property.type; + } + } + if ((propertySchemaType == PROPERTY_TYPES.MAP || (propertySchemaType == PROPERTY_TYPES.LIST && mapChildProp.schema.property.type == PROPERTY_TYPES.MAP)) + && mapChildProp.isChildOfListOrMap) { + propertySchemaType = PROPERTY_TYPES.STRING; + } + return propertySchemaType; }else{ return this.property.schema.property.type; } @@ -379,10 +389,13 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { private hasSameType(property: PropertyBEModel | AttributeBEModel): boolean { if (this.typeHasSchema(this.property.type)) { if ((this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel> this.property).input instanceof DerivedFEProperty) || this.compositionMap) { - if(this.isComplexType(this.property.schemaType) && !this.compositionMap){ - let propertySchemaType = (<PropertyDeclareAPIModel> this.property).input.type; - propertySchemaType = propertySchemaType == PROPERTY_TYPES.MAP ? PROPERTY_TYPES.STRING : propertySchemaType; - return property.type === propertySchemaType; + let childObject : DerivedFEProperty = (<DerivedFEProperty>(<PropertyDeclareAPIModel> this.property).input); + let childSchemaType = this.property.schemaType != null ? this.property.schemaType : childObject.type; + if(this.isComplexType(childSchemaType) && !this.compositionMap){ + if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) { + return property.type === PROPERTY_TYPES.STRING; + } + return property.type === childObject.type; }else{ return property.type === this.property.schema.property.type; } @@ -393,7 +406,11 @@ export class ToscaGetFunctionComponent implements OnInit, OnChanges { return property.type === this.property.type && this.property.schema.property.type === property.schema.property.type; } if (this.property.schema.property.isDataType && this.property instanceof PropertyDeclareAPIModel && (<PropertyDeclareAPIModel>this.property).propertiesName){ - let typeToMatch = this.getType((<PropertyDeclareAPIModel>this.property).propertiesName.split("#").slice(1), this.property.type); + let typeToMatch = (<PropertyDeclareAPIModel> this.property).input.type; + let childObject : DerivedFEProperty = (<DerivedFEProperty>(<PropertyDeclareAPIModel> this.property).input); + if (childObject.type == PROPERTY_TYPES.MAP && childObject.isChildOfListOrMap) { + typeToMatch = PROPERTY_TYPES.STRING; + } return property.type === typeToMatch; } |