Skip to content

Commit 162e793

Browse files
committed
refactor: centralize time-series deletion skip logic and avoid raw string literals
1 parent 0ba1cc4 commit 162e793

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

openmetadata-service/src/main/java/org/openmetadata/service/Entity.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,11 +744,15 @@ public static boolean isTimeSeriesEntity(String entityType) {
744744
return ENTITY_TS_REPOSITORY_MAP.containsKey(entityType);
745745
}
746746

747+
public static boolean shouldSkipTimeSeriesDelete(String entityType) {
748+
return entityType.equalsIgnoreCase(Entity.TEST_CASE_RESOLUTION_STATUS)
749+
|| entityType.equalsIgnoreCase(Entity.TEST_CASE_RESULT);
750+
}
751+
747752
public static void deleteEntity(
748753
String updatedBy, String entityType, UUID entityId, boolean recursive, boolean hardDelete) {
749754
if (isTimeSeriesEntity(entityType)) {
750-
if (entityType.equalsIgnoreCase(Entity.TEST_CASE_RESOLUTION_STATUS)
751-
|| entityType.equalsIgnoreCase(Entity.TEST_CASE_RESULT)) {
755+
if (shouldSkipTimeSeriesDelete(entityType)) {
752756
LOG.debug(
753757
"Skipping delete for time-series entity {} with id {} (handled via cleanup)",
754758
entityType,

openmetadata-service/src/main/java/org/openmetadata/service/apps/bundles/dataRetention/DataRetention.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ private void cleanOrphanedTestCaseResolutionStatusRelationships() {
263263
collectionDAO
264264
.relationshipDAO()
265265
.deleteOrphanedRelationships(
266-
Entity.TEST_CASE, Entity.TEST_CASE_RESOLUTION_STATUS, "test_case"));
266+
Entity.TEST_CASE,
267+
Entity.TEST_CASE_RESOLUTION_STATUS,
268+
collectionDAO.testCaseDAO().getTableName()));
267269
LOG.info("TestCaseResolutionStatus orphaned relationships cleanup complete.");
268270
}
269271

openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,8 +4372,7 @@ protected void batchDeleteChildren(
43724372
private void processDeletionBatch(
43734373
List<UUID> entityIds, String entityType, boolean hardDelete, String updatedBy) {
43744374
if (Entity.isTimeSeriesEntity(entityType)) {
4375-
if (entityType.equalsIgnoreCase(Entity.TEST_CASE_RESOLUTION_STATUS)
4376-
|| entityType.equalsIgnoreCase(Entity.TEST_CASE_RESULT)) {
4375+
if (Entity.shouldSkipTimeSeriesDelete(entityType)) {
43774376
LOG.debug(
43784377
"Skipping batch delete for time-series entity {} (handled via cleanup)", entityType);
43794378
return;

0 commit comments

Comments
 (0)