1d74db67cbf15f1c7334cf1eeb4b53d683867740
[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 VirtualDeploymentUnit extends DescriptorModel {
14
15         static get type() {
16                 return 'vdu';
17         }
18
19         static get className() {
20                 return 'VirtualDeploymentUnit';
21         }
22
23         constructor(model, parent) {
24                 super(model, parent);
25                 this.type = 'vdu';
26                 this.uiState['qualified-type'] = 'vnfd.vdu';
27                 this.className = 'VirtualDeploymentUnit';
28         }
29
30         get key() {
31                 return this.parent.key + '/' + super.key;
32         }
33
34         get connectionPoint() {
35                 const list = this.model['internal-connection-point'] || (this.model['internal-connection-point'] = []);
36                 return list.map(d => DescriptorModelFactory.newVirtualDeploymentUnitInternalConnectionPoint(d, this));
37         }
38
39         set connectionPoint(obj) {
40                 return this.updateModelList('internal-connection-point', obj, DescriptorModelFactory.VirtualDeploymentUnitInternalConnectionPoint);
41         }
42
43         //get internalConnectionPoint() {
44         //      //https://trello.com/c/ZOyKQd3z/122-hide-lines-representing-interface-connection-point-references-both-internal-and-external-interfaces
45         //      const vduc = this;
46         //      if (this.model && this.model['internal-interface']) {
47         //              const icpMap = this.model['internal-connection-point'].reduce((r, d) => {
48         //                      r[d.id] = d;
49         //                      return r;
50         //              }, {});
51         //              return this.model['internal-interface'].reduce((result, internalIfc) => {
52         //                      const id = internalIfc['vdu-internal-connection-point-ref'];
53         //                      const keyPrefix = vduc.parent ? vduc.parent.key + '/' : '';
54         //                      if (icpMap[id]) {
55         //                              const icp = Object.assign({}, icpMap[id], {
56         //                                      key: keyPrefix + id,
57         //                                      name: internalIfc.name,
58         //                                      'virtual-interface': internalIfc['virtual-interface']
59         //                              });
60         //                              result.push(icp);
61         //                      }
62         //                      return result;
63         //              }, []);
64         //      }
65         //      return [];
66         //}
67
68         removeInternalConnectionPoint(icp) {
69                 this.parent.removeAnyConnectionsForConnector(icp);
70                 return this.removeModelListItem('connectionPoint', icp);
71         }
72
73         //get externalConnectionPoint() {
74         //      // https://trello.com/c/ZOyKQd3z/122-hide-lines-representing-interface-connection-point-references-both-internal-and-external-interfaces
75         //      //const vduc = this;
76         //      //if (vduc.model && vduc.model['external-interface']) {
77         //      //      return vduc.model['external-interface'].reduce((result, externalIfc) => {
78         //      //              const id = externalIfc['vnfd-connection-point-ref'];
79         //      //              const keyPrefix = vduc.parent ? vduc.parent.key + '/' : '';
80         //      //              result.push({id: id, key: keyPrefix + id});
81         //      //              return result;
82         //      //      }, []);
83         //      //}
84         //      return [];
85         //}
86         //
87         get connectors() {
88                 return this.connectionPoint;
89         }
90
91         //get connection() {
92         //      return this.externalConnectionPoint;
93         //}
94
95         remove() {
96                 return this.parent.removeVirtualDeploymentUnit(this);
97         }
98
99 }
100