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.
- package/.gitmodules +27 -0
- package/customizations/dashboard.dash.js +5 -2
- package/customizations/frontend.common.js +1 -0
- package/customizations/frontend.formatList.currency.js +2 -0
- package/customizations/keywords.audit.js +1 -0
- package/customizations/keywords.calc.js +1 -0
- package/customizations/keywords.image.js +16 -0
- package/customizations/keywords.js +2 -0
- package/customizations/keywords.kibana.js +16 -0
- package/customizations/keywords.log.js +1 -0
- package/customizations/keywords.styleResults.js +1 -0
- package/lib/commands/customize.js +3 -3
- package/package.json +1 -1
- package/templates/dashboards/dash/package.json +1 -1
- package/templates/frontend/common/{css → templates/frontend/common/css}/_dualColumn.css +0 -0
- package/templates/frontend/common/{css → templates/frontend/common/css}/_global.css +0 -0
- package/templates/frontend/common/{css → templates/frontend/common/css}/_hidden.css +0 -0
- package/templates/frontend/common/{css → templates/frontend/common/css}/_history.css +0 -0
- package/templates/frontend/common/{css → templates/frontend/common/css}/_mobile.css +0 -0
- package/templates/frontend/common/{css → templates/frontend/common/css}/customizations.__MERGE__.css +0 -0
- package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_disable_save_onSubdetail.js +0 -0
- package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_group_references.js +0 -0
- package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_show_hidden.js +0 -0
- package/templates/frontend/common/{js → templates/frontend/common/js}/customizations2.__MERGE__.js +0 -0
- package/templates/frontend/common/templates/frontend/common/package.json +3 -0
- package/templates/frontend/formatList/currency/package.json +3 -0
- package/templates/keywords/audit/backend/scripts/_audit.groovy +48 -53
- package/templates/keywords/audit/package.json +3 -0
- package/templates/keywords/calc/backend/scripts/_calc.groovy +108 -118
- package/templates/keywords/calc/package.json +3 -0
- package/templates/keywords/image/frontend/js/cob/_image.js +30 -0
- package/templates/keywords/image/frontend/js/customizations2.__MERGE__.js +1 -0
- package/templates/keywords/image/package.json +3 -0
- package/templates/keywords/kibana/frontend/js/cob/_kibana.js +58 -0
- package/templates/keywords/kibana/frontend/js/customizations2.__MERGE__.js +1 -0
- package/templates/keywords/kibana/package.json +3 -0
- package/templates/keywords/log/backend/scripts/_log.groovy +52 -56
- package/templates/keywords/log/package.json +3 -0
- 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
|
-
|
|
11
|
+
await copy("../../templates/dashboards/dash/",target)
|
|
12
|
+
return require("../templates/dashboards/dash/package.json").version
|
|
10
13
|
}
|
|
11
14
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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,
|
|
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
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/templates/frontend/common/{css → templates/frontend/common/css}/customizations.__MERGE__.css
RENAMED
|
File without changes
|
|
File without changes
|
package/templates/frontend/common/{js → templates/frontend/common/js}/cob/_group_references.js
RENAMED
|
File without changes
|
|
File without changes
|
package/templates/frontend/common/{js → templates/frontend/common/js}/customizations2.__MERGE__.js
RENAMED
|
File without changes
|
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
&& msg.product == "recordm"
|
|
19
|
+
&& msg.user != "integrationm"
|
|
20
|
+
&& msg.action =~ "add|update" ) {
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
53
|
+
def fieldsSize = definition.fieldDefinitions.length();
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
&& msg.product == "recordm"
|
|
21
|
+
&& msg.user != "integrationm"
|
|
22
|
+
&& msg.action =~ "add|update" ){
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
def updates = executeCalculations(calculationFields, msg.instance.fields)
|
|
26
25
|
def result = actionPacks.recordm.update(messageMap.type, "recordmInstanceId:" + messageMap.instance.id, updates);
|
|
27
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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,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,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");
|
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
&& msg.product == "recordm"
|
|
20
|
+
&& msg.user != "integrationm"
|
|
21
|
+
&& msg.action =~ "add|update"
|
|
22
22
|
) {
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
}
|