1. 'use strict';
  2. var util = require('util');
  3. var Enumeration = require('../system/enumeration.js');
  4. /**
  5. * @classdesc
  6. * Specifies the events of models' data portal operations.
  7. * @description
  8. * Creates a new enumeration to define the data portal events. Members:
  9. *
  10. * * preFetch, postFetch
  11. * * preCreate, postCreate
  12. * * preInsert, postInsert
  13. * * preUpdate, postUpdate
  14. * * preRemove, postRemove
  15. * * preExecute, postExecute
  16. * * preSave, postSave
  17. *
  18. * @memberof bo.shared
  19. * @constructor
  20. *
  21. * @extends bo.system.Enumeration
  22. */
  23. function DataPortalEvent () {
  24. Enumeration.call(this);
  25. /**
  26. * The event before a data portal fetch operation.
  27. * @type {number}
  28. * @readonly
  29. * @default 0
  30. */
  31. this.preFetch = 0;
  32. /**
  33. * The event after a data portal fetch operation.
  34. * @type {number}
  35. * @readonly
  36. * @default 1
  37. */
  38. this.postFetch = 1;
  39. /**
  40. * The event before a data portal create operation.
  41. * @type {number}
  42. * @readonly
  43. * @default 2
  44. */
  45. this.preCreate = 2;
  46. /**
  47. * The event after a data portal create operation.
  48. * @type {number}
  49. * @readonly
  50. * @default 3
  51. */
  52. this.postCreate = 3;
  53. /**
  54. * The event before a data portal insert operation.
  55. * @type {number}
  56. * @readonly
  57. * @default 4
  58. */
  59. this.preInsert = 4;
  60. /**
  61. * The event after a data portal insert operation.
  62. * @type {number}
  63. * @readonly
  64. * @default 5
  65. */
  66. this.postInsert = 5;
  67. /**
  68. * The event before a data portal update operation.
  69. * @type {number}
  70. * @readonly
  71. * @default 6
  72. */
  73. this.preUpdate = 6;
  74. /**
  75. * The event after a data portal update operation.
  76. * @type {number}
  77. * @readonly
  78. * @default 7
  79. */
  80. this.postUpdate = 7;
  81. /**
  82. * The event before a data portal remove operation.
  83. * @type {number}
  84. * @readonly
  85. * @default 8
  86. */
  87. this.preRemove = 8;
  88. /**
  89. * The event after a data portal remove operation.
  90. * @type {number}
  91. * @readonly
  92. * @default 9
  93. */
  94. this.postRemove = 9;
  95. /**
  96. * The event before a data portal execute operation.
  97. * @type {number}
  98. * @readonly
  99. * @default 10
  100. */
  101. this.preExecute = 10;
  102. /**
  103. * The event after a data portal execute operation.
  104. * @type {number}
  105. * @readonly
  106. * @default 11
  107. */
  108. this.postExecute = 11;
  109. /**
  110. * The event before a data portal save operation.
  111. * @type {number}
  112. * @readonly
  113. * @default 12
  114. */
  115. this.preSave = 12;
  116. /**
  117. * The event after a data portal save operation.
  118. * @type {number}
  119. * @readonly
  120. * @default 13
  121. */
  122. this.postSave = 13;
  123. // Immutable object.
  124. Object.freeze(this);
  125. }
  126. util.inherits(DataPortalEvent, Enumeration);
  127. module.exports = new DataPortalEvent();