rollback optional changes for fetchEntityCustomerId method
This commit is contained in:
parent
f167c7c48b
commit
7d9f437927
@ -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) {
|
||||
|
||||
@ -29,7 +29,7 @@ public interface EntityService {
|
||||
|
||||
Optional<String> fetchEntityName(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);
|
||||
|
||||
|
||||
@ -114,7 +114,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()) {
|
||||
|
||||
@ -90,7 +90,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);
|
||||
TbEntityService tbEntityService = entityServiceBeanFactory.getServiceByEntityType(entityId.getEntityType());
|
||||
Optional<HasId<?>> hasIdOpt = tbEntityService.fetchEntity(tenantId, entityId);
|
||||
@ -98,10 +98,10 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe
|
||||
HasId<?> hasId = hasIdOpt.get();
|
||||
if (hasId instanceof HasCustomerId) {
|
||||
HasCustomerId hasCustomerId = (HasCustomerId) hasId;
|
||||
return Optional.ofNullable(hasCustomerId.getCustomerId());
|
||||
return hasCustomerId.getCustomerId();
|
||||
}
|
||||
}
|
||||
return Optional.of(NULL_CUSTOMER_ID);
|
||||
return NULL_CUSTOMER_ID;
|
||||
}
|
||||
|
||||
private static void validateEntityCountQuery(EntityCountQuery query) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user