Parameters.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2015, 2018
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['underscore', 'bi/commons/ui/core/Class', 'bi/admin/common/utils/XMLUtils', 'bi/admin/globalparameters/helpers/SoapHelper', 'doT', 'text!bi/admin/common/templates/getParameters.xml'], function (_, Class, XMLUtils, SoapHelper, doT, GetParametersTemplate) {
  9. var Parameter = Class.extend({
  10. init: function init(options) {
  11. Parameter.inherited('init', this, arguments);
  12. _.extend(this, options);
  13. },
  14. get: function get() {
  15. return this.glassContext.services.fetch.get('v1/objects/' + this.report.id + '?fields=routingServerGroup').then(function (cmResponse) {
  16. var getParametersRequest = doT.template(GetParametersTemplate)({
  17. 'cafContextId': this.glassContext.authInfo.cafContextId,
  18. 'objectPath': SoapHelper.xml_encode(this.report.searchPath),
  19. 'parameterValues': '<parameterValues xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:parameterValue[]"/>',
  20. 'routingServerGroup': cmResponse.data.data[0].routingServerGroup
  21. });
  22. return this.glassContext.services.fetch.post('v1/reports', {
  23. 'headers': {
  24. 'SOAPAction': 'http://www.ibm.com/xmlns/prod/cognos/reportService/201701/.high'
  25. },
  26. 'contentType': 'text/xml; charset=UTF-8',
  27. 'data': getParametersRequest
  28. }).then(function (response) {
  29. return SoapHelper.processResponse(this.report, response.data);
  30. }.bind(this));
  31. }.bind(this)).catch(function (response) {
  32. return {
  33. status: 'error',
  34. report_id: this.report.id,
  35. message: response.message,
  36. code: response.code
  37. };
  38. });
  39. }
  40. });
  41. return Parameter;
  42. });