code update
This commit is contained in:
parent
2af736fb33
commit
f9c65d709d
@ -372,12 +372,14 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
|
||||
existing.setPropagate(existing.isPropagate() || alarm.isPropagate());
|
||||
List<String> existingPropagateRelationTypes = existing.getPropagateRelationTypes();
|
||||
List<String> newRelationTypes = alarm.getPropagateRelationTypes();
|
||||
if (!CollectionUtils.isEmpty(existingPropagateRelationTypes) && !CollectionUtils.isEmpty(newRelationTypes)) {
|
||||
existing.setPropagateRelationTypes(Stream.concat(existingPropagateRelationTypes.stream(), newRelationTypes.stream())
|
||||
.distinct()
|
||||
.collect(Collectors.toList()));
|
||||
} else {
|
||||
existing.setPropagateRelationTypes(Collections.emptyList());
|
||||
if (!CollectionUtils.isEmpty(newRelationTypes)) {
|
||||
if(!CollectionUtils.isEmpty(existingPropagateRelationTypes)) {
|
||||
existing.setPropagateRelationTypes(Stream.concat(existingPropagateRelationTypes.stream(), newRelationTypes.stream())
|
||||
.distinct()
|
||||
.collect(Collectors.toList()));
|
||||
} else {
|
||||
existing.setPropagateRelationTypes(newRelationTypes);
|
||||
}
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@ import org.thingsboard.server.common.data.plugin.ComponentType;
|
||||
import org.thingsboard.server.common.msg.TbMsg;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@ -55,13 +54,12 @@ import java.util.List;
|
||||
public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConfiguration> {
|
||||
|
||||
private static ObjectMapper mapper = new ObjectMapper();
|
||||
private List<String> relationTypes;
|
||||
|
||||
@Override
|
||||
protected TbCreateAlarmNodeConfiguration loadAlarmNodeConfig(TbNodeConfiguration configuration) throws TbNodeException {
|
||||
TbCreateAlarmNodeConfiguration nodeConfiguration = TbNodeUtils.convert(configuration, TbCreateAlarmNodeConfiguration.class);
|
||||
if(nodeConfiguration.getRelationTypes() == null) {
|
||||
nodeConfiguration.setRelationTypes(Collections.emptyList());
|
||||
}
|
||||
relationTypes = nodeConfiguration.getRelationTypes();
|
||||
return nodeConfiguration;
|
||||
}
|
||||
|
||||
@ -72,7 +70,6 @@ public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConf
|
||||
|
||||
if (!config.isUseMessageAlarmData()) {
|
||||
alarmType = TbNodeUtils.processPattern(this.config.getAlarmType(), msg.getMetaData());
|
||||
|
||||
msgAlarm = null;
|
||||
} else {
|
||||
try {
|
||||
@ -105,9 +102,6 @@ public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConf
|
||||
if (msgAlarm.getStatus() == null) {
|
||||
msgAlarm.setStatus(AlarmStatus.ACTIVE_UNACK);
|
||||
}
|
||||
if (msgAlarm.getPropagateRelationTypes() == null) {
|
||||
msgAlarm.setPropagateRelationTypes(Collections.emptyList());
|
||||
}
|
||||
return msgAlarm;
|
||||
}
|
||||
|
||||
@ -139,11 +133,7 @@ public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConf
|
||||
} else {
|
||||
existingAlarm.setSeverity(config.getSeverity());
|
||||
existingAlarm.setPropagate(config.isPropagate());
|
||||
if(config.getRelationTypes() == null) {
|
||||
existingAlarm.setPropagateRelationTypes(Collections.emptyList());
|
||||
} else {
|
||||
existingAlarm.setPropagateRelationTypes(config.getRelationTypes());
|
||||
}
|
||||
existingAlarm.setPropagateRelationTypes(relationTypes);
|
||||
}
|
||||
existingAlarm.setDetails(details);
|
||||
existingAlarm.setEndTs(System.currentTimeMillis());
|
||||
@ -154,10 +144,6 @@ public class TbCreateAlarmNode extends TbAbstractAlarmNode<TbCreateAlarmNodeConf
|
||||
}
|
||||
|
||||
private Alarm buildAlarm(TbMsg msg, JsonNode details, TenantId tenantId) {
|
||||
List<String> relationTypes = this.config.getRelationTypes();
|
||||
if (relationTypes == null) {
|
||||
relationTypes = Collections.emptyList();
|
||||
}
|
||||
return Alarm.builder()
|
||||
.tenantId(tenantId)
|
||||
.originator(msg.getOriginator())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user