fixed entity relation cleanup method

This commit is contained in:
dashevchenko 2025-03-13 16:37:28 +02:00
parent 4cb8b54a2a
commit 46262e8709
2 changed files with 7 additions and 0 deletions

View File

@ -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) {

View File

@ -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));
}
}