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 DescriptorModel
from '../DescriptorModel'
26 import RspConnectionPointRef
from './RspConnectionPointRef'
27 import DescriptorModelFactory
from '../DescriptorModelFactory'
28 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
30 export default class RecordServicePath
extends DescriptorModel
{
36 static get className() {
37 return 'RecordServicePath';
40 constructor(model
, parent
) {
43 this.uiState
['qualified-type'] = 'nsd.vnffgd.rsp';
44 this.className
= 'RecordServicePath';
47 get vnfdConnectionPointRef() {
48 if (!this.model
['vnfd-connection-point-ref']) {
49 this.model
['vnfd-connection-point-ref'] = [];
51 return this.model
['vnfd-connection-point-ref'].map(d
=> DescriptorModelFactory
.newRspConnectionPointRef(d
, this));
54 set vnfdConnectionPointRef(obj
) {
55 this.updateModelList('vnfd-connection-point-ref', obj
, RspConnectionPointRef
);
58 createVnfdConnectionPointRef(connectionPoint
) {
60 if (DescriptorModelFactory
.isConnectionPoint(connectionPoint
)) {
61 ref
= connectionPoint
.toRspConnectionPointRef();
63 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vnffgd.rsp.vnfd-connection-point-ref');
64 ref
= new RspConnectionPointRef(model
, this);
66 this.vnfdConnectionPointRef
= ref
;
70 get connectionPoints() {
71 return this.vnfdConnectionPointRef
;
74 return this.parent
.removeRecordServicePath(this);
78 * Remove all connection points refs associate with this vnfd.
82 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
83 if (typeof vnfdIndex
!== 'undefined') {
84 const len
= this.vnfdConnectionPointRef
.length
;
85 this.vnfdConnectionPointRef
= this.vnfdConnectionPointRef
.filter(d
=> d
.vnfdIndex
!== vnfdIndex
);
86 return len
!== this.vnfdConnectionPointRef
.length
;
90 removeRspConnectionPointRef(child
) {
91 return this.removeModelListItem('vnfdConnectionPointRef', child
);
95 this.parent
.createClassifierForRecordServicePath(this);