throw new ReferenceError('child must be an instance of DescriptorModel class');
}
if (this.findChildByUid(child.uid)) {
- throw new ReferenceError('child already exists');
+ console.warn('Child already exists');
+ // NOTE: Commented out this line because it was causing issues with Internal VLD.
+ // TODO: Check why it caused issues with Internal VLD
+ // throw new ReferenceError('child already exists');
}
if (child.parent instanceof DescriptorModel) {
throw new ReferenceError('child already has a parent');
static newInternalConnectionPointRef(model, parent) {
// note do not find children bc model is not an object it is a leaf-list primative and so the class manages it
- return new InternalConnectionPointRef(model, parent);
+ return findChildDescriptorModelAndUpdateModel(model, parent) || new InternalConnectionPointRef(model, parent);
}
/**
return _.pick(ref, ['member-vnf-index-ref', 'vnfd-id-ref', 'vnfd-connection-point-ref']);
}
},
+ 'internal-connection-point': {
+ serialize(ref) {
+ return _.pick(ref, ['id-ref']);
+ }
+ },
'constituent-vnfd': {
serialize(cvnfdModel) {
if(!cvnfdFields) cvnfdFields = DescriptorModelMetaFactory.getModelFieldNamesForType('nsd.constituent-vnfd');
* limitations under the License.
*
*/
-/**
- * Created by onvelocity on 11/23/15.
- */
'use strict';
-import Position from '../../graph/Position'
-import DescriptorModel from '../DescriptorModel'
-import DescriptorModelFactory from '../DescriptorModelFactory'
+import Position from '../../graph/Position';
+import DescriptorModel from '../DescriptorModel';
+import DescriptorModelFactory from '../DescriptorModelFactory';
+import InternalConnectionPointRef from './InternalConnectionPointRef';
export default class InternalConnectionPoint extends DescriptorModel {
return this.id;
}
+ get id() {
+ return this.model.id;
+ }
+
+ get name() {
+ return this.model.name
+ }
+
+ get idRef() {
+ return this.parent.idRef;
+ }
+
+ get cpNumber() {
+ return this.uiState.cpNumber;
+ }
+
+ set cpNumber(n) {
+ this.uiState.cpNumber = n;
+ }
+
toInternalConnectionPointRef() {
- return DescriptorModelFactory.newInternalConnectionPointRef(this.id);
+ const ref = new InternalConnectionPointRef({});
+ ref.idRef = this.id;
+ // ref.cpNumber = this.cpNumber;
+ return ref;
}
canConnectTo(obj) {
* limitations under the License.
*
*/
-/**
- * Created by onvelocity on 11/23/15.
- */
'use strict';
export default class InternalConnectionPointRef extends DescriptorModel {
static get type() {
- return 'internal-connection-point-ref';
+ return 'internal-connection-point';
}
static get className() {
}
constructor(m, parent) {
- super(!m || typeof m === 'string' ? {id: m, isLeaf: true} : m, parent);
+ super(m, parent);
this.uid = this.id;
this.type = InternalConnectionPointRef.type;
this.uiState['qualified-type'] = InternalConnectionPointRef.qualifiedType;
this.className = InternalConnectionPointRef.className;
}
- toString() {
- return this.valueOf();
+ get key() {
+ return this.model['id-ref'];
}
- remove() {
- return this.parent.removeInternalConnectionPointRefForId(this.id);
+ get idRef() {
+ return this.model['id-ref'];
}
- valueOf() {
- return this.id;
+ set idRef(id) {
+ return this.model['id-ref'] = id;
+ }
+
+ get cpNumber() {
+ return this.uiState.cpNumber;
+ }
+
+ set cpNumber(n) {
+ this.uiState.cpNumber = n;
+ }
+
+ remove() {
+ return this.parent.removeInternalConnectionPointRefForId(this.idRef);
}
}
* 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 {
}
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() {
* limitations under the License.
*
*/
-/**
- * Created by onvelocity on 11/23/15.
- */
'use strict';
import Position from '../../graph/Position'
-import DescriptorModel from '../DescriptorModel'
import InternalConnectionPoint from './InternalConnectionPoint'
-import RspConnectionPointRef from './RspConnectionPointRef'
-import VnfdConnectionPointRef from './VnfdConnectionPointRef'
-import DescriptorModelFactory from '../DescriptorModelFactory'
+
/**
- * A VirtualNetworkFunctionConnectionPoint is always a child of a VNFD. We use it to build VnfdConnectionPointRef instances. So convenience
+ * A VirtualDeploymentUnitInternalConnectionPoint is always a child of a VDU.
+ * We use it to build internal-connection-point.id-ref instances. So convenience
* methods are add to access the fields needed to do that.
*/
export default class VirtualDeploymentUnitInternalConnectionPoint extends InternalConnectionPoint {
* limitations under the License.
*
*/
-/**
- * Created by onvelocity on 11/23/15.
- */
'use strict';