Commit bfd0ed5d047b6c097e7720d164945a97072f0ed0
1 parent
a15e991d
Delta Calculation Node improvement
Showing
2 changed files
with
6 additions
and
8 deletions
... | ... | @@ -45,11 +45,13 @@ import java.util.concurrent.ConcurrentHashMap; |
45 | 45 | |
46 | 46 | @Slf4j |
47 | 47 | @RuleNode(type = ComponentType.ENRICHMENT, |
48 | - name = "calculate delta", | |
48 | + name = "calculate delta", relationTypes = {"Success", "Failure", "Other"}, | |
49 | 49 | configClazz = CalculateDeltaNodeConfiguration.class, |
50 | 50 | nodeDescription = "Calculates and adds 'delta' value into message based on the incoming and previous value", |
51 | 51 | nodeDetails = "Calculates delta and period based on the previous time-series reading and current data. " + |
52 | - "Delta calculation is done in scope of the message originator, e.g. device, asset or customer.", | |
52 | + "Delta calculation is done in scope of the message originator, e.g. device, asset or customer. " + | |
53 | + "If there is input key, the output relation will be 'Success' unless delta is negative and corresponding configuration parameter is set. " + | |
54 | + "If there is no input value key in the incoming message, the output relation will be 'Other'.", | |
53 | 55 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
54 | 56 | configDirective = "tbEnrichmentNodeCalculateDeltaConfig") |
55 | 57 | public class CalculateDeltaNode implements TbNode { |
... | ... | @@ -112,13 +114,11 @@ public class CalculateDeltaNode implements TbNode { |
112 | 114 | ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(result))); |
113 | 115 | }, |
114 | 116 | t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor()); |
115 | - } else if (config.isTellFailureIfInputValueKeyIsAbsent()) { | |
116 | - ctx.tellNext(msg, TbRelationTypes.FAILURE); | |
117 | 117 | } else { |
118 | - ctx.tellSuccess(msg); | |
118 | + ctx.tellNext(msg, "Other"); | |
119 | 119 | } |
120 | 120 | } else { |
121 | - ctx.tellSuccess(msg); | |
121 | + ctx.tellNext(msg, "Other"); | |
122 | 122 | } |
123 | 123 | } |
124 | 124 | ... | ... |
... | ... | @@ -26,7 +26,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul |
26 | 26 | private boolean addPeriodBetweenMsgs; |
27 | 27 | private String periodValueKey; |
28 | 28 | private Integer round; |
29 | - private boolean tellFailureIfInputValueKeyIsAbsent; | |
30 | 29 | private boolean tellFailureIfDeltaIsNegative; |
31 | 30 | |
32 | 31 | @Override |
... | ... | @@ -37,7 +36,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul |
37 | 36 | configuration.setUseCache(true); |
38 | 37 | configuration.setAddPeriodBetweenMsgs(false); |
39 | 38 | configuration.setPeriodValueKey("periodInMs"); |
40 | - configuration.setTellFailureIfInputValueKeyIsAbsent(true); | |
41 | 39 | configuration.setTellFailureIfDeltaIsNegative(true); |
42 | 40 | return configuration; |
43 | 41 | } | ... | ... |