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,11 +45,13 @@ import java.util.concurrent.ConcurrentHashMap; | ||
45 | 45 | ||
46 | @Slf4j | 46 | @Slf4j |
47 | @RuleNode(type = ComponentType.ENRICHMENT, | 47 | @RuleNode(type = ComponentType.ENRICHMENT, |
48 | - name = "calculate delta", | 48 | + name = "calculate delta", relationTypes = {"Success", "Failure", "Other"}, |
49 | configClazz = CalculateDeltaNodeConfiguration.class, | 49 | configClazz = CalculateDeltaNodeConfiguration.class, |
50 | nodeDescription = "Calculates and adds 'delta' value into message based on the incoming and previous value", | 50 | nodeDescription = "Calculates and adds 'delta' value into message based on the incoming and previous value", |
51 | nodeDetails = "Calculates delta and period based on the previous time-series reading and current data. " + | 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 | uiResources = {"static/rulenode/rulenode-core-config.js"}, | 55 | uiResources = {"static/rulenode/rulenode-core-config.js"}, |
54 | configDirective = "tbEnrichmentNodeCalculateDeltaConfig") | 56 | configDirective = "tbEnrichmentNodeCalculateDeltaConfig") |
55 | public class CalculateDeltaNode implements TbNode { | 57 | public class CalculateDeltaNode implements TbNode { |
@@ -112,13 +114,11 @@ public class CalculateDeltaNode implements TbNode { | @@ -112,13 +114,11 @@ public class CalculateDeltaNode implements TbNode { | ||
112 | ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(result))); | 114 | ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(result))); |
113 | }, | 115 | }, |
114 | t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor()); | 116 | t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor()); |
115 | - } else if (config.isTellFailureIfInputValueKeyIsAbsent()) { | ||
116 | - ctx.tellNext(msg, TbRelationTypes.FAILURE); | ||
117 | } else { | 117 | } else { |
118 | - ctx.tellSuccess(msg); | 118 | + ctx.tellNext(msg, "Other"); |
119 | } | 119 | } |
120 | } else { | 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,7 +26,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul | ||
26 | private boolean addPeriodBetweenMsgs; | 26 | private boolean addPeriodBetweenMsgs; |
27 | private String periodValueKey; | 27 | private String periodValueKey; |
28 | private Integer round; | 28 | private Integer round; |
29 | - private boolean tellFailureIfInputValueKeyIsAbsent; | ||
30 | private boolean tellFailureIfDeltaIsNegative; | 29 | private boolean tellFailureIfDeltaIsNegative; |
31 | 30 | ||
32 | @Override | 31 | @Override |
@@ -37,7 +36,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul | @@ -37,7 +36,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul | ||
37 | configuration.setUseCache(true); | 36 | configuration.setUseCache(true); |
38 | configuration.setAddPeriodBetweenMsgs(false); | 37 | configuration.setAddPeriodBetweenMsgs(false); |
39 | configuration.setPeriodValueKey("periodInMs"); | 38 | configuration.setPeriodValueKey("periodInMs"); |
40 | - configuration.setTellFailureIfInputValueKeyIsAbsent(true); | ||
41 | configuration.setTellFailureIfDeltaIsNegative(true); | 39 | configuration.setTellFailureIfDeltaIsNegative(true); |
42 | return configuration; | 40 | return configuration; |
43 | } | 41 | } |