From 1913ab4377e68b1215d4422fc0448c023211d739 Mon Sep 17 00:00:00 2001 From: franciscovila Date: Tue, 1 Nov 2022 14:21:27 +0000 Subject: Issues with 'range' data type detected Fix issues with range data type Issue-ID: SDC-4243 Signed-off-by: franciscovila Change-Id: Ie93f8c38b766d78f890dbe2b854a096bb8546fe8 --- .../import/tosca/data-types/dataTypes.yml | 3 ++ .../models/init/acm/tosca/data-types/dataTypes.yml | 2 ++ .../tosca/data-types/dataTypes.yml | 3 ++ .../upgrade/acm/tosca/data-types/dataTypes.yml | 2 ++ .../tosca/data-types/dataTypes.yml | 3 ++ .../models/properties-inputs/property-be-model.ts | 6 +++- .../input-list-item/input-list-item.component.html | 13 +++++++ .../input-list-item/input-list-item.component.ts | 42 ++++++++++++++++++++-- catalog-ui/src/app/utils/constants.ts | 3 +- 9 files changed, 72 insertions(+), 5 deletions(-) diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml index eab51368fe..5ff50bfcad 100644 --- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml @@ -16,6 +16,9 @@ boolean: float: derived_from: tosca.datatypes.Root +range: + derived_from: tosca.datatypes.Root + list: derived_from: tosca.datatypes.Root diff --git a/catalog-be/src/main/resources/import/tosca/models/init/acm/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/models/init/acm/tosca/data-types/dataTypes.yml index ad496c5737..b879179697 100644 --- a/catalog-be/src/main/resources/import/tosca/models/init/acm/tosca/data-types/dataTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/models/init/acm/tosca/data-types/dataTypes.yml @@ -10,6 +10,8 @@ boolean: derived_from: tosca.datatypes.Root float: derived_from: tosca.datatypes.Root +range: + derived_from: tosca.datatypes.Root list: derived_from: tosca.datatypes.Root map: diff --git a/catalog-be/src/main/resources/import/tosca/models/init/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/models/init/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml index 16de248a43..fa5e0e1e16 100644 --- a/catalog-be/src/main/resources/import/tosca/models/init/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/models/init/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml @@ -16,6 +16,9 @@ boolean: float: derived_from: tosca.datatypes.Root +range: + derived_from: tosca.datatypes.Root + list: derived_from: tosca.datatypes.Root diff --git a/catalog-be/src/main/resources/import/tosca/models/upgrade/acm/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/models/upgrade/acm/tosca/data-types/dataTypes.yml index ad496c5737..b879179697 100644 --- a/catalog-be/src/main/resources/import/tosca/models/upgrade/acm/tosca/data-types/dataTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/models/upgrade/acm/tosca/data-types/dataTypes.yml @@ -10,6 +10,8 @@ boolean: derived_from: tosca.datatypes.Root float: derived_from: tosca.datatypes.Root +range: + derived_from: tosca.datatypes.Root list: derived_from: tosca.datatypes.Root map: diff --git a/catalog-be/src/main/resources/import/tosca/models/upgrade/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/models/upgrade/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml index 16de248a43..fa5e0e1e16 100644 --- a/catalog-be/src/main/resources/import/tosca/models/upgrade/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/models/upgrade/etsi-SOL001-v2.5.1/tosca/data-types/dataTypes.yml @@ -16,6 +16,9 @@ boolean: float: derived_from: tosca.datatypes.Root +range: + derived_from: tosca.datatypes.Root + list: derived_from: tosca.datatypes.Root diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts index b8cccdd213..b4c1c2fce7 100644 --- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts +++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts @@ -33,7 +33,8 @@ export enum DerivedPropertyType { SIMPLE, LIST, MAP, - COMPLEX + COMPLEX, + RANGE } export class PropertyPolicyDetail { policyId: string; @@ -140,6 +141,9 @@ export class PropertyBEModel { if (this.type === PROPERTY_TYPES.LIST) { return DerivedPropertyType.LIST; } + if (this.type === PROPERTY_TYPES.RANGE) { + return DerivedPropertyType.RANGE; + } if (this.type === PROPERTY_TYPES.MAP) { return DerivedPropertyType.MAP; } diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html index fce8e7ea4f..1e0804eb04 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.html @@ -76,6 +76,19 @@ + +
    + +
  • + + {{valueObjRef[i]}} + + +
  • +
    +
+
    diff --git a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts index 4612ca6d60..88ff8deec6 100644 --- a/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/interface-operatons/operation-creator/input-list/input-list-item/input-list-item.component.ts @@ -85,7 +85,7 @@ export class InputListItemComponent implements OnInit { if (this.valueObjRef[property.name] == undefined) { if (this.isTypeComplex(property.type) || this.isTypeMap(property.type)) { this.valueObjRef[property.name] = {}; - } else if (this.isTypeList(property.type)) { + } else if (this.isTypeList(property.type) || this.isTypeRange(property.type)) { this.valueObjRef[property.name] = []; } else { this.valueObjRef[property.name] = null; @@ -100,13 +100,49 @@ export class InputListItemComponent implements OnInit { return DerivedPropertyType.LIST; } else if (typeName === PROPERTY_TYPES.MAP) { return DerivedPropertyType.MAP; + } else if (typeName === PROPERTY_TYPES.RANGE) { + return DerivedPropertyType.RANGE; } else { return DerivedPropertyType.COMPLEX; } } + isTypeWithoutProperties(typeName: string): boolean { + if (this.dataTypeMap.get(typeName) === undefined) { + return true; + } + return this.dataTypeMap.get(typeName).properties === undefined || + this.dataTypeMap.get(typeName).properties.length == 0; + } + + isTypeDerivedFromSimple(typeName: string): boolean { + if (typeName === undefined) { + return false; + } + if (this.dataTypeMap.get(typeName) !== undefined) { + if (this.isTypeRange(typeName)) { + return false; + } + if (this.dataTypeMap.get(typeName).derivedFromName == PROPERTY_DATA.ROOT_DATA_TYPE) { + return false; + } else if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.dataTypeMap.get(typeName).derivedFromName) > -1) { + return true; + } else { + return this.isTypeDerivedFromSimple(this.dataTypeMap.get(typeName).derivedFromName); + } + } + return true; + } + isTypeSimple(typeName: string): boolean { - return this.getType(typeName) == DerivedPropertyType.SIMPLE; + if (this.getType(typeName) == DerivedPropertyType.SIMPLE) { + return true; + } + return this.isTypeDerivedFromSimple(typeName) && (this.isTypeWithoutProperties(typeName)); + } + + isTypeRange(typeName: string): boolean { + return this.getType(typeName) == DerivedPropertyType.RANGE; } isTypeList(typeName: string): boolean { @@ -118,7 +154,7 @@ export class InputListItemComponent implements OnInit { } isTypeComplex(typeName: string): boolean { - return !this.isTypeSimple(typeName) && !this.isTypeList(typeName) && !this.isTypeMap(typeName); + return !this.isTypeSimple(typeName) && !this.isTypeList(typeName) && !this.isTypeMap(typeName) && !this.isTypeRange(typeName); } expandAndCollapse() { diff --git a/catalog-ui/src/app/utils/constants.ts b/catalog-ui/src/app/utils/constants.ts index 0de83d257e..9d11f54db9 100644 --- a/catalog-ui/src/app/utils/constants.ts +++ b/catalog-ui/src/app/utils/constants.ts @@ -137,6 +137,7 @@ export class PROPERTY_TYPES { public static FLOAT = 'float'; public static BOOLEAN = 'boolean'; public static JSON = 'json'; + public static RANGE = 'range'; public static MAP = 'map'; public static LIST = 'list'; public static SCALAR = 'scalar-unit'; @@ -152,7 +153,7 @@ export class SOURCES { } export class PROPERTY_DATA { - public static TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.TIMESTAMP, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME, PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP]; + public static TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.TIMESTAMP, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME, PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP, PROPERTY_TYPES.RANGE]; public static SIMPLE_TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.TIMESTAMP, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME]; public static SIMPLE_TYPES_COMPARABLE = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT]; public static SCALAR_TYPES = [PROPERTY_TYPES.SCALAR, PROPERTY_TYPES.SCALAR_FREQUENCY, PROPERTY_TYPES.SCALAR_SIZE, PROPERTY_TYPES.SCALAR_TIME]; -- cgit 1.2.3-korg