mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-26 18:06:03 +00:00
Co-authored-by: IceS2 <pjt1991@gmail.com>
This commit is contained in:
parent
1dab7c2b4e
commit
0af5e7af32
@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.glassfish.jersey.internal.util.ExceptionUtils;
|
||||
import org.openmetadata.common.utils.CommonUtil;
|
||||
@ -173,7 +174,9 @@ public class DataInsightsEntityEnricherProcessor
|
||||
entityMap.put("descriptionSources", processDescriptionSources(entity, changeSummaryMap));
|
||||
|
||||
// Process Tag Source
|
||||
entityMap.put("tagSources", processTagSources(entity));
|
||||
TagAndTierSources tagAndTierSources = processTagAndTierSources(entity);
|
||||
entityMap.put("tagSources", tagAndTierSources.getTagSources());
|
||||
entityMap.put("tierSources", tagAndTierSources.getTierSources());
|
||||
|
||||
// Process Team
|
||||
Optional.ofNullable(processTeam(entity)).ifPresent(team -> entityMap.put("team", team));
|
||||
@ -299,37 +302,50 @@ public class DataInsightsEntityEnricherProcessor
|
||||
return team;
|
||||
}
|
||||
|
||||
private void processTagSources(List<TagLabel> tagList, Map<String, Integer> tagSources) {
|
||||
private void processTagAndTierSources(
|
||||
List<TagLabel> tagList, TagAndTierSources tagAndTierSources) {
|
||||
Optional.ofNullable(tagList)
|
||||
.ifPresent(
|
||||
tags -> {
|
||||
tags.stream()
|
||||
.filter(tag -> !tag.getTagFQN().startsWith("Tier."))
|
||||
.map(tag -> tag.getLabelType().value())
|
||||
.forEach(
|
||||
tagSource ->
|
||||
tagSources.put(tagSource, tagSources.getOrDefault(tagSource, 0) + 1));
|
||||
tags.forEach(
|
||||
tag -> {
|
||||
String tagSource = tag.getLabelType().value();
|
||||
if (tag.getTagFQN().startsWith("Tier.")) {
|
||||
tagAndTierSources
|
||||
.getTierSources()
|
||||
.put(
|
||||
tagSource,
|
||||
tagAndTierSources.getTierSources().getOrDefault(tagSource, 0) + 1);
|
||||
} else {
|
||||
tagAndTierSources
|
||||
.getTagSources()
|
||||
.put(
|
||||
tagSource,
|
||||
tagAndTierSources.getTagSources().getOrDefault(tagSource, 0) + 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void processEntityTagSources(EntityInterface entity, Map<String, Integer> tagSources) {
|
||||
processTagSources(entity.getTags(), tagSources);
|
||||
private void processEntityTagSources(
|
||||
EntityInterface entity, TagAndTierSources tagAndTierSources) {
|
||||
processTagAndTierSources(entity.getTags(), tagAndTierSources);
|
||||
}
|
||||
|
||||
private void processColumnTagSources(
|
||||
ColumnsEntityInterface entity, Map<String, Integer> tagSources) {
|
||||
ColumnsEntityInterface entity, TagAndTierSources tagAndTierSources) {
|
||||
for (Column column : entity.getColumns()) {
|
||||
processTagSources(column.getTags(), tagSources);
|
||||
processTagAndTierSources(column.getTags(), tagAndTierSources);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Integer> processTagSources(EntityInterface entity) {
|
||||
Map<String, Integer> tagSources = new HashMap<>();
|
||||
processEntityTagSources(entity, tagSources);
|
||||
private TagAndTierSources processTagAndTierSources(EntityInterface entity) {
|
||||
TagAndTierSources tagAndTierSources = new TagAndTierSources();
|
||||
processEntityTagSources(entity, tagAndTierSources);
|
||||
if (hasColumns(entity)) {
|
||||
processColumnTagSources((ColumnsEntityInterface) entity, tagSources);
|
||||
processColumnTagSources((ColumnsEntityInterface) entity, tagAndTierSources);
|
||||
}
|
||||
return tagSources;
|
||||
return tagAndTierSources;
|
||||
}
|
||||
|
||||
private String processTier(EntityInterface entity) {
|
||||
@ -395,4 +411,15 @@ public class DataInsightsEntityEnricherProcessor
|
||||
public StepStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class TagAndTierSources {
|
||||
private final Map<String, Integer> tagSources;
|
||||
private final Map<String, Integer> tierSources;
|
||||
|
||||
public TagAndTierSources() {
|
||||
this.tagSources = new HashMap<>();
|
||||
this.tierSources = new HashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user