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 DescriptorModel
from '../DescriptorModel'
22 import DescriptorModelFactory
from '../DescriptorModelFactory'
23 import DescriptorModelMetaFactory
from '../DescriptorModelMetaFactory'
25 export default class InternalVirtualLink
extends DescriptorModel
{
28 return 'internal-vld';
31 static get className() {
32 return 'InternalVirtualLink';
35 static get qualifiedType() {
36 return 'vnfd.' + InternalVirtualLink
.type
;
39 constructor(model
, parent
) {
41 this.type
= InternalVirtualLink
.type
;
42 this.uiState
['qualified-type'] = InternalVirtualLink
.qualifiedType
;
43 this.className
= InternalVirtualLink
.className
;
47 return super.title
|| (this.type
+ '/' + this.id
);
51 if (!this.model
['internal-connection-point']) {
52 this.model
['internal-connection-point'] = [];
54 return this.model
['internal-connection-point'].map(d
=> DescriptorModelFactory
.newInternalConnectionPointRef(d
, this));
57 set connection(connections
) {
58 return this.updateModelList('internal-connection-point', connections
, DescriptorModelFactory
.InternalConnectionPointRef
);
61 createInternalConnectionPoint(model
) {
62 model
= model
|| DescriptorModelMetaFactory
.createModelInstanceForType('vnfd.internal-vld.internal-connection-point');
63 return this.connection
= DescriptorModelFactory
.newInternalConnectionPointRef(model
, this);
66 removeInternalConnectionPointRefForIdRefKey(cpRefKey
) {
67 const child
= this.connection
.filter(d
=> d
.key
=== cpRefKey
)[0];
68 return this.removeModelListItem('connection', child
);
71 addConnectionPoint(icp
) {
72 this.parent
.removeAnyConnectionsForConnector(icp
);
73 const icpRef
= icp
.toInternalConnectionPointRef();
74 // this.connection = icp.toInternalConnectionPointRef();
75 this.connection
= this.connection
.concat(icpRef
);
78 removeInternalConnectionPointRefForId(idRef
) {
79 // return this.connection = this.connection.filter(d => d.idRef !== idRef).map(d => d.idRef);
80 // KKTODO: Check if below works instead
81 return this.connection
= this.connection
.filter(d
=> d
.idRef
!== idRef
).map(d
=> d
.model
);
85 return this.parent
.removeInternalVirtualLink(this);