cob-cli 2.23.0 → 2.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/.gitmodules +27 -0
  2. package/bin/cob-cli.js +3 -1
  3. package/bin/handleAutoComplete.js +1 -4
  4. package/lib/commands/customize.js +213 -66
  5. package/package.json +3 -2
  6. package/.vscode/launch.json +0 -106
  7. package/customizations/backend.email.js +0 -10
  8. package/customizations/backend.js +0 -14
  9. package/customizations/backend.updateField.js +0 -11
  10. package/customizations/backend.vuepress.js +0 -35
  11. package/customizations/dashboard.dash.js +0 -11
  12. package/customizations/dashboard.js +0 -14
  13. package/customizations/dashboard.simple.js +0 -12
  14. package/customizations/dashboard.vue.empty.js +0 -12
  15. package/customizations/dashboard.vue.grid.js +0 -10
  16. package/customizations/dashboard.vue.js +0 -14
  17. package/customizations/dashboard.vue.menuAndGrid.js +0 -10
  18. package/customizations/frontend.common.js +0 -15
  19. package/customizations/frontend.easy.js +0 -16
  20. package/customizations/frontend.formatList.currency.js +0 -15
  21. package/customizations/frontend.formatList.js +0 -13
  22. package/customizations/frontend.js +0 -14
  23. package/customizations/importer.js +0 -10
  24. package/customizations/keywords.audit.js +0 -17
  25. package/customizations/keywords.calc.js +0 -17
  26. package/customizations/keywords.js +0 -15
  27. package/customizations/keywords.log.js +0 -17
  28. package/customizations/keywords.styleResults.js +0 -17
  29. package/templates/backend/vuepress/integrationm/actions/getVuePressDoc.groovy +0 -74
  30. package/templates/backend/vuepress/integrationm/actions/getVuePressSidebarConfig.groovy +0 -42
  31. package/templates/backend/vuepress/integrationm/actions/getVuePressSidebarRootElements.groovy +0 -17
  32. package/templates/backend/vuepress/others/vuepress/definition_contents_v234.json +0 -619
  33. package/templates/backend/vuepress/others/vuepress/nginx/README.md +0 -28
  34. package/templates/backend/vuepress/others/vuepress/package-lock.json +0 -29656
  35. package/templates/backend/vuepress/others/vuepress/package.json +0 -24
  36. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/DescriptVideo.vue +0 -22
  37. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/Graph.vue +0 -124
  38. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/ReadingTime.vue +0 -26
  39. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/References.vue +0 -228
  40. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/RestrictedContent.vue +0 -77
  41. package/templates/backend/vuepress/others/vuepress/src/.vuepress/config.js +0 -101
  42. package/templates/backend/vuepress/others/vuepress/src/.vuepress/config.json +0 -31
  43. package/templates/backend/vuepress/others/vuepress/src/.vuepress/enhanceApp.js +0 -14
  44. package/templates/backend/vuepress/others/vuepress/src/.vuepress/nav/getNavTranslated.js +0 -52
  45. package/templates/backend/vuepress/others/vuepress/src/.vuepress/plugins/References.js +0 -96
  46. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/Logo-Cult-of-Bits-400x400-1.png +0 -0
  47. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/favicon-cob.png +0 -0
  48. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/logo.png +0 -0
  49. package/templates/backend/vuepress/others/vuepress/src/.vuepress/styles/index.styl +0 -39
  50. package/templates/backend/vuepress/others/vuepress/src/.vuepress/styles/palette.styl +0 -17
  51. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/LICENSE +0 -21
  52. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/README.md +0 -11
  53. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/AlgoliaSearchBox.vue +0 -172
  54. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/DropdownLink.vue +0 -252
  55. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/DropdownTransition.vue +0 -33
  56. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Home.vue +0 -134
  57. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/NavLink.vue +0 -98
  58. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/NavLinks.vue +0 -165
  59. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Navbar.vue +0 -140
  60. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Page.vue +0 -31
  61. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/PageEdit.vue +0 -119
  62. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/PageNav.vue +0 -163
  63. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Sidebar.vue +0 -64
  64. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarButton.vue +0 -40
  65. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarGroup.vue +0 -144
  66. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarLink.vue +0 -140
  67. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarLinks.vue +0 -114
  68. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/Badge.vue +0 -44
  69. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/CodeBlock.vue +0 -41
  70. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/CodeGroup.vue +0 -120
  71. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/index.js +0 -59
  72. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/layouts/404.vue +0 -30
  73. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/layouts/Layout.vue +0 -151
  74. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/noopModule.js +0 -1
  75. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/package.json +0 -44
  76. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/arrow.styl +0 -22
  77. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/code.styl +0 -137
  78. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/config.styl +0 -1
  79. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/custom-blocks.styl +0 -44
  80. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/index.styl +0 -202
  81. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/mobile.styl +0 -37
  82. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/toc.styl +0 -3
  83. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/wrapper.styl +0 -10
  84. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/util/index.js +0 -244
  85. package/templates/dashboards/cob-dashboard-html/demoDashboard.html +0 -18
  86. package/templates/dashboards/cob-dashboard-vue/package-lock.json +0 -25020
  87. package/templates/dashboards/cob-dashboard-vue/package.json +0 -21
  88. package/templates/dashboards/cob-dashboard-vue/src/App.vue +0 -26
  89. package/templates/dashboards/cob-dashboard-vue/src/dashboard.html +0 -31
  90. package/templates/dashboards/cob-dashboard-vue/src/main.js +0 -12
  91. package/templates/dashboards/cob-dashboard-vue/src/plugins/cobUiVueComponents.js +0 -6
  92. package/templates/dashboards/cob-dashboard-vue/src/plugins/vuetify.js +0 -9
  93. package/templates/dashboards/cob-dashboard-vue/vue.config.js +0 -104
  94. package/templates/dashboards/dash/dist/css/app.7b16c01a.css +0 -11
  95. package/templates/dashboards/dash/dist/dashboard.html +0 -25
  96. package/templates/dashboards/dash/dist/fonts/fa-brands-400.a78ffbbe.ttf +0 -0
  97. package/templates/dashboards/dash/dist/fonts/fa-brands-400.cd2b4095.woff2 +0 -0
  98. package/templates/dashboards/dash/dist/fonts/fa-regular-400.b1a1bebb.ttf +0 -0
  99. package/templates/dashboards/dash/dist/fonts/fa-regular-400.e8a1ba41.woff2 +0 -0
  100. package/templates/dashboards/dash/dist/fonts/fa-solid-900.55b416a8.woff2 +0 -0
  101. package/templates/dashboards/dash/dist/fonts/fa-solid-900.73820155.ttf +0 -0
  102. package/templates/dashboards/dash/dist/fonts/fa-v4compatibility.0d6f5f18.ttf +0 -0
  103. package/templates/dashboards/dash/dist/fonts/fa-v4compatibility.786e6b33.woff2 +0 -0
  104. package/templates/dashboards/dash/dist/js/app.13b950c8.js +0 -199
  105. package/templates/dashboards/dash/dist/js/app.13b950c8.js.map +0 -1
  106. package/templates/dashboards/dash/package-lock.json +0 -22646
  107. package/templates/dashboards/dash/package.json +0 -27
  108. package/templates/dashboards/dash/src/App.vue +0 -124
  109. package/templates/dashboards/dash/src/assets/css/all.min.css +0 -6
  110. package/templates/dashboards/dash/src/assets/webfonts/fa-brands-400.ttf +0 -0
  111. package/templates/dashboards/dash/src/assets/webfonts/fa-brands-400.woff2 +0 -0
  112. package/templates/dashboards/dash/src/assets/webfonts/fa-regular-400.ttf +0 -0
  113. package/templates/dashboards/dash/src/assets/webfonts/fa-regular-400.woff2 +0 -0
  114. package/templates/dashboards/dash/src/assets/webfonts/fa-solid-900.ttf +0 -0
  115. package/templates/dashboards/dash/src/assets/webfonts/fa-solid-900.woff2 +0 -0
  116. package/templates/dashboards/dash/src/assets/webfonts/fa-v4compatibility.ttf +0 -0
  117. package/templates/dashboards/dash/src/assets/webfonts/fa-v4compatibility.woff2 +0 -0
  118. package/templates/dashboards/dash/src/collector.js +0 -222
  119. package/templates/dashboards/dash/src/components/Attention.vue +0 -30
  120. package/templates/dashboards/dash/src/components/Board.vue +0 -35
  121. package/templates/dashboards/dash/src/components/Calendar.vue +0 -422
  122. package/templates/dashboards/dash/src/components/Dashboard.vue +0 -27
  123. package/templates/dashboards/dash/src/components/Filter.vue +0 -68
  124. package/templates/dashboards/dash/src/components/Kibana.vue +0 -138
  125. package/templates/dashboards/dash/src/components/Label.vue +0 -15
  126. package/templates/dashboards/dash/src/components/Menu.vue +0 -44
  127. package/templates/dashboards/dash/src/components/Totals.vue +0 -49
  128. package/templates/dashboards/dash/src/components/TotalsValue.vue +0 -59
  129. package/templates/dashboards/dash/src/components/shared/Instance.vue +0 -64
  130. package/templates/dashboards/dash/src/components/shared/Waiting.vue +0 -25
  131. package/templates/dashboards/dash/src/dashboard.html +0 -39
  132. package/templates/dashboards/dash/src/definition_dashboard_v0.json +0 -924
  133. package/templates/dashboards/dash/src/definition_dashboard_v1.json +0 -1
  134. package/templates/dashboards/dash/src/input.css +0 -9
  135. package/templates/dashboards/dash/src/main.js +0 -11
  136. package/templates/dashboards/dash/src/model/ComponentStatePersistence.js +0 -66
  137. package/templates/dashboards/dash/src/output.css +0 -314245
  138. package/templates/dashboards/dash/src/test_collector.js +0 -3719
  139. package/templates/dashboards/dash/src/utils/EsInstanceUtils.js +0 -8
  140. package/templates/dashboards/dash/tailwind.config.js +0 -12
  141. package/templates/dashboards/dash/vue.config.js +0 -104
  142. package/templates/frontend/common/css/_dualColumn.css +0 -46
  143. package/templates/frontend/common/css/_global.css +0 -19
  144. package/templates/frontend/common/css/_hidden.css +0 -13
  145. package/templates/frontend/common/css/_history.css +0 -13
  146. package/templates/frontend/common/css/_mobile.css +0 -125
  147. package/templates/frontend/common/css/customizations.__MERGE__.css +0 -5
  148. package/templates/frontend/common/js/cob/_disable_save_onSubdetail.js +0 -11
  149. package/templates/frontend/common/js/cob/_group_references.js +0 -22
  150. package/templates/frontend/common/js/cob/_show_hidden.js +0 -35
  151. package/templates/frontend/common/js/customizations2.__MERGE__.js +0 -3
  152. package/templates/frontend/easy/css/_easy/googlefonts.css +0 -360
  153. package/templates/frontend/easy/css/_easy/vuetify.cob-scoped.css +0 -10488
  154. package/templates/frontend/easy/js/_easy/lib/axios.min.js +0 -9
  155. package/templates/frontend/easy/js/_easy/lib/marked.min.js +0 -6
  156. package/templates/frontend/easy/js/_easy/lib/vue.js +0 -11912
  157. package/templates/frontend/easy/js/_easy/lib/vue.min.js +0 -6
  158. package/templates/frontend/easy/js/_easy/lib/vuetify.min.js +0 -6
  159. package/templates/frontend/easy/js/customizations2.__MERGE__.js +0 -22
  160. package/templates/frontend/easy/webapp/.browserslistrc +0 -2
  161. package/templates/frontend/easy/webapp/.eslintrc.js +0 -17
  162. package/templates/frontend/easy/webapp/README.md +0 -60
  163. package/templates/frontend/easy/webapp/babel.config.js +0 -5
  164. package/templates/frontend/easy/webapp/dist/css/app.a4fb91f8.css +0 -1
  165. package/templates/frontend/easy/webapp/dist/dashboard.html +0 -13
  166. package/templates/frontend/easy/webapp/dist/js/app.63a57dcd.js +0 -2
  167. package/templates/frontend/easy/webapp/dist/js/app.63a57dcd.js.map +0 -1
  168. package/templates/frontend/easy/webapp/package-lock.json +0 -32986
  169. package/templates/frontend/easy/webapp/package.json +0 -32
  170. package/templates/frontend/easy/webapp/postcss.config.js +0 -5
  171. package/templates/frontend/easy/webapp/public/dashboard.html +0 -13
  172. package/templates/frontend/easy/webapp/src/App.vue +0 -181
  173. package/templates/frontend/easy/webapp/src/assets/logo.png +0 -0
  174. package/templates/frontend/easy/webapp/src/components/HelloWorld.vue +0 -59
  175. package/templates/frontend/easy/webapp/src/components/PermBuilder.vue +0 -163
  176. package/templates/frontend/easy/webapp/src/components/PlanExecutor.vue +0 -225
  177. package/templates/frontend/easy/webapp/src/components/ProductPermBuilder.vue +0 -95
  178. package/templates/frontend/easy/webapp/src/components/RmDefinitionChooser.vue +0 -59
  179. package/templates/frontend/easy/webapp/src/components/RmDomainChooser.vue +0 -60
  180. package/templates/frontend/easy/webapp/src/components/RoleBuilder.vue +0 -73
  181. package/templates/frontend/easy/webapp/src/main.js +0 -19
  182. package/templates/frontend/easy/webapp/src/perm-templates.js +0 -189
  183. package/templates/frontend/easy/webapp/src/perms.js +0 -197
  184. package/templates/frontend/easy/webapp/vue.config.js +0 -66
  185. package/templates/frontend/formatList/currency/css/_format_currency.css +0 -11
  186. package/templates/frontend/formatList/currency/css/customizations.__MERGE__.css +0 -1
  187. package/templates/frontend/formatList/currency/js/cob/_format_currency.js +0 -11
  188. package/templates/frontend/formatList/currency/js/customizations2.__MERGE__.js +0 -1
  189. package/templates/gitignore +0 -14
  190. package/templates/keywords/audit/backend/scripts/_audit.groovy +0 -83
  191. package/templates/keywords/audit/frontend/js/cob/_audit.js +0 -24
  192. package/templates/keywords/audit/frontend/js/customizations2.__MERGE__.js +0 -1
  193. package/templates/keywords/calc/backend/scripts/_calc.groovy +0 -161
  194. package/templates/keywords/calc/frontend/js/cob/_calc.js +0 -193
  195. package/templates/keywords/calc/frontend/js/customizations2.__MERGE__.js +0 -1
  196. package/templates/keywords/log/backend/scripts/_log.groovy +0 -99
  197. package/templates/keywords/log/frontend/css/_log.css +0 -5
  198. package/templates/keywords/log/frontend/css/customizations.__MERGE__.css +0 -1
  199. package/templates/keywords/styleResults/frontend/css/_styleResults.css +0 -86
  200. package/templates/keywords/styleResults/frontend/css/customizations.__MERGE__.css +0 -1
  201. package/templates/keywords/styleResults/frontend/js/cob/_styleResults.js +0 -38
  202. package/templates/keywords/styleResults/frontend/js/customizations2.__MERGE__.js +0 -1
@@ -1,66 +0,0 @@
1
- const DASH_DIR = process.env.npm_package_config_dash_dir
2
- const SERVER = process.env.npm_config_remote_server
3
- || ("https://" + process.env.npm_package_config_remote_server);
4
-
5
- module.exports = {
6
- // temos que fixar o directorio onde colocamos o build,
7
- // para podermos usar o dashboard.html que é gerado sem o editar
8
- // NOTA: o path relativo não funciona bem com o npm run serve
9
- // mas queremos que o build seja relativo, para ser mais fléxivel
10
- publicPath: process.env.NODE_ENV === 'production'
11
- ? './localresource/' + DASH_DIR + '/dist/'
12
- : '/' + DASH_DIR + '/',
13
-
14
- configureWebpack: {
15
- // deve ser igual ao que é usado no afterDeps do public/dashboard.html
16
- externals: {
17
- vue: 'Vue',
18
- vuetify: 'Vuetify',
19
- axios: 'axios',
20
- marked: 'marked'
21
- }
22
- },
23
-
24
- // seguindo https://cli.vuejs.org/guide/webpack.html
25
- chainWebpack: config => {
26
- // para não termos chunks
27
- config.optimization.delete('splitChunks');
28
- // fazemos assim em vez de usar o pages, que confunde o publicPath
29
- config
30
- .plugin('html')
31
- .tap(args => {
32
- args[0].template = 'public/dashboard.html'
33
- args[0].filename = 'dashboard.html'
34
- args[0].inject = false
35
- args[0].minify = false
36
- return args
37
- })
38
- },
39
-
40
- devServer: {
41
- proxy: {
42
- [`^/userm/localresource/${DASH_DIR}`]: {
43
- //logLevel: 'debug',
44
- target: "http://localhost:8080",
45
- pathRewrite: path =>
46
- path.replace(
47
- "/userm/localresource/" + DASH_DIR,
48
- "/" + DASH_DIR
49
- )
50
- },
51
- "^/userm|^/recordm|^/es|^/logm|^/kibana": {
52
- //logLevel: 'debug',
53
- target: SERVER,
54
- ws: true,
55
- changeOrigin: true
56
- },
57
- "/get_user_lang|/security|/localresource|/userm|/user|/reportm|/cas": {
58
- //logLevel: 'debug',
59
- target: SERVER,
60
- ws: true,
61
- changeOrigin: true,
62
- pathRewrite: path => path.replace("/userm/userm", "/userm")
63
- }
64
- }
65
- }
66
- }
@@ -1,11 +0,0 @@
1
- .currency_negative {
2
- color:red;
3
- }
4
- .currency_positive {
5
- color:green;
6
- }
7
-
8
- .currency_negative::after,
9
- .currency_positive::after {
10
- content: ' €';
11
- }
@@ -1 +0,0 @@
1
- @import "_format_currency.css";
@@ -1,11 +0,0 @@
1
- cob.custom.customize.push(function (core, utils, ui) {
2
- core.customizeAllColumns("*", (node, esDoc, colDef) => {
3
- // Test $style[currency], by it self or with other styles
4
- if(/\$style\[([^,]+,)*currency(,[^,]+)*\]/.exec(colDef.fieldDefDescription) != null) {
5
- let value = esDoc[colDef.field] ? esDoc[colDef.field][0] : null
6
- if(value) {
7
- node.classList.add((value[0] === "-") ? "currency_negative" : "currency_positive")
8
- }
9
- }
10
- })
11
- })
@@ -1 +0,0 @@
1
- import("./cob/_format_currency.js");
@@ -1,14 +0,0 @@
1
- .DS_Store
2
- node_modules
3
- .idea
4
- *.iml
5
- .env.json
6
- .test.in.execution
7
-
8
- # NativeScript application
9
- hooks
10
- platforms
11
-
12
- # CoB Enviroment management temporary files
13
- *ENV__DELETE__.*
14
- *ENV__ORIGINAL_BACKUP__.*
@@ -1,83 +0,0 @@
1
- import groovy.transform.Field
2
- import org.codehaus.jettison.json.JSONObject
3
-
4
- import com.google.common.cache.*
5
- import java.util.concurrent.TimeUnit
6
-
7
- // ========================================================================================================
8
- if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
9
-
10
- @Field static cacheOfAuditFieldsForDefinition = CacheBuilder.newBuilder()
11
- .expireAfterWrite(5, TimeUnit.MINUTES)
12
- .build();
13
-
14
- if (msg.product == "recordm-definition") cacheOfAuditFieldsForDefinition.invalidate(msg.type)
15
-
16
- // ========================================================================================================
17
- def auditFields = cacheOfAuditFieldsForDefinition.get(msg.type, { getAuditFields(msg.type) })
18
- if (auditFields.size() > 0
19
- && msg.product == "recordm"
20
- && msg.user != "integrationm"
21
- && msg.action =~ "add|update" ) {
22
-
23
- def updates = getAuditFieldsUpdates(auditFields,msg.instance.fields)
24
- def result = actionPacks.recordm.update(msg.type, "recordmInstanceId:" + msg.instance.id, updates);
25
- if(updates) log.info("[\$audit] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
26
- }
27
-
28
- // ========================================================================================================
29
- def getAuditFieldsUpdates(auditFields,instanceFields) {
30
- def updates = [:]
31
- auditFields.each { auditField ->
32
- if( auditField.op == "creator" && msg.action == "update" && msg.value(auditField.name) != null) return // 'creator' fields are only changed in 'update' if the previous value was empty (meaning it was a field that was not visible)
33
- if( msg.action == 'update' && !msg.diff) return // Only continues if there is at least one change
34
- if( auditField.args == "uri") {
35
- updates << [(auditField.name) : actionPacks.get("userm").getUser(msg.user).data._links.self]
36
-
37
- } else if( auditField.args == "username") {
38
- updates << [(auditField.name) : msg.user]
39
-
40
- } else if( auditField.args == "time") {
41
- if(msg.action == 'add' && Math.abs(msg.value(auditField.name, Long.class)?:0 - msg._timestamp_) < 30000) return // Ignore changes less then 30s
42
- updates << [(auditField.name) : "" + msg._timestamp_]
43
- }
44
- }
45
- return updates
46
- }
47
-
48
- // ========================================================================================================
49
- def getAuditFields(definitionName) {
50
- log.info("[\$audit] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
51
-
52
- // Obtém detalhes da definição
53
- def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
54
- def resp = actionPacks.rmRest.get( "recordm/definitions/name/${definitionEncoded}".toString(), [:], "integrationm");
55
- JSONObject definition = new JSONObject(resp);
56
-
57
- def fieldsSize = definition.fieldDefinitions.length();
58
-
59
- def fields = [:]
60
- (0..fieldsSize-1).each { index ->
61
- def fieldDefinition = definition.fieldDefinitions.getJSONObject(index)
62
- def fieldDescription = fieldDefinition.getString("description")
63
- if(fieldDescription){
64
- def fieldDefId = fieldDefinition.get("id");
65
- def fieldName = fieldDefinition.get("name");
66
- fields[fieldDefId] = [name:fieldName, description: fieldDescription]
67
- }
68
- }
69
-
70
- // Finalmente obtém a lista de campos que é necessário calcular
71
- def auditFields = [];
72
- fields.each { fieldId,field ->
73
- def matcher = field.description =~ /[$]audit\.(creator|updater)\.(username|uri|time)/
74
- if(matcher) {
75
- def op = matcher[0][1]
76
- def arg = matcher[0][2]
77
- auditFields << [fieldId: fieldId, name:field.name, op : op, args: arg]
78
- }
79
- }
80
- log.info("[\$audit] Update 'auditFields' for '$definitionName': $auditFields");
81
- log.info("[\$audit] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
82
- return auditFields
83
- }
@@ -1,24 +0,0 @@
1
- //----------------- $audit ------------------------
2
- cob.custom.customize.push(function (core, utils, ui) {
3
- core.customizeAllInstances((instance, presenter) =>
4
- {
5
- let userFPs = presenter.findFieldPs( fp => /[$]audit\.(creator|updater)\.(username|uri|time)/.exec(fp.field.fieldDefinition.description) )
6
- userFPs.forEach( fp => {
7
- fp.disable()
8
- if( presenter.isGroupEdit() ) return; // Don't do nothing in group edit
9
- if(/[$]audit\.updater\./.exec(fp.field.fieldDefinition.description) && !instance.isNew()) return //Don't do nothing if $audit.updater.* and it's an update interface (updates will only be changed by the backend)
10
- if(fp.isVisible() && /[$]audit\.creator\./.exec(fp.field.fieldDefinition.description) && !instance.isNew()) return //Se campo visível e é um creator não faz nada
11
-
12
- if(/[$]audit\.(creator|updater)\.username/.exec(fp.field.fieldDefinition.description)) {
13
- fp.setValue(core.getCurrentLoggedInUser())
14
- }
15
- if(/[$]audit\.(creator|updater)\.uri/.exec(fp.field.fieldDefinition.description)) {
16
- fp.setValue(core.getCurrentLoggedInUserUri())
17
- }
18
- if(/[$]audit\.(creator|updater)\.time/.exec(fp.field.fieldDefinition.description)) {
19
- fp.setValue(Date.now())
20
- setInterval(() => fp.setValue(Date.now()),15000)
21
- }
22
- })
23
- })
24
- });
@@ -1 +0,0 @@
1
- import("./cob/_audit.js");
@@ -1,161 +0,0 @@
1
- import groovy.transform.Field
2
- import org.codehaus.jettison.json.JSONObject
3
-
4
- import java.math.RoundingMode;
5
-
6
- import com.google.common.cache.*
7
- import java.util.concurrent.TimeUnit
8
-
9
- // ========================================================================================================
10
- if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
11
-
12
- @Field static cacheOfCalcFieldsForDefinition = CacheBuilder.newBuilder()
13
- .expireAfterWrite(5, TimeUnit.MINUTES)
14
- .build();
15
-
16
- if (msg.product == "recordm-definition") cacheOfCalcFieldsForDefinition.invalidate(msg.type)
17
-
18
- // ========================================================================================================
19
- def calculationFields = cacheOfCalcFieldsForDefinition.get(msg.type, { getAllCalculationFields(msg.type) })
20
- if (calculationFields.size() > 0
21
- && msg.product == "recordm"
22
- && msg.user != "integrationm"
23
- && msg.action =~ "add|update" ){
24
-
25
- def updates = executeCalculations(calculationFields, msg.instance.fields)
26
- def result = actionPacks.recordm.update(messageMap.type, "recordmInstanceId:" + messageMap.instance.id, updates);
27
- if(updates) log.info("[\$calc] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
28
- }
29
-
30
- // ==================================================
31
- def getCalculationOperation(fieldDescription) {
32
- def matcher = fieldDescription =~/.*[$]calc.([^(]+)/
33
- def op = matcher[0][1]
34
- return op
35
- }
36
-
37
- // ==================================================
38
- def getCalculationArgNames(fieldDescription) {
39
- def matcher = fieldDescription =~/.*[$]calc.[^(]+\(([^(]+)\)/
40
- def argNamesArray = matcher[0][1].tokenize(",")
41
- return argNamesArray;
42
- }
43
-
44
- // ========================================================================================================
45
- def executeCalculations(calculationFields,instanceFields) {
46
- def updates = [:]
47
- def atLeastOneChangeFlag = false;
48
- def passCount = 0;
49
- def temporaryResults = [:]
50
- while(passCount++ == 0 || atLeastOneChangeFlag && passCount < 10) { //10 is just for security against loops
51
- atLeastOneChangeFlag = false
52
- calculationFields.each { calculation ->
53
- def novoResultado = evaluateExpression(calculation,instanceFields,temporaryResults)
54
- if(temporaryResults[calculation.fieldId] != novoResultado ) {
55
- // log.info("[\$calc] {{passCount:${passCount}, field:${calculation.name} (${calculation.fieldId})" +
56
- // ", calcType:${calculation.op}(${calculation.args})" +
57
- // ", previousResult:${temporaryResults[calculation.fieldId]}" +
58
- // ", calcValue:$novoResultado}}");
59
-
60
- temporaryResults[calculation.fieldId] = novoResultado;
61
- updates << [(calculation.name) : novoResultado]
62
- atLeastOneChangeFlag = true
63
- }
64
- }
65
- }
66
- return updates
67
- }
68
-
69
- // ==================================================
70
- def evaluateExpression(calculation,instanceFields,temporaryResults) {
71
- // Realizar operação
72
- def resultado = new BigDecimal(0)
73
- def args = getCalculationArguments(calculation,instanceFields,temporaryResults)
74
-
75
- if(calculation.op == "multiply" && args.size() > 0) {
76
- resultado = 1
77
- args.each { arg -> resultado = resultado.multiply(new BigDecimal(arg?.trim() ?: 0)) }
78
-
79
- } else if (calculation.op == "divide" && args.size() == 2 && (args[1]?:0 != 0)) {
80
- resultado = new BigDecimal(args[0]?.trim() ?:0);
81
- resultado = resultado.divide(new BigDecimal(args[1]?.trim()), 8, RoundingMode.HALF_UP)
82
-
83
- } else if(calculation.op == "sum") {
84
- args.each { arg -> resultado = resultado + new BigDecimal(arg?.trim() ?: 0)}
85
-
86
- } else if (calculation.op == "subtract" && args.size() == 2) {
87
- resultado = new BigDecimal(args[0]?.trim() ?: 0);
88
- resultado = resultado.subtract(new BigDecimal(args[1]?.trim() ?: 0))
89
- }
90
- return resultado.stripTrailingZeros().toPlainString()
91
- }
92
-
93
- // ==================================================
94
- def getCalculationArguments(calculation,instanceFields,temporaryResults) {
95
- def values = calculation.args.collect { argName,argFieldIds ->
96
- (""+argName).isNumber()
97
- ? argName * 1
98
- : getAllAplicableValuesForVarName(calculation.fieldId,argName,argFieldIds,instanceFields,temporaryResults)
99
- }
100
- return values.flatten()
101
- }
102
-
103
- // ==================================================
104
- def getAllAplicableValuesForVarName(fieldId,varName,varFieldIds,instanceFields,temporaryResults) {
105
- // log.info("[\$calc] find '$varName'($varFieldIds) in $instanceFields (temporaryResults=$temporaryResults) ");
106
- def relevantFields = instanceFields.findAll{ instField -> varFieldIds.indexOf(instField.fieldDefinition.id) >= 0 }
107
-
108
- def result = varFieldIds.collect { varFieldId ->
109
- if(temporaryResults[varFieldId] != null) {
110
- return temporaryResults[varFieldId]
111
- } else {
112
- return temporaryResults[varFieldId] = instanceFields.findAll{ instField -> varFieldId == instField.fieldDefinition.id }?.collect { it.value }
113
- }
114
- }
115
- // log.info("[\$calc] values for '$varName'($varFieldIds) = $result (temporaryResults=$temporaryResults) " );
116
- return result.flatten()
117
- }
118
-
119
- // ========================================================================================================
120
- def getAllCalculationFields(definitionName) {
121
- log.info("[\$calc] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
122
-
123
- // Obtém detalhes da definição
124
- def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
125
- def resp = actionPacks.rmRest.get( "recordm/definitions/name/${definitionEncoded}".toString(), [:], "integrationm");
126
- JSONObject definition = new JSONObject(resp);
127
-
128
- def fieldsSize = definition.fieldDefinitions.length();
129
-
130
- def fields = [:]
131
- (0..fieldsSize-1).each { index ->
132
- def fieldDefinition = definition.fieldDefinitions.getJSONObject(index)
133
- def fieldDescription = fieldDefinition.get("description")
134
- def fieldDefId = fieldDefinition.get("id")
135
- def fieldName = fieldDefinition.get("name");
136
- fields[fieldDefId] = [name:fieldName, description: fieldDescription]
137
- }
138
-
139
- // Finalmente obtém a lista de campos que é necessário calcular
140
- def calculationFields = [];
141
- def previousId
142
- fields.each { fieldId,field ->
143
- if(field.description.toString() =~ /[$]calc\./) {
144
- def op = getCalculationOperation(field.description)
145
- def args = getCalculationArgNames(field.description)
146
- argsFields = [:]
147
- args.each { arg ->
148
- if(arg == "previous") {
149
- argsFields[arg] = [previousId]
150
- } else {
151
- argsFields[arg] = fields.findAll{fId,f -> f.description?.toString() =~ /.*[$]$arg.*/ }.collect { fId,f -> fId}
152
- }
153
- }
154
- calculationFields << [fieldId: fieldId, name:field.name, op : op, args : argsFields]
155
- }
156
- previousId = fieldId
157
- }
158
- log.info("[\$calc] Update 'calculationFields' for '$definitionName': $calculationFields");
159
- log.info("[\$calc] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
160
- return calculationFields
161
- }
@@ -1,193 +0,0 @@
1
- //----------------- Enable do $calc ------------------------
2
- cob.custom.customize.push(function (core, utils, ui) {
3
- core.customizeAllInstances((instance, presenter) => calc_automation(instance, presenter))
4
-
5
- function calc_automation(instance, presenter) {
6
- registerAndExecuteCalculation()
7
- // Repeat 'executeCalculations' every 200ms to compensante not reacting to deletion of duplicate fiels (no event available to subscribe) or changes in top hierarchy (see specific TODO below)
8
- setInterval(executeCalculations,2000)
9
-
10
- //=========================================================
11
- // Support functions
12
- //=========================================================
13
- function registerAndExecuteCalculation() {
14
- registerExecuteCalculationsOnChanges()
15
- executeCalculations()
16
- }
17
-
18
- //=========================================================
19
- function getAllCalculationsFields() {
20
- return presenter
21
- .findFieldPs( fp => /[$]calc\.(.*)/.exec(fp.field.fieldDefinition.description) )
22
- .map( calculationFp => {
23
- calculationFp.disable()
24
- return {
25
- fp: calculationFp,
26
- op: getCalculationOperation(calculationFp),
27
- args: getCalculationArguments(calculationFp)
28
- }
29
- })
30
-
31
- //=========================================================
32
- function getCalculationOperation(calculationFp) {
33
- let fieldDescription = calculationFp.field.fieldDefinition.description
34
- let expr = fieldDescription.substr(fieldDescription.indexOf("$calc.")+6)
35
- let matcher = /([^(]+)/
36
- let op = expr.match(matcher)[1]
37
- return op
38
- }
39
-
40
- //=========================================================
41
- function getCalculationArguments(calculationFp) {
42
- let argNames = getCalculationArgNames(calculationFp)
43
- return argNames
44
- .map( argName => isNaN(argName)
45
- ? getAllAplicableFpsForVarName(calculationFp, argName) // É uma variável, retorna todos os fp associados
46
- : argName * 1 // é uma constante numérica
47
- )
48
- .flat()
49
-
50
- //=========================================================
51
- function getCalculationArgNames(calculationFp) {
52
- let fieldDescription = calculationFp.field.fieldDefinition.description;
53
- let expr = fieldDescription.substr( fieldDescription.indexOf("$calc.") + 6 );
54
- let matcher = /[^(]+\(([^(]+)\)/;
55
- let argNamesArray = expr.match(matcher)[1].split(",");
56
- return argNamesArray;
57
- }
58
-
59
- //=========================================================
60
- function getAllAplicableFpsForVarName(calculationFp, varName) {
61
- let result
62
- if(varName === "previous") {
63
- let todosCampos = presenter.findFieldPs(() => true).map(fp => fp.field.id )
64
- result = presenter.findFieldPs(fp => fp.field.id === todosCampos[todosCampos.indexOf(calculationFp.field.id)-1])
65
- } else {
66
- result = presenter.findFieldPs( fp => fp.field.fieldDefinition.description && fp.field.fieldDefinition.description.includes("$"+varName))
67
- }
68
- return result
69
- }
70
- }
71
- }
72
-
73
- //=========================================================
74
- function registerExecuteCalculationsOnChanges() {
75
- let calculations = getAllCalculationsFields()
76
- calculations.forEach(
77
- calculation => calculation.args.forEach( arg => {
78
- // eventos de field changes de qualquer das variáveis (ou seja, sempre que o argumento não for um número)
79
- if(isNaN(arg)) {
80
- if(arg.field.fieldDefinition.duplicable) {
81
- //O caso de campos duplicáveis é diferente porque é necessário voltar a registar tudo e só depois calcular
82
- presenter.onFieldChange(arg.field.fieldDefinition.name, () => registerAndExecuteCalculation() )
83
- // TODO: reagir à remoção de um duplicado
84
- } else {
85
- //No caso de campos normais só é necessário calcular tudo quando uma dependência muda
86
- presenter.onFieldChange(arg, () => executeCalculations() )
87
- }
88
- //Caso o campo tenha uma condição também temos de reagir a mudanças na condição. TODO: reagir a toda a cadeia superior (sempre que haja uma condição ou seja duplicável) e não apenas condição directa
89
- let conditionFp = presenter.findFieldPs(fp => fp.field.id === arg.field.fieldDefinition.conditionSource)
90
- if(conditionFp.length) presenter.onFieldChange(conditionFp[0].field.fieldDefinition.name, registerAndExecuteCalculation )
91
-
92
- }
93
- })
94
- )
95
- }
96
-
97
- //=========================================================
98
- function executeCalculations() {
99
- const debug = false
100
- if(debug) console.group("[Calculations] eval all $calc");
101
- let calculations = getAllCalculationsFields() // Get fresh values
102
- let t0 = performance.now();
103
- calculations.forEach( calculation => {
104
- let t0parcial = performance.now();
105
- let novoResultado = "" + evaluateExpression(calculation)
106
- if(calculation.fp.getValue() != novoResultado ) {
107
- calculation.fp.setValue(novoResultado)
108
- if(debug) console.groupCollapsed("[Calculations] updated field ", calculation.fp.field.fieldDefinition.id, " '", calculation.fp.field.fieldDefinition.name, "' with ",novoResultado)
109
- if(debug) console.debug("[Calculations]", calculation.op)
110
- if(debug) console.debug("[Calculations]", calculation.args.map(arg => isNaN(arg) ? arg.field.fieldDefinition : arg))
111
- if(debug) console.debug("[Calculations] subcalc took " + (performance.now() - t0parcial) + " milliseconds.");
112
- if(debug) console.groupEnd()
113
-
114
- }
115
- })
116
- if(debug) console.debug("[Calculations] total calc took " + (performance.now() - t0) + " milliseconds.");
117
- if(debug) console.groupEnd();
118
- return ;
119
-
120
- //=========================================================
121
- function evaluateExpression(calculation) {
122
- // Obter valores para variaveis
123
- let values = calculation.args
124
- .filter(arg => !isNaN(arg) || arg.isVisible())
125
- .map(arg =>
126
- arg.getValue
127
- ? isNaN(arg.getValue() * 1)
128
- ? 0
129
- : parseFloat(arg.getValue())
130
- : arg
131
- );
132
-
133
- // Realizar operação
134
- let resultado = new BigDecimal(0)
135
- if (calculation.op === "multiply" && values.length > 0) {
136
- resultado = new BigDecimal(1);
137
- values.forEach(value => resultado = resultado.multiply(new BigDecimal(value)))
138
-
139
- } else if (calculation.op === "divide" && values.length === 2 && values[1] !== 0 ) {
140
- resultado = new BigDecimal(values[0]);
141
- resultado = resultado.divide(new BigDecimal(values[1]))
142
-
143
- } else if (calculation.op === "sum") {
144
- values.forEach(value => resultado = resultado.add(new BigDecimal(value)))
145
-
146
- } else if (calculation.op === "subtract" && values.length === 2) {
147
- resultado = new BigDecimal(values[0]);
148
- resultado = resultado.subtract(new BigDecimal(values[1]))
149
- }
150
- return resultado
151
- }
152
- }
153
- }
154
-
155
- // From https://stackoverflow.com/questions/16742578/bigdecimal-in-javascript
156
- class BigDecimal {
157
- // Configuration: constants
158
- static DECIMALS = 8; // number of decimals on all instances
159
- static ROUNDED = true; // numbers are truncated (false) or rounded (true)
160
- static SHIFT = BigInt("1" + "0".repeat(BigDecimal.DECIMALS)); // derived constant
161
- constructor(value) {
162
- if (value instanceof BigDecimal) return value;
163
- let [ints, decis] = String(value).split(".").concat("");
164
- this._n = BigInt(ints + decis.padEnd(BigDecimal.DECIMALS, "0")
165
- .slice(0, BigDecimal.DECIMALS))
166
- + BigInt(BigDecimal.ROUNDED && decis[BigDecimal.DECIMALS] >= "5");
167
- }
168
- static fromBigInt(bigint) {
169
- return Object.assign(Object.create(BigDecimal.prototype), { _n: bigint });
170
- }
171
- add(num) {
172
- return BigDecimal.fromBigInt(this._n + new BigDecimal(num)._n);
173
- }
174
- subtract(num) {
175
- return BigDecimal.fromBigInt(this._n - new BigDecimal(num)._n);
176
- }
177
- static _divRound(dividend, divisor) {
178
- return BigDecimal.fromBigInt(dividend / divisor
179
- + (BigDecimal.ROUNDED ? dividend * 2n / divisor % 2n : 0n));
180
- }
181
- multiply(num) {
182
- return BigDecimal._divRound(this._n * new BigDecimal(num)._n, BigDecimal.SHIFT);
183
- }
184
- divide(num) {
185
- return BigDecimal._divRound(this._n * BigDecimal.SHIFT, new BigDecimal(num)._n);
186
- }
187
- toString() {
188
- const s = this._n.toString().padStart(BigDecimal.DECIMALS+1, "0");
189
- const decimals = s.slice(-BigDecimal.DECIMALS).replace(/\.?0+$/, "")
190
- return s.slice(0, -BigDecimal.DECIMALS) + (decimals ? ".":"") + decimals;
191
- }
192
- }
193
- });
@@ -1 +0,0 @@
1
- import("./cob/_calc.js");