RIFT-15726 - optimize download size -> lodash usage in UI
[osm/UI.git] / skyquake / plugins / composer / src / src / libraries / model / descriptors / ForwardingGraph.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18 /**
19 * Created by onvelocity on 11/23/15.
20 */
21
22 'use strict';
23
24 import Classifier from './Classifier'
25 import DescriptorModel from '../DescriptorModel'
26 import RecordServicePath from './RecordServicePath'
27 import DescriptorModelFactory from '../DescriptorModelFactory'
28 import DescriptorModelMetaFactory from '../DescriptorModelMetaFactory'
29
30 export default class ForwardingGraph extends DescriptorModel {
31
32 static get type() {
33 return 'vnffgd';
34 }
35
36 static get className() {
37 return 'ForwardingGraph';
38 }
39
40 constructor(model, parent) {
41 super(model, parent);
42 this.type = 'vnffgd';
43 this.uiState['qualified-type'] = 'nsd.vnffgd';
44 this.className = 'ForwardingGraph';
45 }
46
47 get rsp() {
48 if (!this.model.rsp) {
49 this.model.rsp = [];
50 }
51 return this.model.rsp.map(d => DescriptorModelFactory.newRecordServicePath(d, this));
52 }
53
54 set rsp(obj) {
55 this.updateModelList('rsp', obj, RecordServicePath);
56 }
57
58 createRsp() {
59 const model = DescriptorModelMetaFactory.createModelInstanceForType('nsd.vnffgd.rsp');
60 return this.rsp = new RecordServicePath(model, this);
61 }
62
63 removeRsp(obj) {
64 this.children.filter(d => d.id === obj.id).forEach(rsp => rsp.remove());
65 }
66
67 get recordServicePaths() {
68 return this.rsp;
69 }
70
71 removeRecordServicePath(child) {
72 this.rsp = this.rsp.filter(rsp => rsp.uid !== child.uid);
73 this.removeChild(child);
74 }
75
76 get classifier() {
77 if (!this.model['classifier']) {
78 this.model['classifier'] = [];
79 }
80 return this.model['classifier'].map(d => DescriptorModelFactory.newClassifier(d, this));
81 }
82
83 set classifier(obj) {
84 this.updateModelList('classifier', obj, Classifier);
85 }
86
87 createClassifier(model) {
88 model = model || DescriptorModelMetaFactory.createModelInstanceForType(DescriptorModelFactory.Classifier.qualifiedType);
89 return this.classifier = DescriptorModelFactory.newClassifier(model, this);
90 }
91
92 removeClassifier(child) {
93 return this.removeModelListItem('classifier', child);
94 }
95
96 remove() {
97 if (this.parent) {
98 return this.parent.removeVnffgd(this);
99 }
100 }
101
102 getColor() {
103
104 }
105
106 createClassifierForRecordServicePath(rsp) {
107 const classifier = this.createClassifier();
108 classifier.model['rsp-id-ref'] = rsp.id;
109 }
110
111 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex) {
112 this.rsp.forEach(rsp => rsp.removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex));
113 }
114
115 }
116