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 _
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'
31 export default class ForwardingGraph
extends DescriptorModel
{
37 static get className() {
38 return 'ForwardingGraph';
41 constructor(model
, parent
) {
44 this.uiState
['qualified-type'] = 'nsd.vnffgd';
45 this.className
= 'ForwardingGraph';
49 if (!this.model
.rsp
) {
52 return this.model
.rsp
.map(d
=> DescriptorModelFactory
.newRecordServicePath(d
, this));
56 this.updateModelList('rsp', obj
, RecordServicePath
);
60 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vnffgd.rsp');
61 return this.rsp
= new RecordServicePath(model
, this);
65 this.children
.filter(d
=> d
.id
=== obj
.id
).forEach(rsp
=> rsp
.remove());
68 get recordServicePaths() {
72 removeRecordServicePath(child
) {
73 this.rsp
= this.rsp
.filter(rsp
=> rsp
.uid
!== child
.uid
);
74 this.removeChild(child
);
78 if (!this.model
['classifier']) {
79 this.model
['classifier'] = [];
81 return this.model
['classifier'].map(d
=> DescriptorModelFactory
.newClassifier(d
, this));
85 this.updateModelList('classifier', obj
, Classifier
);
88 createClassifier(model
) {
89 model
= model
|| DescriptorModelMetaFactory
.createModelInstanceForType(DescriptorModelFactory
.Classifier
.qualifiedType
);
90 return this.classifier
= DescriptorModelFactory
.newClassifier(model
, this);
93 removeClassifier(child
) {
94 return this.removeModelListItem('classifier', child
);
99 return this.parent
.removeVnffgd(this);
107 createClassifierForRecordServicePath(rsp
) {
108 const classifier
= this.createClassifier();
109 classifier
.model
['rsp-id-ref'] = rsp
.id
;
112 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
113 this.rsp
.forEach(rsp
=> rsp
.removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
));