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 DescriptorModel
from '../DescriptorModel'
25 import RspConnectionPointRef
from './RspConnectionPointRef'
26 import DescriptorModelFactory
from '../DescriptorModelFactory'
27 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
29 export default class RecordServicePath
extends DescriptorModel
{
35 static get className() {
36 return 'RecordServicePath';
39 constructor(model
, parent
) {
42 this.uiState
['qualified-type'] = 'nsd.vnffgd.rsp';
43 this.className
= 'RecordServicePath';
46 get vnfdConnectionPointRef() {
47 if (!this.model
['vnfd-connection-point-ref']) {
48 this.model
['vnfd-connection-point-ref'] = [];
50 return this.model
['vnfd-connection-point-ref'].map(d
=> DescriptorModelFactory
.newRspConnectionPointRef(d
, this));
53 set vnfdConnectionPointRef(obj
) {
54 this.updateModelList('vnfd-connection-point-ref', obj
, RspConnectionPointRef
);
57 createVnfdConnectionPointRef(connectionPoint
) {
59 if (DescriptorModelFactory
.isConnectionPoint(connectionPoint
)) {
60 ref
= connectionPoint
.toRspConnectionPointRef();
62 const model
= DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vnffgd.rsp.vnfd-connection-point-ref');
63 ref
= new RspConnectionPointRef(model
, this);
65 this.vnfdConnectionPointRef
= ref
;
69 get connectionPoints() {
70 return this.vnfdConnectionPointRef
;
73 return this.parent
.removeRecordServicePath(this);
77 * Remove all connection points refs associate with this vnfd.
81 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
82 if (typeof vnfdIndex
!== 'undefined') {
83 const len
= this.vnfdConnectionPointRef
.length
;
84 this.vnfdConnectionPointRef
= this.vnfdConnectionPointRef
.filter(d
=> d
.vnfdIndex
!== vnfdIndex
);
85 return len
!== this.vnfdConnectionPointRef
.length
;
89 removeRspConnectionPointRef(child
) {
90 return this.removeModelListItem('vnfdConnectionPointRef', child
);
94 this.parent
.createClassifierForRecordServicePath(this);