refactoring: RuleChainController comments1
This commit is contained in:
parent
a778305b03
commit
a6a58a3256
@ -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)",
|
||||
|
||||
@ -77,7 +77,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
|
||||
CustomerId customerId, ActionType actionType,
|
||||
List<EdgeId> 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<EdgeId> 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<EdgeId> 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 <E extends HasName, I extends EntityId> 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 <E extends HasName, I extends EntityId> 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 <E extends HasName, I extends EntityId> 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 <E extends HasName, I extends EntityId> void logEntityAction(TenantId tenantId, I entityId, E entity, CustomerId customerId,
|
||||
ActionType actionType, SecurityUser user, Exception e, Object... additionalInfo) {
|
||||
if (user != null) {
|
||||
|
||||
@ -54,7 +54,7 @@ public interface TbNotificationEntityService {
|
||||
CustomerId customerId, List<EdgeId> relatedEdgeIds,
|
||||
SecurityUser user, String body, Object... additionalInfo);
|
||||
|
||||
void notifyDeleteRuleChane(TenantId tenantId, RuleChain ruleChain,
|
||||
void notifyDeleteRuleChain(TenantId tenantId, RuleChain ruleChain,
|
||||
List<EdgeId> relatedEdgeIds, SecurityUser user);
|
||||
|
||||
void notifySaveRuleChainMetaData(TenantId tenantId, RuleChain ruleChain, Object... others);
|
||||
@ -95,7 +95,7 @@ public interface TbNotificationEntityService {
|
||||
|
||||
<E extends HasName, I extends EntityId> 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,
|
||||
|
||||
@ -72,8 +72,6 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp
|
||||
TenantId tenantId = ruleChain.getTenantId();
|
||||
RuleChainId ruleChainId = ruleChain.getId();
|
||||
try {
|
||||
|
||||
|
||||
List<RuleNode> referencingRuleNodes = ruleChainService.getReferencingRuleChainNodes(tenantId, ruleChainId);
|
||||
|
||||
Set<RuleChainId> referencingRuleChainIds = referencingRuleNodes.stream().map(RuleNode::getRuleChainId).collect(Collectors.toSet());
|
||||
@ -94,7 +92,7 @@ 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());
|
||||
@ -103,7 +101,7 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp
|
||||
}
|
||||
|
||||
@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);
|
||||
@ -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<RuleChain> 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);
|
||||
});
|
||||
}
|
||||
|
||||
@ -197,48 +195,43 @@ public class DefaultTbRuleChainNotifyService extends AbstractTbEntityService imp
|
||||
}
|
||||
|
||||
@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 {
|
||||
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;
|
||||
} catch (Exception e) {
|
||||
notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, emptyId(EntityType.RULE_CHAIN),
|
||||
null, user, ActionType.UNASSIGNED_FROM_EDGE, false, e, ruleChainId.toString(), edge.getId().toString());
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleChain setEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user, boolean isSetEdgeTemplateRootRuleChain) throws ThingsboardException {
|
||||
public RuleChain setEdgeTemplateRootRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException {
|
||||
RuleChainId ruleChainId = ruleChain.getId();
|
||||
try {
|
||||
if (isSetEdgeTemplateRootRuleChain) {
|
||||
ruleChainService.setEdgeTemplateRootRuleChain(tenantId, ruleChainId);
|
||||
} else {
|
||||
ruleChainService.setAutoAssignToEdgeRuleChain(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.UPDATED, false, e, ruleChainId.toString());
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleChain setAutoAssignToEdgeRuleChain(TenantId tenantId, RuleChain ruleChain, SecurityUser user) throws ThingsboardException {
|
||||
RuleChainId ruleChainId = ruleChain.getId();
|
||||
try {
|
||||
ruleChainService.setAutoAssignToEdgeRuleChain(tenantId, ruleChainId);
|
||||
|
||||
notificationEntityService.notifyCreateOrUpdateOrDelete(tenantId, null, ruleChainId,
|
||||
ruleChain, user, ActionType.UPDATED, false, null);
|
||||
|
||||
@ -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> {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user