mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-24 22:18:41 +00:00
Delete Tasks related to entity when the entity is deleted (#11660)
* Delete Tasks related to entity when the entity is deleted * Delete all conversation related to entity only when its permanantly deleted * renamed function name deleteTasksForRelatedEntity to deleteAllConversationsRelatedToEntity --------- Co-authored-by: Himank Mehta <himankmehta@Himanks-MacBook-Air.local>
This commit is contained in:
parent
5bd1b09402
commit
ef2869cd9a
@ -174,6 +174,7 @@ public class ChangeEventHandler implements EventHandler {
|
||||
EntityReference entityReference = entityInterface.getEntityReference();
|
||||
String entityType = entityReference.getType();
|
||||
String entityFQN = entityReference.getFullyQualifiedName();
|
||||
deleteAllConversationsRelatedToEntity(entityInterface);
|
||||
return getChangeEvent(updateBy, ENTITY_DELETED, entityType, entityInterface)
|
||||
.withPreviousVersion(entityInterface.getVersion())
|
||||
.withEntity(entityInterface)
|
||||
@ -275,6 +276,15 @@ public class ChangeEventHandler implements EventHandler {
|
||||
.withMessage(message);
|
||||
}
|
||||
|
||||
private void deleteAllConversationsRelatedToEntity(EntityInterface entityInterface) {
|
||||
String entityId = entityInterface.getId().toString();
|
||||
List<String> threadIds = dao.feedDAO().findByEntityId(entityId);
|
||||
for (String threadId : threadIds) {
|
||||
dao.relationshipDAO().deleteAll(threadId, Entity.THREAD);
|
||||
dao.feedDAO().delete(threadId);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
@ -1095,6 +1095,9 @@ public interface CollectionDAO {
|
||||
@Bind("relation") int relation,
|
||||
@Define("condition") String condition);
|
||||
|
||||
@SqlQuery("select id from thread_entity where entityId = :entityId")
|
||||
List<String> findByEntityId(@Bind("entityId") String entityId);
|
||||
|
||||
class CountFieldMapper implements RowMapper<List<String>> {
|
||||
@Override
|
||||
public List<String> map(ResultSet rs, StatementContext ctx) throws SQLException {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user