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 Position
from '../../graph/Position'
25 import DescriptorModel
from '../DescriptorModel'
26 import RspConnectionPointRef
from './RspConnectionPointRef'
27 import VnfdConnectionPointRef
from './VnfdConnectionPointRef'
28 import DescriptorModelFactory
from '../DescriptorModelFactory'
31 * A VirtualNetworkFunctionConnectionPoint is always a child of a VNFD. We use it to build VnfdConnectionPointRef instances. So convenience
32 * methods are add to access the fields needed to do that.
34 export default class ConnectionPoint
extends DescriptorModel
{
37 return 'connection-point';
40 static get className() {
41 return 'VirtualNetworkFunctionConnectionPoint';
44 static get qualifiedType() {
45 return 'vnfd.' + ConnectionPoint
.type
;
48 constructor(model
, parent
, readonly
) {
49 super(model
, parent
, readonly
);
50 this.type
= ConnectionPoint
.type
;
51 this.uiState
['qualified-type'] = ConnectionPoint
.qualifiedType
;
52 this.className
= 'VirtualNetworkFunctionConnectionPoint';
53 this.location
= 'bottom-left';
54 this.position
= new Position(parent
.position
.value());
55 this.position
.top
= parent
.position
.bottom
;
56 this.position
.width
= 14;
57 this.position
.height
= 14;
61 return this.model
.name
;
65 return this.parent
.key
+ '/' + this.model
.name
;
69 return this.model
.name
;
73 return this.parent
.vnfdIndex
;
77 return this.parent
.vnfdId
;
81 return this.uiState
.cpNumber
;
85 this.uiState
.cpNumber
= n
;
89 return this.model
['order'];
93 this.model
['order'] = n
;
97 * Convenience method to generate a VnfdConnectionPointRef instance from any given VirtualNetworkFunctionConnectionPoint.
99 * @returns {RspConnectionPointRef}
101 toRspConnectionPointRef() {
102 const ref
= new RspConnectionPointRef({});
103 ref
.vnfdId
= this.vnfdId
;
104 ref
.vnfdIndex
= this.vnfdIndex
;
105 ref
.vnfdConnectionPointName
= this.name
;
106 ref
.cpNumber
= this.cpNumber
;
107 ref
.order
= this.order
;
111 toVnfdConnectionPointRef() {
112 const ref
= new VnfdConnectionPointRef({});
113 ref
.vnfdId
= this.vnfdId
;
114 ref
.vnfdIndex
= this.vnfdIndex
;
115 ref
.vnfdConnectionPointName
= this.name
;
116 ref
.cpNumber
= this.cpNumber
;
117 ref
.order
= this.order
;
122 return (DescriptorModelFactory
.isVirtualLink(obj
) || DescriptorModelFactory
.isConnectionPoint(obj
)) && obj
.parent
!== this.parent
;
126 return this.parent
.removeConnectionPoint(this);