queryStat.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. queryStat_parameter = {};
  2. function queryStat_init() {
  3. $('#content').html('');
  4. $('#result').html('');
  5. var str = '<table border="1" width="100%">';
  6. str += '<tr><td colspan="2"><a href="#" id="list">list</a>&nbsp;<a href="#" id="get">get</a>&nbsp;<a href="#" id="execute">execute</a></td></tr>';
  7. str += '<tr><td>applicationFlag:</td><td><input type="text" id="applicationFlag" style="width:95%"/></td></tr>';
  8. str += '<tr><td>flag:</td><td><input type="text" id="flag" style="width:95%"/></td></tr>';
  9. str += '<tr><td colspan="2">date</td></tr>';
  10. str += '<tr><td colspan="2"><textarea id="date" style="width:95%;height:300px"></textarea></td></tr>';
  11. str += '<tr><td colspan="2">sample</td></tr>';
  12. str += '<tr><td colspan="2">';
  13. str += '{<br/>';
  14. str += '"dateRangeType":"",<br/>';
  15. str += '//year, season, month, week, date, range, none<br/>';
  16. str += '"dateEffectType":"",<br/>';
  17. str += '//start, completed<br/>';
  18. str += '"start":"",<br/>';
  19. str += '"completed":"",<br/>';
  20. str += '"year":"",<br/>';
  21. str += '"month":"",<br/>';
  22. str += '"date":"",<br/>';
  23. str += '"season":0,<br/>';
  24. str += '"week":0,<br/>';
  25. str += '"adjust":0<br/>';
  26. str += '}';
  27. str += '</td></tr>';
  28. str += '<tr><td colspan="2">filter</td></tr>';
  29. str += '<tr><td colspan="2"><textarea id="filter" style="width:95%;height:300px"></textarea></td></tr>';
  30. str += '<tr><td colspan="2">sample</td></tr>';
  31. str += '<tr><td colspan="2">';
  32. str += '{<br/>';
  33. str += '"path":"",<br/>';
  34. str += '"value":"",<br/>';
  35. str += '"formatType":"",<br/>';
  36. str += '//textValue, numberValue, booleanValue, dateTimeValue<br/>';
  37. str += '"logic":"",<br/>';
  38. str += '//and,or<br/>';
  39. str += '"comparison":"",<br/>';
  40. str += '//equals,notEquals,greaterThan,greaterThanOrEqualTo,lessThan,lessThanOrEqualTo,like,notLike<br/>';
  41. str += '}';
  42. str += '</td></tr>';
  43. str += '<tr><td colspan="2">column</td></tr>';
  44. str += '<tr><td colspan="2"><textarea id="column" style="width:95%;height:100px"></textarea></td></tr>';
  45. str += '<tr><td colspan="2">sample</td></tr>';
  46. str += '<tr><td colspan="2">number or string</textarea></td></tr>';
  47. str += '<tr><td colspan="2">where application</td></tr>';
  48. str += '<tr><td colspan="2"><textarea id="application" style="width:95%;height:100px"></textarea></td></tr>';
  49. str += '<tr><td colspan="2">where process</td></tr>';
  50. str += '<tr><td colspan="2"><textarea id="process" style="width:95%;height:100px"></textarea></td></tr>';
  51. str += '<tr><td colspan="2">where company</td></tr>';
  52. str += '<tr><td colspan="2"><textarea id="company" style="width:95%;height:100px"></textarea></td></tr>';
  53. str += '<tr><td colspan="2">where department</td></tr>';
  54. str += '<tr><td colspan="2"><textarea id="department" style="width:95%;height:100px"></textarea></td></tr>';
  55. str += '<tr><td colspan="2">where person</td></tr>';
  56. str += '<tr><td colspan="2"><textarea id="person" style="width:95%;height:100px"></textarea></td></tr>';
  57. str += '<tr><td colspan="2">where identity</td></tr>';
  58. str += '<tr><td colspan="2"><textarea id="identity" style="width:95%;height:100px"></textarea></td></tr>';
  59. str += '</table>';
  60. $('#content').html(str);
  61. $('#list').click(function() {
  62. queryStat_list($('#applicationFlag').val());
  63. });
  64. $('#get').click(function() {
  65. queryStat_get($('#flag').val(), $('#applicationFlag').val());
  66. });
  67. $('#execute').click(function() {
  68. queryStat_execute($('#flag').val(), $('#applicationFlag').val());
  69. });
  70. }
  71. function queryStat_list(applicationFlag) {
  72. $('#result').html('');
  73. $.ajax({
  74. type : 'get',
  75. dataType : 'json',
  76. url : '../jaxrs/querystat/list/application/flag/' + applicationFlag,
  77. xhrFields : {
  78. 'withCredentials' : true
  79. },
  80. crossDomain : true
  81. }).always(function(json) {
  82. $('#result').html(JSON.stringify(json, null, 4));
  83. });
  84. }
  85. function queryStat_get(flag, applicationFlag) {
  86. $('#result').html('');
  87. $.ajax({
  88. type : 'get',
  89. dataType : 'json',
  90. url : '../jaxrs/querystat/flag/' + flag + '/application/flag/' + applicationFlag,
  91. xhrFields : {
  92. 'withCredentials' : true
  93. },
  94. crossDomain : true
  95. }).always(function(json) {
  96. $('#result').html(JSON.stringify(json, null, 4));
  97. });
  98. }
  99. function queryStat_execute(flag, applicationFlag) {
  100. $('#result').html('');
  101. var data = {};
  102. if ($('#date').val().length > 0) {
  103. data.date = JSON.parse($('#date').val());
  104. }
  105. if ($('#filter').val().length > 0) {
  106. data.filter = JSON.parse($('#filter').val());
  107. }
  108. if ($('#application').val().length > 0) {
  109. data.application = JSON.parse($('#application').val());
  110. }
  111. if ($('#process').val().length > 0) {
  112. data.process = JSON.parse($('#process').val());
  113. }
  114. if ($('#company').val().length > 0) {
  115. data.company = JSON.parse($('#company').val());
  116. }
  117. if ($('#department').val().length > 0) {
  118. data.department = JSON.parse($('#department').val());
  119. }
  120. if ($('#person').val().length > 0) {
  121. data.person = JSON.parse($('#person').val());
  122. }
  123. if ($('#identity').val().length > 0) {
  124. data.identity = JSON.parse($('#identity').val());
  125. }
  126. if ($('#column').val().length > 0) {
  127. data.column = JSON.parse($('#column').val());
  128. }
  129. $.ajax({
  130. type : 'put',
  131. dataType : 'json',
  132. url : '../jaxrs/querystat/flag/' + flag + '/application/flag/' + applicationFlag + '/execute',
  133. contentType : 'application/json; charset=utf-8',
  134. data : JSON.stringify(data),
  135. xhrFields : {
  136. 'withCredentials' : true
  137. },
  138. crossDomain : true
  139. }).always(function(json) {
  140. $('#result').html(JSON.stringify(json, null, 4));
  141. });
  142. }