From 369ede4108a770ceb9639c6009f732ebce9be836 Mon Sep 17 00:00:00 2001 From: ahmedeldeeb50 Date: Tue, 18 Feb 2020 14:13:29 +0200 Subject: Adding DSL-Definition to vlb.json file. Fixing HashMap key and value conflict Issue-ID: CCSDK-2066 Signed-off-by: ahmedeldeeb50 Change-Id: I781f1ffc47a4ce22eeef9651aaff1dad4bf6fcc3 --- .../creationModes/DesignerCreationMode.ts | 25 +++++++++++++--------- .../creationModes/PackageCreationModes.ts | 12 +++++------ .../mapping-models/definitions/VlbDefinition.ts | 20 +++++++++++------ .../package-creation/package-creation.component.ts | 22 +++++++++---------- .../package-creation/package-creation.utils.ts | 2 -- 5 files changed, 45 insertions(+), 36 deletions(-) (limited to 'cds-ui') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts index 41b81eea3..b44e844be 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts @@ -1,8 +1,8 @@ -import {PackageCreationModes} from './PackageCreationModes'; -import {CBAPackage, Scripts} from '../mapping-models/CBAPacakge.model'; -import {FilesContent} from '../mapping-models/metadata/MetaDataTab.model'; -import {Import, Metadata, VlbDefinition} from '../mapping-models/definitions/VlbDefinition'; -import {PackageCreationUtils} from '../package-creation.utils'; +import { PackageCreationModes } from './PackageCreationModes'; +import { CBAPackage, Scripts } from '../mapping-models/CBAPacakge.model'; +import { FilesContent } from '../mapping-models/metadata/MetaDataTab.model'; +import { Import, Metadata, VlbDefinition } from '../mapping-models/definitions/VlbDefinition'; +import { PackageCreationUtils } from '../package-creation.utils'; export class DesignerCreationMode extends PackageCreationModes { @@ -18,13 +18,13 @@ export class DesignerCreationMode extends PackageCreationModes { } private addScriptsFolder(scripts: Scripts) { - scripts.files.forEach((key, value) => { + scripts.files.forEach((value, key) => { FilesContent.putData(key, value); }); } private createDefinitionsFolder(cbaPackage: CBAPackage, packageCreationUtils: PackageCreationUtils) { - cbaPackage.definitions.imports.forEach((key, valueOfFile) => { + cbaPackage.definitions.imports.forEach((valueOfFile, key) => { FilesContent.putData(key, valueOfFile); }); @@ -38,16 +38,21 @@ export class DesignerCreationMode extends PackageCreationModes { metadata.template_version = cbaPackage.metaData.version; metadata['author-email'] = 'shaaban.eltanany.ext@orange.com'; metadata['user-groups'] = 'test'; - cbaPackage.definitions.metaDataTab.mapOfCustomKey.forEach((key, customKeyValue) => { + cbaPackage.definitions.metaDataTab.mapOfCustomKey.forEach((customKeyValue, key) => { metadata[key] = customKeyValue; }); vlbDefinition.metadata = metadata; const files: Import[] = []; - cbaPackage.definitions.imports.forEach((key, valueOfFile) => { - files.push({file: valueOfFile}); + cbaPackage.definitions.imports.forEach((valueOfFile, key) => { + files.push({ file: valueOfFile }); }); console.log(vlbDefinition); vlbDefinition.imports = files; + console.log(cbaPackage.definitions.dslDefinition.content); + if (cbaPackage.definitions.dslDefinition.content) { + vlbDefinition.dsl_definitions = JSON.parse(cbaPackage.definitions.dslDefinition.content); + } + console.log(vlbDefinition); const value = packageCreationUtils.transformToJson(vlbDefinition); FilesContent.putData(filenameEntry, value); console.log('hello there'); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts index 400304aab..2d234958c 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts @@ -1,7 +1,7 @@ -import {CBAPackage} from '../mapping-models/CBAPacakge.model'; -import {ModeType} from '../mapping-models/ModeType'; -import {FilesContent, MetaDataTabModel} from '../mapping-models/metadata/MetaDataTab.model'; -import {PackageCreationUtils} from '../package-creation.utils'; +import { CBAPackage } from '../mapping-models/CBAPacakge.model'; +import { ModeType } from '../mapping-models/ModeType'; +import { FilesContent, MetaDataTabModel } from '../mapping-models/metadata/MetaDataTab.model'; +import { PackageCreationUtils } from '../package-creation.utils'; export abstract class PackageCreationModes { @@ -44,11 +44,11 @@ export abstract class PackageCreationModes { protected addToscaMetaDataFile(metaDataTab: MetaDataTabModel) { const filename = 'TOSCA-Metadata/TOSCA.meta'; - FilesContent.putData(this.getValueOfMetaData(metaDataTab), filename); + FilesContent.putData(filename, this.getValueOfMetaData(metaDataTab)); } - abstract execute(cbaPackage: CBAPackage, packageCreationUtils: PackageCreationUtils) ; + abstract execute(cbaPackage: CBAPackage, packageCreationUtils: PackageCreationUtils); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts index 2d5e520ee..c4f3ee8bd 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts @@ -1,4 +1,4 @@ -import {Any, JsonObject, JsonProperty} from 'json2typescript'; +import { Any, JsonObject, JsonProperty } from 'json2typescript'; @JsonObject @@ -8,29 +8,35 @@ export class VlbDefinition { tosca_definitions_version: string; metadata: Metadata; imports: Import[]; - // dsl_definitions: DSLDefinitions; + // tslint:disable-next-line: variable-name + dsl_definitions: DslContent; // topology_template: TopologyTemplate; } +@JsonObject('dsl_definitions') +export class DslContent { + +} + @JsonObject('metadata') export class Metadata { @JsonProperty('template_author') - // tslint:disable-next-line:variable-name + // tslint:disable-next-line:variable-name template_author: string; 'author-email': string; 'user-groups': string; @JsonProperty('template_name') - // tslint:disable-next-line:variable-name + // tslint:disable-next-line:variable-name template_name: string; @JsonProperty('template_version') - // tslint:disable-next-line:variable-name + // tslint:disable-next-line:variable-name template_version: string; @JsonProperty('template_tag') - // tslint:disable-next-line:variable-name + // tslint:disable-next-line:variable-name template_tags: string; @JsonProperty('dictionary_group') - // tslint:disable-next-line:variable-name + // tslint:disable-next-line:variable-name dictionary_group: string; diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts index c15a5dd4f..58c04e83e 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts @@ -19,15 +19,15 @@ limitations under the License. ============LICENSE_END============================================ */ -import {Component, OnInit} from '@angular/core'; -import {FilesContent, FolderNodeElement, MetaDataTabModel} from './mapping-models/metadata/MetaDataTab.model'; +import { Component, OnInit } from '@angular/core'; +import { FilesContent, FolderNodeElement, MetaDataTabModel } from './mapping-models/metadata/MetaDataTab.model'; import * as JSZip from 'jszip'; -import {PackageCreationStore} from './package-creation.store'; -import {Definition} from './mapping-models/CBAPacakge.model'; -import {PackageCreationModes} from './creationModes/PackageCreationModes'; -import {PackageCreationBuilder} from './creationModes/PackageCreationBuilder'; -import {PackageCreationUtils} from './package-creation.utils'; +import { PackageCreationStore } from './package-creation.store'; +import { Definition } from './mapping-models/CBAPacakge.model'; +import { PackageCreationModes } from './creationModes/PackageCreationModes'; +import { PackageCreationBuilder } from './creationModes/PackageCreationBuilder'; +import { PackageCreationUtils } from './package-creation.utils'; @Component({ @@ -38,8 +38,8 @@ import {PackageCreationUtils} from './package-creation.utils'; export class PackageCreationComponent implements OnInit { counter = 0; modes: object[] = [ - {name: 'Designer Mode', style: 'mode-icon icon-designer-mode'}, - {name: 'Scripting Mode', style: 'mode-icon icon-scripting-mode'}]; + { name: 'Designer Mode', style: 'mode-icon icon-designer-mode' }, + { name: 'Scripting Mode', style: 'mode-icon icon-scripting-mode' }]; private metaDataTab: MetaDataTabModel = new MetaDataTabModel(); private folder: FolderNodeElement = new FolderNodeElement(); private zipFile: JSZip = new JSZip(); @@ -76,7 +76,7 @@ export class PackageCreationComponent implements OnInit { saveBluePrintToDataBase() { this.create(); - this.zipFile.generateAsync({type: 'blob'}) + this.zipFile.generateAsync({ type: 'blob' }) .then(blob => { this.packageCreationStore.saveBluePrint(blob); }); @@ -84,7 +84,7 @@ export class PackageCreationComponent implements OnInit { create() { - FilesContent.getMapOfFilesNamesAndContent().forEach((key, value) => { + FilesContent.getMapOfFilesNamesAndContent().forEach((value, key) => { this.zipFile.folder(key.split('/')[0]); this.zipFile.file(key, value); }); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.utils.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.utils.ts index 4bccb3dd5..81a0ac181 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.utils.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.utils.ts @@ -21,8 +21,6 @@ limitations under the License. import {JsonPipe} from '@angular/common'; import {Injectable} from '@angular/core'; -import {JsonConvert} from 'json2typescript'; - @Injectable({ providedIn: 'root' -- cgit 1.2.3-korg