Fix entities deletion task reprocessing
This commit is contained in:
parent
d88aa95bfc
commit
8d34a2003e
@ -50,6 +50,9 @@ public abstract class RuleEngineComponentActor<T extends EntityId, P extends Com
|
||||
}
|
||||
|
||||
private void processNotificationRule(ComponentLifecycleEvent event, Throwable e) {
|
||||
if (processor == null) {
|
||||
return;
|
||||
}
|
||||
systemContext.getNotificationRuleProcessor().process(RuleEngineComponentLifecycleEventTrigger.builder()
|
||||
.tenantId(tenantId)
|
||||
.ruleChainId(getRuleChainId())
|
||||
|
||||
@ -155,6 +155,9 @@ public class BaseResourceService extends AbstractCachedEntityService<ResourceInf
|
||||
resourceValidator.validateDelete(tenantId, resourceId);
|
||||
}
|
||||
TbResource resource = findResourceById(tenantId, resourceId);
|
||||
if (resource == null) {
|
||||
return;
|
||||
}
|
||||
resourceDao.removeById(tenantId, resourceId.getId());
|
||||
eventPublisher.publishEvent(DeleteEntityEvent.builder().tenantId(tenantId).entity(resource).entityId(resourceId).build());
|
||||
}
|
||||
|
||||
@ -433,19 +433,20 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
|
||||
public void deleteRuleChainById(TenantId tenantId, RuleChainId ruleChainId) {
|
||||
Validator.validateId(ruleChainId, "Incorrect rule chain id for delete request.");
|
||||
RuleChain ruleChain = ruleChainDao.findById(tenantId, ruleChainId.getId());
|
||||
if (ruleChain == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<RuleNode> referencingRuleNodes = getReferencingRuleChainNodes(tenantId, ruleChainId);
|
||||
Set<RuleChainId> referencingRuleChainIds = referencingRuleNodes.stream().map(RuleNode::getRuleChainId).collect(Collectors.toSet());
|
||||
|
||||
if (ruleChain != null) {
|
||||
if (ruleChain.isRoot()) {
|
||||
throw new DataValidationException("Deletion of Root Tenant Rule Chain is prohibited!");
|
||||
}
|
||||
if (RuleChainType.EDGE.equals(ruleChain.getType())) {
|
||||
for (Edge edge : new PageDataIterable<>(link -> edgeService.findEdgesByTenantIdAndEntityId(tenantId, ruleChainId, link), DEFAULT_PAGE_SIZE)) {
|
||||
if (edge.getRootRuleChainId() != null && edge.getRootRuleChainId().equals(ruleChainId)) {
|
||||
throw new DataValidationException("Can't delete rule chain that is root for edge [" + edge.getName() + "]. Please assign another root rule chain first to the edge!");
|
||||
}
|
||||
if (ruleChain.isRoot()) {
|
||||
throw new DataValidationException("Deletion of Root Tenant Rule Chain is prohibited!");
|
||||
}
|
||||
if (RuleChainType.EDGE.equals(ruleChain.getType())) {
|
||||
for (Edge edge : new PageDataIterable<>(link -> edgeService.findEdgesByTenantIdAndEntityId(tenantId, ruleChainId, link), DEFAULT_PAGE_SIZE)) {
|
||||
if (edge.getRootRuleChainId() != null && edge.getRootRuleChainId().equals(ruleChainId)) {
|
||||
throw new DataValidationException("Can't delete rule chain that is root for edge [" + edge.getName() + "]. Please assign another root rule chain first to the edge!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -457,6 +458,9 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
|
||||
public void deleteEntity(TenantId tenantId, EntityId id, boolean force) {
|
||||
if (force) {
|
||||
RuleChain ruleChain = findRuleChainById(tenantId, (RuleChainId) id);
|
||||
if (ruleChain == null) {
|
||||
return;
|
||||
}
|
||||
checkRuleNodesAndDelete(tenantId, ruleChain, null);
|
||||
} else {
|
||||
deleteRuleChainById(tenantId, (RuleChainId) id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user