Skip to content

Commit

Permalink
Fix Charts Tasks for description update
Browse files Browse the repository at this point in the history
  • Loading branch information
mohityadav766 committed Dec 20, 2023
1 parent da51591 commit 4ee95c6
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 4ee95c6

Please sign in to comment.