ActivitiRest.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var ActivitiRest = {
  2. options: {},
  3. getProcessDefinitionByKey: function(processDefinitionKey, callback) {
  4. var url = Lang.sub(this.options.processDefinitionByKeyUrl, {processDefinitionKey: processDefinitionKey});
  5. $.ajax({
  6. url: url,
  7. dataType: 'jsonp',
  8. cache: false,
  9. async: true,
  10. success: function(data, textStatus) {
  11. var processDefinition = data;
  12. if (!processDefinition) {
  13. console.error("Process definition '" + processDefinitionKey + "' not found");
  14. } else {
  15. callback.apply({processDefinitionId: processDefinition.id});
  16. }
  17. }
  18. }).done(function(data, textStatus) {
  19. console.log("ajax done");
  20. }).fail(function(jqXHR, textStatus, error){
  21. console.error('Get diagram layout['+processDefinitionKey+'] failure: ', textStatus, 'error: ', error, jqXHR);
  22. });
  23. },
  24. getProcessDefinition: function(processDefinitionId, callback) {
  25. var url = Lang.sub(this.options.processDefinitionUrl, {processDefinitionId: processDefinitionId});
  26. $.ajax({
  27. url: url,
  28. dataType: 'jsonp',
  29. cache: false,
  30. async: true,
  31. success: function(data, textStatus) {
  32. var processDefinitionDiagramLayout = data;
  33. if (!processDefinitionDiagramLayout) {
  34. console.error("Process definition diagram layout '" + processDefinitionId + "' not found");
  35. return;
  36. } else {
  37. callback.apply({processDefinitionDiagramLayout: processDefinitionDiagramLayout});
  38. }
  39. }
  40. }).done(function(data, textStatus) {
  41. console.log("ajax done");
  42. }).fail(function(jqXHR, textStatus, error){
  43. console.log('Get diagram layout['+processDefinitionId+'] failure: ', textStatus, jqXHR);
  44. });
  45. },
  46. getHighLights: function(processInstanceId, callback) {
  47. var url = Lang.sub(this.options.processInstanceHighLightsUrl, {processInstanceId: processInstanceId});
  48. $.ajax({
  49. url: url,
  50. dataType: 'jsonp',
  51. cache: false,
  52. async: true,
  53. success: function(data, textStatus) {
  54. console.log("ajax returned data");
  55. var highLights = data;
  56. if (!highLights) {
  57. console.log("highLights not found");
  58. return;
  59. } else {
  60. callback.apply({highLights: highLights});
  61. }
  62. }
  63. }).done(function(data, textStatus) {
  64. console.log("ajax done");
  65. }).fail(function(jqXHR, textStatus, error){
  66. console.log('Get HighLights['+processInstanceId+'] failure: ', textStatus, jqXHR);
  67. });
  68. }
  69. };