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 property
= DescriptorModelMetaFactory
.getModelMetaForType('nsd.vnffgd.rsp');
60 const uniqueName
= DescriptorModelMetaFactory
.generateItemUniqueName(this.rsp
, property
);
61 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vnffgd.rsp', uniqueName
);
62 return this.rsp
= new RecordServicePath(model
, this);
66 this.children
.filter(d
=> d
.id
=== obj
.id
).forEach(rsp
=> rsp
.remove());
69 get recordServicePaths() {
73 removeRecordServicePath(child
) {
74 this.rsp
= this.rsp
.filter(rsp
=> rsp
.uid
!== child
.uid
);
75 this.removeChild(child
);
79 if (!this.model
['classifier']) {
80 this.model
['classifier'] = [];
82 return this.model
['classifier'].map(d
=> DescriptorModelFactory
.newClassifier(d
, this));
86 this.updateModelList('classifier', obj
, Classifier
);
89 createClassifier(model
) {
90 model
= model
|| DescriptorModelMetaFactory
.createModelInstanceForType(DescriptorModelFactory
.Classifier
.qualifiedType
);
91 return this.classifier
= DescriptorModelFactory
.newClassifier(model
, this);
94 removeClassifier(child
) {
95 return this.removeModelListItem('classifier', child
);
100 return this.parent
.removeVnffgd(this);
108 createClassifierForRecordServicePath(rsp
) {
109 const classifier
= this.createClassifier();
110 classifier
.model
['rsp-id-ref'] = rsp
.id
;
113 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
114 this.rsp
.forEach(rsp
=> rsp
.removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
));