ESPLogicalFile.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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/_base/xhr",
  20. "hpcc/ESPResult",
  21. "hpcc/ESPBase"
  22. ], function (declare, lang, xhr,
  23. ESPResult, ESPBase) {
  24. return declare(ESPBase, {
  25. cluster: "",
  26. logicalName: "",
  27. result: [],
  28. constructor: function (args) {
  29. declare.safeMixin(this, args);
  30. this.DFUInfoResponse = {
  31. Name: this.logicalName,
  32. Cluster: this.cluster
  33. };
  34. },
  35. save: function (description, args) {
  36. //WsDfu/DFUInfo?FileName=progguide%3A%3Aexampledata%3A%3Akeys%3A%3Apeople.lastname.firstname&UpdateDescription=true&FileDesc=%C2%A0123&Save+Description=Save+Description
  37. var request = {
  38. FileName: this.logicalName,
  39. Cluster: this.cluster,
  40. UpdateDescription: true,
  41. FileDesc: description
  42. };
  43. var context = this;
  44. xhr.post({
  45. url: this.getBaseURL("WsDfu") + "/DFUInfo.json",
  46. handleAs: "json",
  47. content: request,
  48. load: function (response) {
  49. if (response.DFUInfoResponse) {
  50. context.processDFUInfoResponse(response.DFUInfoResponse, args);
  51. }
  52. },
  53. error: function (e) {
  54. }
  55. });
  56. },
  57. getInfo: function (args) {
  58. //WsDfu/DFUInfo?Name=progguide::exampledata::keys::people.state.city.zip.lastname.firstname.payload&Cluster=hthor__myeclagent HTTP/1.1
  59. var request = {
  60. Name: this.logicalName,
  61. Cluster: this.cluster
  62. };
  63. var context = this;
  64. xhr.post({
  65. url: this.getBaseURL("WsDfu") + "/DFUInfo.json",
  66. handleAs: "json",
  67. content: request,
  68. load: function (response) {
  69. if (response.DFUInfoResponse) {
  70. context.processDFUInfoResponse(response.DFUInfoResponse, args);
  71. }
  72. },
  73. error: function (e) {
  74. var d = 0;
  75. }
  76. });
  77. },
  78. processDFUInfoResponse: function(dfuInfoResponse, args) {
  79. var fileDetail = dfuInfoResponse.FileDetail;
  80. this.DFUInfoResponse = fileDetail;
  81. this.result = new ESPResult(fileDetail);
  82. if (args.onGetAll) {
  83. args.onGetAll(fileDetail);
  84. }
  85. },
  86. fetchStructure: function (format, onFetchStructure) {
  87. var request = {
  88. Name: this.logicalName,
  89. Format: format,
  90. rawxml_: true
  91. };
  92. var context = this;
  93. xhr.post({
  94. url: this.getBaseURL("WsDfu") + "/DFUDefFile",
  95. handleAs: "text",
  96. content: request,
  97. load: function (response) {
  98. onFetchStructure(response);
  99. },
  100. error: function (e) {
  101. }
  102. });
  103. },
  104. fetchDEF: function (onFetchXML) {
  105. this.fetchStructure("def", onFetchXML);
  106. },
  107. fetchXML: function (onFetchXML) {
  108. var request = {
  109. Name: this.logicalName,
  110. Format: "xml",
  111. rawxml_: true
  112. };
  113. var context = this;
  114. xhr.post({
  115. url: this.getBaseURL("WsDfu") + "/DFUDefFile",
  116. handleAs: "text",
  117. content: request,
  118. load: function (response) {
  119. onFetchXML(response);
  120. },
  121. error: function (e) {
  122. var d = 0;
  123. }
  124. });
  125. }
  126. });
  127. });