Commit 076f5483587d5ea1a7e0cd1d79f16a70e0fd6c84
Committed by
Andrew Shvayka
1 parent
150b1bb8
refactored AlarmState
Showing
1 changed file
with
4 additions
and
3 deletions
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/profile/AlarmState.java
... | ... | @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; |
19 | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
20 | 20 | import lombok.Data; |
21 | 21 | import lombok.extern.slf4j.Slf4j; |
22 | +import org.apache.commons.lang3.StringUtils; | |
22 | 23 | import org.thingsboard.rule.engine.action.TbAlarmResult; |
23 | 24 | import org.thingsboard.rule.engine.api.TbContext; |
24 | 25 | import org.thingsboard.rule.engine.profile.state.PersistedAlarmRuleState; |
... | ... | @@ -239,18 +240,18 @@ class AlarmState { |
239 | 240 | JsonNode alarmDetails; |
240 | 241 | String alarmDetailsStr = ruleState.getAlarmRule().getAlarmDetails(); |
241 | 242 | |
242 | - if (alarmDetailsStr != null) { | |
243 | + if (StringUtils.isNotEmpty(alarmDetailsStr)) { | |
243 | 244 | for (KeyFilter keyFilter : ruleState.getAlarmRule().getCondition().getCondition()) { |
244 | 245 | EntityKeyValue entityKeyValue = dataSnapshot.getValue(keyFilter.getKey()); |
245 | 246 | alarmDetailsStr = alarmDetailsStr.replaceAll(String.format("\\$\\{%s}", keyFilter.getKey().getKey()), getValueAsString(entityKeyValue)); |
246 | 247 | } |
247 | - ObjectNode newDetails = JacksonUtil.OBJECT_MAPPER.createObjectNode(); | |
248 | + ObjectNode newDetails = JacksonUtil.newObjectNode(); | |
248 | 249 | newDetails.put("data", alarmDetailsStr); |
249 | 250 | alarmDetails = newDetails; |
250 | 251 | } else if (currentAlarm != null) { |
251 | 252 | alarmDetails = currentAlarm.getDetails(); |
252 | 253 | } else { |
253 | - alarmDetails = JacksonUtil.OBJECT_MAPPER.createObjectNode(); | |
254 | + alarmDetails = JacksonUtil.newObjectNode(); | |
254 | 255 | } |
255 | 256 | |
256 | 257 | return alarmDetails; | ... | ... |