WsTopology.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. ], function (declare, lang, xhr, Deferred, QueryResults, ESPBase) {
  25. var TpServiceQuery = declare(ESPBase, {
  26. idProperty: "Wuid",
  27. constructor: function (options) {
  28. declare.safeMixin(this, options);
  29. },
  30. getIdentity: function (object) {
  31. return object[this.idProperty];
  32. },
  33. query: function (query, options) {
  34. var request = {
  35. Type: "ALLSERVICES"
  36. };
  37. lang.mixin(request, options.query);
  38. request['rawxml_'] = "1";
  39. var results = xhr.get({
  40. url: this.getBaseURL("WsTopology") + "/TpServiceQuery",
  41. handleAs: "xml",
  42. content: request
  43. });
  44. var context = this;
  45. var parsedResults = results.then(function (domXml) {
  46. var data = context.getValues(domXml, "TpDropZone", ["TpMachine"]);
  47. return data;
  48. });
  49. lang.mixin(parsedResults, {
  50. total: Deferred.when(parsedResults, function (data) {
  51. return data.length;
  52. })
  53. });
  54. return QueryResults(parsedResults);
  55. }
  56. });
  57. return {
  58. TpServiceQuery: TpServiceQuery
  59. };
  60. });