From da5159194070e9c4ea5a22cde914e37e5acb9884 Mon Sep 17 00:00:00 2001 From: mohitdeuex Date: Wed, 20 Dec 2023 15:37:24 +0530 Subject: [PATCH 1/2] Fix Charts Tasks for description update --- .../service/jdbi3/DashboardRepository.java | 10 ++-------- .../org/openmetadata/service/jdbi3/FeedRepository.java | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java index 1a43d4b2d0f8..327c7d2b8fea 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java @@ -16,7 +16,6 @@ import static org.openmetadata.common.utils.CommonUtil.listOrEmpty; import static org.openmetadata.schema.type.Include.ALL; import static org.openmetadata.service.Entity.DASHBOARD; -import static org.openmetadata.service.Entity.FIELD_DESCRIPTION; import java.util.ArrayList; import java.util.Collections; @@ -29,7 +28,6 @@ import org.openmetadata.schema.type.EntityReference; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.Relationship; -import org.openmetadata.schema.type.TaskType; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.CatalogExceptionMessage; import org.openmetadata.service.jdbi3.FeedRepository.TaskWorkflow; @@ -67,12 +65,6 @@ public void setFullyQualifiedName(Dashboard dashboard) { public TaskWorkflow getTaskWorkflow(ThreadContext threadContext) { EntityLink entityLink = threadContext.getAbout(); if (entityLink.getFieldName().equals("charts")) { - TaskType taskType = threadContext.getThread().getTask().getType(); - if (!entityLink.getFieldName().equals(FIELD_DESCRIPTION)) { - // Only description field can be updated - throw new IllegalArgumentException( - CatalogExceptionMessage.invalidFieldForTask(entityLink.getFieldName(), taskType)); - } return new ChartDescriptionTaskWorkflow(threadContext); } return super.getTaskWorkflow(threadContext); @@ -93,6 +85,8 @@ static class ChartDescriptionTaskWorkflow extends DescriptionTaskWorkflow { new IllegalArgumentException( CatalogExceptionMessage.invalidFieldName("chart", chartName))); Chart chart = Entity.getEntity(chartReference, "", ALL); + threadContext.setAbout( + new EntityLink(Entity.CHART, chart.getFullyQualifiedName(), "description", null, null)); threadContext.setAboutEntity(chart); } } diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java index 2039ac456720..ba7c024a14ee 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/FeedRepository.java @@ -136,7 +136,7 @@ public int getNextTaskId() { public static class ThreadContext { @Getter protected final Thread thread; - @Getter protected final EntityLink about; + @Getter @Setter protected EntityLink about; @Getter @Setter protected EntityInterface aboutEntity; @Getter private final EntityReference createdBy; From 4ee95c6167cf154f5f6468e6cae130fe4335a09a Mon Sep 17 00:00:00 2001 From: mohitdeuex Date: Wed, 20 Dec 2023 19:27:58 +0530 Subject: [PATCH 2/2] Fix Charts Tasks for description update --- .../service/jdbi3/DashboardRepository.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java index 327c7d2b8fea..89b984490440 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DashboardRepository.java @@ -16,6 +16,8 @@ import static org.openmetadata.common.utils.CommonUtil.listOrEmpty; import static org.openmetadata.schema.type.Include.ALL; import static org.openmetadata.service.Entity.DASHBOARD; +import static org.openmetadata.service.Entity.FIELD_DESCRIPTION; +import static org.openmetadata.service.Entity.FIELD_TAGS; import java.util.ArrayList; import java.util.Collections; @@ -28,6 +30,7 @@ import org.openmetadata.schema.type.EntityReference; import org.openmetadata.schema.type.Include; import org.openmetadata.schema.type.Relationship; +import org.openmetadata.schema.type.TaskType; import org.openmetadata.service.Entity; import org.openmetadata.service.exception.CatalogExceptionMessage; import org.openmetadata.service.jdbi3.FeedRepository.TaskWorkflow; @@ -65,14 +68,20 @@ public void setFullyQualifiedName(Dashboard dashboard) { public TaskWorkflow getTaskWorkflow(ThreadContext threadContext) { EntityLink entityLink = threadContext.getAbout(); if (entityLink.getFieldName().equals("charts")) { - return new ChartDescriptionTaskWorkflow(threadContext); + TaskType taskType = threadContext.getThread().getTask().getType(); + if (entityLink.getArrayFieldValue() != null) { + return new ChartDescriptionAndTagTaskWorkflow(threadContext); + } + throw new IllegalArgumentException( + CatalogExceptionMessage.invalidFieldForTask(entityLink.getFieldName(), taskType)); } return super.getTaskWorkflow(threadContext); } - static class ChartDescriptionTaskWorkflow extends DescriptionTaskWorkflow { - ChartDescriptionTaskWorkflow(ThreadContext threadContext) { + static class ChartDescriptionAndTagTaskWorkflow extends DescriptionTaskWorkflow { + ChartDescriptionAndTagTaskWorkflow(ThreadContext threadContext) { super(threadContext); + EntityLink entityLink = threadContext.getAbout(); Dashboard dashboard = Entity.getEntity(DASHBOARD, threadContext.getAboutEntity().getId(), "charts", ALL); String chartName = threadContext.getAbout().getArrayFieldName(); @@ -85,8 +94,14 @@ static class ChartDescriptionTaskWorkflow extends DescriptionTaskWorkflow { new IllegalArgumentException( CatalogExceptionMessage.invalidFieldName("chart", chartName))); Chart chart = Entity.getEntity(chartReference, "", ALL); - threadContext.setAbout( - new EntityLink(Entity.CHART, chart.getFullyQualifiedName(), "description", null, null)); + if (entityLink.getArrayFieldValue().equals(FIELD_DESCRIPTION)) { + threadContext.setAbout( + new EntityLink( + Entity.CHART, chart.getFullyQualifiedName(), FIELD_DESCRIPTION, null, null)); + } else if (entityLink.getArrayFieldValue().equals(FIELD_TAGS)) { + threadContext.setAbout( + new EntityLink(Entity.CHART, chart.getFullyQualifiedName(), FIELD_TAGS, null, null)); + } threadContext.setAboutEntity(chart); } }