added notification entities to the TenantIdLoader
This commit is contained in:
parent
b10e162b19
commit
b53f656f72
@ -70,6 +70,11 @@ import org.thingsboard.server.dao.entityview.EntityViewService;
|
|||||||
import org.thingsboard.server.dao.event.EventService;
|
import org.thingsboard.server.dao.event.EventService;
|
||||||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor;
|
import org.thingsboard.server.dao.nosql.CassandraBufferedRateReadExecutor;
|
||||||
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor;
|
import org.thingsboard.server.dao.nosql.CassandraBufferedRateWriteExecutor;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRequestService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRuleProcessingService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRuleService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTargetService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTemplateService;
|
||||||
import org.thingsboard.server.dao.ota.OtaPackageService;
|
import org.thingsboard.server.dao.ota.OtaPackageService;
|
||||||
import org.thingsboard.server.dao.queue.QueueService;
|
import org.thingsboard.server.dao.queue.QueueService;
|
||||||
import org.thingsboard.server.dao.relation.RelationService;
|
import org.thingsboard.server.dao.relation.RelationService;
|
||||||
@ -95,7 +100,6 @@ import org.thingsboard.server.service.executors.ExternalCallExecutorService;
|
|||||||
import org.thingsboard.server.service.executors.NotificationExecutorService;
|
import org.thingsboard.server.service.executors.NotificationExecutorService;
|
||||||
import org.thingsboard.server.service.executors.SharedEventLoopGroupService;
|
import org.thingsboard.server.service.executors.SharedEventLoopGroupService;
|
||||||
import org.thingsboard.server.service.mail.MailExecutorService;
|
import org.thingsboard.server.service.mail.MailExecutorService;
|
||||||
import org.thingsboard.server.dao.notification.NotificationRuleProcessingService;
|
|
||||||
import org.thingsboard.server.service.profile.TbAssetProfileCache;
|
import org.thingsboard.server.service.profile.TbAssetProfileCache;
|
||||||
import org.thingsboard.server.service.profile.TbDeviceProfileCache;
|
import org.thingsboard.server.service.profile.TbDeviceProfileCache;
|
||||||
import org.thingsboard.server.service.rpc.TbCoreDeviceRpcService;
|
import org.thingsboard.server.service.rpc.TbCoreDeviceRpcService;
|
||||||
@ -339,6 +343,22 @@ public class ActorSystemContext {
|
|||||||
@Getter
|
@Getter
|
||||||
private NotificationRuleProcessingService notificationRuleProcessingService;
|
private NotificationRuleProcessingService notificationRuleProcessingService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Getter
|
||||||
|
private NotificationTargetService notificationTargetService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Getter
|
||||||
|
private NotificationTemplateService notificationTemplateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Getter
|
||||||
|
private NotificationRequestService notificationRequestService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Getter
|
||||||
|
private NotificationRuleService notificationRuleService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Getter
|
@Getter
|
||||||
private SlackService slackService;
|
private SlackService slackService;
|
||||||
|
|||||||
@ -88,6 +88,10 @@ import org.thingsboard.server.dao.edge.EdgeService;
|
|||||||
import org.thingsboard.server.dao.entityview.EntityViewService;
|
import org.thingsboard.server.dao.entityview.EntityViewService;
|
||||||
import org.thingsboard.server.dao.nosql.CassandraStatementTask;
|
import org.thingsboard.server.dao.nosql.CassandraStatementTask;
|
||||||
import org.thingsboard.server.dao.nosql.TbResultSetFuture;
|
import org.thingsboard.server.dao.nosql.TbResultSetFuture;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRequestService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRuleService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTargetService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTemplateService;
|
||||||
import org.thingsboard.server.dao.ota.OtaPackageService;
|
import org.thingsboard.server.dao.ota.OtaPackageService;
|
||||||
import org.thingsboard.server.dao.queue.QueueService;
|
import org.thingsboard.server.dao.queue.QueueService;
|
||||||
import org.thingsboard.server.dao.relation.RelationService;
|
import org.thingsboard.server.dao.relation.RelationService;
|
||||||
@ -698,6 +702,26 @@ class DefaultTbContext implements TbContext {
|
|||||||
return mainCtx.getNotificationCenter();
|
return mainCtx.getNotificationCenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationTargetService getNotificationTargetService() {
|
||||||
|
return mainCtx.getNotificationTargetService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationTemplateService getNotificationTemplateService() {
|
||||||
|
return mainCtx.getNotificationTemplateService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationRequestService getNotificationRequestService() {
|
||||||
|
return mainCtx.getNotificationRequestService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationRuleService getNotificationRuleService() {
|
||||||
|
return mainCtx.getNotificationRuleService();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlackService getSlackService() {
|
public SlackService getSlackService() {
|
||||||
return mainCtx.getSlackService();
|
return mainCtx.getSlackService();
|
||||||
|
|||||||
@ -58,6 +58,10 @@ import org.thingsboard.server.dao.edge.EdgeService;
|
|||||||
import org.thingsboard.server.dao.entityview.EntityViewService;
|
import org.thingsboard.server.dao.entityview.EntityViewService;
|
||||||
import org.thingsboard.server.dao.nosql.CassandraStatementTask;
|
import org.thingsboard.server.dao.nosql.CassandraStatementTask;
|
||||||
import org.thingsboard.server.dao.nosql.TbResultSetFuture;
|
import org.thingsboard.server.dao.nosql.TbResultSetFuture;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRequestService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRuleService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTargetService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTemplateService;
|
||||||
import org.thingsboard.server.dao.ota.OtaPackageService;
|
import org.thingsboard.server.dao.ota.OtaPackageService;
|
||||||
import org.thingsboard.server.dao.queue.QueueService;
|
import org.thingsboard.server.dao.queue.QueueService;
|
||||||
import org.thingsboard.server.dao.relation.RelationService;
|
import org.thingsboard.server.dao.relation.RelationService;
|
||||||
@ -288,6 +292,14 @@ public interface TbContext {
|
|||||||
|
|
||||||
NotificationCenter getNotificationCenter();
|
NotificationCenter getNotificationCenter();
|
||||||
|
|
||||||
|
NotificationTargetService getNotificationTargetService();
|
||||||
|
|
||||||
|
NotificationTemplateService getNotificationTemplateService();
|
||||||
|
|
||||||
|
NotificationRequestService getNotificationRequestService();
|
||||||
|
|
||||||
|
NotificationRuleService getNotificationRuleService();
|
||||||
|
|
||||||
SlackService getSlackService();
|
SlackService getSlackService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -29,6 +29,10 @@ import org.thingsboard.server.common.data.id.DeviceProfileId;
|
|||||||
import org.thingsboard.server.common.data.id.EdgeId;
|
import org.thingsboard.server.common.data.id.EdgeId;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||||
|
import org.thingsboard.server.common.data.id.NotificationRequestId;
|
||||||
|
import org.thingsboard.server.common.data.id.NotificationRuleId;
|
||||||
|
import org.thingsboard.server.common.data.id.NotificationTargetId;
|
||||||
|
import org.thingsboard.server.common.data.id.NotificationTemplateId;
|
||||||
import org.thingsboard.server.common.data.id.OtaPackageId;
|
import org.thingsboard.server.common.data.id.OtaPackageId;
|
||||||
import org.thingsboard.server.common.data.id.QueueId;
|
import org.thingsboard.server.common.data.id.QueueId;
|
||||||
import org.thingsboard.server.common.data.id.RpcId;
|
import org.thingsboard.server.common.data.id.RpcId;
|
||||||
@ -123,6 +127,20 @@ public class TenantIdLoader {
|
|||||||
tenantEntity = null;
|
tenantEntity = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NOTIFICATION_TARGET:
|
||||||
|
tenantEntity = ctx.getNotificationTargetService().findNotificationTargetById(ctxTenantId, new NotificationTargetId(id));
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_TEMPLATE:
|
||||||
|
tenantEntity = ctx.getNotificationTemplateService().findNotificationTemplateById(ctxTenantId, new NotificationTemplateId(id));
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_REQUEST:
|
||||||
|
tenantEntity = ctx.getNotificationRequestService().findNotificationRequestById(ctxTenantId, new NotificationRequestId(id));
|
||||||
|
break;
|
||||||
|
case NOTIFICATION:
|
||||||
|
return ctxTenantId;
|
||||||
|
case NOTIFICATION_RULE:
|
||||||
|
tenantEntity = ctx.getNotificationRuleService().findNotificationRuleById(ctxTenantId, new NotificationRuleId(id));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected entity type: " + entityId.getEntityType());
|
throw new RuntimeException("Unexpected entity type: " + entityId.getEntityType());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,8 +48,13 @@ import org.thingsboard.server.common.data.id.AssetProfileId;
|
|||||||
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.EntityIdFactory;
|
import org.thingsboard.server.common.data.id.EntityIdFactory;
|
||||||
|
import org.thingsboard.server.common.data.id.NotificationId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.id.TenantProfileId;
|
import org.thingsboard.server.common.data.id.TenantProfileId;
|
||||||
|
import org.thingsboard.server.common.data.notification.NotificationRequest;
|
||||||
|
import org.thingsboard.server.common.data.notification.rule.NotificationRule;
|
||||||
|
import org.thingsboard.server.common.data.notification.targets.NotificationTarget;
|
||||||
|
import org.thingsboard.server.common.data.notification.template.NotificationTemplate;
|
||||||
import org.thingsboard.server.common.data.queue.Queue;
|
import org.thingsboard.server.common.data.queue.Queue;
|
||||||
import org.thingsboard.server.common.data.rpc.Rpc;
|
import org.thingsboard.server.common.data.rpc.Rpc;
|
||||||
import org.thingsboard.server.common.data.rule.RuleChain;
|
import org.thingsboard.server.common.data.rule.RuleChain;
|
||||||
@ -63,6 +68,11 @@ import org.thingsboard.server.dao.dashboard.DashboardService;
|
|||||||
import org.thingsboard.server.dao.device.DeviceService;
|
import org.thingsboard.server.dao.device.DeviceService;
|
||||||
import org.thingsboard.server.dao.edge.EdgeService;
|
import org.thingsboard.server.dao.edge.EdgeService;
|
||||||
import org.thingsboard.server.dao.entityview.EntityViewService;
|
import org.thingsboard.server.dao.entityview.EntityViewService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRequestService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationRuleService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTargetService;
|
||||||
|
import org.thingsboard.server.dao.notification.NotificationTemplateService;
|
||||||
import org.thingsboard.server.dao.ota.OtaPackageService;
|
import org.thingsboard.server.dao.ota.OtaPackageService;
|
||||||
import org.thingsboard.server.dao.queue.QueueService;
|
import org.thingsboard.server.dao.queue.QueueService;
|
||||||
import org.thingsboard.server.dao.resource.ResourceService;
|
import org.thingsboard.server.dao.resource.ResourceService;
|
||||||
@ -121,9 +131,20 @@ public class TenantIdLoaderTest {
|
|||||||
private RuleEngineRpcService rpcService;
|
private RuleEngineRpcService rpcService;
|
||||||
@Mock
|
@Mock
|
||||||
private RuleEngineApiUsageStateService ruleEngineApiUsageStateService;
|
private RuleEngineApiUsageStateService ruleEngineApiUsageStateService;
|
||||||
|
@Mock
|
||||||
|
private NotificationTargetService notificationTargetService;
|
||||||
|
@Mock
|
||||||
|
private NotificationTemplateService notificationTemplateService;
|
||||||
|
@Mock
|
||||||
|
private NotificationRequestService notificationRequestService;
|
||||||
|
@Mock
|
||||||
|
private NotificationService notificationService;
|
||||||
|
@Mock
|
||||||
|
private NotificationRuleService notificationRuleService;
|
||||||
|
|
||||||
private TenantId tenantId;
|
private TenantId tenantId;
|
||||||
private TenantProfileId tenantProfileId;
|
private TenantProfileId tenantProfileId;
|
||||||
|
private NotificationId notificationId;
|
||||||
private AbstractListeningExecutor dbExecutor;
|
private AbstractListeningExecutor dbExecutor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -137,6 +158,7 @@ public class TenantIdLoaderTest {
|
|||||||
dbExecutor.init();
|
dbExecutor.init();
|
||||||
this.tenantId = new TenantId(UUID.randomUUID());
|
this.tenantId = new TenantId(UUID.randomUUID());
|
||||||
this.tenantProfileId = new TenantProfileId(UUID.randomUUID());
|
this.tenantProfileId = new TenantProfileId(UUID.randomUUID());
|
||||||
|
this.notificationId = new NotificationId(UUID.randomUUID());
|
||||||
|
|
||||||
when(ctx.getTenantId()).thenReturn(tenantId);
|
when(ctx.getTenantId()).thenReturn(tenantId);
|
||||||
|
|
||||||
@ -153,6 +175,7 @@ public class TenantIdLoaderTest {
|
|||||||
private void initMocks(EntityType entityType, TenantId tenantId) {
|
private void initMocks(EntityType entityType, TenantId tenantId) {
|
||||||
switch (entityType) {
|
switch (entityType) {
|
||||||
case TENANT:
|
case TENANT:
|
||||||
|
case NOTIFICATION:
|
||||||
break;
|
break;
|
||||||
case CUSTOMER:
|
case CUSTOMER:
|
||||||
Customer customer = new Customer();
|
Customer customer = new Customer();
|
||||||
@ -310,6 +333,30 @@ public class TenantIdLoaderTest {
|
|||||||
|
|
||||||
when(ctx.getTenantProfile()).thenReturn(tenantProfile);
|
when(ctx.getTenantProfile()).thenReturn(tenantProfile);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_TARGET:
|
||||||
|
NotificationTarget notificationTarget = new NotificationTarget();
|
||||||
|
notificationTarget.setTenantId(tenantId);
|
||||||
|
when(ctx.getNotificationTargetService()).thenReturn(notificationTargetService);
|
||||||
|
doReturn(notificationTarget).when(notificationTargetService).findNotificationTargetById(eq(tenantId), any());
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_TEMPLATE:
|
||||||
|
NotificationTemplate notificationTemplate = new NotificationTemplate();
|
||||||
|
notificationTemplate.setTenantId(tenantId);
|
||||||
|
when(ctx.getNotificationTemplateService()).thenReturn(notificationTemplateService);
|
||||||
|
doReturn(notificationTemplate).when(notificationTemplateService).findNotificationTemplateById(eq(tenantId), any());
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_REQUEST:
|
||||||
|
NotificationRequest notificationRequest = new NotificationRequest();
|
||||||
|
notificationRequest.setTenantId(tenantId);
|
||||||
|
when(ctx.getNotificationRequestService()).thenReturn(notificationRequestService);
|
||||||
|
doReturn(notificationRequest).when(notificationRequestService).findNotificationRequestById(eq(tenantId), any());
|
||||||
|
break;
|
||||||
|
case NOTIFICATION_RULE:
|
||||||
|
NotificationRule notificationRule = new NotificationRule();
|
||||||
|
notificationRule.setTenantId(tenantId);
|
||||||
|
when(ctx.getNotificationRuleService()).thenReturn(notificationRuleService);
|
||||||
|
doReturn(notificationRule).when(notificationRuleService).findNotificationRuleById(eq(tenantId), any());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unexpected original EntityType " + entityType);
|
throw new RuntimeException("Unexpected original EntityType " + entityType);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user