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.
21 import UID
from '../../../libraries/UniqueId'
22 import DescriptorModel
from '../DescriptorModel'
23 import DescriptorModelFactory
from '../DescriptorModelFactory'
24 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
26 export default class VirtualLink
extends DescriptorModel
{
32 static get className() {
36 static get qualifiedType() {
37 return 'nsd.' + VirtualLink
.type
;
40 constructor(model
, parent
) {
42 this.type
= VirtualLink
.type
;
43 this.uiState
['qualified-type'] = VirtualLink
.qualifiedType
;
44 this.className
= VirtualLink
.className
;
48 const title
= this.model
['short-name'] || this.model
.name
|| (this.model
.type
+ '/' + this.id
);
49 if (title
&& title
.length
> 18) {
50 return title
.substr(0, 18) + '...';
56 if (!this.model
['vnfd-connection-point-ref']) {
57 this.model
['vnfd-connection-point-ref'] = [];
59 return this.model
['vnfd-connection-point-ref'].map(d
=> DescriptorModelFactory
.newVnfdConnectionPointRef(d
, this));
62 set connection(connections
) {
63 this.updateModelList('vnfd-connection-point-ref', connections
, DescriptorModelFactory
.VnfdConnectionPointRef
);
66 createVnfdConnectionPointRef(model
) {
67 model
= model
|| DescriptorModelMetaFactory
.createModelInstanceForType('nsd.vld.vnfd-connection-point-ref');
68 return this.connection
= DescriptorModelFactory
.newVnfdConnectionPointRef(model
, this);
71 removeVnfdConnectionPointRefKey(cpRefKey
) {
72 const child
= this.connection
.filter(d
=> d
.key
=== cpRefKey
)[0];
73 return this.removeModelListItem('connection', child
);
76 addConnectionPoint(cp
) {
77 this.parent
.removeAnyConnectionsForConnector(cp
);
78 const cpRef
= cp
.toVnfdConnectionPointRef();
79 this.connection
= this.connection
.concat(cpRef
);
82 findConnectionPointRef(vnfdId
, vnfdIndex
, vnfdConnectionPointName
) {
83 return this.connection
.filter(d
=> d
.vnfdId
=== vnfdId
&& d
.vnfdIndex
=== vnfdIndex
&& d
.vnfdConnectionPointName
=== vnfdConnectionPointName
)[0];
87 const nsdc
= this.parent
;
88 return nsdc
.removeVLD(this);
91 removeVnfdConnectionPointRefForVnfdIndex(vnfdIndex
) {
92 const size
= this.connection
.length
;
93 if (typeof vnfdIndex
!== 'undefined') {
94 this.connection
= this.connection
.filter(d
=> d
.vnfdIndex
!== vnfdIndex
).map(d
=> d
.model
);
96 return size
!== this.connection
.length
;