AsyncCapableHelper.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. 'use strict';
  2. var map = require('lodash/map');
  3. var extensionElementsHelper = require('./ExtensionElementsHelper');
  4. /**
  5. * Returns true if the attribute 'activiti:asyncBefore' is set
  6. * to true.
  7. *
  8. * @param {ModdleElement} bo
  9. *
  10. * @return {boolean} a boolean value
  11. */
  12. function isAsyncBefore(bo) {
  13. return !!(bo.get('activiti:asyncBefore') || bo.get('activiti:async'));
  14. }
  15. module.exports.isAsyncBefore = isAsyncBefore;
  16. /**
  17. * Returns true if the attribute 'activiti:asyncAfter' is set
  18. * to true.
  19. *
  20. * @param {ModdleElement} bo
  21. *
  22. * @return {boolean} a boolean value
  23. */
  24. function isAsyncAfter(bo) {
  25. return !!bo.get('activiti:asyncAfter');
  26. }
  27. module.exports.isAsyncAfter = isAsyncAfter;
  28. /**
  29. * Returns true if the attribute 'activiti:exclusive' is set
  30. * to true.
  31. *
  32. * @param {ModdleElement} bo
  33. *
  34. * @return {boolean} a boolean value
  35. */
  36. function isExclusive(bo) {
  37. return !!bo.get('activiti:exclusive');
  38. }
  39. module.exports.isExclusive = isExclusive;
  40. /**
  41. * Get first 'activiti:FailedJobRetryTimeCycle' from the business object.
  42. *
  43. * @param {ModdleElement} bo
  44. *
  45. * @return {Array<ModdleElement>} a list of 'activiti:FailedJobRetryTimeCycle'
  46. */
  47. function getFailedJobRetryTimeCycle(bo) {
  48. return (extensionElementsHelper.getExtensionElements(bo, 'activiti:FailedJobRetryTimeCycle') || [])[0];
  49. }
  50. module.exports.getFailedJobRetryTimeCycle = getFailedJobRetryTimeCycle;
  51. /**
  52. * Removes all existing 'activiti:FailedJobRetryTimeCycle' from the business object
  53. *
  54. * @param {ModdleElement} bo
  55. *
  56. * @return {Array<ModdleElement>} a list of 'activiti:FailedJobRetryTimeCycle'
  57. */
  58. function removeFailedJobRetryTimeCycle(bo, element) {
  59. var retryTimeCycles = extensionElementsHelper.getExtensionElements(bo, 'activiti:FailedJobRetryTimeCycle');
  60. return map(retryTimeCycles, function(cycle) {
  61. return extensionElementsHelper.removeEntry(bo, element, cycle);
  62. });
  63. }
  64. module.exports.removeFailedJobRetryTimeCycle = removeFailedJobRetryTimeCycle;