fix(ui) Display glossary term name in analytics page properly (#7128)

This commit is contained in:
Chris Collins 2023-01-24 19:58:13 -05:00 committed by GitHub
parent af3fa6f22d
commit ea7b2abca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -180,7 +180,7 @@ public final class GetChartsResolver implements DataFetcher<List<AnalyticsChartG
ImmutableList.of("glossaryTerms.keyword"), Collections.emptyMap(),
ImmutableMap.of("removed", ImmutableList.of("true")), Optional.empty(), false);
AnalyticsUtil.hydrateDisplayNameForBars(_entityClient, entitiesPerTerm, Constants.GLOSSARY_TERM_ENTITY_NAME,
ImmutableSet.of(Constants.GLOSSARY_TERM_KEY_ASPECT_NAME), AnalyticsUtil::getTermName, authentication);
ImmutableSet.of(Constants.GLOSSARY_TERM_KEY_ASPECT_NAME, Constants.GLOSSARY_TERM_INFO_ASPECT_NAME), AnalyticsUtil::getTermName, authentication);
if (!entitiesPerTerm.isEmpty()) {
charts.add(BarChart.builder().setTitle("Entities per Term").setBars(entitiesPerTerm).build());
}

View File

@ -107,7 +107,7 @@ public final class GetMetadataAnalyticsResolver implements DataFetcher<List<Anal
if (termAggregation.isPresent()) {
List<NamedBar> termChart = buildBarChart(termAggregation.get());
AnalyticsUtil.hydrateDisplayNameForBars(_entityClient, termChart, Constants.GLOSSARY_TERM_ENTITY_NAME,
ImmutableSet.of(Constants.GLOSSARY_TERM_KEY_ASPECT_NAME), AnalyticsUtil::getTermName, authentication);
ImmutableSet.of(Constants.GLOSSARY_TERM_KEY_ASPECT_NAME, Constants.GLOSSARY_TERM_INFO_ASPECT_NAME), AnalyticsUtil::getTermName, authentication);
charts.add(BarChart.builder().setTitle("Entities by Term").setBars(termChart).build());
}

View File

@ -16,6 +16,7 @@ import com.linkedin.domain.DomainProperties;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspect;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.glossary.GlossaryTermInfo;
import com.linkedin.metadata.Constants;
import com.linkedin.metadata.key.DatasetKey;
import com.linkedin.metadata.key.GlossaryTermKey;
@ -140,11 +141,20 @@ public class AnalyticsUtil {
}
public static Optional<String> getTermName(EntityResponse entityResponse) {
EnvelopedAspect envelopedDatasetKey = entityResponse.getAspects().get(Constants.GLOSSARY_TERM_KEY_ASPECT_NAME);
if (envelopedDatasetKey == null) {
EnvelopedAspect envelopedTermInfo = entityResponse.getAspects().get(Constants.GLOSSARY_TERM_INFO_ASPECT_NAME);
if (envelopedTermInfo != null) {
GlossaryTermInfo glossaryTermInfo = new GlossaryTermInfo(envelopedTermInfo.getValue().data());
if (glossaryTermInfo.hasName()) {
return Optional.ofNullable(glossaryTermInfo.getName());
}
}
// if name is not set on GlossaryTermInfo or there is no GlossaryTermInfo
EnvelopedAspect envelopedGlossaryTermKey = entityResponse.getAspects().get(Constants.GLOSSARY_TERM_KEY_ASPECT_NAME);
if (envelopedGlossaryTermKey == null) {
return Optional.empty();
}
GlossaryTermKey glossaryTermKey = new GlossaryTermKey(envelopedDatasetKey.getValue().data());
GlossaryTermKey glossaryTermKey = new GlossaryTermKey(envelopedGlossaryTermKey.getValue().data());
return Optional.of(glossaryTermKey.getName());
}
}