2 * Copyright 2016 RIFT.IO Inc
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * STANDARD_RIFT_IO_COPYRIGHT
21 * Created by onvelocity on 11/23/15.
26 import Position from '../../graph/Position'
27 import DescriptorModel from '../DescriptorModel'
28 import RspConnectionPointRef from './RspConnectionPointRef'
29 import VnfdConnectionPointRef from './VnfdConnectionPointRef'
30 import DescriptorModelFactory from '../DescriptorModelFactory'
33 * A VirtualNetworkFunctionConnectionPoint is always a child of a VNFD. We use it to build VnfdConnectionPointRef instances. So convenience
34 * methods are add to access the fields needed to do that.
36 export default class ConnectionPoint extends DescriptorModel {
39 return 'connection-point';
42 static get className() {
43 return 'VirtualNetworkFunctionConnectionPoint';
46 static get qualifiedType() {
47 return 'vnfd.' + ConnectionPoint.type;
50 constructor(model, parent) {
52 this.type = ConnectionPoint.type;
53 this.uiState['qualified-type'] = ConnectionPoint.qualifiedType;
54 this.className = 'VirtualNetworkFunctionConnectionPoint';
55 this.location = 'bottom-left';
56 this.position = new Position(parent.position.value());
57 this.position.top = parent.position.bottom;
58 this.position.width = 14;
59 this.position.height = 14;
63 return this.model.name;
67 return this.parent.key + '/' + this.model.name;
71 return this.model.name;
75 return this.parent.vnfdIndex;
79 return this.parent.vnfdId;
83 return this.uiState.cpNumber;
87 this.uiState.cpNumber = n;
91 * Convenience method to generate a VnfdConnectionPointRef instance from any given VirtualNetworkFunctionConnectionPoint.
93 * @returns {RspConnectionPointRef}
95 toRspConnectionPointRef() {
96 const ref = new RspConnectionPointRef({});
97 ref.vnfdId = this.vnfdId;
98 ref.vnfdIndex = this.vnfdIndex;
99 ref.vnfdConnectionPointName = this.name;
100 ref.cpNumber = this.cpNumber;
104 toVnfdConnectionPointRef() {
105 const ref = new VnfdConnectionPointRef({});
106 ref.vnfdId = this.vnfdId;
107 ref.vnfdIndex = this.vnfdIndex;
108 ref.vnfdConnectionPointName = this.name;
109 ref.cpNumber = this.cpNumber;
114 return (DescriptorModelFactory.isVirtualLink(obj) || DescriptorModelFactory.isConnectionPoint(obj)) && obj.parent !== this.parent;
118 return this.parent.removeConnectionPoint(this);