RIFT-14705 - UI Composer: Add IVLD to VNFD is broken intg_ui_so_1
authorKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Fri, 21 Oct 2016 15:20:10 +0000 (11:20 -0400)
committerKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Fri, 21 Oct 2016 15:20:20 +0000 (11:20 -0400)
Signed-off-by: KIRAN KASHALKAR <kiran.kashalkar@riftio.com>
skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js
skyquake/plugins/composer/src/src/libraries/model/DescriptorModelFactory.js
skyquake/plugins/composer/src/src/libraries/model/DescriptorModelSerializer.js
skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPoint.js
skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalConnectionPointRef.js
skyquake/plugins/composer/src/src/libraries/model/descriptors/InternalVirtualLink.js
skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualDeploymentUnitInternalConnectionPoint.js
skyquake/plugins/composer/src/src/libraries/model/descriptors/VirtualLink.js

index 02bbfcd..1a2ba4f 100644 (file)
@@ -182,7 +182,10 @@ export default class DescriptorModel {
                        throw new ReferenceError('child must be an instance of DescriptorModel class');
                }
                if (this.findChildByUid(child.uid)) {
                        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');
                }
                if (child.parent instanceof DescriptorModel) {
                        throw new ReferenceError('child already has a parent');
index 68b70d7..ac59872 100644 (file)
@@ -262,7 +262,7 @@ class DescriptorModelFactory {
 
        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
 
        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);
        }
 
        /**
        }
 
        /**
index 7581ed5..4e6b792 100644 (file)
@@ -165,6 +165,11 @@ const DescriptorModelSerializer = {
                        return _.pick(ref, ['member-vnf-index-ref', 'vnfd-id-ref', 'vnfd-connection-point-ref']);
                }
        },
                        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');
        'constituent-vnfd': {
                serialize(cvnfdModel) {
                        if(!cvnfdFields) cvnfdFields = DescriptorModelMetaFactory.getModelFieldNamesForType('nsd.constituent-vnfd');
index 6648dc9..14a74f0 100644 (file)
  *   limitations under the License.
  *
  */
  *   limitations under the License.
  *
  */
-/**
- * Created by onvelocity on 11/23/15.
- */
 
 'use strict';
 
 
 '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 {
 
 
 export default class InternalConnectionPoint extends DescriptorModel {
 
@@ -56,8 +54,31 @@ export default class InternalConnectionPoint extends DescriptorModel {
                return this.id;
        }
 
                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() {
        toInternalConnectionPointRef() {
-               return DescriptorModelFactory.newInternalConnectionPointRef(this.id);
+               const ref = new InternalConnectionPointRef({});
+               ref.idRef = this.id;
+               // ref.cpNumber = this.cpNumber;
+               return ref;
        }
 
        canConnectTo(obj) {
        }
 
        canConnectTo(obj) {
index a7ea751..ad70b57 100644 (file)
@@ -15,9 +15,6 @@
  *   limitations under the License.
  *
  */
  *   limitations under the License.
  *
  */
-/**
- * Created by onvelocity on 11/23/15.
- */
 
 'use strict';
 
 
 'use strict';
 
@@ -27,7 +24,7 @@ import DescriptorModelFactory from '../DescriptorModelFactory'
 export default class InternalConnectionPointRef extends DescriptorModel {
 
        static get type() {
 export default class InternalConnectionPointRef extends DescriptorModel {
 
        static get type() {
-               return 'internal-connection-point-ref';
+               return 'internal-connection-point';
        }
 
        static get className() {
        }
 
        static get className() {
@@ -39,23 +36,35 @@ export default class InternalConnectionPointRef extends DescriptorModel {
        }
 
        constructor(m, parent) {
        }
 
        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;
        }
 
                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);
        }
 
 }
        }
 
 }
index c3822d5..b3e4fc6 100644 (file)
  *   limitations under the License.
  *
  */
  *   limitations under the License.
  *
  */
-/**
- * Created by onvelocity on 11/23/15.
- */
 
 'use strict';
 
 import DescriptorModel from '../DescriptorModel'
 import DescriptorModelFactory from '../DescriptorModelFactory'
 
 'use strict';
 
 import DescriptorModel from '../DescriptorModel'
 import DescriptorModelFactory from '../DescriptorModelFactory'
+import DescriptorModelMetaFactory from '../DescriptorModelMetaFactory'
 
 export default class InternalVirtualLink extends DescriptorModel {
 
 
 export default class InternalVirtualLink extends DescriptorModel {
 
@@ -50,22 +48,37 @@ export default class InternalVirtualLink extends DescriptorModel {
        }
 
        get connection() {
        }
 
        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) {
        }
 
        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) {
        }
 
        addConnectionPoint(icp) {
-               icp.model['internal-vld-ref'] = this.id;
                this.parent.removeAnyConnectionsForConnector(icp);
                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() {
        }
 
        remove() {
index 47947c8..c34d823 100644 (file)
  *   limitations under the License.
  *
  */
  *   limitations under the License.
  *
  */
-/**
- * Created by onvelocity on 11/23/15.
- */
 
 'use strict';
 
 import Position from '../../graph/Position'
 
 'use strict';
 
 import Position from '../../graph/Position'
-import DescriptorModel from '../DescriptorModel'
 import InternalConnectionPoint from './InternalConnectionPoint'
 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 {
  * methods are add to access the fields needed to do that.
  */
 export default class VirtualDeploymentUnitInternalConnectionPoint extends InternalConnectionPoint {
index 50c4653..47370e5 100644 (file)
@@ -15,9 +15,6 @@
  *   limitations under the License.
  *
  */
  *   limitations under the License.
  *
  */
-/**
- * Created by onvelocity on 11/23/15.
- */
 
 'use strict';
 
 
 'use strict';