ModelToQueryJSON.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /*
  4. *+------------------------------------------------------------------------+
  5. *| Licensed Materials - Property of IBM
  6. *| IBM Cognos Products: Dashboard
  7. *| (C) Copyright IBM Corp. 2019
  8. *|
  9. *| US Government Users Restricted Rights - Use, duplication or disclosure
  10. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  11. *+------------------------------------------------------------------------+
  12. */
  13. define(['underscore'], function (_) {
  14. 'use strict';
  15. /**
  16. * @return the JSON-like object for use in the query (stripped of attributes not relevant to query)
  17. */
  18. var ModelToQueryJSON = function () {
  19. function ModelToQueryJSON() {
  20. _classCallCheck(this, ModelToQueryJSON);
  21. }
  22. ModelToQueryJSON.prototype.toQueryJSON = function toQueryJSON() {
  23. var _this = this;
  24. var o = this.toJSON(null, this.queryBlacklistAttrs);
  25. _.each(_.extend({}, this.nestedCollections, this.nestedModels), function (modelClass, modelName) {
  26. if (o[modelName]) {
  27. var modelObj = _this.get(modelName);
  28. if (modelObj && modelObj.toQueryJSON) {
  29. var modelQueryJSON = modelObj.toQueryJSON();
  30. o[modelName] = modelQueryJSON;
  31. }
  32. }
  33. });
  34. return o;
  35. };
  36. return ModelToQueryJSON;
  37. }();
  38. return ModelToQueryJSON;
  39. });
  40. //# sourceMappingURL=ModelToQueryJSON.js.map