cob-cli 2.6.1 → 2.6.2
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/package.json
CHANGED
|
@@ -5,40 +5,39 @@ import com.google.common.cache.*
|
|
|
5
5
|
import java.util.concurrent.TimeUnit
|
|
6
6
|
|
|
7
7
|
// ========================================================================================================
|
|
8
|
+
if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
|
|
9
|
+
|
|
8
10
|
@Field static cacheOfAuditFieldsForDefinition = CacheBuilder.newBuilder()
|
|
9
11
|
.expireAfterWrite(5, TimeUnit.MINUTES)
|
|
10
12
|
.build();
|
|
11
13
|
|
|
12
14
|
if (msg.product == "recordm-definition") cacheOfAuditFieldsForDefinition.invalidate(msg.type)
|
|
13
|
-
def auditFields = cacheOfAuditFieldsForDefinition.get(msg.type, { getAuditFields(msg.type) })
|
|
14
15
|
|
|
15
16
|
// ========================================================================================================
|
|
16
|
-
|
|
17
|
+
def auditFields = cacheOfAuditFieldsForDefinition.get(msg.type, { getAuditFields(msg.type) })
|
|
17
18
|
if (auditFields.size() > 0
|
|
18
|
-
&& msg.product == "recordm"
|
|
19
19
|
&& msg.user != "integrationm"
|
|
20
20
|
&& msg.action =~ "add|update" ) {
|
|
21
21
|
|
|
22
|
-
def updates =
|
|
22
|
+
def updates = getAuditFieldsUpdates(auditFields,msg.instance.fields)
|
|
23
23
|
def result = actionPacks.recordm.update(msg.type, "recordmInstanceId:" + msg.instance.id, updates);
|
|
24
|
-
|
|
24
|
+
if(updates) log.info("[\$audit] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// ========================================================================================================
|
|
28
|
-
def
|
|
29
|
-
def userm = actionPacks.get("userm");
|
|
28
|
+
def getAuditFieldsUpdates(auditFields,instanceFields) {
|
|
30
29
|
def updates = [:]
|
|
31
30
|
auditFields.each { auditField ->
|
|
32
|
-
if( auditField.op == "creator" && msg.action == "update" && msg.value(auditField.name) != null) return
|
|
33
|
-
if(
|
|
34
|
-
|
|
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 == "usermURI") {
|
|
34
|
+
updates << [(auditField.name) : actionPacks.get("userm").getUser(msg.user).data._links.self]
|
|
35
35
|
|
|
36
36
|
} else if( auditField.args == "username") {
|
|
37
37
|
updates << [(auditField.name) : msg.user]
|
|
38
38
|
|
|
39
39
|
} else if( auditField.args == "time") {
|
|
40
40
|
if(msg.action == 'add' && Math.abs(msg.value(auditField.name, Long.class)?:0 - msg._timestamp_) < 30000) return // Ignore changes less then 30s
|
|
41
|
-
if(msg.action == 'update' && !msg.diff) return // Only continues if there is at least one change
|
|
42
41
|
updates << [(auditField.name) : "" + msg._timestamp_]
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -48,7 +47,7 @@ def updateUser(auditFields,instanceFields) {
|
|
|
48
47
|
// ========================================================================================================
|
|
49
48
|
def getAuditFields(definitionName) {
|
|
50
49
|
/**/log.info("[\$audit] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
|
51
|
-
/**/log.info("[\$audit] Update auditFields for $definitionName
|
|
50
|
+
/**/log.info("[\$audit] Update 'auditFields' for '$definitionName'... ");
|
|
52
51
|
|
|
53
52
|
// Obtém detalhes da definição
|
|
54
53
|
def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
|
|
@@ -69,7 +68,7 @@ def getAuditFields(definitionName) {
|
|
|
69
68
|
// Finalmente obtém a lista de campos que é necessário calcular
|
|
70
69
|
def auditFields = [];
|
|
71
70
|
fields.each { fieldId,field ->
|
|
72
|
-
def matcher = field.description =~ /[$]audit\.(creator|updater)\.(username|
|
|
71
|
+
def matcher = field.description =~ /[$]audit\.(creator|updater)\.(username|usermURI|time)/
|
|
73
72
|
if(matcher) {
|
|
74
73
|
def op = matcher[0][1]
|
|
75
74
|
def arg = matcher[0][2]
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
cob.custom.customize.push(function (core, utils, ui) {
|
|
3
3
|
core.customizeAllInstances((instance, presenter) =>
|
|
4
4
|
{
|
|
5
|
-
let userFPs = presenter.findFieldPs( fp => /[$]audit\.(creator|updater)\.(username|
|
|
5
|
+
let userFPs = presenter.findFieldPs( fp => /[$]audit\.(creator|updater)\.(username|usermURI|time)/.exec(fp.field.fieldDefinition.description) )
|
|
6
6
|
userFPs.forEach( fp => {
|
|
7
7
|
fp.disable()
|
|
8
8
|
if(!instance.isNew() || presenter.isGroupEdit()) return //Only update if it's on create interface (updates will only be changed by the backend)
|
|
9
9
|
if(/[$]audit\.(creator|updater)\.username/.exec(fp.field.fieldDefinition.description)) {
|
|
10
10
|
fp.setValue(core.getCurrentLoggedInUser())
|
|
11
11
|
}
|
|
12
|
-
if(/[$]audit\.(creator|updater)\.
|
|
12
|
+
if(/[$]audit\.(creator|updater)\.usermURI/.exec(fp.field.fieldDefinition.description)) {
|
|
13
13
|
fp.setValue(core.getCurrentLoggedInUserUri())
|
|
14
14
|
}
|
|
15
15
|
if(/[$]audit\.(creator|updater)\.time/.exec(fp.field.fieldDefinition.description)) {
|
|
@@ -7,14 +7,16 @@ import com.google.common.cache.*
|
|
|
7
7
|
import java.util.concurrent.TimeUnit
|
|
8
8
|
|
|
9
9
|
// ========================================================================================================
|
|
10
|
+
if (msg.product != "recordm-definition" && msg.product != "recordm" ) return
|
|
11
|
+
|
|
10
12
|
@Field static cacheOfCalcFieldsForDefinition = CacheBuilder.newBuilder()
|
|
11
13
|
.expireAfterWrite(5, TimeUnit.MINUTES)
|
|
12
14
|
.build();
|
|
13
15
|
|
|
14
16
|
if (msg.product == "recordm-definition") cacheOfCalcFieldsForDefinition.invalidate(msg.type)
|
|
15
|
-
def calculationFields = cacheOfCalcFieldsForDefinition.get(msg.type, { getAllCalculationFields(msg.type) })
|
|
16
17
|
|
|
17
18
|
// ========================================================================================================
|
|
19
|
+
def calculationFields = cacheOfCalcFieldsForDefinition.get(msg.type, { getAllCalculationFields(msg.type) })
|
|
18
20
|
if (calculationFields.size() > 0
|
|
19
21
|
&& msg.product == "recordm"
|
|
20
22
|
&& msg.user != "integrationm"
|
|
@@ -22,7 +24,7 @@ if (calculationFields.size() > 0
|
|
|
22
24
|
|
|
23
25
|
def updates = executeCalculations(calculationFields, msg.instance.fields)
|
|
24
26
|
def result = actionPacks.recordm.update(messageMap.type, "recordmInstanceId:" + messageMap.instance.id, updates);
|
|
25
|
-
log.info("[\$calc]
|
|
27
|
+
if(updates) log.info("[\$calc] UPDATE '${msg.type}' id:${msg.instance.id}, updates: ${updates}, result:${result.getStatus()} | ${result.getStatusInfo()} ");
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
// ==================================================
|
|
@@ -117,7 +119,7 @@ def getAllAplicableValuesForVarName(fieldId,varName,varFieldIds,instanceFields,t
|
|
|
117
119
|
// ========================================================================================================
|
|
118
120
|
def getAllCalculationFields(definitionName) {
|
|
119
121
|
log.info("[\$calc] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
|
120
|
-
log.info("[\$calc] update calculationFields for $definitionName... ");
|
|
122
|
+
log.info("[\$calc] update 'calculationFields' for '$definitionName'... ");
|
|
121
123
|
|
|
122
124
|
// Obtém detalhes da definição
|
|
123
125
|
def definitionEncoded = URLEncoder.encode(definitionName, "utf-8").replace("+", "%20")
|