3 * Copyright 2016 RIFT.IO Inc
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * Created by onvelocity on 11/23/15.
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'
30 export default class ForwardingGraph
extends DescriptorModel
{
36 static get className() {
37 return 'ForwardingGraph';
40 constructor(model
, parent
) {
43 this.uiState
['qualified-type'] = 'nsd.vnffgd';
44 this.className
= 'ForwardingGraph';
48 if (!this.model
.rsp
) {
51 return this.model
.rsp
.map(d
=> DescriptorModelFactory
.newRecordServicePath(d
, this));
55 this.updateModelList('rsp', obj
, RecordServicePath
);
59 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vnffgd.rsp');
60 return this.rsp
= new RecordServicePath(model
, this);
64 this.children
.filter(d
=> d
.id
=== obj
.id
).forEach(rsp
=> rsp
.remove());
67 get recordServicePaths() {
71 removeRecordServicePath(child
) {
72 this.rsp
= this.rsp
.filter(rsp
=> rsp
.uid
!== child
.uid
);
73 this.removeChild(child
);
77 if (!this.model
['classifier']) {
78 this.model
['classifier'] = [];
80 return this.model
['classifier'].map(d
=> DescriptorModelFactory
.newClassifier(d
, this));
84 this.updateModelList('classifier', obj
, Classifier
);
87 createClassifier(model
) {
88 model
= model
|| DescriptorModelMetaFactory
.createModelInstanceForType(DescriptorModelFactory
.Classifier
.qualifiedType
);
89 return this.classifier
= DescriptorModelFactory
.newClassifier(model
, this);
92 removeClassifier(child
) {
93 return this.removeModelListItem('classifier', child
);
98 return this.parent
.removeVnffgd(this);
106 createClassifierForRecordServicePath(rsp
) {
107 const classifier
= this.createClassifier();
108 classifier
.model
['rsp-id-ref'] = rsp
.id
;
111 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
112 this.rsp
.forEach(rsp
=> rsp
.removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
));