diff --git a/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java b/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java index 0ab6564c48..e3dc0c0a98 100644 --- a/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java +++ b/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java @@ -43,6 +43,7 @@ import org.thingsboard.server.actors.tenant.DebugTbRateLimits; import org.thingsboard.server.common.data.DataConstants; import org.thingsboard.server.common.data.Event; import org.thingsboard.server.common.data.StringUtils; +import org.thingsboard.server.common.data.audit.ActionType; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.exception.ThingsboardException; import org.thingsboard.server.common.data.id.EdgeId; @@ -66,7 +67,6 @@ import org.thingsboard.server.common.msg.TbMsgMetaData; import org.thingsboard.server.dao.event.EventService; import org.thingsboard.server.queue.util.TbCoreComponent; import org.thingsboard.server.service.entitiy.ruleChain.TbRuleChainNotifyService; -import org.thingsboard.server.service.install.InstallScripts; import org.thingsboard.server.service.rule.TbRuleChainService; import org.thingsboard.server.service.script.JsInvokeService; import org.thingsboard.server.service.script.RuleNodeJsScriptEngine; @@ -142,9 +142,6 @@ public class RuleChainController extends BaseController { @Autowired protected TbRuleChainService tbRuleChainService; - @Autowired - private InstallScripts installScripts; - @Autowired private EventService eventService; @@ -260,7 +257,7 @@ public class RuleChainController extends BaseController { checkNotNull(request); checkParameter(request.getName(), "name"); - return tbRuleChainNotifyService.saveRuleChain(getTenantId(), request, getCurrentUser()); + return tbRuleChainNotifyService.saveDefaultByName(getTenantId(), request, getCurrentUser()); } @ApiOperation(value = "Set Root Rule Chain (setRootRuleChain)", @@ -540,9 +537,10 @@ public class RuleChainController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.WRITE); RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); - checkRuleChain(ruleChainId, Operation.READ); + RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.READ); - return tbRuleChainNotifyService.assignRuleChainToEdge(getTenantId(), ruleChainId, edge, getCurrentUser()); + return tbRuleChainNotifyService.assignUnassignRuleChainToEdge(getTenantId(), ruleChain, edge, + ActionType.ASSIGNED_TO_EDGE, getCurrentUser()); } @ApiOperation(value = "Unassign rule chain from edge (unassignRuleChainFromEdge)", @@ -564,7 +562,8 @@ public class RuleChainController extends BaseController { RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.READ); - return tbRuleChainNotifyService.unassignRuleChainFromEdge(getTenantId(), ruleChain, edge, getCurrentUser()); + return tbRuleChainNotifyService.assignUnassignRuleChainToEdge(getTenantId(), ruleChain, edge, + ActionType.UNASSIGNED_FROM_EDGE, getCurrentUser()); } @ApiOperation(value = "Get Edge Rule Chains (getEdgeRuleChains)", @@ -608,7 +607,7 @@ public class RuleChainController extends BaseController { checkParameter(RULE_CHAIN_ID, strRuleChainId); RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.WRITE); - return tbRuleChainNotifyService.setEdgeRuleChain(getTenantId(), ruleChain, getCurrentUser(), true); + return tbRuleChainNotifyService.setEdgeTemplateRootRuleChain(getTenantId(), ruleChain, getCurrentUser()); } @ApiOperation(value = "Set Auto Assign To Edge Rule Chain (setAutoAssignToEdgeRuleChain)", @@ -622,7 +621,7 @@ public class RuleChainController extends BaseController { checkParameter(RULE_CHAIN_ID, strRuleChainId); RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.WRITE); - return tbRuleChainNotifyService.setEdgeRuleChain(getTenantId(), ruleChain, getCurrentUser(), false); + return tbRuleChainNotifyService.setAutoAssignToEdgeRuleChain(getTenantId(), ruleChain, getCurrentUser()); } @ApiOperation(value = "Unset Auto Assign To Edge Rule Chain (unsetAutoAssignToEdgeRuleChain)", diff --git a/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java b/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java index 2ed55ac126..c6526476d2 100644 --- a/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java +++ b/application/src/main/java/org/thingsboard/server/service/entitiy/DefaultTbNotificationEntityService.java @@ -77,7 +77,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS CustomerId customerId, ActionType actionType, List relatedEdgeIds, SecurityUser user, Object... additionalInfo) { - logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo); + logEntityAction(tenantId, entityId, entity, customerId, actionType, user, null, additionalInfo); sendDeleteNotificationMsg(tenantId, entityId, entity, relatedEdgeIds); } @@ -86,15 +86,15 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS List relatedEdgeIds, SecurityUser user, String body, Object... additionalInfo) { - logEntityAction(tenantId, originatorId, alarm, customerId, ActionType.DELETED, user, additionalInfo); + logEntityAction(tenantId, originatorId, alarm, customerId, ActionType.DELETED, user, null, additionalInfo); sendAlarmDeleteNotificationMsg(tenantId, alarm, relatedEdgeIds, body); } @Override - public void notifyDeleteRuleChane(TenantId tenantId, RuleChain ruleChain, + public void notifyDeleteRuleChain(TenantId tenantId, RuleChain ruleChain, List relatedEdgeIds, SecurityUser user) { RuleChainId ruleChainId = ruleChain.getId(); - logEntityAction(tenantId, ruleChainId, ruleChain, null, ActionType.DELETED, user, ruleChainId.toString()); + logEntityAction(tenantId, ruleChainId, ruleChain, null, ActionType.DELETED, user, null, ruleChainId.toString()); if (RuleChainType.EDGE.equals(ruleChain.getType())) { sendDeleteNotificationMsg(tenantId, ruleChainId, relatedEdgeIds, null); } @@ -108,7 +108,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS RuleChain updatedRuleChain = (RuleChain)others[0]; RuleChainMetaData updatedRuleChainMetaData = (RuleChainMetaData)others[1]; SecurityUser user = (SecurityUser)others[2]; - logEntityAction(tenantId, updatedRuleChain.getId(), updatedRuleChain, null, ActionType.UPDATED, user, updatedRuleChainMetaData); + logEntityAction(tenantId, updatedRuleChain.getId(), updatedRuleChain, null, ActionType.UPDATED, user, null, updatedRuleChainMetaData); if (RuleChainType.EDGE.equals(ruleChain.getType())) { sendEntityNotificationMsg(updatedRuleChain.getTenantId(), updatedRuleChain.getId(), EdgeEventActionType.UPDATED); } @@ -122,7 +122,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS EdgeEventActionType edgeActionType, SecurityUser user, boolean sendToEdge, Object... additionalInfo) { - logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo); + logEntityAction(tenantId, entityId, entity, customerId, actionType, user, null, additionalInfo); if (sendToEdge) { sendEntityAssignToCustomerNotificationMsg(tenantId, entityId, customerId, edgeActionType); @@ -134,7 +134,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS CustomerId customerId, EdgeId edgeId, E entity, ActionType actionType, SecurityUser user, Object... additionalInfo) { - logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo); + logEntityAction(tenantId, entityId, entity, customerId, actionType, user, null, additionalInfo); sendEntityAssignToEdgeNotificationMsg(tenantId, edgeId, entityId, edgeTypeByActionType(actionType)); } @@ -155,7 +155,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS Device device, Device oldDevice, ActionType actionType, SecurityUser user, Object... additionalInfo) { tbClusterService.onDeviceUpdated(device, oldDevice); - logEntityAction(tenantId, deviceId, device, customerId, actionType, user, additionalInfo); + logEntityAction(tenantId, deviceId, device, customerId, actionType, user, null, additionalInfo); } @Override @@ -172,19 +172,19 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS DeviceCredentials deviceCredentials, SecurityUser user) { tbClusterService.pushMsgToCore(new DeviceCredentialsUpdateNotificationMsg(tenantId, deviceCredentials.getDeviceId(), deviceCredentials), null); sendEntityNotificationMsg(tenantId, deviceId, EdgeEventActionType.CREDENTIALS_UPDATED); - logEntityAction(tenantId, deviceId, device, customerId, ActionType.CREDENTIALS_UPDATED, user, deviceCredentials); + logEntityAction(tenantId, deviceId, device, customerId, ActionType.CREDENTIALS_UPDATED, user, null, deviceCredentials); } @Override public void notifyAssignDeviceToTenant(TenantId tenantId, TenantId newTenantId, DeviceId deviceId, CustomerId customerId, Device device, Tenant tenant, SecurityUser user, Object... additionalInfo) { - logEntityAction(tenantId, deviceId, device, customerId, ActionType.ASSIGNED_TO_TENANT, user, additionalInfo); + logEntityAction(tenantId, deviceId, device, customerId, ActionType.ASSIGNED_TO_TENANT, user, null, additionalInfo); pushAssignedFromNotification(tenant, newTenantId, device); } @Override public void notifyCreateOrUpdateEntity(TenantId tenantId, I entityId, E entity, CustomerId customerId, ActionType actionType, SecurityUser user, Object... additionalInfo) { - logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo); + logEntityAction(tenantId, entityId, entity, customerId, actionType, user, null, additionalInfo); if (actionType == ActionType.UPDATED) { sendEntityNotificationMsg(tenantId, entityId, EdgeEventActionType.UPDATED); } @@ -218,7 +218,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS } tbClusterService.broadcastEntityStateChangeEvent(tenantId, edgeId, lifecycleEvent); - logEntityAction(tenantId, edgeId, edge, customerId, actionType, user, additionalInfo); + logEntityAction(tenantId, edgeId, edge, customerId, actionType, user, null, additionalInfo); //Send notification to edge if (edgeEventActionType != null) { @@ -228,17 +228,17 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS @Override public void notifyCreateOrUpdateAlarm(Alarm alarm, ActionType actionType, SecurityUser user, Object... additionalInfo) { - logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarm, alarm.getCustomerId(), actionType, user, additionalInfo); + logEntityAction(alarm.getTenantId(), alarm.getOriginator(), alarm, alarm.getCustomerId(), actionType, user, null, additionalInfo); sendEntityNotificationMsg(alarm.getTenantId(), alarm.getId(), edgeTypeByActionType(actionType)); } @Override public void notifyCreateOrUpdateOrDelete(TenantId tenantId, CustomerId customerId, I entityId, E entity, SecurityUser user, - ActionType actionType, boolean isSendMsg, Exception e, + ActionType actionType, boolean sendNotifyMsgToEdge, Exception e, Object... additionalInfo) { notifyEntity(tenantId, entityId, entity, customerId, actionType, user, e, additionalInfo); - if (isSendMsg) { + if (sendNotifyMsgToEdge) { sendEntityNotificationMsg(tenantId, entityId, edgeTypeByActionType(actionType)); } } @@ -263,11 +263,6 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS } } - private void logEntityAction(TenantId tenantId, I entityId, E entity, CustomerId customerId, - ActionType actionType, SecurityUser user, Object... additionalInfo) { - logEntityAction(tenantId, entityId, entity, customerId, actionType, user, null, additionalInfo); - } - private void logEntityAction(TenantId tenantId, I entityId, E entity, CustomerId customerId, ActionType actionType, SecurityUser user, Exception e, Object... additionalInfo) { if (user != null) { diff --git a/application/src/main/java/org/thingsboard/server/service/entitiy/TbNotificationEntityService.java b/application/src/main/java/org/thingsboard/server/service/entitiy/TbNotificationEntityService.java index 59ae1aca8e..49510a4738 100644 --- a/application/src/main/java/org/thingsboard/server/service/entitiy/TbNotificationEntityService.java +++ b/application/src/main/java/org/thingsboard/server/service/entitiy/TbNotificationEntityService.java @@ -54,8 +54,8 @@ public interface TbNotificationEntityService { CustomerId customerId, List relatedEdgeIds, SecurityUser user, String body, Object... additionalInfo); - void notifyDeleteRuleChane(TenantId tenantId, RuleChain ruleChain, - List relatedEdgeIds, SecurityUser user); + void notifyDeleteRuleChain(TenantId tenantId, RuleChain ruleChain, + List relatedEdgeIds, SecurityUser user); void notifySaveRuleChainMetaData(TenantId tenantId, RuleChain ruleChain, Object... others); @@ -95,7 +95,7 @@ public interface TbNotificationEntityService { void notifyCreateOrUpdateOrDelete(TenantId tenantId, CustomerId customerId, I entityId, E entity, SecurityUser user, - ActionType actionType, boolean isSendMsg, Exception e, + ActionType actionType, boolean sendNotifyMsgToEdge, Exception e, Object... additionalInfo); void notifyCreateOrUpdateOrDeleteRelation(TenantId tenantId, CustomerId customerId, diff --git a/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/DefaultTbRuleChainNotifyService.java b/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/DefaultTbRuleChainNotifyService.java index 833f10e21b..7291f77f8d 100644 --- a/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/DefaultTbRuleChainNotifyService.java +++ b/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/DefaultTbRuleChainNotifyService.java @@ -72,8 +72,6 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp TenantId tenantId = ruleChain.getTenantId(); RuleChainId ruleChainId = ruleChain.getId(); try { - - List referencingRuleNodes = ruleChainService.getReferencingRuleChainNodes(tenantId, ruleChainId); Set referencingRuleChainIds = referencingRuleNodes.stream().map(RuleNode::getRuleChainId).collect(Collectors.toSet()); @@ -94,16 +92,16 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp tbClusterService.broadcastEntityStateChangeEvent(tenantId, ruleChain.getId(), ComponentLifecycleEvent.DELETED); } - notificationEntityService.notifyDeleteRuleChane(tenantId, ruleChain, relatedEdgeIds, user); + notificationEntityService.notifyDeleteRuleChain(tenantId, ruleChain, relatedEdgeIds, user); } catch (Exception e) { notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, emptyId(EntityType.RULE_CHAIN), - null, user, ActionType.DELETED, false, e, ruleChainId.toString()); + null, user, ActionType.DELETED, false, e, ruleChainId.toString()); throw handleException(e); } } @Override - public RuleChain saveRuleChain(TenantId tenantId, DefaultRuleChainCreateRequest request, SecurityUser user) throws ThingsboardException { + public RuleChain saveDefaultByName(TenantId tenantId, DefaultRuleChainCreateRequest request, SecurityUser user) throws ThingsboardException { try { RuleChain savedRuleChain = installScripts.createDefaultRuleChain(tenantId, request.getName()); tbClusterService.broadcastEntityStateChangeEvent(tenantId, savedRuleChain.getId(), ComponentLifecycleEvent.CREATED); @@ -144,7 +142,7 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp return ruleChain; } catch (Exception e) { notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, emptyId(EntityType.RULE_CHAIN), - ruleChain, user, ActionType.UPDATED, false, e, ruleChainId.toString()); + ruleChain, user, ActionType.UPDATED, false, e, ruleChainId.toString()); throw handleException(e); } } @@ -153,24 +151,24 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp public RuleChainMetaData saveRuleChainMetaData(TenantId tenantId, RuleChain ruleChain, RuleChainMetaData ruleChainMetaData, boolean updateRelated, SecurityUser user) throws ThingsboardException { RuleChainId ruleChainId = ruleChain.getId(); + RuleChainId ruleChainMetaDataId = ruleChainMetaData.getRuleChainId(); try { - RuleChainUpdateResult result = ruleChainService.saveRuleChainMetaData(tenantId, ruleChainMetaData); checkNotNull(result.isSuccess() ? true : null); List updatedRuleChains; if (updateRelated && result.isSuccess()) { - updatedRuleChains = tbRuleChainService.updateRelatedRuleChains(tenantId, ruleChainMetaData.getRuleChainId(), result); + updatedRuleChains = tbRuleChainService.updateRelatedRuleChains(tenantId, ruleChainMetaDataId, result); } else { updatedRuleChains = Collections.emptyList(); } - RuleChainMetaData savedRuleChainMetaData = checkNotNull(ruleChainService.loadRuleChainMetaData(tenantId, ruleChainMetaData.getRuleChainId())); + RuleChainMetaData savedRuleChainMetaData = checkNotNull(ruleChainService.loadRuleChainMetaData(tenantId, ruleChainMetaDataId)); if (RuleChainType.CORE.equals(ruleChain.getType())) { - tbClusterService.broadcastEntityStateChangeEvent(ruleChain.getTenantId(), ruleChain.getId(), ComponentLifecycleEvent.UPDATED); + tbClusterService.broadcastEntityStateChangeEvent(tenantId, ruleChainId, ComponentLifecycleEvent.UPDATED); updatedRuleChains.forEach(updatedRuleChain -> { - tbClusterService.broadcastEntityStateChangeEvent(updatedRuleChain.getTenantId(), updatedRuleChain.getId(), ComponentLifecycleEvent.UPDATED); + tbClusterService.broadcastEntityStateChangeEvent(tenantId, updatedRuleChain.getId(), ComponentLifecycleEvent.UPDATED); }); } @@ -191,56 +189,51 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp return savedRuleChainMetaData; } catch (Exception e) { notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, emptyId(EntityType.RULE_CHAIN), - null, user, ActionType.ADDED, false, e, ruleChainMetaData); + null, user, ActionType.ADDED, false, e, ruleChainMetaData); throw handleException(e); } } @Override - public RuleChain assignRuleChainToEdge(TenantId tenantId, RuleChainId ruleChainId, Edge edge, SecurityUser user) throws ThingsboardException { + public RuleChain assignUnassignRuleChainToEdge(TenantId tenantId, RuleChain ruleChain, Edge edge, ActionType actionType, SecurityUser user) throws ThingsboardException { + RuleChainId ruleChainId = ruleChain.getId(); try { RuleChain savedRuleChain = checkNotNull(ruleChainService.assignRuleChainToEdge(tenantId, ruleChainId, edge.getId())); notificationEntityService.notifyAssignOrUnassignEntityToEdge(tenantId, ruleChainId, null, edge.getId(), - savedRuleChain, ActionType.ASSIGNED_TO_EDGE, + savedRuleChain, actionType, user, ruleChainId.toString(), edge.getId().toString(), edge.getName()); return savedRuleChain; } catch (Exception e) { notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, emptyId(EntityType.RULE_CHAIN), - null, user, ActionType.ASSIGNED_TO_EDGE, false, e, ruleChainId.toString(), edge.getId().toString()); + null, user, actionType, false, e, ruleChainId.toString(), edge.getId().toString()); throw handleException(e); } } @Override - public RuleChain unassignRuleChainFromEdge(TenantId tenantId, RuleChain ruleChain, Edge edge, SecurityUser user) throws ThingsboardException { + public RuleChain setEdgeTemplateRootRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException { RuleChainId ruleChainId = ruleChain.getId(); - EdgeId edgeId = edge.getId(); try { - RuleChain savedRuleChain = checkNotNull(ruleChainService.unassignRuleChainFromEdge(tenantId, ruleChainId, edgeId, false)); - notificationEntityService.notifyAssignOrUnassignEntityToEdge(tenantId, ruleChainId, - null, edge.getId(), - savedRuleChain, ActionType.UNASSIGNED_FROM_EDGE, - user, ruleChainId.toString(), edge.getId().toString(), edge.getName()); - return savedRuleChain; + ruleChainService.setEdgeTemplateRootRuleChain(tenantId, ruleChainId); + + notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, ruleChainId, + ruleChain, user, ActionType.UPDATED, false, null); + return ruleChain; } catch (Exception e) { notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, emptyId(EntityType.RULE_CHAIN), - null, user, ActionType.UNASSIGNED_FROM_EDGE, false, e, ruleChainId.toString(), edge.getId().toString()); + null, user, ActionType.UPDATED, false, e, ruleChainId.toString()); throw handleException(e); } } @Override - public RuleChain setEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user, boolean isSetEdgeTemplateRootRuleChain) throws ThingsboardException { + public RuleChain setAutoAssignToEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException { RuleChainId ruleChainId = ruleChain.getId(); try { - if (isSetEdgeTemplateRootRuleChain) { - ruleChainService.setEdgeTemplateRootRuleChain(tenantId, ruleChainId); - } else { - ruleChainService.setAutoAssignToEdgeRuleChain(tenantId, ruleChainId); - } + ruleChainService.setAutoAssignToEdgeRuleChain(tenantId, ruleChainId); - notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, ruleChainId, + notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, ruleChainId, ruleChain, user, ActionType.UPDATED, false, null); return ruleChain; } catch (Exception e) { @@ -255,7 +248,7 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp RuleChainId ruleChainId = ruleChain.getId(); try { ruleChainService.unsetAutoAssignToEdgeRuleChain(tenantId, ruleChainId); - notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, ruleChainId, + notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, ruleChainId, ruleChain, user, ActionType.UPDATED, false, null); return ruleChain; } catch (Exception e) { diff --git a/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/TbRuleChainNotifyService.java b/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/TbRuleChainNotifyService.java index b4cf9d5097..a6f5011507 100644 --- a/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/TbRuleChainNotifyService.java +++ b/application/src/main/java/org/thingsboard/server/service/entitiy/ruleChain/TbRuleChainNotifyService.java @@ -15,9 +15,9 @@ */ package org.thingsboard.server.service.entitiy.ruleChain; +import org.thingsboard.server.common.data.audit.ActionType; import org.thingsboard.server.common.data.edge.Edge; import org.thingsboard.server.common.data.exception.ThingsboardException; -import org.thingsboard.server.common.data.id.RuleChainId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.rule.DefaultRuleChainCreateRequest; import org.thingsboard.server.common.data.rule.RuleChain; @@ -27,18 +27,19 @@ import org.thingsboard.server.service.security.model.SecurityUser; public interface TbRuleChainNotifyService extends SimpleTbEntityService { - RuleChain saveRuleChain(TenantId tenantId, DefaultRuleChainCreateRequest request, SecurityUser user) throws ThingsboardException; + RuleChain saveDefaultByName(TenantId tenantId, DefaultRuleChainCreateRequest request, SecurityUser user) throws ThingsboardException; RuleChain setRootRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException; RuleChainMetaData saveRuleChainMetaData(TenantId tenantId, RuleChain ruleChain, RuleChainMetaData ruleChainMetaData, boolean updateRelated, SecurityUser user) throws ThingsboardException; - RuleChain assignRuleChainToEdge(TenantId tenantId, RuleChainId ruleChainId, Edge edge, SecurityUser user) throws ThingsboardException; + RuleChain assignUnassignRuleChainToEdge(TenantId tenantId, RuleChain ruleChain, Edge edge, ActionType actionType, + SecurityUser user) throws ThingsboardException; - RuleChain unassignRuleChainFromEdge(TenantId tenantId, RuleChain ruleChain, Edge edge, SecurityUser user) throws ThingsboardException; + RuleChain setEdgeTemplateRootRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException; - RuleChain setEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user, boolean isSetEdgeTemplateRootRuleChain) throws ThingsboardException; + RuleChain setAutoAssignToEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException; RuleChain unsetAutoAssignToEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException; }