2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2019 Orange. All rights reserved.
5 ===================================================================
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 ============LICENSE_END============================================
22 import { Injectable } from '@angular/core';
24 import { Store } from '../../../../common/core/stores/Store';
26 import { CBAPackage, DslDefinition } from './mapping-models/CBAPacakge.model';
27 import { PackageCreationService } from './package-creation.service';
28 import { FolderNodeElement, MetaDataTabModel } from './mapping-models/metadata/MetaDataTab.model';
29 import * as JSZip from 'jszip';
30 import { Observable } from 'rxjs';
31 import { ResourceDictionary } from './mapping-models/ResourceDictionary.model';
37 export class PackageCreationStore extends Store<CBAPackage> {
39 private folder: FolderNodeElement = new FolderNodeElement();
40 private zipFile: JSZip = new JSZip();
42 constructor(private packageCreationService: PackageCreationService) {
43 super(new CBAPackage());
46 changeMetaData(metaDataObject: MetaDataTabModel) {
50 metaData: metaDataObject
54 changeDslDefinition(dslDefinition: DslDefinition) {
58 definitions: this.state.definitions.setDslDefinition(dslDefinition)
63 addDefinition(name: string, content: string) {
67 definitions: this.state.definitions.setImports(name, content)
71 addScripts(name: string, content: string) {
75 scripts: this.state.scripts.setScripts(name, content)
80 removeFileFromState(name: string) {
81 this.state.scripts.files.delete(name);
84 removeFileFromDefinition(filename) {
85 this.state.definitions.imports.delete(filename);
89 this.packageCreationService.savePackage(blob);
92 addTemplate(filePath: string, fileContent: string) {
95 templates: this.state.templates.setTemplates(filePath, fileContent)
99 addMapping(filePath: string, fileContent: string) {
102 mapping: this.state.mapping.setContent(filePath, fileContent)
106 getTemplateAndMapping(variables: string[]): Observable<ResourceDictionary[]> {
107 return this.packageCreationService.getTemplateAndMapping(variables);