Merge with develop/3.5

This commit is contained in:
zbeacon 2022-12-29 20:49:58 +02:00
parent d9add9bdf8
commit 022aee36d0
5 changed files with 10 additions and 14 deletions

View File

@ -561,7 +561,7 @@ public class DefaultDataUpdateService implements DataUpdateService {
while (hasNext) {
for (Alarm alarm : alarms.getData()) {
if (alarm.getCustomerId() == null && alarm.getOriginator() != null) {
alarm.setCustomerId(entityService.fetchEntityCustomerId(tenantId, alarm.getOriginator()).get());
alarm.setCustomerId(entityService.fetchEntityCustomerId(tenantId, alarm.getOriginator()));
alarmDao.save(tenantId, alarm);
}
if (processed.incrementAndGet() % 1000 == 0) {

View File

@ -31,7 +31,7 @@ public interface EntityService {
Optional<String> fetchEntityLabel(TenantId tenantId, EntityId entityId);
Optional<CustomerId> fetchEntityCustomerId(TenantId tenantId, EntityId entityId);
CustomerId fetchEntityCustomerId(TenantId tenantId, EntityId entityId);
long countEntitiesByQuery(TenantId tenantId, CustomerId customerId, EntityCountQuery query);

View File

@ -122,7 +122,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
if (alarm.getEndTs() == 0L) {
alarm.setEndTs(alarm.getStartTs());
}
alarm.setCustomerId(entityService.fetchEntityCustomerId(alarm.getTenantId(), alarm.getOriginator()).get());
alarm.setCustomerId(entityService.fetchEntityCustomerId(alarm.getTenantId(), alarm.getOriginator()));
if (alarm.getId() == null) {
Alarm existing = alarmDao.findLatestByOriginatorAndType(alarm.getTenantId(), alarm.getOriginator(), alarm.getType());
if (existing == null || existing.getStatus().isCleared()) {
@ -172,7 +172,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
log.debug("New Alarm : {}", alarm);
Alarm saved = alarmDao.save(alarm.getTenantId(), alarm);
List<EntityId> propagatedEntitiesList = createEntityAlarmRecords(saved);
AlarmInfo alarmInfo = getAlarmInfo(alarm.getTenantId(), alarm);
AlarmInfo alarmInfo = getAlarmInfo(alarm.getTenantId(), saved);
return new AlarmOperationResult(alarmInfo, true, true, propagatedEntitiesList);
}
@ -463,7 +463,7 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
String assigneeLastName = null;
String assigneeEmail = null;
originatorName = entityService.fetchEntityName(tenantId, alarm.getOriginator()).orElse("Deleted");
originatorName = entityService.fetchEntityName(tenantId, alarm.getOriginator()).orElse(null);
originatorLabel = entityService.fetchEntityLabel(tenantId, alarm.getOriginator()).orElse(null);
if (alarm.getAssigneeId() != null) {

View File

@ -96,7 +96,7 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
public Optional<String> fetchEntityLabel(TenantId tenantId, EntityId entityId) {
log.trace("Executing fetchEntityLabel [{}]", entityId);
EntityDaoService entityDaoService = entityServiceRegistry.getServiceByEntityType(entityId.getEntityType());
Optional<HasId<?>> entityOpt = entityDaoService.fetchEntity(tenantId, entityId);
Optional<HasId<?>> entityOpt = entityDaoService.findEntity(tenantId, entityId);
String entityLabel = null;
if (entityOpt.isPresent()) {
HasId<?> entity = entityOpt.get();
@ -117,7 +117,7 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
}
@Override
public Optional<CustomerId> fetchEntityCustomerId(TenantId tenantId, EntityId entityId) {
public CustomerId fetchEntityCustomerId(TenantId tenantId, EntityId entityId) {
log.trace("Executing fetchEntityCustomerId [{}]", entityId);
EntityDaoService entityDaoService = entityServiceRegistry.getServiceByEntityType(entityId.getEntityType());
Optional<HasId<?>> hasIdOpt = entityDaoService.findEntity(tenantId, entityId);
@ -125,14 +125,10 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
HasId<?> hasId = hasIdOpt.get();
if (hasId instanceof HasCustomerId) {
HasCustomerId hasCustomerId = (HasCustomerId) hasId;
CustomerId customerId = hasCustomerId.getCustomerId();
if (customerId == null) {
customerId = NULL_CUSTOMER_ID;
}
return Optional.of(customerId);
return hasCustomerId.getCustomerId();
}
}
return Optional.of(NULL_CUSTOMER_ID);
return null;
}
private static void validateEntityCountQuery(EntityCountQuery query) {

View File

@ -163,7 +163,7 @@ public abstract class AbstractAlarmEntity<T extends Alarm> extends BaseSqlEntity
if (!CollectionUtils.isEmpty(alarm.getPropagateRelationTypes())) {
this.propagateRelationTypes = String.join(",", alarm.getPropagateRelationTypes());
} else {
this.propagateRelationTypes = null;
this.propagateRelationTypes = "";
}
}