b4de578b9a20ae1a8abb8c3a7a222c1d5780cdd5
[ccsdk/cds.git] /
1 import { ResourceDictionary } from './ResourceDictionary.model';
2 import { JsonObject, JsonProperty, JsonConvert } from 'json2typescript';
3
4 // Convert ResourceDictionary object to store Mapping.
5 export class MappingAdapter {
6
7     constructor(
8         private resourceDictionary: ResourceDictionary,
9         private dependancies: Map<string, Array<string>>,
10         private dependanciesSource: Map<string, string>) { }
11
12     ToMapping(): Mapping {
13         const mapping = new Mapping();
14         mapping.name = this.resourceDictionary.name;
15         mapping.dictionaryName = this.resourceDictionary.name;
16         mapping.property = this.resourceDictionary.definition.property;
17         mapping.inputParam = false;
18         mapping.dictionarySource = this.dependanciesSource.get(mapping.name);
19         if (this.dependancies.get(mapping.name)) {
20             mapping.dependencies = this.dependancies.get(mapping.name);
21         } else {
22             mapping.dependencies = [];
23         }
24         mapping.version = 0;
25         return mapping;
26     }
27 }
28
29 @JsonObject('Mapping')
30 export class Mapping {
31     @JsonProperty('name')
32     name: string;
33     @JsonProperty()
34     property: any;
35     @JsonProperty('input-param', Boolean)
36     inputParam: boolean;
37     @JsonProperty('dictionary-name')
38     dictionaryName: string;
39     @JsonProperty('dictionary-source')
40     dictionarySource: string;
41     @JsonProperty()
42     dependencies: string[];
43     @JsonProperty()
44     version: number;
45 }