Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / composer / src / src / libraries / model / descriptors / VirtualDeploymentUnit.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 */
18 /**
19 * Created by onvelocity on 11/23/15.
20 */
21
22 'use strict';
23
24 import DescriptorModel from '../DescriptorModel'
25 import DescriptorModelFactory from '../DescriptorModelFactory'
26
27 export default class VirtualDeploymentUnit extends DescriptorModel {
28
29 static get type() {
30 return 'vdu';
31 }
32
33 static get className() {
34 return 'VirtualDeploymentUnit';
35 }
36
37 constructor(model, parent) {
38 super(model, parent);
39 this.type = 'vdu';
40 this.uiState['qualified-type'] = 'vnfd.vdu';
41 this.className = 'VirtualDeploymentUnit';
42 }
43
44 get key() {
45 return this.parent.key + '/' + super.key;
46 }
47
48 get connectionPoint() {
49 const list = this.model['internal-connection-point'] || (this.model['internal-connection-point'] = []);
50 return list.map(d => DescriptorModelFactory.newVirtualDeploymentUnitInternalConnectionPoint(d, this));
51 }
52
53 set connectionPoint(obj) {
54 return this.updateModelList('internal-connection-point', obj, DescriptorModelFactory.VirtualDeploymentUnitInternalConnectionPoint);
55 }
56
57 //get internalConnectionPoint() {
58 // //https://trello.com/c/ZOyKQd3z/122-hide-lines-representing-interface-connection-point-references-both-internal-and-external-interfaces
59 // const vduc = this;
60 // if (this.model && this.model['internal-interface']) {
61 // const icpMap = this.model['internal-connection-point'].reduce((r, d) => {
62 // r[d.id] = d;
63 // return r;
64 // }, {});
65 // return this.model['internal-interface'].reduce((result, internalIfc) => {
66 // const id = internalIfc['vdu-internal-connection-point-ref'];
67 // const keyPrefix = vduc.parent ? vduc.parent.key + '/' : '';
68 // if (icpMap[id]) {
69 // const icp = Object.assign({}, icpMap[id], {
70 // key: keyPrefix + id,
71 // name: internalIfc.name,
72 // 'virtual-interface': internalIfc['virtual-interface']
73 // });
74 // result.push(icp);
75 // }
76 // return result;
77 // }, []);
78 // }
79 // return [];
80 //}
81
82 removeInternalConnectionPoint(icp) {
83 this.parent.removeAnyConnectionsForConnector(icp);
84 return this.removeModelListItem('connectionPoint', icp);
85 }
86
87 //get externalConnectionPoint() {
88 // // https://trello.com/c/ZOyKQd3z/122-hide-lines-representing-interface-connection-point-references-both-internal-and-external-interfaces
89 // //const vduc = this;
90 // //if (vduc.model && vduc.model['external-interface']) {
91 // // return vduc.model['external-interface'].reduce((result, externalIfc) => {
92 // // const id = externalIfc['vnfd-connection-point-ref'];
93 // // const keyPrefix = vduc.parent ? vduc.parent.key + '/' : '';
94 // // result.push({id: id, key: keyPrefix + id});
95 // // return result;
96 // // }, []);
97 // //}
98 // return [];
99 //}
100 //
101 get connectors() {
102 return this.connectionPoint;
103 }
104
105 //get connection() {
106 // return this.externalConnectionPoint;
107 //}
108
109 remove() {
110 return this.parent.removeVirtualDeploymentUnit(this);
111 }
112
113 }
114