Browse Source
Merge pull request #12919 from dashevchenko/entityDeletionFix
Fixed entity relation cleanup method
pull/12936/head
Viacheslav Klimov
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
0 deletions
-
application/src/test/java/org/thingsboard/server/service/entitiy/EntityServiceTest.java
-
dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java
|
|
|
@ -282,6 +282,10 @@ public class EntityServiceTest extends AbstractControllerTest { |
|
|
|
data.forEach(entityData -> Assert.assertNotNull(entityData.getLatest().get(EntityKeyType.ENTITY_FIELD).get("phone"))); |
|
|
|
|
|
|
|
countByQueryAndCheck(query, 5); |
|
|
|
|
|
|
|
// delete user
|
|
|
|
userService.deleteUser(tenantId, users.get(0)); |
|
|
|
countByQueryAndCheck(query, 4); |
|
|
|
} |
|
|
|
|
|
|
|
private void createTestUserRelations(TenantId tenantId, List<User> users) { |
|
|
|
|
|
|
|
@ -236,6 +236,7 @@ public class BaseRelationService implements RelationService { |
|
|
|
return Futures.transform(future, deletedEvent -> { |
|
|
|
if (deletedEvent != null) { |
|
|
|
handleEvictEvent(EntityRelationEvent.from(deletedEvent)); |
|
|
|
eventPublisher.publishEvent(new RelationActionEvent(tenantId, deletedEvent, ActionType.RELATION_DELETED)); |
|
|
|
} |
|
|
|
return deletedEvent != null; |
|
|
|
}, MoreExecutors.directExecutor()); |
|
|
|
@ -267,6 +268,7 @@ public class BaseRelationService implements RelationService { |
|
|
|
|
|
|
|
for (EntityRelation relation : inboundRelations) { |
|
|
|
eventPublisher.publishEvent(EntityRelationEvent.from(relation)); |
|
|
|
eventPublisher.publishEvent(new RelationActionEvent(tenantId, relation, ActionType.RELATION_DELETED)); |
|
|
|
} |
|
|
|
|
|
|
|
List<EntityRelation> outboundRelations; |
|
|
|
@ -278,6 +280,7 @@ public class BaseRelationService implements RelationService { |
|
|
|
|
|
|
|
for (EntityRelation relation : outboundRelations) { |
|
|
|
eventPublisher.publishEvent(EntityRelationEvent.from(relation)); |
|
|
|
eventPublisher.publishEvent(new RelationActionEvent(tenantId, relation, ActionType.RELATION_DELETED)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|