cob-cli 2.25.0 → 2.27.1

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 (221) hide show
  1. package/bin/cob-cli.js +6 -7
  2. package/bin/handleAutoComplete.js +3 -4
  3. package/lib/commands/customize.js +216 -63
  4. package/package.json +3 -2
  5. package/.gitmodules +0 -27
  6. package/.vscode/launch.json +0 -106
  7. package/README.Development.md +0 -294
  8. package/README.publish.md +0 -10
  9. package/customizations/backend.email.js +0 -10
  10. package/customizations/backend.js +0 -14
  11. package/customizations/backend.updateField.js +0 -11
  12. package/customizations/backend.vuepress.js +0 -35
  13. package/customizations/dashboard.dash.js +0 -14
  14. package/customizations/dashboard.js +0 -14
  15. package/customizations/dashboard.simple.js +0 -12
  16. package/customizations/dashboard.vue.empty.js +0 -12
  17. package/customizations/dashboard.vue.grid.js +0 -10
  18. package/customizations/dashboard.vue.js +0 -14
  19. package/customizations/dashboard.vue.menuAndGrid.js +0 -10
  20. package/customizations/frontend.common.js +0 -16
  21. package/customizations/frontend.easy.js +0 -16
  22. package/customizations/frontend.formatList.currency.js +0 -17
  23. package/customizations/frontend.formatList.js +0 -13
  24. package/customizations/frontend.js +0 -14
  25. package/customizations/importer.js +0 -10
  26. package/customizations/keywords.audit.js +0 -18
  27. package/customizations/keywords.calc.js +0 -18
  28. package/customizations/keywords.image.js +0 -16
  29. package/customizations/keywords.js +0 -17
  30. package/customizations/keywords.kibana.js +0 -16
  31. package/customizations/keywords.log.js +0 -18
  32. package/customizations/keywords.styleResults.js +0 -18
  33. package/lib/task_lists/customize_copy.js +0 -51
  34. package/lib/task_lists/customize_mergeFiles.js +0 -42
  35. package/lib/task_lists/customize_questions.js +0 -40
  36. package/templates/backend/vuepress/integrationm/actions/getVuePressDoc.groovy +0 -74
  37. package/templates/backend/vuepress/integrationm/actions/getVuePressSidebarConfig.groovy +0 -42
  38. package/templates/backend/vuepress/integrationm/actions/getVuePressSidebarRootElements.groovy +0 -17
  39. package/templates/backend/vuepress/others/vuepress/definition_contents_v234.json +0 -619
  40. package/templates/backend/vuepress/others/vuepress/nginx/README.md +0 -28
  41. package/templates/backend/vuepress/others/vuepress/package-lock.json +0 -29656
  42. package/templates/backend/vuepress/others/vuepress/package.json +0 -24
  43. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/DescriptVideo.vue +0 -22
  44. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/Graph.vue +0 -124
  45. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/ReadingTime.vue +0 -26
  46. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/References.vue +0 -228
  47. package/templates/backend/vuepress/others/vuepress/src/.vuepress/components/RestrictedContent.vue +0 -77
  48. package/templates/backend/vuepress/others/vuepress/src/.vuepress/config.js +0 -101
  49. package/templates/backend/vuepress/others/vuepress/src/.vuepress/config.json +0 -31
  50. package/templates/backend/vuepress/others/vuepress/src/.vuepress/enhanceApp.js +0 -14
  51. package/templates/backend/vuepress/others/vuepress/src/.vuepress/nav/getNavTranslated.js +0 -52
  52. package/templates/backend/vuepress/others/vuepress/src/.vuepress/plugins/References.js +0 -96
  53. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/Logo-Cult-of-Bits-400x400-1.png +0 -0
  54. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/favicon-cob.png +0 -0
  55. package/templates/backend/vuepress/others/vuepress/src/.vuepress/public/logo.png +0 -0
  56. package/templates/backend/vuepress/others/vuepress/src/.vuepress/styles/index.styl +0 -39
  57. package/templates/backend/vuepress/others/vuepress/src/.vuepress/styles/palette.styl +0 -17
  58. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/LICENSE +0 -21
  59. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/README.md +0 -11
  60. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/AlgoliaSearchBox.vue +0 -172
  61. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/DropdownLink.vue +0 -252
  62. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/DropdownTransition.vue +0 -33
  63. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Home.vue +0 -134
  64. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/NavLink.vue +0 -98
  65. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/NavLinks.vue +0 -165
  66. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Navbar.vue +0 -140
  67. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Page.vue +0 -31
  68. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/PageEdit.vue +0 -119
  69. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/PageNav.vue +0 -163
  70. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/Sidebar.vue +0 -64
  71. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarButton.vue +0 -40
  72. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarGroup.vue +0 -144
  73. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarLink.vue +0 -140
  74. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/components/SidebarLinks.vue +0 -114
  75. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/Badge.vue +0 -44
  76. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/CodeBlock.vue +0 -41
  77. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/global-components/CodeGroup.vue +0 -120
  78. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/index.js +0 -59
  79. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/layouts/404.vue +0 -30
  80. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/layouts/Layout.vue +0 -151
  81. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/noopModule.js +0 -1
  82. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/package.json +0 -44
  83. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/arrow.styl +0 -22
  84. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/code.styl +0 -137
  85. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/config.styl +0 -1
  86. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/custom-blocks.styl +0 -44
  87. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/index.styl +0 -202
  88. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/mobile.styl +0 -37
  89. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/toc.styl +0 -3
  90. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/styles/wrapper.styl +0 -10
  91. package/templates/backend/vuepress/others/vuepress/src/.vuepress/theme/util/index.js +0 -244
  92. package/templates/dashboards/cob-dashboard-html/demoDashboard.html +0 -18
  93. package/templates/dashboards/cob-dashboard-vue/package-lock.json +0 -25020
  94. package/templates/dashboards/cob-dashboard-vue/package.json +0 -21
  95. package/templates/dashboards/cob-dashboard-vue/src/App.vue +0 -26
  96. package/templates/dashboards/cob-dashboard-vue/src/dashboard.html +0 -31
  97. package/templates/dashboards/cob-dashboard-vue/src/main.js +0 -12
  98. package/templates/dashboards/cob-dashboard-vue/src/plugins/cobUiVueComponents.js +0 -6
  99. package/templates/dashboards/cob-dashboard-vue/src/plugins/vuetify.js +0 -9
  100. package/templates/dashboards/cob-dashboard-vue/vue.config.js +0 -104
  101. package/templates/dashboards/dash/dist/css/app.7b16c01a.css +0 -11
  102. package/templates/dashboards/dash/dist/dashboard.html +0 -25
  103. package/templates/dashboards/dash/dist/fonts/fa-brands-400.a78ffbbe.ttf +0 -0
  104. package/templates/dashboards/dash/dist/fonts/fa-brands-400.cd2b4095.woff2 +0 -0
  105. package/templates/dashboards/dash/dist/fonts/fa-regular-400.b1a1bebb.ttf +0 -0
  106. package/templates/dashboards/dash/dist/fonts/fa-regular-400.e8a1ba41.woff2 +0 -0
  107. package/templates/dashboards/dash/dist/fonts/fa-solid-900.55b416a8.woff2 +0 -0
  108. package/templates/dashboards/dash/dist/fonts/fa-solid-900.73820155.ttf +0 -0
  109. package/templates/dashboards/dash/dist/fonts/fa-v4compatibility.0d6f5f18.ttf +0 -0
  110. package/templates/dashboards/dash/dist/fonts/fa-v4compatibility.786e6b33.woff2 +0 -0
  111. package/templates/dashboards/dash/dist/js/app.13b950c8.js +0 -199
  112. package/templates/dashboards/dash/dist/js/app.13b950c8.js.map +0 -1
  113. package/templates/dashboards/dash/package-lock.json +0 -22646
  114. package/templates/dashboards/dash/package.json +0 -27
  115. package/templates/dashboards/dash/src/App.vue +0 -124
  116. package/templates/dashboards/dash/src/assets/css/all.min.css +0 -6
  117. package/templates/dashboards/dash/src/assets/webfonts/fa-brands-400.ttf +0 -0
  118. package/templates/dashboards/dash/src/assets/webfonts/fa-brands-400.woff2 +0 -0
  119. package/templates/dashboards/dash/src/assets/webfonts/fa-regular-400.ttf +0 -0
  120. package/templates/dashboards/dash/src/assets/webfonts/fa-regular-400.woff2 +0 -0
  121. package/templates/dashboards/dash/src/assets/webfonts/fa-solid-900.ttf +0 -0
  122. package/templates/dashboards/dash/src/assets/webfonts/fa-solid-900.woff2 +0 -0
  123. package/templates/dashboards/dash/src/assets/webfonts/fa-v4compatibility.ttf +0 -0
  124. package/templates/dashboards/dash/src/assets/webfonts/fa-v4compatibility.woff2 +0 -0
  125. package/templates/dashboards/dash/src/collector.js +0 -222
  126. package/templates/dashboards/dash/src/components/Attention.vue +0 -30
  127. package/templates/dashboards/dash/src/components/Board.vue +0 -35
  128. package/templates/dashboards/dash/src/components/Calendar.vue +0 -422
  129. package/templates/dashboards/dash/src/components/Dashboard.vue +0 -27
  130. package/templates/dashboards/dash/src/components/Filter.vue +0 -68
  131. package/templates/dashboards/dash/src/components/Kibana.vue +0 -138
  132. package/templates/dashboards/dash/src/components/Label.vue +0 -15
  133. package/templates/dashboards/dash/src/components/Menu.vue +0 -44
  134. package/templates/dashboards/dash/src/components/Totals.vue +0 -49
  135. package/templates/dashboards/dash/src/components/TotalsValue.vue +0 -59
  136. package/templates/dashboards/dash/src/components/shared/Instance.vue +0 -64
  137. package/templates/dashboards/dash/src/components/shared/Waiting.vue +0 -25
  138. package/templates/dashboards/dash/src/dashboard.html +0 -39
  139. package/templates/dashboards/dash/src/definition_dashboard_v0.json +0 -924
  140. package/templates/dashboards/dash/src/definition_dashboard_v1.json +0 -1
  141. package/templates/dashboards/dash/src/input.css +0 -9
  142. package/templates/dashboards/dash/src/main.js +0 -11
  143. package/templates/dashboards/dash/src/model/ComponentStatePersistence.js +0 -66
  144. package/templates/dashboards/dash/src/output.css +0 -314245
  145. package/templates/dashboards/dash/src/test_collector.js +0 -3719
  146. package/templates/dashboards/dash/src/utils/EsInstanceUtils.js +0 -8
  147. package/templates/dashboards/dash/tailwind.config.js +0 -12
  148. package/templates/dashboards/dash/vue.config.js +0 -104
  149. package/templates/frontend/common/templates/frontend/common/css/_dualColumn.css +0 -46
  150. package/templates/frontend/common/templates/frontend/common/css/_global.css +0 -19
  151. package/templates/frontend/common/templates/frontend/common/css/_hidden.css +0 -13
  152. package/templates/frontend/common/templates/frontend/common/css/_history.css +0 -13
  153. package/templates/frontend/common/templates/frontend/common/css/_mobile.css +0 -125
  154. package/templates/frontend/common/templates/frontend/common/css/customizations.__MERGE__.css +0 -5
  155. package/templates/frontend/common/templates/frontend/common/js/cob/_disable_save_onSubdetail.js +0 -11
  156. package/templates/frontend/common/templates/frontend/common/js/cob/_group_references.js +0 -22
  157. package/templates/frontend/common/templates/frontend/common/js/cob/_show_hidden.js +0 -35
  158. package/templates/frontend/common/templates/frontend/common/js/customizations2.__MERGE__.js +0 -3
  159. package/templates/frontend/common/templates/frontend/common/package.json +0 -3
  160. package/templates/frontend/easy/css/_easy/googlefonts.css +0 -360
  161. package/templates/frontend/easy/css/_easy/vuetify.cob-scoped.css +0 -10488
  162. package/templates/frontend/easy/js/_easy/lib/axios.min.js +0 -9
  163. package/templates/frontend/easy/js/_easy/lib/marked.min.js +0 -6
  164. package/templates/frontend/easy/js/_easy/lib/vue.js +0 -11912
  165. package/templates/frontend/easy/js/_easy/lib/vue.min.js +0 -6
  166. package/templates/frontend/easy/js/_easy/lib/vuetify.min.js +0 -6
  167. package/templates/frontend/easy/js/customizations2.__MERGE__.js +0 -22
  168. package/templates/frontend/easy/webapp/.browserslistrc +0 -2
  169. package/templates/frontend/easy/webapp/.eslintrc.js +0 -17
  170. package/templates/frontend/easy/webapp/README.md +0 -60
  171. package/templates/frontend/easy/webapp/babel.config.js +0 -5
  172. package/templates/frontend/easy/webapp/dist/css/app.a4fb91f8.css +0 -1
  173. package/templates/frontend/easy/webapp/dist/dashboard.html +0 -13
  174. package/templates/frontend/easy/webapp/dist/js/app.63a57dcd.js +0 -2
  175. package/templates/frontend/easy/webapp/dist/js/app.63a57dcd.js.map +0 -1
  176. package/templates/frontend/easy/webapp/package-lock.json +0 -32986
  177. package/templates/frontend/easy/webapp/package.json +0 -32
  178. package/templates/frontend/easy/webapp/postcss.config.js +0 -5
  179. package/templates/frontend/easy/webapp/public/dashboard.html +0 -13
  180. package/templates/frontend/easy/webapp/src/App.vue +0 -181
  181. package/templates/frontend/easy/webapp/src/assets/logo.png +0 -0
  182. package/templates/frontend/easy/webapp/src/components/HelloWorld.vue +0 -59
  183. package/templates/frontend/easy/webapp/src/components/PermBuilder.vue +0 -163
  184. package/templates/frontend/easy/webapp/src/components/PlanExecutor.vue +0 -225
  185. package/templates/frontend/easy/webapp/src/components/ProductPermBuilder.vue +0 -95
  186. package/templates/frontend/easy/webapp/src/components/RmDefinitionChooser.vue +0 -59
  187. package/templates/frontend/easy/webapp/src/components/RmDomainChooser.vue +0 -60
  188. package/templates/frontend/easy/webapp/src/components/RoleBuilder.vue +0 -73
  189. package/templates/frontend/easy/webapp/src/main.js +0 -19
  190. package/templates/frontend/easy/webapp/src/perm-templates.js +0 -189
  191. package/templates/frontend/easy/webapp/src/perms.js +0 -197
  192. package/templates/frontend/easy/webapp/vue.config.js +0 -66
  193. package/templates/frontend/formatList/currency/css/_format_currency.css +0 -11
  194. package/templates/frontend/formatList/currency/css/customizations.__MERGE__.css +0 -1
  195. package/templates/frontend/formatList/currency/js/cob/_format_currency.js +0 -11
  196. package/templates/frontend/formatList/currency/js/customizations2.__MERGE__.js +0 -1
  197. package/templates/frontend/formatList/currency/package.json +0 -3
  198. package/templates/gitignore +0 -14
  199. package/templates/keywords/audit/backend/scripts/_audit.groovy +0 -78
  200. package/templates/keywords/audit/frontend/js/cob/_audit.js +0 -24
  201. package/templates/keywords/audit/frontend/js/customizations2.__MERGE__.js +0 -1
  202. package/templates/keywords/audit/package.json +0 -3
  203. package/templates/keywords/calc/backend/scripts/_calc.groovy +0 -151
  204. package/templates/keywords/calc/frontend/js/cob/_calc.js +0 -193
  205. package/templates/keywords/calc/frontend/js/customizations2.__MERGE__.js +0 -1
  206. package/templates/keywords/calc/package.json +0 -3
  207. package/templates/keywords/image/frontend/js/cob/_image.js +0 -30
  208. package/templates/keywords/image/frontend/js/customizations2.__MERGE__.js +0 -1
  209. package/templates/keywords/image/package.json +0 -3
  210. package/templates/keywords/kibana/frontend/js/cob/_kibana.js +0 -58
  211. package/templates/keywords/kibana/frontend/js/customizations2.__MERGE__.js +0 -1
  212. package/templates/keywords/kibana/package.json +0 -3
  213. package/templates/keywords/log/backend/scripts/_log.groovy +0 -95
  214. package/templates/keywords/log/frontend/css/_log.css +0 -5
  215. package/templates/keywords/log/frontend/css/customizations.__MERGE__.css +0 -1
  216. package/templates/keywords/log/package.json +0 -3
  217. package/templates/keywords/styleResults/frontend/css/_styleResults.css +0 -86
  218. package/templates/keywords/styleResults/frontend/css/customizations.__MERGE__.css +0 -1
  219. package/templates/keywords/styleResults/frontend/js/cob/_styleResults.js +0 -38
  220. package/templates/keywords/styleResults/frontend/js/customizations2.__MERGE__.js +0 -1
  221. 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
- }