blob: a994da4a306138dbc055e7bfa55eea132ec33285 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
import { ResourceDictionary } from './ResourceDictionary.model';
import { JsonObject, JsonProperty } from 'json2typescript';
// Convert ResourceDictionary object to store Mapping.
export class MappingAdapter {
constructor(
private resourceDictionary: ResourceDictionary,
private dependancies: Map<string, Array<string>>,
private dependanciesSource: Map<string, string>) { }
ToMapping(): Mapping {
// console.log(this.resourceDictionary.definition.property);
const mapping = new Mapping();
mapping.name = this.resourceDictionary.name;
mapping.dictionaryName = this.resourceDictionary.name;
// move all properties at once
mapping.property = Object.assign({}, this.resourceDictionary.definition.property);
mapping.inputParam = this.resourceDictionary.definition.property['input-param'] || false;
// for reading
mapping.sources = this.resourceDictionary.definition.sources;
console.log(mapping.sources);
mapping.version = 0;
return mapping;
}
// Get the final object to save
finalize(mapping: Mapping): Mapping {
mapping.dictionarySource = this.dependanciesSource.get(mapping.name);
if (this.dependancies.get(mapping.name)) {
mapping.dependencies = this.dependancies.get(mapping.name);
} else {
mapping.dependencies = [];
}
delete mapping.sources;
return mapping;
}
}
@JsonObject('Mapping')
export class Mapping {
@JsonProperty('name')
name: string;
@JsonProperty()
property: any;
@JsonProperty('input-param', Boolean)
inputParam: boolean;
@JsonProperty('dictionary-name')
dictionaryName: string;
@JsonProperty(true)
sources: string[];
@JsonProperty('dictionary-source')
dictionarySource: string;
@JsonProperty()
dependencies: string[];
@JsonProperty()
version: number;
}
|