mirror of
https://github.com/datahub-project/datahub.git
synced 2026-01-07 15:27:05 +00:00
fix(ui) Display glossary term name in analytics page properly (#7128)
This commit is contained in:
parent
af3fa6f22d
commit
ea7b2abca5
@ -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());
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user