cob-cli 2.25.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 (215) hide show
  1. package/bin/cob-cli.js +3 -1
  2. package/bin/handleAutoComplete.js +1 -4
  3. package/lib/commands/customize.js +213 -66
  4. package/package.json +3 -2
  5. package/.vscode/launch.json +0 -106
  6. package/customizations/backend.email.js +0 -10
  7. package/customizations/backend.js +0 -14
  8. package/customizations/backend.updateField.js +0 -11
  9. package/customizations/backend.vuepress.js +0 -35
  10. package/customizations/dashboard.dash.js +0 -14
  11. package/customizations/dashboard.js +0 -14
  12. package/customizations/dashboard.simple.js +0 -12
  13. package/customizations/dashboard.vue.empty.js +0 -12
  14. package/customizations/dashboard.vue.grid.js +0 -10
  15. package/customizations/dashboard.vue.js +0 -14
  16. package/customizations/dashboard.vue.menuAndGrid.js +0 -10
  17. package/customizations/frontend.common.js +0 -16
  18. package/customizations/frontend.easy.js +0 -16
  19. package/customizations/frontend.formatList.currency.js +0 -17
  20. package/customizations/frontend.formatList.js +0 -13
  21. package/customizations/frontend.js +0 -14
  22. package/customizations/importer.js +0 -10
  23. package/customizations/keywords.audit.js +0 -18
  24. package/customizations/keywords.calc.js +0 -18
  25. package/customizations/keywords.image.js +0 -16
  26. package/customizations/keywords.js +0 -17
  27. package/customizations/keywords.kibana.js +0 -16
  28. package/customizations/keywords.log.js +0 -18
  29. package/customizations/keywords.styleResults.js +0 -18
  30. package/templates/backend/vuepress/integrationm/actions/getVuePressDoc.groovy +0 -74
  31. package/templates/backend/vuepress/integrationm/actions/getVuePressSidebarConfig.groovy +0 -42
  32. package/templates/backend/vuepress/integrationm/actions/getVuePressSidebarRootElements.groovy +0 -17
  33. package/templates/backend/vuepress/others/vuepress/definition_contents_v234.json +0 -619
  34. package/templates/backend/vuepress/others/vuepress/nginx/README.md +0 -28
  35. package/templates/backend/vuepress/others/vuepress/package-lock.json +0 -29656
  36. package/templates/backend/vuepress/others/vuepress/package.json +0 -24
  37. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/DescriptVideo.vue +0 -22
  38. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/Graph.vue +0 -124
  39. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/ReadingTime.vue +0 -26
  40. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/References.vue +0 -228
  41. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/RestrictedContent.vue +0 -77
  42. package/templates/backend/vuepress/others/vuepress/src/.vuepress/config.js +0 -101
  43. package/templates/backend/vuepress/others/vuepress/src/.vuepress/config.json +0 -31
  44. package/templates/backend/vuepress/others/vuepress/src/.vuepress/enhanceApp.js +0 -14
  45. package/templates/backend/vuepress/others/vuepress/src/.vuepress/nav/getNavTranslated.js +0 -52
  46. package/templates/backend/vuepress/others/vuepress/src/.vuepress/plugins/References.js +0 -96
  47. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/Logo-Cult-of-Bits-400x400-1.png +0 -0
  48. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/favicon-cob.png +0 -0
  49. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/logo.png +0 -0
  50. package/templates/backend/vuepress/others/vuepress/src/.vuepress/styles/index.styl +0 -39
  51. package/templates/backend/vuepress/others/vuepress/src/.vuepress/styles/palette.styl +0 -17
  52. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/LICENSE +0 -21
  53. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/README.md +0 -11
  54. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/AlgoliaSearchBox.vue +0 -172
  55. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/DropdownLink.vue +0 -252
  56. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/DropdownTransition.vue +0 -33
  57. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Home.vue +0 -134
  58. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/NavLink.vue +0 -98
  59. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/NavLinks.vue +0 -165
  60. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Navbar.vue +0 -140
  61. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Page.vue +0 -31
  62. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/PageEdit.vue +0 -119
  63. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/PageNav.vue +0 -163
  64. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Sidebar.vue +0 -64
  65. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarButton.vue +0 -40
  66. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarGroup.vue +0 -144
  67. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarLink.vue +0 -140
  68. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarLinks.vue +0 -114
  69. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/Badge.vue +0 -44
  70. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/CodeBlock.vue +0 -41
  71. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/CodeGroup.vue +0 -120
  72. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/index.js +0 -59
  73. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/layouts/404.vue +0 -30
  74. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/layouts/Layout.vue +0 -151
  75. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/noopModule.js +0 -1
  76. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/package.json +0 -44
  77. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/arrow.styl +0 -22
  78. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/code.styl +0 -137
  79. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/config.styl +0 -1
  80. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/custom-blocks.styl +0 -44
  81. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/index.styl +0 -202
  82. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/mobile.styl +0 -37
  83. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/toc.styl +0 -3
  84. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/wrapper.styl +0 -10
  85. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/util/index.js +0 -244
  86. package/templates/dashboards/cob-dashboard-html/demoDashboard.html +0 -18
  87. package/templates/dashboards/cob-dashboard-vue/package-lock.json +0 -25020
  88. package/templates/dashboards/cob-dashboard-vue/package.json +0 -21
  89. package/templates/dashboards/cob-dashboard-vue/src/App.vue +0 -26
  90. package/templates/dashboards/cob-dashboard-vue/src/dashboard.html +0 -31
  91. package/templates/dashboards/cob-dashboard-vue/src/main.js +0 -12
  92. package/templates/dashboards/cob-dashboard-vue/src/plugins/cobUiVueComponents.js +0 -6
  93. package/templates/dashboards/cob-dashboard-vue/src/plugins/vuetify.js +0 -9
  94. package/templates/dashboards/cob-dashboard-vue/vue.config.js +0 -104
  95. package/templates/dashboards/dash/dist/css/app.7b16c01a.css +0 -11
  96. package/templates/dashboards/dash/dist/dashboard.html +0 -25
  97. package/templates/dashboards/dash/dist/fonts/fa-brands-400.a78ffbbe.ttf +0 -0
  98. package/templates/dashboards/dash/dist/fonts/fa-brands-400.cd2b4095.woff2 +0 -0
  99. package/templates/dashboards/dash/dist/fonts/fa-regular-400.b1a1bebb.ttf +0 -0
  100. package/templates/dashboards/dash/dist/fonts/fa-regular-400.e8a1ba41.woff2 +0 -0
  101. package/templates/dashboards/dash/dist/fonts/fa-solid-900.55b416a8.woff2 +0 -0
  102. package/templates/dashboards/dash/dist/fonts/fa-solid-900.73820155.ttf +0 -0
  103. package/templates/dashboards/dash/dist/fonts/fa-v4compatibility.0d6f5f18.ttf +0 -0
  104. package/templates/dashboards/dash/dist/fonts/fa-v4compatibility.786e6b33.woff2 +0 -0
  105. package/templates/dashboards/dash/dist/js/app.13b950c8.js +0 -199
  106. package/templates/dashboards/dash/dist/js/app.13b950c8.js.map +0 -1
  107. package/templates/dashboards/dash/package-lock.json +0 -22646
  108. package/templates/dashboards/dash/package.json +0 -27
  109. package/templates/dashboards/dash/src/App.vue +0 -124
  110. package/templates/dashboards/dash/src/assets/css/all.min.css +0 -6
  111. package/templates/dashboards/dash/src/assets/webfonts/fa-brands-400.ttf +0 -0
  112. package/templates/dashboards/dash/src/assets/webfonts/fa-brands-400.woff2 +0 -0
  113. package/templates/dashboards/dash/src/assets/webfonts/fa-regular-400.ttf +0 -0
  114. package/templates/dashboards/dash/src/assets/webfonts/fa-regular-400.woff2 +0 -0
  115. package/templates/dashboards/dash/src/assets/webfonts/fa-solid-900.ttf +0 -0
  116. package/templates/dashboards/dash/src/assets/webfonts/fa-solid-900.woff2 +0 -0
  117. package/templates/dashboards/dash/src/assets/webfonts/fa-v4compatibility.ttf +0 -0
  118. package/templates/dashboards/dash/src/assets/webfonts/fa-v4compatibility.woff2 +0 -0
  119. package/templates/dashboards/dash/src/collector.js +0 -222
  120. package/templates/dashboards/dash/src/components/Attention.vue +0 -30
  121. package/templates/dashboards/dash/src/components/Board.vue +0 -35
  122. package/templates/dashboards/dash/src/components/Calendar.vue +0 -422
  123. package/templates/dashboards/dash/src/components/Dashboard.vue +0 -27
  124. package/templates/dashboards/dash/src/components/Filter.vue +0 -68
  125. package/templates/dashboards/dash/src/components/Kibana.vue +0 -138
  126. package/templates/dashboards/dash/src/components/Label.vue +0 -15
  127. package/templates/dashboards/dash/src/components/Menu.vue +0 -44
  128. package/templates/dashboards/dash/src/components/Totals.vue +0 -49
  129. package/templates/dashboards/dash/src/components/TotalsValue.vue +0 -59
  130. package/templates/dashboards/dash/src/components/shared/Instance.vue +0 -64
  131. package/templates/dashboards/dash/src/components/shared/Waiting.vue +0 -25
  132. package/templates/dashboards/dash/src/dashboard.html +0 -39
  133. package/templates/dashboards/dash/src/definition_dashboard_v0.json +0 -924
  134. package/templates/dashboards/dash/src/definition_dashboard_v1.json +0 -1
  135. package/templates/dashboards/dash/src/input.css +0 -9
  136. package/templates/dashboards/dash/src/main.js +0 -11
  137. package/templates/dashboards/dash/src/model/ComponentStatePersistence.js +0 -66
  138. package/templates/dashboards/dash/src/output.css +0 -314245
  139. package/templates/dashboards/dash/src/test_collector.js +0 -3719
  140. package/templates/dashboards/dash/src/utils/EsInstanceUtils.js +0 -8
  141. package/templates/dashboards/dash/tailwind.config.js +0 -12
  142. package/templates/dashboards/dash/vue.config.js +0 -104
  143. package/templates/frontend/common/templates/frontend/common/css/_dualColumn.css +0 -46
  144. package/templates/frontend/common/templates/frontend/common/css/_global.css +0 -19
  145. package/templates/frontend/common/templates/frontend/common/css/_hidden.css +0 -13
  146. package/templates/frontend/common/templates/frontend/common/css/_history.css +0 -13
  147. package/templates/frontend/common/templates/frontend/common/css/_mobile.css +0 -125
  148. package/templates/frontend/common/templates/frontend/common/css/customizations.__MERGE__.css +0 -5
  149. package/templates/frontend/common/templates/frontend/common/js/cob/_disable_save_onSubdetail.js +0 -11
  150. package/templates/frontend/common/templates/frontend/common/js/cob/_group_references.js +0 -22
  151. package/templates/frontend/common/templates/frontend/common/js/cob/_show_hidden.js +0 -35
  152. package/templates/frontend/common/templates/frontend/common/js/customizations2.__MERGE__.js +0 -3
  153. package/templates/frontend/common/templates/frontend/common/package.json +0 -3
  154. package/templates/frontend/easy/css/_easy/googlefonts.css +0 -360
  155. package/templates/frontend/easy/css/_easy/vuetify.cob-scoped.css +0 -10488
  156. package/templates/frontend/easy/js/_easy/lib/axios.min.js +0 -9
  157. package/templates/frontend/easy/js/_easy/lib/marked.min.js +0 -6
  158. package/templates/frontend/easy/js/_easy/lib/vue.js +0 -11912
  159. package/templates/frontend/easy/js/_easy/lib/vue.min.js +0 -6
  160. package/templates/frontend/easy/js/_easy/lib/vuetify.min.js +0 -6
  161. package/templates/frontend/easy/js/customizations2.__MERGE__.js +0 -22
  162. package/templates/frontend/easy/webapp/.browserslistrc +0 -2
  163. package/templates/frontend/easy/webapp/.eslintrc.js +0 -17
  164. package/templates/frontend/easy/webapp/README.md +0 -60
  165. package/templates/frontend/easy/webapp/babel.config.js +0 -5
  166. package/templates/frontend/easy/webapp/dist/css/app.a4fb91f8.css +0 -1
  167. package/templates/frontend/easy/webapp/dist/dashboard.html +0 -13
  168. package/templates/frontend/easy/webapp/dist/js/app.63a57dcd.js +0 -2
  169. package/templates/frontend/easy/webapp/dist/js/app.63a57dcd.js.map +0 -1
  170. package/templates/frontend/easy/webapp/package-lock.json +0 -32986
  171. package/templates/frontend/easy/webapp/package.json +0 -32
  172. package/templates/frontend/easy/webapp/postcss.config.js +0 -5
  173. package/templates/frontend/easy/webapp/public/dashboard.html +0 -13
  174. package/templates/frontend/easy/webapp/src/App.vue +0 -181
  175. package/templates/frontend/easy/webapp/src/assets/logo.png +0 -0
  176. package/templates/frontend/easy/webapp/src/components/HelloWorld.vue +0 -59
  177. package/templates/frontend/easy/webapp/src/components/PermBuilder.vue +0 -163
  178. package/templates/frontend/easy/webapp/src/components/PlanExecutor.vue +0 -225
  179. package/templates/frontend/easy/webapp/src/components/ProductPermBuilder.vue +0 -95
  180. package/templates/frontend/easy/webapp/src/components/RmDefinitionChooser.vue +0 -59
  181. package/templates/frontend/easy/webapp/src/components/RmDomainChooser.vue +0 -60
  182. package/templates/frontend/easy/webapp/src/components/RoleBuilder.vue +0 -73
  183. package/templates/frontend/easy/webapp/src/main.js +0 -19
  184. package/templates/frontend/easy/webapp/src/perm-templates.js +0 -189
  185. package/templates/frontend/easy/webapp/src/perms.js +0 -197
  186. package/templates/frontend/easy/webapp/vue.config.js +0 -66
  187. package/templates/frontend/formatList/currency/css/_format_currency.css +0 -11
  188. package/templates/frontend/formatList/currency/css/customizations.__MERGE__.css +0 -1
  189. package/templates/frontend/formatList/currency/js/cob/_format_currency.js +0 -11
  190. package/templates/frontend/formatList/currency/js/customizations2.__MERGE__.js +0 -1
  191. package/templates/frontend/formatList/currency/package.json +0 -3
  192. package/templates/gitignore +0 -14
  193. package/templates/keywords/audit/backend/scripts/_audit.groovy +0 -78
  194. package/templates/keywords/audit/frontend/js/cob/_audit.js +0 -24
  195. package/templates/keywords/audit/frontend/js/customizations2.__MERGE__.js +0 -1
  196. package/templates/keywords/audit/package.json +0 -3
  197. package/templates/keywords/calc/backend/scripts/_calc.groovy +0 -151
  198. package/templates/keywords/calc/frontend/js/cob/_calc.js +0 -193
  199. package/templates/keywords/calc/frontend/js/customizations2.__MERGE__.js +0 -1
  200. package/templates/keywords/calc/package.json +0 -3
  201. package/templates/keywords/image/frontend/js/cob/_image.js +0 -30
  202. package/templates/keywords/image/frontend/js/customizations2.__MERGE__.js +0 -1
  203. package/templates/keywords/image/package.json +0 -3
  204. package/templates/keywords/kibana/frontend/js/cob/_kibana.js +0 -58
  205. package/templates/keywords/kibana/frontend/js/customizations2.__MERGE__.js +0 -1
  206. package/templates/keywords/kibana/package.json +0 -3
  207. package/templates/keywords/log/backend/scripts/_log.groovy +0 -95
  208. package/templates/keywords/log/frontend/css/_log.css +0 -5
  209. package/templates/keywords/log/frontend/css/customizations.__MERGE__.css +0 -1
  210. package/templates/keywords/log/package.json +0 -3
  211. package/templates/keywords/styleResults/frontend/css/_styleResults.css +0 -86
  212. package/templates/keywords/styleResults/frontend/css/customizations.__MERGE__.css +0 -1
  213. package/templates/keywords/styleResults/frontend/js/cob/_styleResults.js +0 -38
  214. package/templates/keywords/styleResults/frontend/js/customizations2.__MERGE__.js +0 -1
  215. package/templates/keywords/styleResults/package.json +0 -3
@@ -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,3 +0,0 @@
1
- {
2
- "version": "1.0.0"
3
- }
@@ -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,78 +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
- if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
8
-
9
- @Field static cacheOfAuditFieldsForDefinition = CacheBuilder.newBuilder()
10
- .expireAfterWrite(5, TimeUnit.MINUTES)
11
- .build();
12
-
13
- if (msg.product == "recordm-definition") cacheOfAuditFieldsForDefinition.invalidate(msg.type)
14
-
15
- // ========================================================================================================
16
- def auditFields = cacheOfAuditFieldsForDefinition.get(msg.type, { getAuditFields(msg.type) })
17
- if (auditFields.size() > 0
18
- && msg.product == "recordm"
19
- && msg.user != "integrationm"
20
- && msg.action =~ "add|update" ) {
21
-
22
- def updates = getAuditFieldsUpdates(auditFields,msg.instance.fields)
23
- def result = actionPacks.recordm.update(msg.type, "recordmInstanceId:" + msg.instance.id, updates);
24
- if(updates) log.info("[\$audit] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
25
- }
26
-
27
- // ========================================================================================================
28
- def getAuditFieldsUpdates(auditFields,instanceFields) {
29
- def updates = [:]
30
- auditFields.each { auditField ->
31
- 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)
32
- if( msg.action == 'update' && !msg.diff) return // Only continues if there is at least one change
33
- if( auditField.args == "uri") {
34
- updates << [(auditField.name) : actionPacks.get("userm").getUser(msg.user).data._links.self]
35
-
36
- } else if( auditField.args == "username") {
37
- updates << [(auditField.name) : msg.user]
38
-
39
- } else if( auditField.args == "time") {
40
- if(msg.action == 'add' && Math.abs(msg.value(auditField.name, Long.class)?:0 - msg._timestamp_) < 30000) return // Ignore changes less then 30s
41
- updates << [(auditField.name) : "" + msg._timestamp_]
42
- }
43
- }
44
- return updates
45
- }
46
-
47
- def getAuditFields(definitionName) {
48
- // Obtém detalhes da definição
49
- def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
50
- def resp = actionPacks.rmRest.get( "recordm/definitions/name/${definitionEncoded}".toString(), [:], "integrationm");
51
- JSONObject definition = new JSONObject(resp);
52
-
53
- def fieldsSize = definition.fieldDefinitions.length();
54
-
55
- def fields = [:]
56
- (0..fieldsSize-1).each { index ->
57
- def fieldDefinition = definition.fieldDefinitions.getJSONObject(index)
58
- def fieldDescription = fieldDefinition.getString("description")
59
- if(fieldDescription){
60
- def fieldDefId = fieldDefinition.get("id");
61
- def fieldName = fieldDefinition.get("name");
62
- fields[fieldDefId] = [name:fieldName, description: fieldDescription]
63
- }
64
- }
65
-
66
- // Finalmente obtém a lista de campos que é necessário calcular
67
- def auditFields = [];
68
- fields.each { fieldId,field ->
69
- def matcher = field.description =~ /[$]audit\.(creator|updater)\.(username|uri|time)/
70
- if(matcher) {
71
- def op = matcher[0][1]
72
- def arg = matcher[0][2]
73
- auditFields << [fieldId: fieldId, name:field.name, op : op, args: arg]
74
- }
75
- }
76
- log.info("[\$audit] Update 'auditFields' for '$definitionName': $auditFields");
77
- return auditFields
78
- }
@@ -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,3 +0,0 @@
1
- {
2
- "version": "1.1.12"
3
- }
@@ -1,151 +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
- if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
10
-
11
- @Field static cacheOfCalcFieldsForDefinition = CacheBuilder.newBuilder()
12
- .expireAfterWrite(5, TimeUnit.MINUTES)
13
- .build();
14
-
15
- if (msg.product == "recordm-definition") cacheOfCalcFieldsForDefinition.invalidate(msg.type)
16
-
17
- // ========================================================================================================
18
- def calculationFields = cacheOfCalcFieldsForDefinition.get(msg.type, { getAllCalculationFields(msg.type) })
19
- if (calculationFields.size() > 0
20
- && msg.product == "recordm"
21
- && msg.user != "integrationm"
22
- && msg.action =~ "add|update" ){
23
-
24
- def updates = executeCalculations(calculationFields, msg.instance.fields)
25
- def result = actionPacks.recordm.update(messageMap.type, "recordmInstanceId:" + messageMap.instance.id, updates);
26
- if(updates) log.info("[\$calc] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
27
- }
28
- // ========================================================================================================
29
-
30
- def getCalculationOperation(fieldDescription) {
31
- def matcher = fieldDescription =~/.*[$]calc.([^(]+)/
32
- def op = matcher[0][1]
33
- return op
34
- }
35
-
36
- def getCalculationArgNames(fieldDescription) {
37
- def matcher = fieldDescription =~/.*[$]calc.[^(]+\(([^(]+)\)/
38
- def argNamesArray = matcher[0][1].tokenize(",")
39
- return argNamesArray;
40
- }
41
-
42
- def executeCalculations(calculationFields,instanceFields) {
43
- def updates = [:]
44
- def atLeastOneChangeFlag = false;
45
- def passCount = 0;
46
- def temporaryResults = [:]
47
- while(passCount++ == 0 || atLeastOneChangeFlag && passCount < 10) { //10 is just for security against loops
48
- atLeastOneChangeFlag = false
49
- calculationFields.each { calculation ->
50
- def novoResultado = evaluateExpression(calculation,instanceFields,temporaryResults)
51
- if(temporaryResults[calculation.fieldId] != novoResultado ) {
52
- // log.info("[\$calc] {{passCount:${passCount}, field:${calculation.name} (${calculation.fieldId})" +
53
- // ", calcType:${calculation.op}(${calculation.args})" +
54
- // ", previousResult:${temporaryResults[calculation.fieldId]}" +
55
- // ", calcValue:$novoResultado}}");
56
-
57
- temporaryResults[calculation.fieldId] = novoResultado;
58
- updates << [(calculation.name) : novoResultado]
59
- atLeastOneChangeFlag = true
60
- }
61
- }
62
- }
63
- return updates
64
- }
65
-
66
- def evaluateExpression(calculation,instanceFields,temporaryResults) {
67
- // Realizar operação
68
- def resultado = new BigDecimal(0)
69
- def args = getCalculationArguments(calculation,instanceFields,temporaryResults)
70
-
71
- if(calculation.op == "multiply" && args.size() > 0) {
72
- resultado = 1
73
- args.each { arg -> resultado = resultado.multiply(new BigDecimal(arg?.trim() ?: 0)) }
74
-
75
- } else if (calculation.op == "divide" && args.size() == 2 && (args[1]?:0 != 0)) {
76
- resultado = new BigDecimal(args[0]?.trim() ?:0);
77
- resultado = resultado.divide(new BigDecimal(args[1]?.trim()), 8, RoundingMode.HALF_UP)
78
-
79
- } else if(calculation.op == "sum") {
80
- args.each { arg -> resultado = resultado + new BigDecimal(arg?.trim() ?: 0)}
81
-
82
- } else if (calculation.op == "subtract" && args.size() == 2) {
83
- resultado = new BigDecimal(args[0]?.trim() ?: 0);
84
- resultado = resultado.subtract(new BigDecimal(args[1]?.trim() ?: 0))
85
- }
86
- return resultado.stripTrailingZeros().toPlainString()
87
- }
88
-
89
- def getCalculationArguments(calculation,instanceFields,temporaryResults) {
90
- def values = calculation.args.collect { argName,argFieldIds ->
91
- (""+argName).isNumber()
92
- ? argName * 1
93
- : getAllAplicableValuesForVarName(calculation.fieldId,argName,argFieldIds,instanceFields,temporaryResults)
94
- }
95
- return values.flatten()
96
- }
97
-
98
- def getAllAplicableValuesForVarName(fieldId,varName,varFieldIds,instanceFields,temporaryResults) {
99
- // log.info("[\$calc] find '$varName'($varFieldIds) in $instanceFields (temporaryResults=$temporaryResults) ");
100
- def relevantFields = instanceFields.findAll{ instField -> varFieldIds.indexOf(instField.fieldDefinition.id) >= 0 }
101
-
102
- def result = varFieldIds.collect { varFieldId ->
103
- if(temporaryResults[varFieldId] != null) {
104
- return temporaryResults[varFieldId]
105
- } else {
106
- return temporaryResults[varFieldId] = instanceFields.findAll{ instField -> varFieldId == instField.fieldDefinition.id }?.collect { it.value }
107
- }
108
- }
109
- // log.info("[\$calc] values for '$varName'($varFieldIds) = $result (temporaryResults=$temporaryResults) " );
110
- return result.flatten()
111
- }
112
-
113
- def getAllCalculationFields(definitionName) {
114
- // Obtém detalhes da definição
115
- def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
116
- def resp = actionPacks.rmRest.get( "recordm/definitions/name/${definitionEncoded}".toString(), [:], "integrationm");
117
- JSONObject definition = new JSONObject(resp);
118
-
119
- def fieldsSize = definition.fieldDefinitions.length();
120
-
121
- def fields = [:]
122
- (0..fieldsSize-1).each { index ->
123
- def fieldDefinition = definition.fieldDefinitions.getJSONObject(index)
124
- def fieldDescription = fieldDefinition.get("description")
125
- def fieldDefId = fieldDefinition.get("id")
126
- def fieldName = fieldDefinition.get("name");
127
- fields[fieldDefId] = [name:fieldName, description: fieldDescription]
128
- }
129
-
130
- // Finalmente obtém a lista de campos que é necessário calcular
131
- def calculationFields = [];
132
- def previousId
133
- fields.each { fieldId,field ->
134
- if(field.description.toString() =~ /[$]calc\./) {
135
- def op = getCalculationOperation(field.description)
136
- def args = getCalculationArgNames(field.description)
137
- argsFields = [:]
138
- args.each { arg ->
139
- if(arg == "previous") {
140
- argsFields[arg] = [previousId]
141
- } else {
142
- argsFields[arg] = fields.findAll{fId,f -> f.description?.toString() =~ /.*[$]$arg.*/ }.collect { fId,f -> fId}
143
- }
144
- }
145
- calculationFields << [fieldId: fieldId, name:field.name, op : op, args : argsFields]
146
- }
147
- previousId = fieldId
148
- }
149
- log.info("[\$calc] Update 'calculationFields' for '$definitionName': $calculationFields");
150
- return calculationFields
151
- }
@@ -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");
@@ -1,3 +0,0 @@
1
- {
2
- "version": "1.0.11"
3
- }
@@ -1,30 +0,0 @@
1
- //----------------- $image ------------------------
2
- cob.custom.customize.push(function (core, utils, ui) {
3
- const matcher = /[$]image(.add|.replace)?(\(.+\))?/;
4
-
5
- core.customizeAllInstances((instance, presenter) => {
6
- if (instance.isNew() || presenter.isGroupEdit()) return;
7
-
8
- let imagesFPs = presenter.findFieldPs((fp) => matcher.exec( fp.field.fieldDefinition.description ) );
9
- imagesFPs.forEach((fp) => {
10
- let args = fp.field.fieldDefinition.description.match(matcher);
11
- let replaceFlag = (args && args[1] && args[1] == ".replace") || false;
12
- let width = (args && args[2]) || "";
13
- debugger;
14
- let $image = $(
15
- '<div style="width:100%;text-align:center">' +
16
- "<img " +
17
- (width ? 'style="width:' + width + 'px" ' : "") +
18
- 'src="' +
19
- (fp.field.fieldDefinition.description.match(/[$]file/)
20
- ? $(fp.content()[0]).find(".link-container a")[0].href
21
- : fp.field.htmlEncodedValue) +
22
- '">' +
23
- "</img>" +
24
- "</div>"
25
- );
26
- fp.content()[0].append($image[0]);
27
- fp.content()[0].children[0].style.display = replaceFlag ? "none" : "";
28
- });
29
- });
30
- });
@@ -1 +0,0 @@
1
- import("./cob/_image.js");
@@ -1,3 +0,0 @@
1
- {
2
- "version": "1.0.0"
3
- }