Skip to content

Commit

Permalink
feat(structured-props) Extend structured props support to other entit…
Browse files Browse the repository at this point in the history
…y types (#9780)
  • Loading branch information
chriscollins3456 authored Feb 8, 2024
1 parent 33dc96b commit 5d23b79
Show file tree
Hide file tree
Showing 49 changed files with 340 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public class ChartType
EMBED_ASPECT_NAME,
DATA_PRODUCTS_ASPECT_NAME,
BROWSE_PATHS_V2_ASPECT_NAME,
SUB_TYPES_ASPECT_NAME);
SUB_TYPES_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);
private static final Set<String> FACET_FIELDS =
ImmutableSet.of("access", "queryType", "tool", "type");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.mappers.GlossaryTermsMapper;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.domain.Domains;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.metadata.key.ChartKey;
import com.linkedin.metadata.key.DataPlatformKey;
import com.linkedin.metadata.utils.EntityKeyUtils;
import com.linkedin.structured.StructuredProperties;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;

Expand Down Expand Up @@ -121,6 +123,11 @@ public Chart apply(@Nonnull final EntityResponse entityResponse) {
mappingHelper.mapToResult(
SUB_TYPES_ASPECT_NAME,
(dashboard, dataMap) -> dashboard.setSubTypes(SubTypesMapper.map(new SubTypes(dataMap))));
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((chart, dataMap) ->
chart.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));
return mappingHelper.getResult();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public class ContainerType
Constants.CONTAINER_ASPECT_NAME,
Constants.DOMAINS_ASPECT_NAME,
Constants.DEPRECATION_ASPECT_NAME,
Constants.DATA_PRODUCTS_ASPECT_NAME);
Constants.DATA_PRODUCTS_ASPECT_NAME,
Constants.STRUCTURED_PROPERTIES_ASPECT_NAME);

private static final Set<String> FACET_FIELDS = ImmutableSet.of("origin", "platform");
private static final String ENTITY_NAME = "container";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
import com.linkedin.datahub.graphql.types.common.mappers.util.SystemMetadataUtils;
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.mappers.GlossaryTermsMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.domain.Domains;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspect;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.metadata.Constants;
import com.linkedin.structured.StructuredProperties;
import javax.annotation.Nullable;

public class ContainerMapper {
Expand Down Expand Up @@ -139,6 +141,13 @@ public static Container map(final EntityResponse entityResponse) {
DeprecationMapper.map(new Deprecation(envelopedDeprecation.getValue().data())));
}

final EnvelopedAspect envelopedStructuredProps = aspects.get(STRUCTURED_PROPERTIES_ASPECT_NAME);
if (envelopedStructuredProps != null) {
result.setStructuredProperties(
StructuredPropertiesMapper.map(
new StructuredProperties(envelopedStructuredProps.getValue().data())));
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import com.linkedin.datahub.graphql.types.common.mappers.OwnershipMapper;
import com.linkedin.datahub.graphql.types.common.mappers.util.MappingHelper;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.identity.CorpGroupEditableInfo;
import com.linkedin.identity.CorpGroupInfo;
import com.linkedin.metadata.key.CorpGroupKey;
import com.linkedin.structured.StructuredProperties;
import javax.annotation.Nonnull;

/**
Expand Down Expand Up @@ -45,6 +47,11 @@ public CorpGroup apply(@Nonnull final EntityResponse entityResponse) {
mappingHelper.mapToResult(CORP_GROUP_EDITABLE_INFO_ASPECT_NAME, this::mapCorpGroupEditableInfo);
mappingHelper.mapToResult(
OWNERSHIP_ASPECT_NAME, (entity, dataMap) -> this.mapOwnership(entity, dataMap, entityUrn));
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((entity, dataMap) ->
entity.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));
if (aspectMap.containsKey(ORIGIN_ASPECT_NAME)) {
mappingHelper.mapToResult(ORIGIN_ASPECT_NAME, this::mapEntityOriginType);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.linkedin.datahub.graphql.generated.EntityType;
import com.linkedin.datahub.graphql.types.common.mappers.CustomPropertiesMapper;
import com.linkedin.datahub.graphql.types.common.mappers.util.MappingHelper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspect;
Expand All @@ -25,6 +26,7 @@
import com.linkedin.identity.CorpUserSettings;
import com.linkedin.identity.CorpUserStatus;
import com.linkedin.metadata.key.CorpUserKey;
import com.linkedin.structured.StructuredProperties;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -73,6 +75,11 @@ public CorpUser apply(
(corpUser, dataMap) ->
corpUser.setStatus(CorpUserStatusMapper.map(new CorpUserStatus(dataMap))));
mappingHelper.mapToResult(CORP_USER_CREDENTIALS_ASPECT_NAME, this::mapIsNativeUser);
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((entity, dataMap) ->
entity.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));

mapCorpUserSettings(
result, aspectMap.getOrDefault(CORP_USER_SETTINGS_ASPECT_NAME, null), featureFlags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public class DashboardType
SUB_TYPES_ASPECT_NAME,
EMBED_ASPECT_NAME,
DATA_PRODUCTS_ASPECT_NAME,
BROWSE_PATHS_V2_ASPECT_NAME);
BROWSE_PATHS_V2_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);
private static final Set<String> FACET_FIELDS = ImmutableSet.of("access", "tool");

private final EntityClient _entityClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.mappers.GlossaryTermsMapper;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.domain.Domains;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.metadata.key.DashboardKey;
import com.linkedin.metadata.key.DataPlatformKey;
import com.linkedin.metadata.utils.EntityKeyUtils;
import com.linkedin.structured.StructuredProperties;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;

Expand Down Expand Up @@ -122,6 +124,11 @@ public Dashboard apply(@Nonnull final EntityResponse entityResponse) {
BROWSE_PATHS_V2_ASPECT_NAME,
(dashboard, dataMap) ->
dashboard.setBrowsePathV2(BrowsePathsV2Mapper.map(new BrowsePathsV2(dataMap))));
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((dashboard, dataMap) ->
dashboard.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));
return mappingHelper.getResult();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public class DataFlowType
DEPRECATION_ASPECT_NAME,
DATA_PLATFORM_INSTANCE_ASPECT_NAME,
DATA_PRODUCTS_ASPECT_NAME,
BROWSE_PATHS_V2_ASPECT_NAME);
BROWSE_PATHS_V2_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);
private static final Set<String> FACET_FIELDS = ImmutableSet.of("orchestrator", "cluster");
private final EntityClient _entityClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.mappers.GlossaryTermsMapper;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.datajob.EditableDataFlowProperties;
import com.linkedin.domain.Domains;
Expand All @@ -38,6 +39,7 @@
import com.linkedin.metadata.key.DataFlowKey;
import com.linkedin.metadata.key.DataPlatformKey;
import com.linkedin.metadata.utils.EntityKeyUtils;
import com.linkedin.structured.StructuredProperties;
import javax.annotation.Nonnull;

public class DataFlowMapper implements ModelMapper<EntityResponse, DataFlow> {
Expand Down Expand Up @@ -99,6 +101,11 @@ public DataFlow apply(@Nonnull final EntityResponse entityResponse) {
BROWSE_PATHS_V2_ASPECT_NAME,
(dataFlow, dataMap) ->
dataFlow.setBrowsePathV2(BrowsePathsV2Mapper.map(new BrowsePathsV2(dataMap))));
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((entity, dataMap) ->
entity.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));

return mappingHelper.getResult();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public class DataJobType
DATA_PLATFORM_INSTANCE_ASPECT_NAME,
DATA_PRODUCTS_ASPECT_NAME,
BROWSE_PATHS_V2_ASPECT_NAME,
SUB_TYPES_ASPECT_NAME);
SUB_TYPES_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);
private static final Set<String> FACET_FIELDS = ImmutableSet.of("flow");
private final EntityClient _entityClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.mappers.GlossaryTermsMapper;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.datajob.EditableDataJobProperties;
import com.linkedin.domain.Domains;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.metadata.key.DataJobKey;
import com.linkedin.structured.StructuredProperties;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;

Expand Down Expand Up @@ -119,6 +121,9 @@ public DataJob apply(@Nonnull final EntityResponse entityResponse) {
result.setBrowsePathV2(BrowsePathsV2Mapper.map(new BrowsePathsV2(data)));
} else if (SUB_TYPES_ASPECT_NAME.equals(name)) {
result.setSubTypes(SubTypesMapper.map(new SubTypes(data)));
} else if (STRUCTURED_PROPERTIES_ASPECT_NAME.equals(name)) {
result.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(data)));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static com.linkedin.metadata.Constants.GLOSSARY_TERMS_ASPECT_NAME;
import static com.linkedin.metadata.Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME;
import static com.linkedin.metadata.Constants.OWNERSHIP_ASPECT_NAME;
import static com.linkedin.metadata.Constants.STRUCTURED_PROPERTIES_ASPECT_NAME;

import com.google.common.collect.ImmutableSet;
import com.linkedin.common.urn.Urn;
Expand Down Expand Up @@ -49,7 +50,8 @@ public class DataProductType
GLOBAL_TAGS_ASPECT_NAME,
GLOSSARY_TERMS_ASPECT_NAME,
DOMAINS_ASPECT_NAME,
INSTITUTIONAL_MEMORY_ASPECT_NAME);
INSTITUTIONAL_MEMORY_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);
private final EntityClient _entityClient;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static com.linkedin.metadata.Constants.GLOSSARY_TERMS_ASPECT_NAME;
import static com.linkedin.metadata.Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME;
import static com.linkedin.metadata.Constants.OWNERSHIP_ASPECT_NAME;
import static com.linkedin.metadata.Constants.STRUCTURED_PROPERTIES_ASPECT_NAME;

import com.linkedin.common.GlobalTags;
import com.linkedin.common.GlossaryTerms;
Expand All @@ -23,11 +24,13 @@
import com.linkedin.datahub.graphql.types.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.mappers.GlossaryTermsMapper;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
import com.linkedin.dataproduct.DataProductProperties;
import com.linkedin.domain.Domains;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.structured.StructuredProperties;
import javax.annotation.Nonnull;

public class DataProductMapper implements ModelMapper<EntityResponse, DataProduct> {
Expand Down Expand Up @@ -74,6 +77,11 @@ public DataProduct apply(@Nonnull final EntityResponse entityResponse) {
(dataProduct, dataMap) ->
dataProduct.setInstitutionalMemory(
InstitutionalMemoryMapper.map(new InstitutionalMemory(dataMap), entityUrn)));
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((entity, dataMap) ->
entity.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public Dataset apply(@Nonnull final EntityResponse entityResponse) {
dataset.setAccess(AccessMapper.map(new Access(dataMap), entityUrn))));
mappingHelper.mapToResult(
STRUCTURED_PROPERTIES_ASPECT_NAME,
((dataset, dataMap) ->
dataset.setStructuredProperties(
((entity, dataMap) ->
entity.setStructuredProperties(
StructuredPropertiesMapper.map(new StructuredProperties(dataMap)))));
mappingHelper.mapToResult(
FORMS_ASPECT_NAME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package com.linkedin.datahub.graphql.types.domain;

import static com.linkedin.metadata.Constants.STRUCTURED_PROPERTIES_ASPECT_NAME;

import com.linkedin.common.InstitutionalMemory;
import com.linkedin.common.Ownership;
import com.linkedin.common.urn.Urn;
import com.linkedin.datahub.graphql.generated.Domain;
import com.linkedin.datahub.graphql.generated.EntityType;
import com.linkedin.datahub.graphql.types.common.mappers.InstitutionalMemoryMapper;
import com.linkedin.datahub.graphql.types.common.mappers.OwnershipMapper;
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
import com.linkedin.domain.DomainProperties;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspect;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.metadata.Constants;
import com.linkedin.metadata.key.DomainKey;
import com.linkedin.structured.StructuredProperties;

public class DomainMapper {

Expand Down Expand Up @@ -53,6 +57,13 @@ public static Domain map(final EntityResponse entityResponse) {
new InstitutionalMemory(envelopedInstitutionalMemory.getValue().data()), entityUrn));
}

final EnvelopedAspect envelopedStructuredProps = aspects.get(STRUCTURED_PROPERTIES_ASPECT_NAME);
if (envelopedStructuredProps != null) {
result.setStructuredProperties(
StructuredPropertiesMapper.map(
new StructuredProperties(envelopedStructuredProps.getValue().data())));
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public class DomainType
Constants.DOMAIN_KEY_ASPECT_NAME,
Constants.DOMAIN_PROPERTIES_ASPECT_NAME,
Constants.OWNERSHIP_ASPECT_NAME,
Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME);
Constants.INSTITUTIONAL_MEMORY_ASPECT_NAME,
Constants.STRUCTURED_PROPERTIES_ASPECT_NAME);
private final EntityClient _entityClient;

public DomainType(final EntityClient entityClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_INFO_ASPECT_NAME;
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_KEY_ASPECT_NAME;
import static com.linkedin.metadata.Constants.OWNERSHIP_ASPECT_NAME;
import static com.linkedin.metadata.Constants.STRUCTURED_PROPERTIES_ASPECT_NAME;

import com.google.common.collect.ImmutableSet;
import com.linkedin.common.urn.Urn;
Expand All @@ -29,7 +30,10 @@ public class GlossaryNodeType

static final Set<String> ASPECTS_TO_RESOLVE =
ImmutableSet.of(
GLOSSARY_NODE_KEY_ASPECT_NAME, GLOSSARY_NODE_INFO_ASPECT_NAME, OWNERSHIP_ASPECT_NAME);
GLOSSARY_NODE_KEY_ASPECT_NAME,
GLOSSARY_NODE_INFO_ASPECT_NAME,
OWNERSHIP_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);

private final EntityClient _entityClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class GlossaryTermType
STATUS_ASPECT_NAME,
BROWSE_PATHS_ASPECT_NAME,
DOMAINS_ASPECT_NAME,
DEPRECATION_ASPECT_NAME);
DEPRECATION_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME);

private final EntityClient _entityClient;

Expand Down
Loading

0 comments on commit 5d23b79

Please sign in to comment.