QueryTestWidget.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/lang",
  19. "dojo/i18n",
  20. "dojo/i18n!./nls/hpcc",
  21. "dojo/_base/array",
  22. "dijit/registry",
  23. "hpcc/_TabContainerWidget",
  24. "hpcc/WsTopology",
  25. "hpcc/ESPQuery",
  26. "dijit/layout/BorderContainer",
  27. "dijit/layout/TabContainer",
  28. "dijit/layout/ContentPane",
  29. "dojo/text!../templates/QueryTestWidget.html"
  30. ], function (declare, lang, i18n, nlsHPCC, arrayUtil,
  31. registry,
  32. _TabContainerWidget, WsTopology, ESPQuery,
  33. BorderContainer, TabContainer, ContentPane,
  34. template) {
  35. return declare("QueryTestWidget", [_TabContainerWidget], {
  36. templateString: template,
  37. baseClass: "QueryTestWidget",
  38. i18n: nlsHPCC,
  39. initalized: false,
  40. soapTab: null,
  41. jsonTab: null,
  42. requestTab: null,
  43. responseTab: null,
  44. requestSchemaTab: null,
  45. responseSchemaTab: null,
  46. wsdlTab: null,
  47. paramXmlTab: null,
  48. formTab: null,
  49. linksTab: null,
  50. postCreate: function (args) {
  51. this.inherited(arguments);
  52. this.soapTab = registry.byId(this.id + "_SOAP");
  53. this.jsonTab = registry.byId(this.id + "_JSON");
  54. this.wsdlTab = registry.byId(this.id + "_WSDL");
  55. this.requestSchemaTab = registry.byId(this.id + "_RequestSchema");
  56. this.responseSchemaTab = registry.byId(this.id + "ResponseSchema");
  57. this.requestTab = registry.byId(this.id + "_Request");
  58. this.responseTab = registry.byId(this.id + "_Response");
  59. this.paramXmlTab = registry.byId(this.id + "_ParamXML");
  60. this.formTab = registry.byId(this.id + "_Form");
  61. this.linksTab = registry.byId(this.id + "_Links");
  62. },
  63. // Hitched actions ---
  64. _onRefresh: function () {
  65. },
  66. // Implementation ---
  67. init: function (params) {
  68. if (this.inherited(arguments))
  69. return;
  70. this.query = ESPQuery.Get(params.QuerySet, params.QueryId);
  71. this.selectChild(this.soapTab, true);
  72. },
  73. setContent: function (target, type, postfix) {
  74. var context = this;
  75. WsTopology.GetWsEclIFrameURL(type).then(function (response) {
  76. var src = response + encodeURIComponent(context.params.QuerySet + "/" + context.params.QueryId + (postfix ? postfix : ""));
  77. target.set("content", dojo.create("iframe", {
  78. src: src,
  79. style: "border: 0; width: 100%; height: 100%"
  80. }));
  81. });
  82. },
  83. initTab: function () {
  84. var currSel = this.getSelectedChild();
  85. if (!currSel.initalized) {
  86. if (currSel.id === this.id + "_SOAP") {
  87. // .../WsEcl/forms/soap/query/roxie/countydeeds.1
  88. this.setContent(currSel, "forms/soap");
  89. } else if (currSel.id === this.id + "_JSON") {
  90. // .../WsEcl/forms/json/query/roxie/countydeeds.1
  91. this.setContent(currSel, "forms/json");
  92. } else if (currSel.id === this.id + "_WSDL") {
  93. // .../WsEcl/definitions/query/roxie/countydeeds.1/main/countydeeds.1.wsdl?display
  94. this.setContent(currSel, "definitions", "/main/" + this.params.QueryId + ".wsdl?display");
  95. } else if (currSel.id === this.id + "_RequestSchema") {
  96. // .../WsEcl/definitions/query/roxie/countydeeds.1/main/countydeeds.1.xsd?display
  97. this.setContent(currSel, "definitions", "/main/" + this.params.QueryId + ".xsd?display");
  98. } else if (currSel.id === this.id + "_ResponseSchemaBorder") {
  99. var wu = this.query.getWorkunit();
  100. var context = this;
  101. wu.fetchResults(function (response) {
  102. arrayUtil.forEach(response, function (item, idx) {
  103. var responseSchema = new ContentPane({
  104. id: context.id + "ResponseSchema" + item.Name,
  105. title: item.Name,
  106. closable: false
  107. });
  108. context.responseSchemaTab.addChild(responseSchema);
  109. // .../WsEcl/definitions/query/roxie/countydeeds.1/result/jo_orig.xsd?display
  110. context.setContent(responseSchema, "definitions", "/result/" + item.Name + ".xsd?display");
  111. });
  112. });
  113. } else if (currSel.id === this.id + "_Request") {
  114. // .../WsEcl/example/request/query/roxie/countydeeds.1?display
  115. this.setContent(currSel, "example/request", "?display");
  116. } else if (currSel.id === this.id + "_Response") {
  117. // .../WsEcl/example/response/query/roxie/countydeeds.1?display
  118. this.setContent(currSel, "example/response", "?display");
  119. } else if (currSel.id === this.id + "_ParamXML") {
  120. // .../WsEcl/definitions/query/roxie/countydeeds.1/resource/soap/countydeeds.1.xml?display
  121. this.setContent(currSel, "definitions", "/resource/soap/" + this.params.QueryId + ".xml?display");
  122. } else if (currSel.id === this.id + "_Form") {
  123. // .../WsEcl/forms/ecl/query/roxie/countydeeds.1
  124. this.setContent(currSel, "forms/ecl");
  125. } else if (currSel.id === this.id + "_Links") {
  126. // .../WsEcl/links/query/roxie/countydeeds.1
  127. this.setContent(currSel, "links");
  128. } else if (currSel.init) {
  129. currSel.init(this.params);
  130. }
  131. currSel.initalized = true;
  132. }
  133. }
  134. });
  135. });