diff options
author | ShaabanEltanany <shaaban.eltanany.ext@orange.com> | 2020-10-22 11:32:41 +0200 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2020-10-22 17:58:50 +0000 |
commit | cf1e08373c11c19ef6acf6f1390225c6e9ccf4eb (patch) | |
tree | d46f0ab2f9d2decf1631702f71a7da8b4f76063a /cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation | |
parent | b88ab26ba1890190956c2c003660152027ebcdac (diff) |
adding support for plans and requirements of importing package
Issue-ID: CCSDK-2930
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: I495054a8cf24ea44251e6600a8fe8ada88ead61b
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/DesignerCreationMode.ts | 36 | ||||
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts | 13 | ||||
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/CBADefinition.ts (renamed from cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/definitions/VlbDefinition.ts) | 2 | ||||
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation-extraction.service.ts | 18 | ||||
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts | 18 |
5 files changed, 70 insertions, 17 deletions
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 d6e15ed09..b8929819e 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,7 +1,7 @@ import {PackageCreationModes} from './PackageCreationModes'; -import {CBAPackage, Scripts} from '../mapping-models/CBAPacakge.model'; +import {CBAPackage, Plans, Requirements, Scripts} from '../mapping-models/CBAPacakge.model'; import {FilesContent} from '../mapping-models/metadata/MetaDataTab.model'; -import {Import, Metadata, VlbDefinition} from '../mapping-models/definitions/VlbDefinition'; +import {CBADefinition, Import, Metadata} from '../mapping-models/definitions/CBADefinition'; import {PackageCreationUtils} from '../package-creation.utils'; @@ -17,6 +17,8 @@ export class DesignerCreationMode extends PackageCreationModes { this.createDefinitionsFolder(cbaPackage, packageCreationUtils); this.addScriptsFolder(cbaPackage.scripts); this.addTemplateFolder(cbaPackage); + this.addPlansFolder(cbaPackage.plans); + this.addRequirementsFolder(cbaPackage.requirements); } private addScriptsFolder(scripts: Scripts) { @@ -25,6 +27,18 @@ export class DesignerCreationMode extends PackageCreationModes { }); } + private addRequirementsFolder(requirements: Requirements) { + requirements.files.forEach((value, key) => { + FilesContent.putData(key, value); + }); + } + + private addPlansFolder(plans: Plans) { + plans.files.forEach((value, key) => { + FilesContent.putData(key, value); + }); + } + private addTemplateFolder(cbaPackage: CBAPackage) { // Create Template Files Folder cbaPackage.templates.files.forEach((value, key) => { @@ -44,7 +58,7 @@ export class DesignerCreationMode extends PackageCreationModes { } const filenameEntry = 'Definitions/' + cbaPackage.metaData.name.trim() + '.json'; - const vlbDefinition: VlbDefinition = new VlbDefinition(); + const cbaDefinition: CBADefinition = new CBADefinition(); const metadata: Metadata = new Metadata(); metadata.template_author = 'Shaaban Ebrahim'; @@ -72,9 +86,9 @@ export class DesignerCreationMode extends PackageCreationModes { }); } metadata.template_tags = fullTags; - vlbDefinition.metadata = metadata; + cbaDefinition.metadata = metadata; const files: Import[] = []; - let insideVlbDefinition: VlbDefinition = null; + let insideVlbDefinition: CBADefinition = null; if (cbaPackage.definitions.imports && cbaPackage.definitions.imports.size > 0) { cbaPackage.definitions.imports.forEach((valueOfFile, key) => { if (!key.includes(cbaPackage.metaData.name)) { @@ -86,20 +100,20 @@ export class DesignerCreationMode extends PackageCreationModes { } }); } - vlbDefinition.imports = files; + cbaDefinition.imports = files; if (cbaPackage.definitions && cbaPackage.definitions.dslDefinition && cbaPackage.definitions.dslDefinition.content) { - vlbDefinition.dsl_definitions = JSON.parse(cbaPackage.definitions.dslDefinition.content); + cbaDefinition.dsl_definitions = JSON.parse(cbaPackage.definitions.dslDefinition.content); } - // vlbDefinition.imports = files; + // cbaDefinition.imports = files; if (cbaPackage.templateTopology && cbaPackage.templateTopology.content) { - vlbDefinition.topology_template = JSON.parse(cbaPackage.templateTopology.content); + cbaDefinition.topology_template = JSON.parse(cbaPackage.templateTopology.content); } else if (insideVlbDefinition && insideVlbDefinition.topology_template) { - vlbDefinition.topology_template = insideVlbDefinition.topology_template; + cbaDefinition.topology_template = insideVlbDefinition.topology_template; } - const value = packageCreationUtils.transformToJson(vlbDefinition); + const value = packageCreationUtils.transformToJson(cbaDefinition); FilesContent.putData(filenameEntry, value); console.log(FilesContent.getMapOfFilesNamesAndContent()); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts index e34b5491b..c8c93cd14 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts @@ -1,5 +1,5 @@ import {MetaDataTabModel} from './metadata/MetaDataTab.model'; -import {TemplateTopology} from './definitions/VlbDefinition'; +import {TemplateTopology} from './definitions/CBADefinition'; export class Definition { @@ -65,6 +65,13 @@ export class Scripts { } } +export class Plans extends Base { + +} + +export class Requirements extends Base { +} + export class Template { public files: Map<string, string>; @@ -94,6 +101,8 @@ export class CBAPackage { public templates: Template; public mapping: Mapping; public templateTopology: TemplateTopology; + public plans: Plans; + public requirements: Requirements; constructor() { @@ -103,6 +112,8 @@ export class CBAPackage { this.templates = new Template(); this.mapping = new Mapping(); this.templateTopology = new TemplateTopology(); + this.plans = new Plans(); + this.requirements = new Requirements(); } 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/CBADefinition.ts index 7a029fb3f..74681fb2c 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/CBADefinition.ts @@ -9,7 +9,7 @@ export class TemplateTopology { } @JsonObject -export class VlbDefinition { +export class CBADefinition { // tslint:disable-next-line:variable-name tosca_definitions_version: string; diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation-extraction.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation-extraction.service.ts index f44f68887..585c16929 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation-extraction.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation-extraction.service.ts @@ -1,6 +1,6 @@ import {Injectable, ViewChild} from '@angular/core'; import {MetaDataTabModel} from './mapping-models/metadata/MetaDataTab.model'; -import {TemplateTopology, VlbDefinition} from './mapping-models/definitions/VlbDefinition'; +import {CBADefinition, TemplateTopology} from './mapping-models/definitions/CBADefinition'; import {DslDefinition} from './mapping-models/CBAPacakge.model'; import {PackageCreationStore} from './package-creation.store'; import * as JSZip from 'jszip'; @@ -67,6 +67,10 @@ export class PackageCreationExtractionService { } else if (filename.includes('Definitions/')) { this.setImports(filename, fileData, packageName); + } else if (filename.includes('Plans/')) { + this.setPlans(filename, fileData); + } else if (filename.includes('Requirements/')) { + this.setRequirements(filename, fileData); } } }); @@ -78,11 +82,19 @@ export class PackageCreationExtractionService { this.packageCreationStore.addScripts(filename, fileData); } + public setPlans(filename: string, fileData: any) { + this.packageCreationStore.addPlans(filename, fileData); + } + + public setRequirements(filename: string, fileData: any) { + this.packageCreationStore.addRequirements(filename, fileData); + } + public setImports(filename: string, fileData: any, packageName: string) { console.log(filename); if (filename.includes('Definitions/' + packageName.trim() + '.json')) { - let definition = new VlbDefinition(); - definition = fileData as VlbDefinition; + let definition = new CBADefinition(); + definition = fileData as CBADefinition; definition = JSON.parse(fileData); const dslDefinition = new DslDefinition(); dslDefinition.content = this.packageCreationUtils.transformToJson(definition.dsl_definitions); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts index 77867e55e..24a4d4735 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts @@ -25,7 +25,7 @@ import {Store} from '../../../../common/core/stores/Store'; import {CBAPackage, DslDefinition} from './mapping-models/CBAPacakge.model'; import {MetaDataTabModel} from './mapping-models/metadata/MetaDataTab.model'; -import {TemplateTopology} from './mapping-models/definitions/VlbDefinition'; +import {TemplateTopology} from './mapping-models/definitions/CBADefinition'; @Injectable({ @@ -82,6 +82,22 @@ export class PackageCreationStore extends Store<CBAPackage> { } + addPlans(name: string, content: string) { + this.setState({ + ...this.state, + plans: this.state.plans.setContent(name, content) + }); + + } + + addRequirements(name: string, content: string) { + this.setState({ + ...this.state, + requirements: this.state.requirements.setContent(name, content) + }); + + } + removeFileFromState(name: string) { this.state.scripts.files.delete(name); } |