mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 17:34:41 +00:00
Fix Deletion of Entities (#20129)
This commit is contained in:
parent
c65a504ffd
commit
97bce917be
@ -369,13 +369,12 @@ public class AppRepository extends EntityRepository<App> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup(App app) {
|
protected void entitySpecificCleanup(App app) {
|
||||||
// Remove the Pipelines for Application
|
// Remove the Pipelines for Application
|
||||||
List<EntityReference> pipelineRef = getIngestionPipelines(app);
|
List<EntityReference> pipelineRef = getIngestionPipelines(app);
|
||||||
pipelineRef.forEach(
|
pipelineRef.forEach(
|
||||||
reference ->
|
reference ->
|
||||||
Entity.deleteEntity("admin", reference.getType(), reference.getId(), true, true));
|
Entity.deleteEntity("admin", reference.getType(), reference.getId(), true, true));
|
||||||
super.cleanup(app);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1474,15 +1474,22 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
protected final void cleanup(T entityInterface) {
|
||||||
protected void cleanup(T entityInterface) {
|
Entity.getJdbi()
|
||||||
|
.inTransaction(
|
||||||
|
handle -> {
|
||||||
|
// Perform Entity Specific Cleanup
|
||||||
|
entitySpecificCleanup(entityInterface);
|
||||||
|
|
||||||
UUID id = entityInterface.getId();
|
UUID id = entityInterface.getId();
|
||||||
|
|
||||||
// Delete all the relationships to other entities
|
// Delete all the relationships to other entities
|
||||||
daoCollection.relationshipDAO().deleteAll(id, entityType);
|
daoCollection.relationshipDAO().deleteAll(id, entityType);
|
||||||
|
|
||||||
// Delete all the field relationships to other entities
|
// Delete all the field relationships to other entities
|
||||||
daoCollection.fieldRelationshipDAO().deleteAllByPrefix(entityInterface.getFullyQualifiedName());
|
daoCollection
|
||||||
|
.fieldRelationshipDAO()
|
||||||
|
.deleteAllByPrefix(entityInterface.getFullyQualifiedName());
|
||||||
|
|
||||||
// Delete all the extensions of entity
|
// Delete all the extensions of entity
|
||||||
daoCollection.entityExtensionDAO().deleteAll(id);
|
daoCollection.entityExtensionDAO().deleteAll(id);
|
||||||
@ -1493,7 +1500,9 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
.deleteTagLabelsByTargetPrefix(entityInterface.getFullyQualifiedName());
|
.deleteTagLabelsByTargetPrefix(entityInterface.getFullyQualifiedName());
|
||||||
|
|
||||||
// when the glossary and tag is deleted, delete its usage
|
// when the glossary and tag is deleted, delete its usage
|
||||||
daoCollection.tagUsageDAO().deleteTagLabelsByFqn(entityInterface.getFullyQualifiedName());
|
daoCollection
|
||||||
|
.tagUsageDAO()
|
||||||
|
.deleteTagLabelsByFqn(entityInterface.getFullyQualifiedName());
|
||||||
// Delete all the usage data
|
// Delete all the usage data
|
||||||
daoCollection.usageDAO().delete(id);
|
daoCollection.usageDAO().delete(id);
|
||||||
|
|
||||||
@ -1508,8 +1517,13 @@ public abstract class EntityRepository<T extends EntityInterface> {
|
|||||||
|
|
||||||
// Finally, delete the entity
|
// Finally, delete the entity
|
||||||
dao.delete(id);
|
dao.delete(id);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void entitySpecificCleanup(T entityInterface) {}
|
||||||
|
|
||||||
private void invalidate(T entity) {
|
private void invalidate(T entity) {
|
||||||
CACHE_WITH_ID.invalidate(new ImmutablePair<>(entityType, entity.getId()));
|
CACHE_WITH_ID.invalidate(new ImmutablePair<>(entityType, entity.getId()));
|
||||||
CACHE_WITH_NAME.invalidate(new ImmutablePair<>(entityType, entity.getFullyQualifiedName()));
|
CACHE_WITH_NAME.invalidate(new ImmutablePair<>(entityType, entity.getFullyQualifiedName()));
|
||||||
|
@ -552,7 +552,6 @@ public class FeedRepository {
|
|||||||
dao.feedDAO().delete(id);
|
dao.feedDAO().delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
|
||||||
public void deleteByAbout(UUID entityId) {
|
public void deleteByAbout(UUID entityId) {
|
||||||
List<String> threadIds = listOrEmpty(dao.feedDAO().findByEntityId(entityId.toString()));
|
List<String> threadIds = listOrEmpty(dao.feedDAO().findByEntityId(entityId.toString()));
|
||||||
for (String threadId : threadIds) {
|
for (String threadId : threadIds) {
|
||||||
|
@ -305,7 +305,7 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup(Pipeline pipeline) {
|
protected void entitySpecificCleanup(Pipeline pipeline) {
|
||||||
// When a pipeline is removed , the linege needs to be removed
|
// When a pipeline is removed , the linege needs to be removed
|
||||||
daoCollection
|
daoCollection
|
||||||
.relationshipDAO()
|
.relationshipDAO()
|
||||||
@ -313,7 +313,6 @@ public class PipelineRepository extends EntityRepository<Pipeline> {
|
|||||||
pipeline.getId(),
|
pipeline.getId(),
|
||||||
LineageDetails.Source.PIPELINE_LINEAGE.value(),
|
LineageDetails.Source.PIPELINE_LINEAGE.value(),
|
||||||
Relationship.UPSTREAM.ordinal());
|
Relationship.UPSTREAM.ordinal());
|
||||||
super.cleanup(pipeline);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +72,7 @@ public class StoredProcedureRepository extends EntityRepository<StoredProcedure>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup(StoredProcedure storedProcedure) {
|
protected void entitySpecificCleanup(StoredProcedure storedProcedure) {
|
||||||
// When a pipeline is removed , the linege needs to be removed
|
// When a pipeline is removed , the linege needs to be removed
|
||||||
daoCollection
|
daoCollection
|
||||||
.relationshipDAO()
|
.relationshipDAO()
|
||||||
@ -80,7 +80,6 @@ public class StoredProcedureRepository extends EntityRepository<StoredProcedure>
|
|||||||
storedProcedure.getId(),
|
storedProcedure.getId(),
|
||||||
LineageDetails.Source.QUERY_LINEAGE.value(),
|
LineageDetails.Source.QUERY_LINEAGE.value(),
|
||||||
Relationship.UPSTREAM.ordinal());
|
Relationship.UPSTREAM.ordinal());
|
||||||
super.cleanup(storedProcedure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -295,7 +295,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup(Team team) {
|
protected void entitySpecificCleanup(Team team) {
|
||||||
// When a team is deleted, if the children team don't have another parent, set Organization as
|
// When a team is deleted, if the children team don't have another parent, set Organization as
|
||||||
// the parent
|
// the parent
|
||||||
for (EntityReference child : listOrEmpty(team.getChildren())) {
|
for (EntityReference child : listOrEmpty(team.getChildren())) {
|
||||||
@ -308,7 +308,6 @@ public class TeamRepository extends EntityRepository<Team> {
|
|||||||
LOG.info("Moving parent of team " + childTeam.getId() + " to organization");
|
LOG.info("Moving parent of team " + childTeam.getId() + " to organization");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.cleanup(team);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -368,10 +368,8 @@ public class TestCaseRepository extends EntityRepository<TestCase> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
|
||||||
@Override
|
@Override
|
||||||
protected void cleanup(TestCase entityInterface) {
|
protected void entitySpecificCleanup(TestCase entityInterface) {
|
||||||
super.cleanup(entityInterface);
|
|
||||||
deleteAllTestCaseResults(entityInterface.getFullyQualifiedName());
|
deleteAllTestCaseResults(entityInterface.getFullyQualifiedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user