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 {MetaDataTabModel} from './mapping-models/metadata/MetaDataTab.model';
28 import {TemplateTopology} from './mapping-models/definitions/CBADefinition';
34 export class PackageCreationStore extends Store<CBAPackage> {
38 super(new CBAPackage());
41 changeMetaData(metaDataObject: MetaDataTabModel) {
45 metaData: metaDataObject
49 setCustomKeys(mapOfCustomKey: Map<string, string>) {
52 metaData: this.state.metaData.setCustomKey(mapOfCustomKey)
56 istemplateExist(): boolean {
57 return this.state.templates.files.size > 0 && this.state.mapping.files.size > 0;
60 changeDslDefinition(dslDefinition: DslDefinition) {
64 definitions: this.state.definitions.setDslDefinition(dslDefinition)
69 addDefinition(name: string, content: string) {
73 definitions: this.state.definitions.setImports(name, content)
77 addScripts(name: string, content: string) {
80 scripts: this.state.scripts.setScripts(name, content)
85 addPlans(name: string, content: string) {
88 plans: this.state.plans.setContent(name, content)
93 addRequirements(name: string, content: string) {
96 requirements: this.state.requirements.setContent(name, content)
101 removeFileFromState(name: string) {
102 this.state.scripts.files.delete(name);
105 fileExist(key: string) {
106 return this.state.templates.files.has(key);
109 removeFileFromDefinition(filename) {
110 this.state.definitions.imports.delete(filename);
114 addTemplate(filePath: string, fileContent: string) {
117 templates: this.state.templates.setTemplates(filePath, fileContent)
121 addMapping(filePath: string, fileContent: string) {
124 mapping: this.state.mapping.setContent(filePath, fileContent)
129 console.log('clearing the store');
130 this.setState(new CBAPackage());
131 console.log('it should be empty');
134 setEntryDefinition(data: string) {
135 console.log('setting manual enrichment ');
138 addTopologyTemplate(templateTopology: TemplateTopology) {
146 return this.state.metaData;