Commit 14c5cf242cb6f456be019ad5781d7762dba79dd7
1 parent
17825b2c
Fix to alarm state change during missing originator
Showing
1 changed file
with
5 additions
and
8 deletions
... | ... | @@ -47,6 +47,7 @@ import javax.annotation.PostConstruct; |
47 | 47 | import javax.annotation.PreDestroy; |
48 | 48 | import java.util.ArrayList; |
49 | 49 | import java.util.List; |
50 | +import java.util.Set; | |
50 | 51 | import java.util.concurrent.ExecutionException; |
51 | 52 | import java.util.concurrent.ExecutorService; |
52 | 53 | import java.util.concurrent.Executors; |
... | ... | @@ -336,15 +337,11 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ |
336 | 337 | |
337 | 338 | private void updateRelations(Alarm alarm, AlarmStatus oldStatus, AlarmStatus newStatus) { |
338 | 339 | try { |
339 | - if (alarm.isPropagate()) { | |
340 | - EntityRelationsQuery query = new EntityRelationsQuery(); | |
341 | - query.setParameters(new RelationsSearchParameters(alarm.getOriginator(), EntitySearchDirection.TO, Integer.MAX_VALUE)); | |
342 | - List<EntityId> parentEntities = relationService.findByQuery(query).get().stream().map(r -> r.getFrom()).collect(Collectors.toList()); | |
343 | - for (EntityId parentId : parentEntities) { | |
344 | - updateAlarmRelation(parentId, alarm.getId(), oldStatus, newStatus); | |
345 | - } | |
340 | + List<EntityRelation> relations = relationService.findByTo(alarm.getId(), RelationTypeGroup.ALARM).get(); | |
341 | + Set<EntityId> parents = relations.stream().map(EntityRelation::getFrom).collect(Collectors.toSet()); | |
342 | + for (EntityId parentId : parents) { | |
343 | + updateAlarmRelation(parentId, alarm.getId(), oldStatus, newStatus); | |
346 | 344 | } |
347 | - updateAlarmRelation(alarm.getOriginator(), alarm.getId(), oldStatus, newStatus); | |
348 | 345 | } catch (ExecutionException | InterruptedException e) { |
349 | 346 | log.warn("[{}] Failed to update relations. Old status: [{}], New status: [{}]", alarm.getId(), oldStatus, newStatus); |
350 | 347 | throw new RuntimeException(e); | ... | ... |