aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/forwarding-path.ts
blob: 2158dfe4799c8c158ea53eb0558cbac078e418e4 (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
import {PathElements} from './path-elements';
import {ForwardingPathLink} from "./forwarding-path-link";

export class ForwardingPath {
    public name:string;
    public destinationPortNumber:string;
    public protocol:string;
    public uniqueId:string;
    public ownerId: string;
    public pathElements: PathElements;

    addPathLink(fromNode:string, fromCP:string, toNode:string, toCP:string, fromCPOriginId: string, toCPOriginId: string) {
        if (!this.pathElements) {
            this.pathElements = new PathElements();
        }
        this.pathElements.listToscaDataDefinition[this.pathElements.listToscaDataDefinition.length] = new ForwardingPathLink(fromNode, fromCP, toNode, toCP, fromCPOriginId, toCPOriginId);
    }

    deserialize(response:any) {
        this.name = response.name;
        this.destinationPortNumber = response.destinationPortNumber;
        this.protocol = response.protocol;
        if (response.pathElements && response.pathElements.listToscaDataDefinition) {
            let list = response.pathElements.listToscaDataDefinition;
            for (let i = 0; i < list.length; i++) {
                this.addPathLink(list[i].fromNode, list[i].fromCP, list[i].toNode, list[i].toCP, list[i].fromCPOriginId, list[i].toCPOriginId);
            }
        }
    }
};