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 UID
from '../../../libraries/UniqueId'
25 import DescriptorModel
from '../DescriptorModel'
26 import DescriptorModelFactory
from '../DescriptorModelFactory'
27 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
29 export default class VirtualLink
extends DescriptorModel
{
35 static get className() {
39 static get qualifiedType() {
40 return 'nsd.' + VirtualLink
.type
;
43 constructor(model
, parent
) {
45 this.type
= VirtualLink
.type
;
46 this.uiState
['qualified-type'] = VirtualLink
.qualifiedType
;
47 this.className
= VirtualLink
.className
;
51 const title
= this.model
['short-name'] || this.model
.name
|| (this.model
.type
+ '/' + this.id
);
52 if (title
&& title
.length
> 18) {
53 return title
.substr(0, 18) + '...';
59 if (!this.model
['vnfd-connection-point-ref']) {
60 this.model
['vnfd-connection-point-ref'] = [];
62 return this.model
['vnfd-connection-point-ref'].map(d
=> DescriptorModelFactory
.newVnfdConnectionPointRef(d
, this));
65 set connection(connections
) {
66 this.updateModelList('vnfd-connection-point-ref', connections
, DescriptorModelFactory
.VnfdConnectionPointRef
);
69 createVnfdConnectionPointRef(model
) {
70 model
= model
|| DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vld.vnfd-connection-point-ref');
71 return this.connection
= DescriptorModelFactory
.newVnfdConnectionPointRef(model
, this);
74 removeVnfdConnectionPointRefKey(cpRefKey
) {
75 const child
= this.connection
.filter(d
=> d
.key
=== cpRefKey
)[0];
76 return this.removeModelListItem('connection', child
);
79 addConnectionPoint(cp
) {
80 this.parent
.removeAnyConnectionsForConnector(cp
);
81 const cpRef
= cp
.toVnfdConnectionPointRef();
82 this.connection
= this.connection
.concat(cpRef
);
85 findConnectionPointRef(vnfdId
, vnfdIndex
, vnfdConnectionPointName
) {
86 return this.connection
.filter(d
=> d
.vnfdId
=== vnfdId
&& d
.vnfdIndex
=== vnfdIndex
&& d
.vnfdConnectionPointName
=== vnfdConnectionPointName
)[0];
90 const nsdc
= this.parent
;
91 return nsdc
.removeVLD(this);
94 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
95 const size
= this.connection
.length
;
96 if (typeof vnfdIndex
!== 'undefined') {
97 this.connection
= this.connection
.filter(d
=> d
.vnfdIndex
!== vnfdIndex
).map(d
=> d
.model
);
99 return size
!== this.connection
.length
;