changed entity name to device name when alarm
This commit is contained in:
parent
ef20700b88
commit
45f298fb0d
@ -82,7 +82,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
resultAlarm = unassign(alarm, alarm.getAssignTs(), user);
|
||||
}
|
||||
if (result.isModified()) {
|
||||
logEntityActionService.logEntityAction(tenantId, resultAlarm.getId(), resultAlarm,
|
||||
logEntityActionService.logEntityAction(tenantId, alarm.getOriginator(), 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.getId(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), 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.getId(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), 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.getId(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), 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.getId(), alarmInfo,
|
||||
logEntityActionService.logEntityAction(alarm.getTenantId(), alarm.getOriginator(), 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.getId(), alarm, alarm.getCustomerId(),
|
||||
ActionType.ALARM_DELETE, user, alarm.getOriginator());
|
||||
logEntityActionService.logEntityAction(tenantId, alarm.getOriginator(), alarm, alarm.getCustomerId(),
|
||||
ActionType.ALARM_DELETE, user, alarm.getId());
|
||||
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().getId(), result.getAlarm(), result.getAlarm().getCustomerId(), ActionType.ALARM_UNASSIGNED, null);
|
||||
logEntityActionService.logEntityAction(result.getAlarm().getTenantId(), result.getAlarm().getOriginator(), result.getAlarm(), result.getAlarm().getCustomerId(), ActionType.ALARM_UNASSIGNED, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ import org.thingsboard.server.common.data.AttributeScope;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.HasName;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.alarm.Alarm;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmComment;
|
||||
import org.thingsboard.server.common.data.audit.ActionStatus;
|
||||
import org.thingsboard.server.common.data.audit.ActionType;
|
||||
@ -123,7 +124,7 @@ public class AuditLogServiceImpl implements AuditLogService {
|
||||
ActionStatus actionStatus = ActionStatus.SUCCESS;
|
||||
String failureDetails = "";
|
||||
String entityName = "N/A";
|
||||
if (entity != null) {
|
||||
if (entity != null && !(entity instanceof Alarm)) {
|
||||
entityName = entity.getName();
|
||||
} else {
|
||||
try {
|
||||
@ -192,9 +193,9 @@ 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);
|
||||
EntityId alarmId = extractParameter(EntityId.class, additionalInfo);
|
||||
actionData.put("alarmId", alarmId != null ? alarmId.toString() : null);
|
||||
actionData.put("originatorId", entityId.toString());
|
||||
break;
|
||||
case DELETED:
|
||||
case ACTIVATED:
|
||||
|
||||
@ -934,11 +934,11 @@
|
||||
"type-relation-add-or-update": "Relation updated",
|
||||
"type-relation-delete": "Relation deleted",
|
||||
"type-relations-delete": "All relation deleted",
|
||||
"type-alarm-ack": "Acknowledged",
|
||||
"type-alarm-clear": "Cleared",
|
||||
"type-alarm-delete": "Deleted",
|
||||
"type-alarm-assign": "Assigned",
|
||||
"type-alarm-unassign": "Unassigned",
|
||||
"type-alarm-ack": "Alarm acknowledged",
|
||||
"type-alarm-clear": "Alarm cleared",
|
||||
"type-alarm-delete": "Alarm deleted",
|
||||
"type-alarm-assign": "Alarm assigned",
|
||||
"type-alarm-unassign": "Alarm unassigned",
|
||||
"type-added-comment": "Added comment",
|
||||
"type-updated-comment": "Updated comment",
|
||||
"type-deleted-comment": "Deleted comment",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user