cob-cli 2.23.0 → 2.25.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 (39) hide show
  1. package/.gitmodules +27 -0
  2. package/customizations/dashboard.dash.js +5 -2
  3. package/customizations/frontend.common.js +1 -0
  4. package/customizations/frontend.formatList.currency.js +2 -0
  5. package/customizations/keywords.audit.js +1 -0
  6. package/customizations/keywords.calc.js +1 -0
  7. package/customizations/keywords.image.js +16 -0
  8. package/customizations/keywords.js +2 -0
  9. package/customizations/keywords.kibana.js +16 -0
  10. package/customizations/keywords.log.js +1 -0
  11. package/customizations/keywords.styleResults.js +1 -0
  12. package/lib/commands/customize.js +3 -3
  13. package/package.json +1 -1
  14. package/templates/dashboards/dash/package.json +1 -1
  15. package/templates/frontend/common/{css → templates/frontend/common/css}/_dualColumn.css +0 -0
  16. package/templates/frontend/common/{css → templates/frontend/common/css}/_global.css +0 -0
  17. package/templates/frontend/common/{css → templates/frontend/common/css}/_hidden.css +0 -0
  18. package/templates/frontend/common/{css → templates/frontend/common/css}/_history.css +0 -0
  19. package/templates/frontend/common/{css → templates/frontend/common/css}/_mobile.css +0 -0
  20. package/templates/frontend/common/{css → templates/frontend/common/css}/customizations.__MERGE__.css +0 -0
  21. package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_disable_save_onSubdetail.js +0 -0
  22. package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_group_references.js +0 -0
  23. package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_show_hidden.js +0 -0
  24. package/templates/frontend/common/{js → templates/frontend/common/js}/customizations2.__MERGE__.js +0 -0
  25. package/templates/frontend/common/templates/frontend/common/package.json +3 -0
  26. package/templates/frontend/formatList/currency/package.json +3 -0
  27. package/templates/keywords/audit/backend/scripts/_audit.groovy +48 -53
  28. package/templates/keywords/audit/package.json +3 -0
  29. package/templates/keywords/calc/backend/scripts/_calc.groovy +108 -118
  30. package/templates/keywords/calc/package.json +3 -0
  31. package/templates/keywords/image/frontend/js/cob/_image.js +30 -0
  32. package/templates/keywords/image/frontend/js/customizations2.__MERGE__.js +1 -0
  33. package/templates/keywords/image/package.json +3 -0
  34. package/templates/keywords/kibana/frontend/js/cob/_kibana.js +58 -0
  35. package/templates/keywords/kibana/frontend/js/customizations2.__MERGE__.js +1 -0
  36. package/templates/keywords/kibana/package.json +3 -0
  37. package/templates/keywords/log/backend/scripts/_log.groovy +52 -56
  38. package/templates/keywords/log/package.json +3 -0
  39. package/templates/keywords/styleResults/package.json +3 -0
package/.gitmodules ADDED
@@ -0,0 +1,27 @@
1
+ [submodule "templates/keywords/image"]
2
+ path = templates/keywords/image
3
+ url = https://github.com/cob/customize.keywords.image.git
4
+ [submodule "templates/keywords/styleResults"]
5
+ path = templates/keywords/styleResults
6
+ url = git@github.com:cob/customize.keywords.styleResults.git
7
+ [submodule "templates/keywords/log"]
8
+ path = templates/keywords/log
9
+ url = git@github.com:cob/customize.keywords.log.git
10
+ [submodule "templates/keywords/calc"]
11
+ path = templates/keywords/calc
12
+ url = git@github.com:cob/customize.keywords.calc.git
13
+ [submodule "templates/keywords/audit"]
14
+ path = templates/keywords/audit
15
+ url = git@github.com:cob/customize.keywords.audit.git
16
+ [submodule "templates/frontend/common"]
17
+ path = templates/frontend/common
18
+ url = git@github.com:cob/customize.frontend.common.git
19
+ [submodule "templates/frontend/formatList/currency"]
20
+ path = templates/frontend/formatList/currency
21
+ url = git@github.com:cob/customize.frontend.formatList.currency.git
22
+ [submodule "templates/dashboards/dash"]
23
+ path = templates/dashboards/dash
24
+ url = git@github.com:cob/customize.dashboard.dash.git
25
+ [submodule "templates/keywords/kibana"]
26
+ path = templates/keywords/kibana
27
+ url = git@github.com:cob/customize.keywords.kibana.git
@@ -3,9 +3,12 @@ exports.option = {
3
3
  short: "Dash",
4
4
  questions: [
5
5
  ],
6
- customization: function (answers) {
6
+ customization: async function (answers) {
7
+ console.log("\nApplying Dash keyword customizations ...")
8
+
7
9
  const { copy } = require("../lib/task_lists/customize_copy");
8
10
  const target = "./recordm/customUI/dash/"
9
- return copy("../../templates/dashboards/dash/",target)
11
+ await copy("../../templates/dashboards/dash/",target)
12
+ return require("../templates/dashboards/dash/package.json").version
10
13
  }
11
14
  }
@@ -11,5 +11,6 @@ exports.option = {
11
11
  const target = "./recordm/customUI/"
12
12
  await copy("../../templates/frontend/common/",target)
13
13
  await mergeFiles("Frontend.Common")
14
+ return require("../templates/frontend/common/package.json").version
14
15
  }
15
16
  }
@@ -5,11 +5,13 @@ exports.option = {
5
5
  ],
6
6
  customization: async function (answers) {
7
7
  console.log("\nApplying FormatCurrency frontend customizations ...")
8
+
8
9
  const { copy } = require("../lib/task_lists/customize_copy");
9
10
  const { mergeFiles } = require("../lib/task_lists/customize_mergeFiles");
10
11
 
11
12
  const target = "./recordm/customUI/"
12
13
  await copy("../../templates/frontend/formatList/currency/",target)
13
14
  await mergeFiles("frontend.formatList.currency.js")
15
+ return require("../templates/frontend/formatList/currency/package.json").version
14
16
  }
15
17
  }
@@ -13,5 +13,6 @@ exports.option = {
13
13
  const be_target = "./integrationm/"
14
14
  await copy("../../templates/keywords/audit/backend",be_target)
15
15
  await mergeFiles("Keyword.Audit")
16
+ return require("../templates/keywords/audit/package.json").version
16
17
  }
17
18
  }
@@ -13,5 +13,6 @@ exports.option = {
13
13
  const be_target = "./integrationm/"
14
14
  await copy("../../templates/keywords/calc/backend/",be_target)
15
15
  await mergeFiles("Keyword.Calc")
16
+ return require("../templates/keywords/calc/package.json").version
16
17
  }
17
18
  }
@@ -0,0 +1,16 @@
1
+ exports.option = {
2
+ name: 'Image - Allows for $image[.replace|.add][(width)]',
3
+ short: "Image",
4
+ questions: [
5
+ ],
6
+ customization: async function (answers) {
7
+ console.log("\nApplying Image keyword customizations ...")
8
+
9
+ const { copy } = require("../lib/task_lists/customize_copy");
10
+ const { mergeFiles } = require("../lib/task_lists/customize_mergeFiles");
11
+ const fe_target = "./recordm/customUI/"
12
+ await copy("../../templates/keywords/image/frontend",fe_target)
13
+ await mergeFiles("Keyword.Image")
14
+ return require("../templates/keywords/image/package.json").version
15
+ }
16
+ }
@@ -9,6 +9,8 @@ exports.option = {
9
9
  require("./keywords.calc").option,
10
10
  require("./keywords.audit").option,
11
11
  require("./keywords.styleResults").option,
12
+ require("./keywords.image").option,
13
+ require("./keywords.kibana").option,
12
14
  require("./keywords.log").option
13
15
  ]}
14
16
  ]
@@ -0,0 +1,16 @@
1
+ exports.option = {
2
+ name: 'Kibana - Allows for $kibana[dashboardId [,heigth])',
3
+ short: "Kibana",
4
+ questions: [
5
+ ],
6
+ customization: async function (answers) {
7
+ console.log("\nApplying Kibana keyword customizations ...")
8
+
9
+ const { copy } = require("../lib/task_lists/customize_copy");
10
+ const { mergeFiles } = require("../lib/task_lists/customize_mergeFiles");
11
+ const fe_target = "./recordm/customUI/"
12
+ await copy("../../templates/keywords/kibana/frontend",fe_target)
13
+ await mergeFiles("Keyword.Kibana")
14
+ return require("../templates/keywords/kibana/package.json").version
15
+ }
16
+ }
@@ -13,5 +13,6 @@ exports.option = {
13
13
  const be_target = "./integrationm/"
14
14
  await copy("../../templates/keywords/log/backend",be_target)
15
15
  await mergeFiles("Keyword.Log")
16
+ return require("../templates/keywords/log/package.json").version
16
17
  }
17
18
  }
@@ -13,5 +13,6 @@ exports.option = {
13
13
  const be_target = "./integrationm/"
14
14
  await copy("../../templates/keywords/styleResults/backend",be_target)
15
15
  await mergeFiles("Keyword.StyleResults")
16
+ return require("../templates/keywords/styleResults/package.json").version
16
17
  }
17
18
  }
@@ -62,9 +62,9 @@ function processOption(option) {
62
62
  })
63
63
  } else if(option.customization) {
64
64
  // Final customization options HAVE a 'customization' function, that process the answers, and HAVE one or more questions
65
- return inquirer.prompt(option.questions).then( answers => {
66
- option.customization(answers)
67
- updateCustomizationsVersions(option.short, require('../../package.json').version)
65
+ return inquirer.prompt(option.questions).then( async (answers) => {
66
+ let version = await option.customization(answers) || require('../../package.json').version
67
+ updateCustomizationsVersions(option.short, version)
68
68
  })
69
69
  }
70
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cob-cli",
3
- "version": "2.23.0",
3
+ "version": "2.25.0",
4
4
  "description": "A command line utility to help Cult of Bits partners develop with higher speed and reusing common code and best practices.",
5
5
  "preferGlobal": true,
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cob-dashboard-vue",
3
- "version": "0.1.0",
3
+ "version": "2.3.1",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.0"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.0"
3
+ }
@@ -4,7 +4,6 @@ import org.codehaus.jettison.json.JSONObject
4
4
  import com.google.common.cache.*
5
5
  import java.util.concurrent.TimeUnit
6
6
 
7
- // ========================================================================================================
8
7
  if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
9
8
 
10
9
  @Field static cacheOfAuditFieldsForDefinition = CacheBuilder.newBuilder()
@@ -16,68 +15,64 @@ if (msg.product == "recordm-definition") cacheOfAuditFieldsForDefinition.invalid
16
15
  // ========================================================================================================
17
16
  def auditFields = cacheOfAuditFieldsForDefinition.get(msg.type, { getAuditFields(msg.type) })
18
17
  if (auditFields.size() > 0
19
- && msg.product == "recordm"
20
- && msg.user != "integrationm"
21
- && msg.action =~ "add|update" ) {
18
+ && msg.product == "recordm"
19
+ && msg.user != "integrationm"
20
+ && msg.action =~ "add|update" ) {
22
21
 
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()} ");
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()} ");
26
25
  }
27
26
 
28
27
  // ========================================================================================================
29
28
  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]
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]
36
35
 
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
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
46
45
  }
47
46
 
48
- // ========================================================================================================
49
47
  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);
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);
56
52
 
57
- def fieldsSize = definition.fieldDefinitions.length();
53
+ def fieldsSize = definition.fieldDefinitions.length();
58
54
 
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
- }
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
+ }
69
65
 
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
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
83
78
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.1.12"
3
+ }
@@ -6,7 +6,6 @@ import java.math.RoundingMode;
6
6
  import com.google.common.cache.*
7
7
  import java.util.concurrent.TimeUnit
8
8
 
9
- // ========================================================================================================
10
9
  if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
11
10
 
12
11
  @Field static cacheOfCalcFieldsForDefinition = CacheBuilder.newBuilder()
@@ -18,144 +17,135 @@ if (msg.product == "recordm-definition") cacheOfCalcFieldsForDefinition.invalida
18
17
  // ========================================================================================================
19
18
  def calculationFields = cacheOfCalcFieldsForDefinition.get(msg.type, { getAllCalculationFields(msg.type) })
20
19
  if (calculationFields.size() > 0
21
- && msg.product == "recordm"
22
- && msg.user != "integrationm"
23
- && msg.action =~ "add|update" ){
20
+ && msg.product == "recordm"
21
+ && msg.user != "integrationm"
22
+ && msg.action =~ "add|update" ){
24
23
 
25
- def updates = executeCalculations(calculationFields, msg.instance.fields)
24
+ def updates = executeCalculations(calculationFields, msg.instance.fields)
26
25
  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()} ");
26
+ if(updates) log.info("[\$calc] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
28
27
  }
28
+ // ========================================================================================================
29
29
 
30
- // ==================================================
31
30
  def getCalculationOperation(fieldDescription) {
32
- def matcher = fieldDescription =~/.*[$]calc.([^(]+)/
33
- def op = matcher[0][1]
34
- return op
31
+ def matcher = fieldDescription =~/.*[$]calc.([^(]+)/
32
+ def op = matcher[0][1]
33
+ return op
35
34
  }
36
35
 
37
- // ==================================================
38
36
  def getCalculationArgNames(fieldDescription) {
39
- def matcher = fieldDescription =~/.*[$]calc.[^(]+\(([^(]+)\)/
40
- def argNamesArray = matcher[0][1].tokenize(",")
41
- return argNamesArray;
37
+ def matcher = fieldDescription =~/.*[$]calc.[^(]+\(([^(]+)\)/
38
+ def argNamesArray = matcher[0][1].tokenize(",")
39
+ return argNamesArray;
42
40
  }
43
41
 
44
- // ========================================================================================================
45
42
  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
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
67
64
  }
68
65
 
69
- // ==================================================
70
66
  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()
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()
91
87
  }
92
88
 
93
- // ==================================================
94
89
  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()
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()
101
96
  }
102
97
 
103
- // ==================================================
104
98
  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()
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()
117
111
  }
118
112
 
119
- // ========================================================================================================
120
113
  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
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
161
151
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.11"
3
+ }
@@ -0,0 +1,30 @@
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
+ });
@@ -0,0 +1 @@
1
+ import("./cob/_image.js");
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.0"
3
+ }
@@ -0,0 +1,58 @@
1
+ //----------------- $kibana ------------------------
2
+ cob.custom.customize.push(function (core, utils, ui) {
3
+ core.customizeAllInstances((instance, presenter) =>
4
+ {
5
+ if (instance.isNew() || presenter.isGroupEdit()) return;
6
+
7
+ let iFramesFPs = presenter.findFieldPs((fp) =>
8
+ /[$]kibana\(.+\)/.exec(fp.field.fieldDefinition.description)
9
+ );
10
+ iFramesFPs.forEach((fp) => {
11
+ let matcher = /[$]kibana\(([^,]+),([^,]+)(,([^,]+))??\)/;
12
+ let args = fp.field.fieldDefinition.description.match(matcher);
13
+ let dashboardKibana = args[1];
14
+ let query = args[2];
15
+ let height = args[4] || "300";
16
+
17
+ let varsMatcher = /{{(.+)}}/;
18
+ let vars = query.match(varsMatcher);
19
+
20
+ for (let i = 1; i < vars.length; i++) {
21
+ let varValue =
22
+ instance.findFields(vars[i]) &&
23
+ instance.findFields(vars[i])[0].value;
24
+ query = query.replaceAll(
25
+ "{{" + vars[i] + "}}",
26
+ '"' + varValue + '"'
27
+ );
28
+ }
29
+
30
+ if (
31
+ !$("#" + dashboardKibana).length &&
32
+ !instance.isNew() &&
33
+ !presenter.isGroupEdit()
34
+ ) {
35
+ let $kibana = $(
36
+ '<li id="' +
37
+ dashboardKibana +
38
+ '" style="margin:0;">' +
39
+ "<iframe " +
40
+ 'src="/kibana/app/dashboards#/view/' +
41
+ dashboardKibana +
42
+ "?embed=true" +
43
+ "&hide-filter-bar=true" +
44
+ "&_a=(query:(language:lucene,query:'" +
45
+ encodeURI(query) +
46
+ "'))\" " +
47
+ 'height="' +
48
+ height +
49
+ '" ' +
50
+ 'width="99.6%" style="border: 1px solid lightgray;">' +
51
+ "</iframe>" +
52
+ "</li>"
53
+ );
54
+ fp.content()[0].append($kibana[0]);
55
+ }
56
+ });
57
+ })
58
+ });
@@ -0,0 +1 @@
1
+ import("./cob/_kibana.js");
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.0"
3
+ }
@@ -16,12 +16,12 @@ if (msg.product == "recordm-definition") cacheOfLogFieldsForDefinition.invalidat
16
16
  // ========================================================================================================
17
17
  def logFields = cacheOfLogFieldsForDefinition.get(msg.type, { getLogFields(msg.type) })
18
18
  if( logFields.size() > 0
19
- && msg.product == "recordm"
20
- && msg.user != "integrationm"
21
- && msg.action =~ "add|update"
19
+ && msg.product == "recordm"
20
+ && msg.user != "integrationm"
21
+ && msg.action =~ "add|update"
22
22
  ) {
23
- def updates = getLogUpdates(logFields)
24
- def result = recordm.update(messageMap.type, "recordmInstanceId:" + messageMap.instance.id, updates);
23
+ def updates = getLogUpdates(logFields)
24
+ def result = recordm.update(messageMap.type, "recordmInstanceId:" + messageMap.instance.id, updates);
25
25
  if (updates) log.info("[\$log] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result} ");
26
26
  }
27
27
 
@@ -31,30 +31,30 @@ def getLogUpdates(logFields){
31
31
  def updates = [:]
32
32
  def currentUser = actionPacks.get("userm").getUser(msg.user).data.name;
33
33
 
34
- logFields.each { logField ->
35
- def commentLogs = msg.value(logField.name);
36
- def newComment = msg.value(logField.sourceField);
37
- def fieldMsg = getFieldMessage(logField.stateField);
38
-
39
- if( newComment != null || msg.field(logField.stateField).changed() ){
40
- def newLogEntry = "#### " + (new Date()).format('yyyy-MM-dd HH:mm:ss').toString() + " - " + currentUser;
41
- newLogEntry += " [$fieldMsg] "
42
- newLogEntry +="\n\n";
43
- newLogEntry += newComment != null ? newComment : "";
44
- newLogEntry +="\n\n";
45
-
46
- if(commentLogs!=null) {
47
- newLogEntry += "======================================================================\n";
48
- }
49
- updates << [(logField.name) : "" + newLogEntry + (commentLogs ?: "")];
50
- updates << [(logField.sourceField) : ""];
51
- }
52
- }
34
+ logFields.each { logField ->
35
+ def commentLogs = msg.value(logField.name);
36
+ def newComment = msg.value(logField.sourceField);
37
+ def fieldMsg = getFieldMessage(logField.stateField);
38
+
39
+ if( newComment != null || msg.field(logField.stateField).changed() ){
40
+ def newLogEntry = "#### " + (new Date()).format('yyyy-MM-dd HH:mm:ss').toString() + " - " + currentUser;
41
+ newLogEntry += " [$fieldMsg] "
42
+ newLogEntry +="\n\n";
43
+ newLogEntry += newComment != null ? newComment : "";
44
+ newLogEntry +="\n\n";
45
+
46
+ if(commentLogs!=null) {
47
+ newLogEntry += "======================================================================\n";
48
+ }
49
+ updates << [(logField.name) : "" + newLogEntry + (commentLogs ?: "")];
50
+ updates << [(logField.sourceField) : ""];
51
+ }
52
+ }
53
53
  return updates
54
54
  }
55
55
 
56
56
  def getFieldMessage(field){
57
- String newValue = msg.value(field) ?: "";
57
+ String newValue = msg.value(field) ?: "";
58
58
  if( msg.field(field).changed() ){
59
59
  String oldValue = msg.oldInstance.value(field) ?: "";
60
60
  return "$field: $oldValue -> $newValue";
@@ -63,37 +63,33 @@ def getFieldMessage(field){
63
63
  }
64
64
  }
65
65
 
66
- // ========================================================================================================
67
66
  def getLogFields(definitionName) {
68
- log.info("[\$log] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
69
-
70
- // Obtém detalhes da definição
71
- def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
72
- def resp = actionPacks.rmRest.get( "recordm/definitions/name/${definitionEncoded}".toString(), [:], "");
73
- JSONObject definition = new JSONObject(resp);
74
-
75
- def fieldsSize = definition.fieldDefinitions.length();
76
-
77
- def fields = [:]
78
- (0..fieldsSize-1).each { index ->
79
- def fieldDefinition = definition.fieldDefinitions.getJSONObject(index)
80
- def fieldDescription = fieldDefinition.get("description")
81
- def fieldDefId = fieldDefinition.get("id")
82
- def fieldName = fieldDefinition.get("name");
83
- fields[fieldDefId] = [name:fieldName, description: fieldDescription]
84
- }
67
+ // Obtém detalhes da definição
68
+ def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
69
+ def resp = actionPacks.rmRest.get( "recordm/definitions/name/${definitionEncoded}".toString(), [:], "");
70
+ JSONObject definition = new JSONObject(resp);
71
+
72
+ def fieldsSize = definition.fieldDefinitions.length();
73
+
74
+ def fields = [:]
75
+ (0..fieldsSize-1).each { index ->
76
+ def fieldDefinition = definition.fieldDefinitions.getJSONObject(index)
77
+ def fieldDescription = fieldDefinition.get("description")
78
+ def fieldDefId = fieldDefinition.get("id")
79
+ def fieldName = fieldDefinition.get("name");
80
+ fields[fieldDefId] = [name:fieldName, description: fieldDescription]
81
+ }
85
82
 
86
- // Finalmente obtém a lista de campos que é necessário calcular
87
- def auditFields = [];
88
- fields.each { fieldId,field ->
89
- def matcher = field.description.toString() =~ /[$]log\(([^(]+),\s*([^(]+)\)/
90
- if(matcher) {
91
- def sourceField = matcher[0][1]
92
- def stateField = matcher[0][2]
93
- auditFields << [name: field.name, sourceField : sourceField, stateField : stateField]
94
- }
95
- }
96
- log.info("[\$log] Update 'logFields' for '$definitionName': $auditFields");
97
- log.info("[\$log] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
98
- return auditFields
83
+ // Finalmente obtém a lista de campos que é necessário calcular
84
+ def auditFields = [];
85
+ fields.each { fieldId,field ->
86
+ def matcher = field.description.toString() =~ /[$]log\(([^(]+),\s*([^(]+)\)/
87
+ if(matcher) {
88
+ def sourceField = matcher[0][1]
89
+ def stateField = matcher[0][2]
90
+ auditFields << [name: field.name, sourceField : sourceField, stateField : stateField]
91
+ }
92
+ }
93
+ log.info("[\$log] Update 'logFields' for '$definitionName': $auditFields");
94
+ return auditFields
99
95
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.0"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "1.0.0"
3
+ }