WsTopology.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*##############################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ############################################################################## */
  17. define([
  18. "dojo/_base/declare",
  19. "dojo/_base/lang",
  20. "dojo/_base/xhr",
  21. "dojo/_base/Deferred",
  22. "dojo/store/util/QueryResults",
  23. "hpcc/ESPBase",
  24. "hpcc/ESPRequest"
  25. ], function (declare, lang, xhr, Deferred, QueryResults,
  26. ESPBase, ESPRequest) {
  27. var TpServiceQuery = declare(ESPBase, {
  28. idProperty: "Wuid",
  29. constructor: function (options) {
  30. declare.safeMixin(this, options);
  31. },
  32. getIdentity: function (object) {
  33. return object[this.idProperty];
  34. },
  35. query: function (query, options) {
  36. var request = {
  37. Type: "ALLSERVICES"
  38. };
  39. lang.mixin(request, options.query);
  40. request['rawxml_'] = "1";
  41. var results = xhr.get({
  42. url: this.getBaseURL("WsTopology") + "/TpServiceQuery",
  43. handleAs: "xml",
  44. content: request
  45. });
  46. var context = this;
  47. var parsedResults = results.then(function (domXml) {
  48. var data = context.getValues(domXml, "TpDropZone", ["TpMachine"]);
  49. return data;
  50. });
  51. lang.mixin(parsedResults, {
  52. total: Deferred.when(parsedResults, function (data) {
  53. return data.length;
  54. })
  55. });
  56. return QueryResults(parsedResults);
  57. }
  58. });
  59. return {
  60. TpServiceQuery: TpServiceQuery,
  61. TpServiceQuery: function (params) {
  62. lang.mixin(params.request, {
  63. Type: "ALLSERVICES"
  64. });
  65. ESPRequest.send("WsTopology", "TpServiceQuery", params);
  66. },
  67. TpTargetClusterQuery: function (params) {
  68. ESPRequest.send("WsTopology", "TpTargetClusterQuery", params);
  69. },
  70. TpGroupQuery: function (params) {
  71. ESPRequest.send("WsTopology", "TpGroupQuery", params);
  72. }
  73. };
  74. });