WsSMC.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/store/Observable",
  19. "hpcc/ESPRequest",
  20. "hpcc/ESPWorkunit",
  21. "hpcc/ESPDFUWorkunit"
  22. ], function (declare, Observable,
  23. ESPRequest, ESPWorkunit, ESPDFUWorkunit) {
  24. var Store = declare([ESPRequest.Store], {
  25. service: "WsSMC",
  26. action: "Activity",
  27. responseQualifier: "ActivityResponse.Running.ActiveWorkunit",
  28. idProperty: "Wuid",
  29. _watched: [],
  30. create: function (id, item) {
  31. if (item.Server === "DFUserver") {
  32. return ESPDFUWorkunit.Get(id);
  33. }
  34. return ESPWorkunit.Get(id);
  35. },
  36. update: function (id, item) {
  37. var storeItem = this.get(id);
  38. storeItem.updateData(item);
  39. if (!this._watched[id]) {
  40. var context = this;
  41. this._watched[id] = storeItem.watch("changedCount", function (name, oldValue, newValue) {
  42. if (context.notify && oldValue !== newValue) {
  43. context.notify(storeItem, id);
  44. }
  45. });
  46. }
  47. },
  48. postProcessResults: function (items) {
  49. return items;
  50. }
  51. });
  52. return {
  53. CreateActivityStore: function (options) {
  54. var store = new Store(options);
  55. return store;//Observable(store);
  56. },
  57. Activity: function (params) {
  58. return ESPRequest.send("WsSMC", "Activity", params);
  59. },
  60. };
  61. });