X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Flibraries%2Fmodel%2Fdescriptors%2FInternalVirtualLink.js;h=3cf79db4b4d627e2fda9c8372a8a2d23dad0f0d2;hp=c3822d562da091d22d75ffa60a93d7218bfbd655;hb=03156e335275de1dafbc2a816e98006afdf249bf;hpb=e29efc315df33d546237e270470916e26df391d6 diff --git a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js index c3822d562..3cf79db4b 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js +++ b/skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js @@ -15,14 +15,12 @@ * limitations under the License. * */ -/** - * Created by onvelocity on 11/23/15. - */ 'use strict'; import DescriptorModel from '../DescriptorModel' import DescriptorModelFactory from '../DescriptorModelFactory' +import DescriptorModelMetaFactory from '../DescriptorModelMetaFactory' export default class InternalVirtualLink extends DescriptorModel { @@ -38,8 +36,8 @@ export default class InternalVirtualLink extends DescriptorModel { return 'vnfd.' + InternalVirtualLink.type; } - constructor(model, parent) { - super(model, parent); + constructor(model, parent, readonly) { + super(model, parent, readonly); this.type = InternalVirtualLink.type; this.uiState['qualified-type'] = InternalVirtualLink.qualifiedType; this.className = InternalVirtualLink.className; @@ -50,22 +48,37 @@ export default class InternalVirtualLink extends DescriptorModel { } get connection() { - const list = this.model['internal-connection-point-ref'] || (this.model['internal-connection-point-ref'] = []); - return list.map(d => DescriptorModelFactory.newInternalConnectionPointRef(d, this)); + if (!this.model['internal-connection-point']) { + this.model['internal-connection-point'] = []; + } + return this.model['internal-connection-point'].map(d => DescriptorModelFactory.newInternalConnectionPointRef(d, this)); } set connection(connections) { - return this.updateModelList('internal-connection-point-ref', connections, DescriptorModelFactory.InternalConnectionPointRef); + return this.updateModelList('internal-connection-point', connections, DescriptorModelFactory.InternalConnectionPointRef); + } + + createInternalConnectionPoint(model) { + model = model || DescriptorModelMetaFactory.createModelInstanceForType('vnfd.internal-vld.internal-connection-point'); + return this.connection = DescriptorModelFactory.newInternalConnectionPointRef(model, this); + } + + removeInternalConnectionPointRefForIdRefKey(cpRefKey) { + const child = this.connection.filter(d => d.key === cpRefKey)[0]; + return this.removeModelListItem('connection', child); } addConnectionPoint(icp) { - icp.model['internal-vld-ref'] = this.id; this.parent.removeAnyConnectionsForConnector(icp); - this.connection = icp.toInternalConnectionPointRef(); + const icpRef = icp.toInternalConnectionPointRef(); + // this.connection = icp.toInternalConnectionPointRef(); + this.connection = this.connection.concat(icpRef); } - removeInternalConnectionPointRefForId(id) { - return this.connection = this.connection.filter(d => d.id !== id).map(d => d.id); + removeInternalConnectionPointRefForId(idRef) { + // return this.connection = this.connection.filter(d => d.idRef !== idRef).map(d => d.idRef); + // KKTODO: Check if below works instead + return this.connection = this.connection.filter(d => d.idRef !== idRef).map(d => d.model); } remove() {