Delta Calculation Node improvement
This commit is contained in:
parent
a15e991d23
commit
bfd0ed5d04
@ -45,11 +45,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RuleNode(type = ComponentType.ENRICHMENT,
|
@RuleNode(type = ComponentType.ENRICHMENT,
|
||||||
name = "calculate delta",
|
name = "calculate delta", relationTypes = {"Success", "Failure", "Other"},
|
||||||
configClazz = CalculateDeltaNodeConfiguration.class,
|
configClazz = CalculateDeltaNodeConfiguration.class,
|
||||||
nodeDescription = "Calculates and adds 'delta' value into message based on the incoming and previous value",
|
nodeDescription = "Calculates and adds 'delta' value into message based on the incoming and previous value",
|
||||||
nodeDetails = "Calculates delta and period based on the previous time-series reading and current data. " +
|
nodeDetails = "Calculates delta and period based on the previous time-series reading and current data. " +
|
||||||
"Delta calculation is done in scope of the message originator, e.g. device, asset or customer.",
|
"Delta calculation is done in scope of the message originator, e.g. device, asset or customer. " +
|
||||||
|
"If there is input key, the output relation will be 'Success' unless delta is negative and corresponding configuration parameter is set. " +
|
||||||
|
"If there is no input value key in the incoming message, the output relation will be 'Other'.",
|
||||||
uiResources = {"static/rulenode/rulenode-core-config.js"},
|
uiResources = {"static/rulenode/rulenode-core-config.js"},
|
||||||
configDirective = "tbEnrichmentNodeCalculateDeltaConfig")
|
configDirective = "tbEnrichmentNodeCalculateDeltaConfig")
|
||||||
public class CalculateDeltaNode implements TbNode {
|
public class CalculateDeltaNode implements TbNode {
|
||||||
@ -112,13 +114,11 @@ public class CalculateDeltaNode implements TbNode {
|
|||||||
ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(result)));
|
ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(result)));
|
||||||
},
|
},
|
||||||
t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor());
|
t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor());
|
||||||
} else if (config.isTellFailureIfInputValueKeyIsAbsent()) {
|
|
||||||
ctx.tellNext(msg, TbRelationTypes.FAILURE);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.tellSuccess(msg);
|
ctx.tellNext(msg, "Other");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.tellSuccess(msg);
|
ctx.tellNext(msg, "Other");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul
|
|||||||
private boolean addPeriodBetweenMsgs;
|
private boolean addPeriodBetweenMsgs;
|
||||||
private String periodValueKey;
|
private String periodValueKey;
|
||||||
private Integer round;
|
private Integer round;
|
||||||
private boolean tellFailureIfInputValueKeyIsAbsent;
|
|
||||||
private boolean tellFailureIfDeltaIsNegative;
|
private boolean tellFailureIfDeltaIsNegative;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,7 +36,6 @@ public class CalculateDeltaNodeConfiguration implements NodeConfiguration<Calcul
|
|||||||
configuration.setUseCache(true);
|
configuration.setUseCache(true);
|
||||||
configuration.setAddPeriodBetweenMsgs(false);
|
configuration.setAddPeriodBetweenMsgs(false);
|
||||||
configuration.setPeriodValueKey("periodInMs");
|
configuration.setPeriodValueKey("periodInMs");
|
||||||
configuration.setTellFailureIfInputValueKeyIsAbsent(true);
|
|
||||||
configuration.setTellFailureIfDeltaIsNegative(true);
|
configuration.setTellFailureIfDeltaIsNegative(true);
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user