/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
return constituentVNFD;
});
-
+ for (var key in confd) {
+ checkForChoiceAndRemove(key, confd, nsdModel);
+ }
// serialize the VLD instances
confd.vld = confd.vld.map(d => {
return DescriptorModelSerializer.serialize(d);
// once that is fixed, remove this piece of code.
// fix-start
for (var key in confd) {
- if (confd.hasOwnProperty(key) && confd[key] === '') {
- delete confd[key];
- }
+ if (confd.hasOwnProperty(key) && confd[key] === '') {
+ delete confd[key];
+ } else {
+ //removes choice properties from top level object and copies immediate children onto it.
+ checkForChoiceAndRemove(key, confd, vldModel);
+ }
}
+
const deepProperty = 'provider-network';
for (var key in confd[deepProperty]) {
if (confd[deepProperty].hasOwnProperty(key) && confd[deepProperty][key] === '') {
}
}
// fix-end
-
-
confd[property] = confd[property].map(d => DescriptorModelSerializer[property].serialize(d));
return confd;
}
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');
},
vdu: {
serialize(vduModel) {
- const confd = _.omit(vduModel, ['uiState']);
+ const copy = _.cloneDeep(vduModel);
+ for (let k in copy) {
+ checkForChoiceAndRemove(k, copy, vduModel)
+ }
+ const confd = _.omit(copy, ['uiState']);
return confd;
}
}
};
+
+function checkForChoiceAndRemove(k, confd, model) {
+ let state = model.uiState;
+ if (state.choice) {
+ let choice = state.choice[k]
+ if(choice) {
+ for (let key in confd[k]) {
+ if(choice && (choice.selected.indexOf(key) > -1)) {
+ confd[key] = confd[k][key]
+ }
+ };
+ delete confd[k];
+ }
+ }
+ return confd;
+}
+
export default DescriptorModelSerializer;