Browse Source
Merge pull request #14640 from dashevchenko/alarmOriginatorDisplayNameFix
Fixed sorting by originatorDisplayName
pull/14653/head
Viacheslav Klimov
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
11 additions and
2 deletions
-
common/data/src/main/java/org/thingsboard/server/common/data/alarm/AlarmInfo.java
-
dao/src/main/java/org/thingsboard/server/dao/model/ModelConstants.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/query/AlarmDataAdapter.java
-
dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultAlarmQueryRepository.java
|
|
|
@ -41,7 +41,6 @@ public class AlarmInfo extends Alarm { |
|
|
|
@Schema(description = "Alarm originator label", example = "Thermostat label") |
|
|
|
private String originatorLabel; |
|
|
|
|
|
|
|
@Getter |
|
|
|
@Setter |
|
|
|
@Schema(description = "Originator display name", example = "Thermostat") |
|
|
|
private String originatorDisplayName; |
|
|
|
@ -59,10 +58,15 @@ public class AlarmInfo extends Alarm { |
|
|
|
super(alarm); |
|
|
|
} |
|
|
|
|
|
|
|
public String getOriginatorDisplayName() { |
|
|
|
return originatorDisplayName != null ? originatorDisplayName : (originatorLabel != null ? originatorLabel : originatorName); |
|
|
|
} |
|
|
|
|
|
|
|
public AlarmInfo(AlarmInfo alarmInfo) { |
|
|
|
super(alarmInfo); |
|
|
|
this.originatorName = alarmInfo.getOriginatorName(); |
|
|
|
this.originatorLabel = alarmInfo.getOriginatorLabel(); |
|
|
|
this.originatorDisplayName = alarmInfo.getOriginatorDisplayName(); |
|
|
|
this.assignee = alarmInfo.getAssignee(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -257,6 +257,7 @@ public class ModelConstants { |
|
|
|
public static final String ALARM_ORIGINATOR_NAME_PROPERTY = "originator_name"; |
|
|
|
public static final String ALARM_ORIGINATOR_LABEL_PROPERTY = "originator_label"; |
|
|
|
public static final String ALARM_ORIGINATOR_TYPE_PROPERTY = "originator_type"; |
|
|
|
public static final String ALARM_ORIGINATOR_DISPLAY_NAME_PROPERTY = "originator_display_name"; |
|
|
|
public static final String ALARM_SEVERITY_PROPERTY = "severity"; |
|
|
|
public static final String ALARM_ASSIGNEE_ID_PROPERTY = "assignee_id"; |
|
|
|
public static final String ALARM_ASSIGNEE_FIRST_NAME_PROPERTY = "assignee_first_name"; |
|
|
|
|
|
|
|
@ -117,11 +117,13 @@ public class AlarmDataAdapter { |
|
|
|
String originatorName = originatorNameObj != null ? originatorNameObj.toString() : null; |
|
|
|
Object originatorLabelObj = row.get(ModelConstants.ALARM_ORIGINATOR_LABEL_PROPERTY); |
|
|
|
String originatorLabel = originatorLabelObj != null ? originatorLabelObj.toString() : null; |
|
|
|
Object originatorDisplayNameObj = row.get(ModelConstants.ALARM_ORIGINATOR_DISPLAY_NAME_PROPERTY); |
|
|
|
String originatorDisplayName = originatorDisplayNameObj != null ? originatorDisplayNameObj.toString() : null; |
|
|
|
|
|
|
|
AlarmData alarmData = new AlarmData(alarm, entityId); |
|
|
|
alarmData.setOriginatorName(originatorName); |
|
|
|
alarmData.setOriginatorLabel(originatorLabel); |
|
|
|
alarmData.setOriginatorDisplayName(StringUtils.isBlank(originatorLabel) ? originatorName : originatorLabel); |
|
|
|
alarmData.setOriginatorDisplayName(originatorDisplayName); |
|
|
|
if (alarm.getAssigneeId() != null) { |
|
|
|
alarmData.setAssignee(new AlarmAssignee(alarm.getAssigneeId(), assigneeFirstName, assigneeLastName, assigneeEmail)); |
|
|
|
} |
|
|
|
|
|
|
|
@ -83,6 +83,7 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository { |
|
|
|
alarmFieldColumnMap.put(ASSIGNEE_FIRST_NAME_KEY, ModelConstants.ALARM_ASSIGNEE_FIRST_NAME_PROPERTY); |
|
|
|
alarmFieldColumnMap.put(ASSIGNEE_LAST_NAME_KEY, ModelConstants.ALARM_ASSIGNEE_LAST_NAME_PROPERTY); |
|
|
|
alarmFieldColumnMap.put(ASSIGNEE_EMAIL_KEY, ModelConstants.ALARM_ASSIGNEE_EMAIL_PROPERTY); |
|
|
|
alarmFieldColumnMap.put("originatorDisplayName", ModelConstants.ALARM_ORIGINATOR_DISPLAY_NAME_PROPERTY); |
|
|
|
} |
|
|
|
|
|
|
|
private static final String FIELDS_SELECTION = "select a.id as id," + |
|
|
|
@ -106,6 +107,7 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository { |
|
|
|
" a.type as type, " + |
|
|
|
" a.originator_name as originator_name, " + |
|
|
|
" a.originator_label as originator_label, " + |
|
|
|
" coalesce(a.originator_label, a.originator_name) as originator_display_name, " + |
|
|
|
" a.assignee_first_name as assignee_first_name, " + |
|
|
|
" a.assignee_last_name as assignee_last_name, " + |
|
|
|
" a.assignee_email as assignee_email, " + |
|
|
|
|