27a070e03027d32a5d453e7dfcc5a74ca0209618
[osm/riftware.git] /
1 /*
2  * STANDARD_RIFT_IO_COPYRIGHT
3  */
4 /**
5  * Created by onvelocity on 11/23/15.
6  */
7
8 'use strict';
9
10 import DescriptorModel from '../DescriptorModel'
11 import DescriptorModelFactory from '../DescriptorModelFactory'
12
13 export default class InternalVirtualLink extends DescriptorModel {
14
15         static get type() {
16                 return 'internal-vld';
17         }
18
19         static get className() {
20                 return 'InternalVirtualLink';
21         }
22
23         static get qualifiedType() {
24                 return 'vnfd.' + InternalVirtualLink.type;
25         }
26
27         constructor(model, parent) {
28                 super(model, parent);
29                 this.type = InternalVirtualLink.type;
30                 this.uiState['qualified-type'] = InternalVirtualLink.qualifiedType;
31                 this.className = InternalVirtualLink.className;
32         }
33
34         get title() {
35                 return super.title || (this.type + '/' + this.id);
36         }
37
38         get connection() {
39                 const list = this.model['internal-connection-point-ref'] || (this.model['internal-connection-point-ref'] = []);
40                 return list.map(d => DescriptorModelFactory.newInternalConnectionPointRef(d, this));
41         }
42
43         set connection(connections) {
44                 return this.updateModelList('internal-connection-point-ref', connections, DescriptorModelFactory.InternalConnectionPointRef);
45         }
46
47         addConnectionPoint(icp) {
48                 icp.model['internal-vld-ref'] = this.id;
49                 this.parent.removeAnyConnectionsForConnector(icp);
50                 this.connection = icp.toInternalConnectionPointRef();
51         }
52
53         removeInternalConnectionPointRefForId(id) {
54                 return this.connection = this.connection.filter(d => d.id !== id).map(d => d.id);
55         }
56
57         remove() {
58                 return this.parent.removeInternalVirtualLink(this);
59         }
60
61 }