Merge pull request #8398 from dashevchenko/newMessageTypes
Added new message types to rule engine
This commit is contained in:
commit
76f24827aa
@ -90,11 +90,11 @@ public class EntityActionService {
|
||||
case ALARM_CLEAR:
|
||||
msgType = DataConstants.ALARM_CLEAR;
|
||||
break;
|
||||
case ALARM_ASSIGN:
|
||||
msgType = DataConstants.ALARM_ASSIGN;
|
||||
case ALARM_ASSIGNED:
|
||||
msgType = DataConstants.ALARM_ASSIGNED;
|
||||
break;
|
||||
case ALARM_UNASSIGN:
|
||||
msgType = DataConstants.ALARM_UNASSIGN;
|
||||
case ALARM_UNASSIGNED:
|
||||
msgType = DataConstants.ALARM_UNASSIGNED;
|
||||
break;
|
||||
case ALARM_DELETE:
|
||||
msgType = DataConstants.ALARM_DELETE;
|
||||
|
||||
@ -309,10 +309,10 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
|
||||
return EdgeEventActionType.ALARM_ACK;
|
||||
case ALARM_CLEAR:
|
||||
return EdgeEventActionType.ALARM_CLEAR;
|
||||
case ALARM_ASSIGN:
|
||||
return EdgeEventActionType.ALARM_ASSIGN;
|
||||
case ALARM_UNASSIGN:
|
||||
return EdgeEventActionType.ALARM_UNASSIGN;
|
||||
case ALARM_ASSIGNED:
|
||||
return EdgeEventActionType.ALARM_ASSIGNED;
|
||||
case ALARM_UNASSIGNED:
|
||||
return EdgeEventActionType.ALARM_UNASSIGNED;
|
||||
case DELETED:
|
||||
return EdgeEventActionType.DELETED;
|
||||
case RELATION_ADD_OR_UPDATE:
|
||||
|
||||
@ -175,7 +175,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
} catch (ThingsboardException e) {
|
||||
log.error("Failed to save alarm comment", e);
|
||||
}
|
||||
notificationEntityService.notifyCreateOrUpdateAlarm(result.getAlarm(), ActionType.ALARM_ASSIGN, user);
|
||||
notificationEntityService.notifyCreateOrUpdateAlarm(result.getAlarm(), ActionType.ALARM_ASSIGNED, user);
|
||||
} else {
|
||||
throw new ThingsboardException("Alarm was already assigned to this user!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||
}
|
||||
@ -203,7 +203,7 @@ public class DefaultTbAlarmService extends AbstractTbEntityService implements Tb
|
||||
} catch (ThingsboardException e) {
|
||||
log.error("Failed to save alarm comment", e);
|
||||
}
|
||||
notificationEntityService.notifyCreateOrUpdateAlarm(result.getAlarm(), ActionType.ALARM_UNASSIGN, user);
|
||||
notificationEntityService.notifyCreateOrUpdateAlarm(result.getAlarm(), ActionType.ALARM_UNASSIGNED, user);
|
||||
} else {
|
||||
throw new ThingsboardException("Alarm was already unassigned!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class AlarmAssignmentTriggerProcessor implements RuleEngineMsgNotificatio
|
||||
|
||||
@Override
|
||||
public boolean matchesFilter(RuleEngineMsgTrigger trigger, AlarmAssignmentNotificationRuleTriggerConfig triggerConfig) {
|
||||
Action action = trigger.getMsg().getType().equals(DataConstants.ALARM_ASSIGN) ? Action.ASSIGNED : Action.UNASSIGNED;
|
||||
Action action = trigger.getMsg().getType().equals(DataConstants.ALARM_ASSIGNED) ? Action.ASSIGNED : Action.UNASSIGNED;
|
||||
if (!triggerConfig.getNotifyOn().contains(action)) {
|
||||
return false;
|
||||
}
|
||||
@ -53,7 +53,7 @@ public class AlarmAssignmentTriggerProcessor implements RuleEngineMsgNotificatio
|
||||
AlarmInfo alarmInfo = JacksonUtil.fromString(trigger.getMsg().getData(), AlarmInfo.class);
|
||||
AlarmAssignee assignee = alarmInfo.getAssignee();
|
||||
return AlarmAssignmentNotificationInfo.builder()
|
||||
.action(trigger.getMsg().getType().equals(DataConstants.ALARM_ASSIGN) ? "assigned" : "unassigned")
|
||||
.action(trigger.getMsg().getType().equals(DataConstants.ALARM_ASSIGNED) ? "assigned" : "unassigned")
|
||||
.assigneeFirstName(assignee != null ? assignee.getFirstName() : null)
|
||||
.assigneeLastName(assignee != null ? assignee.getLastName() : null)
|
||||
.assigneeEmail(assignee != null ? assignee.getEmail() : null)
|
||||
@ -78,7 +78,7 @@ public class AlarmAssignmentTriggerProcessor implements RuleEngineMsgNotificatio
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedMsgTypes() {
|
||||
return Set.of(DataConstants.ALARM_ASSIGN, DataConstants.ALARM_UNASSIGN);
|
||||
return Set.of(DataConstants.ALARM_ASSIGNED, DataConstants.ALARM_UNASSIGNED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.Device;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
@ -180,7 +179,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
|
||||
foundAlarm = doGet("/api/alarm/info/" + updatedAlarm.getId(), AlarmInfo.class);
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGNED);
|
||||
|
||||
alarm = updatedAlarm;
|
||||
alarm.setAssigneeId(null);
|
||||
@ -192,7 +191,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
|
||||
foundAlarm = doGet("/api/alarm/info/" + updatedAlarm.getId(), AlarmInfo.class);
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_UNASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_UNASSIGNED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -414,7 +413,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGNED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -445,7 +444,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGNED);
|
||||
|
||||
logout();
|
||||
|
||||
@ -462,7 +461,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ALARM_ASSIGN);
|
||||
tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ALARM_ASSIGNED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -480,7 +479,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGNED);
|
||||
|
||||
beforeAssignmentTs = System.currentTimeMillis();
|
||||
Thread.sleep(2);
|
||||
@ -491,7 +490,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_UNASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_UNASSIGNED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -509,7 +508,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGN);
|
||||
tenantId, customerId, tenantAdminUserId, TENANT_ADMIN_EMAIL, ActionType.ALARM_ASSIGNED);
|
||||
|
||||
logout();
|
||||
loginCustomerUser();
|
||||
@ -525,7 +524,7 @@ public abstract class BaseAlarmControllerTest extends AbstractControllerTest {
|
||||
Assert.assertTrue(foundAlarm.getAssignTs() > beforeAssignmentTs && foundAlarm.getAssignTs() < System.currentTimeMillis());
|
||||
|
||||
testNotifyEntityAllOneTime(foundAlarm, foundAlarm.getId(), foundAlarm.getOriginator(),
|
||||
tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ALARM_UNASSIGN);
|
||||
tenantId, customerId, customerUserId, CUSTOMER_USER_EMAIL, ActionType.ALARM_UNASSIGNED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -74,8 +74,8 @@ public class DataConstants {
|
||||
public static final String TIMESERIES_DELETED = "TIMESERIES_DELETED";
|
||||
public static final String ALARM_ACK = "ALARM_ACK";
|
||||
public static final String ALARM_CLEAR = "ALARM_CLEAR";
|
||||
public static final String ALARM_ASSIGN = "ALARM_ASSIGN";
|
||||
public static final String ALARM_UNASSIGN = "ALARM_UNASSIGN";
|
||||
public static final String ALARM_ASSIGNED = "ALARM_ASSIGNED";
|
||||
public static final String ALARM_UNASSIGNED = "ALARM_UNASSIGNED";
|
||||
public static final String ALARM_DELETE = "ALARM_DELETE";
|
||||
public static final String COMMENT_CREATED = "COMMENT_CREATED";
|
||||
public static final String COMMENT_UPDATED = "COMMENT_UPDATED";
|
||||
|
||||
@ -40,8 +40,8 @@ public enum ActionType {
|
||||
ALARM_ACK(false),
|
||||
ALARM_CLEAR(false),
|
||||
ALARM_DELETE(false),
|
||||
ALARM_ASSIGN(false),
|
||||
ALARM_UNASSIGN(false),
|
||||
ALARM_ASSIGNED(false),
|
||||
ALARM_UNASSIGNED(false),
|
||||
LOGIN(false),
|
||||
LOGOUT(false),
|
||||
LOCKOUT(false),
|
||||
|
||||
@ -31,8 +31,8 @@ public enum EdgeEventActionType {
|
||||
RPC_CALL,
|
||||
ALARM_ACK,
|
||||
ALARM_CLEAR,
|
||||
ALARM_ASSIGN,
|
||||
ALARM_UNASSIGN,
|
||||
ALARM_ASSIGNED,
|
||||
ALARM_UNASSIGNED,
|
||||
ASSIGNED_TO_EDGE,
|
||||
UNASSIGNED_FROM_EDGE,
|
||||
CREDENTIALS_REQUEST,
|
||||
|
||||
@ -166,8 +166,8 @@ public class AuditLogServiceImpl implements AuditLogService {
|
||||
case UPDATED:
|
||||
case ALARM_ACK:
|
||||
case ALARM_CLEAR:
|
||||
case ALARM_ASSIGN:
|
||||
case ALARM_UNASSIGN:
|
||||
case ALARM_ASSIGNED:
|
||||
case ALARM_UNASSIGNED:
|
||||
case RELATIONS_DELETED:
|
||||
case ASSIGNED_TO_TENANT:
|
||||
if (entity != null) {
|
||||
|
||||
@ -35,7 +35,7 @@ import org.thingsboard.server.common.msg.session.SessionMsgType;
|
||||
configClazz = EmptyNodeConfiguration.class,
|
||||
relationTypes = {"Post attributes", "Post telemetry", "RPC Request from Device", "RPC Request to Device", "RPC Queued", "RPC Sent", "RPC Delivered", "RPC Successful", "RPC Timeout", "RPC Expired", "RPC Failed", "RPC Deleted",
|
||||
"Activity Event", "Inactivity Event", "Connect Event", "Disconnect Event", "Entity Created", "Entity Updated", "Entity Deleted", "Entity Assigned",
|
||||
"Entity Unassigned", "Attributes Updated", "Attributes Deleted", "Alarm Acknowledged", "Alarm Cleared", "Other", "Entity Assigned From Tenant", "Entity Assigned To Tenant",
|
||||
"Entity Unassigned", "Attributes Updated", "Attributes Deleted", "Alarm Acknowledged", "Alarm Cleared", "Alarm Assigned", "Alarm Unassigned", "Comment Created", "Comment Updated", "Other", "Entity Assigned From Tenant", "Entity Assigned To Tenant",
|
||||
"Relation Added or Updated", "Relation Deleted", "All Relations Deleted", "Timeseries Updated", "Timeseries Deleted"},
|
||||
nodeDescription = "Route incoming messages by Message Type",
|
||||
nodeDetails = "Sends messages with message types <b>\"Post attributes\", \"Post telemetry\", \"RPC Request\"</b> etc. via corresponding chain, otherwise <b>Other</b> chain is used.",
|
||||
@ -85,6 +85,14 @@ public class TbMsgTypeSwitchNode implements TbNode {
|
||||
relationType = "Alarm Acknowledged";
|
||||
} else if (msg.getType().equals(DataConstants.ALARM_CLEAR)) {
|
||||
relationType = "Alarm Cleared";
|
||||
} else if (msg.getType().equals(DataConstants.ALARM_ASSIGNED)) {
|
||||
relationType = "Alarm Assigned";
|
||||
} else if (msg.getType().equals(DataConstants.ALARM_UNASSIGNED)) {
|
||||
relationType = "Alarm Unassigned";
|
||||
} else if (msg.getType().equals(DataConstants.COMMENT_CREATED)) {
|
||||
relationType = "Comment Created";
|
||||
} else if (msg.getType().equals(DataConstants.COMMENT_UPDATED)) {
|
||||
relationType = "Comment Updated";
|
||||
} else if (msg.getType().equals(DataConstants.RPC_CALL_FROM_SERVER_TO_DEVICE)) {
|
||||
relationType = "RPC Request to Device";
|
||||
} else if (msg.getType().equals(DataConstants.ENTITY_ASSIGNED_FROM_TENANT)) {
|
||||
|
||||
@ -47,8 +47,8 @@ export enum ActionType {
|
||||
RELATIONS_DELETED = 'RELATIONS_DELETED',
|
||||
ALARM_ACK = 'ALARM_ACK',
|
||||
ALARM_CLEAR = 'ALARM_CLEAR',
|
||||
ALARM_ASSIGN = 'ALARM_ASSIGN',
|
||||
ALARM_UNASSIGN = 'ALARM_UNASSIGN',
|
||||
ALARM_ASSIGNED = 'ALARM_ASSIGNED',
|
||||
ALARM_UNASSIGNED = 'ALARM_UNASSIGNED',
|
||||
ADDED_COMMENT = 'ADDED_COMMENT',
|
||||
UPDATED_COMMENT = 'UPDATED_COMMENT',
|
||||
DELETED_COMMENT = 'DELETED_COMMENT',
|
||||
@ -90,8 +90,8 @@ export const actionTypeTranslations = new Map<ActionType, string>(
|
||||
[ActionType.RELATIONS_DELETED, 'audit-log.type-relations-delete'],
|
||||
[ActionType.ALARM_ACK, 'audit-log.type-alarm-ack'],
|
||||
[ActionType.ALARM_CLEAR, 'audit-log.type-alarm-clear'],
|
||||
[ActionType.ALARM_ASSIGN, 'audit-log.type-alarm-assign'],
|
||||
[ActionType.ALARM_UNASSIGN, 'audit-log.type-alarm-unassign'],
|
||||
[ActionType.ALARM_ASSIGNED, 'audit-log.type-alarm-assign'],
|
||||
[ActionType.ALARM_UNASSIGNED, 'audit-log.type-alarm-unassign'],
|
||||
[ActionType.ADDED_COMMENT, 'audit-log.type-added-comment'],
|
||||
[ActionType.UPDATED_COMMENT, 'audit-log.type-updated-comment'],
|
||||
[ActionType.DELETED_COMMENT, 'audit-log.type-deleted-comment'],
|
||||
|
||||
@ -373,6 +373,10 @@ export enum MessageType {
|
||||
ATTRIBUTES_DELETED = 'ATTRIBUTES_DELETED',
|
||||
ALARM_ACKNOWLEDGED = 'ALARM_ACKNOWLEDGED',
|
||||
ALARM_CLEARED = 'ALARM_CLEARED',
|
||||
ALARM_ASSIGNED = 'ALARM_ASSIGNED',
|
||||
ALARM_UNASSIGNED = 'ALARM_UNASSIGNED',
|
||||
COMMENT_CREATED = 'COMMENT_CREATED',
|
||||
COMMENT_UPDATED = 'COMMENT_UPDATED',
|
||||
ENTITY_ASSIGNED_FROM_TENANT = 'ENTITY_ASSIGNED_FROM_TENANT',
|
||||
ENTITY_ASSIGNED_TO_TENANT = 'ENTITY_ASSIGNED_TO_TENANT',
|
||||
TIMESERIES_UPDATED = 'TIMESERIES_UPDATED',
|
||||
@ -406,6 +410,10 @@ export const messageTypeNames = new Map<MessageType, string>(
|
||||
[MessageType.ATTRIBUTES_DELETED, 'Attributes Deleted'],
|
||||
[MessageType.ALARM_ACKNOWLEDGED, 'Alarm Acknowledged'],
|
||||
[MessageType.ALARM_CLEARED, 'Alarm Cleared'],
|
||||
[MessageType.ALARM_ASSIGNED, 'Alarm Assigned'],
|
||||
[MessageType.ALARM_UNASSIGNED, 'Alarm Unassigned'],
|
||||
[MessageType.COMMENT_CREATED, 'Comment Created'],
|
||||
[MessageType.COMMENT_UPDATED, 'Comment Updated'],
|
||||
[MessageType.ENTITY_ASSIGNED_FROM_TENANT, 'Entity Assigned From Tenant'],
|
||||
[MessageType.ENTITY_ASSIGNED_TO_TENANT, 'Entity Assigned To Tenant'],
|
||||
[MessageType.TIMESERIES_UPDATED, 'Timeseries Updated'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user