diff options
author | andre.schmid <andre.schmid@est.tech> | 2022-02-09 19:00:35 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-03-11 15:25:28 +0000 |
commit | f13f58eb867c763e6ed1c3b674fd99b1081a0664 (patch) | |
tree | c0ccc70b8fdf4362bce26efa0a5bb1c435f98575 /catalog-ui/src/app/models/data-types.ts | |
parent | 767b122ea026099e17a2ffde30e6718d2abf150f (diff) |
Support complex types in interface operation inputs
Issue-ID: SDC-3897
Change-Id: Ieac2d74ad340de1d9f6e4cd3ac830e2ec8c35d5b
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Signed-off-by: vasraz <vasyl.razinkov@est.tech>
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'catalog-ui/src/app/models/data-types.ts')
-rw-r--r-- | catalog-ui/src/app/models/data-types.ts | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/catalog-ui/src/app/models/data-types.ts b/catalog-ui/src/app/models/data-types.ts index 7004b43cbc..7fc788bf93 100644 --- a/catalog-ui/src/app/models/data-types.ts +++ b/catalog-ui/src/app/models/data-types.ts @@ -25,6 +25,7 @@ import {PropertyBEModel} from "./properties-inputs/property-be-model"; import {AttributeBEModel} from "./attributes-outputs/attribute-be-model"; import {Model} from "./model"; +import {PROPERTY_DATA} from "../utils/constants"; export class DataTypeModel { @@ -39,16 +40,24 @@ export class DataTypeModel { attributes: Array<AttributeBEModel>; model: Model; - constructor(dataType:DataTypeModel) { + constructor(dataType: DataTypeModel) { if (dataType) { this.uniqueId = dataType.uniqueId; this.name = dataType.name; this.derivedFromName = dataType.derivedFromName; + if (dataType.derivedFrom) { + this.derivedFrom = new DataTypeModel(dataType.derivedFrom); + } this.creationTime = dataType.creationTime; this.modificationTime = dataType.modificationTime; - this.properties = dataType.properties; + if (dataType.properties) { + this.properties = []; + dataType.properties.forEach(property => { + this.properties.push(new PropertyBEModel(property)); + }); + } this.attributes = dataType.attributes; - this.model = this.model; + this.model = dataType.model; } } @@ -56,5 +65,25 @@ export class DataTypeModel { return this; }; + + /** + * Parses the default value to JSON. + */ + public parseDefaultValueToJson(): any { + if (PROPERTY_DATA.TYPES.indexOf(this.name) > -1) { + return undefined; + } + const defaultValue = {}; + if (this.properties) { + this.properties.forEach(property => { + const propertyDefaultValue = property.parseDefaultValueToJson(); + if (propertyDefaultValue != undefined) { + defaultValue[property.name] = propertyDefaultValue; + } + }); + } + + return defaultValue === {} ? undefined : defaultValue; + } } |