Rift.IO OSM R1 Initial Submission
[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 _ from 'lodash'
25 import Classifier from './Classifier'
26 import DescriptorModel from '../DescriptorModel'
27 import RecordServicePath from './RecordServicePath'
28 import DescriptorModelFactory from '../DescriptorModelFactory'
29 import DescriptorModelMetaFactory from '../DescriptorModelMetaFactory'
30
31 export default class ForwardingGraph extends DescriptorModel {
32
33 static get type() {
34 return 'vnffgd';
35 }
36
37 static get className() {
38 return 'ForwardingGraph';
39 }
40
41 constructor(model, parent) {
42 super(model, parent);
43 this.type = 'vnffgd';
44 this.uiState['qualified-type'] = 'nsd.vnffgd';
45 this.className = 'ForwardingGraph';
46 }
47
48 get rsp() {
49 if (!this.model.rsp) {
50 this.model.rsp = [];
51 }
52 return this.model.rsp.map(d => DescriptorModelFactory.newRecordServicePath(d, this));
53 }
54
55 set rsp(obj) {
56 this.updateModelList('rsp', obj, RecordServicePath);
57 }
58
59 createRsp() {
60 const model = DescriptorModelMetaFactory.createModelInstanceForType('nsd.vnffgd.rsp');
61 return this.rsp = new RecordServicePath(model, this);
62 }
63
64 removeRsp(obj) {
65 this.children.filter(d => d.id === obj.id).forEach(rsp => rsp.remove());
66 }
67
68 get recordServicePaths() {
69 return this.rsp;
70 }
71
72 removeRecordServicePath(child) {
73 this.rsp = this.rsp.filter(rsp => rsp.uid !== child.uid);
74 this.removeChild(child);
75 }
76
77 get classifier() {
78 if (!this.model['classifier']) {
79 this.model['classifier'] = [];
80 }
81 return this.model['classifier'].map(d => DescriptorModelFactory.newClassifier(d, this));
82 }
83
84 set classifier(obj) {
85 this.updateModelList('classifier', obj, Classifier);
86 }
87
88 createClassifier(model) {
89 model = model || DescriptorModelMetaFactory.createModelInstanceForType(DescriptorModelFactory.Classifier.qualifiedType);
90 return this.classifier = DescriptorModelFactory.newClassifier(model, this);
91 }
92
93 removeClassifier(child) {
94 return this.removeModelListItem('classifier', child);
95 }
96
97 remove() {
98 if (this.parent) {
99 return this.parent.removeVnffgd(this);
100 }
101 }
102
103 getColor() {
104
105 }
106
107 createClassifierForRecordServicePath(rsp) {
108 const classifier = this.createClassifier();
109 classifier.model['rsp-id-ref'] = rsp.id;
110 }
111
112 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex) {
113 this.rsp.forEach(rsp => rsp.removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex));
114 }
115
116 }
117