changed entity type in audit logs to Alarm, add entityId and originatorId to details
This commit is contained in:
parent
ed0a7d5adb
commit
ef20700b88
@ -82,7 +82,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
resultAlarm = unassign(alarm, alarm.getAssignTs(), user);
|
||||
}
|
||||
if (result.isModified()) {
|
||||
logEntityActionService.logEntityAction(tenantId, alarm.getOriginator(), resultAlarm,
|
||||
logEntityActionService.logEntityAction(tenantId, resultAlarm.getId(), resultAlarm,
|
||||
resultAlarm.getCustomerId(), actionType, user);
|
||||
}
|
||||
return new Alarm(resultAlarm);
|
||||
@ -107,7 +107,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
if (result.isModified()) {
|
||||
String systemComment = String.format("Alarm was acknowledged by user %s", user.getTitle());
|
||||
addSystemAlarmComment(alarmInfo, user, "ACK", systemComment);
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getId(), alarmInfo,
|
||||
alarmInfo.getCustomerId(), ActionType.ALARM_ACK, user);
|
||||
} else {
|
||||
throw new ThingsboardException("Alarm was already acknowledged!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||
@ -130,7 +130,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
if (result.isCleared()) {
|
||||
String systemComment = String.format("Alarm was cleared by user %s", user.getTitle());
|
||||
addSystemAlarmComment(alarmInfo, user, "CLEAR", systemComment);
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getId(), alarmInfo,
|
||||
alarmInfo.getCustomerId(), ActionType.ALARM_CLEAR, user);
|
||||
} else {
|
||||
throw new ThingsboardException("Alarm was already cleared!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||
@ -149,7 +149,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
AlarmAssignee assignee = alarmInfo.getAssignee();
|
||||
String systemComment = String.format("Alarm was assigned by user %s to user %s", user.getTitle(), assignee.getTitle());
|
||||
addSystemAlarmComment(alarmInfo, user, "ASSIGN", systemComment, assignee.getId());
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getId(), alarmInfo,
|
||||
alarmInfo.getCustomerId(), ActionType.ALARM_ASSIGNED, user);
|
||||
} else {
|
||||
throw new ThingsboardException("Alarm was already assigned to this user!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||
@ -167,7 +167,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
if (result.isModified()) {
|
||||
String systemComment = String.format("Alarm was unassigned by user %s", user.getTitle());
|
||||
addSystemAlarmComment(alarmInfo, user, "ASSIGN", systemComment);
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getId(), alarmInfo,
|
||||
alarmInfo.getCustomerId(), ActionType.ALARM_UNASSIGNED, user);
|
||||
} else {
|
||||
throw new ThingsboardException("Alarm was already unassigned!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||
@ -195,8 +195,8 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
@Override
|
||||
public Boolean delete(Alarm alarm, User user) {
|
||||
TenantId tenantId = alarm.getTenantId();
|
||||
logEntityActionService.logEntityAction(tenantId, alarm.getOriginator(), alarm, alarm.getCustomerId(),
|
||||
ActionType.ALARM_DELETE, user);
|
||||
logEntityActionService.logEntityAction(tenantId, alarm.getId(), alarm, alarm.getCustomerId(),
|
||||
ActionType.ALARM_DELETE, user, alarm.getOriginator());
|
||||
return alarmSubscriptionService.deleteAlarm(tenantId, alarm.getId());
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
if (result.isModified()) {
|
||||
String comment = String.format("Alarm was unassigned because user %s - was deleted", userTitle);
|
||||
addSystemAlarmComment(result.getAlarm(), null, "ASSIGN", comment);
|
||||
logEntityActionService.logEntityAction(result.getAlarm().getTenantId(), result.getAlarm().getOriginator(), result.getAlarm(), result.getAlarm().getCustomerId(), ActionType.ALARM_UNASSIGNED, null);
|
||||
logEntityActionService.logEntityAction(result.getAlarm().getTenantId(), result.getAlarm().getId(), result.getAlarm(), result.getAlarm().getCustomerId(), ActionType.ALARM_UNASSIGNED, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class DefaultTbAlarmServiceTest {
|
||||
public void testDelete() {
|
||||
service.delete(new Alarm(), new User());
|
||||
|
||||
verify(logEntityActionService, times(1)).logEntityAction(any(), any(), any(), any(), eq(ActionType.ALARM_DELETE), any());
|
||||
verify(logEntityActionService, times(1)).logEntityAction(any(), any(), any(), any(), eq(ActionType.ALARM_DELETE), any(), any());
|
||||
verify(alarmSubscriptionService, times(1)).deleteAlarm(any(), any());
|
||||
}
|
||||
|
||||
|
||||
@ -192,6 +192,10 @@ public class AuditLogServiceImpl implements AuditLogService {
|
||||
actionData.set("comment", comment.getComment());
|
||||
break;
|
||||
case ALARM_DELETE:
|
||||
actionData.put("entityId", entityId.toString());
|
||||
EntityId originatorId = extractParameter(EntityId.class, additionalInfo);
|
||||
actionData.put("originatorId", originatorId != null ? originatorId.toString() : null);
|
||||
break;
|
||||
case DELETED:
|
||||
case ACTIVATED:
|
||||
case SUSPENDED:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user