Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Domain to Glossary Terms #6135

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class GlossaryTermType implements SearchableEntityType<GlossaryTerm, Stri
OWNERSHIP_ASPECT_NAME,
STATUS_ASPECT_NAME,
BROWSE_PATHS_ASPECT_NAME,
DOMAINS_ASPECT_NAME,
DEPRECATION_ASPECT_NAME
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import com.linkedin.datahub.graphql.types.common.mappers.InstitutionalMemoryMapper;
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.domain.DomainAssociationMapper;
import com.linkedin.datahub.graphql.types.glossary.GlossaryTermUtils;
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
import com.linkedin.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.glossary.GlossaryTermInfo;
import com.linkedin.metadata.key.GlossaryTermKey;
import com.linkedin.domain.Domains;
import javax.annotation.Nonnull;

import static com.linkedin.metadata.Constants.*;
Expand Down Expand Up @@ -54,6 +56,7 @@ public GlossaryTerm apply(@Nonnull final EntityResponse entityResponse) {
glossaryTerm.setProperties(GlossaryTermPropertiesMapper.map(new GlossaryTermInfo(dataMap), entityUrn)));
mappingHelper.mapToResult(OWNERSHIP_ASPECT_NAME, (glossaryTerm, dataMap) ->
glossaryTerm.setOwnership(OwnershipMapper.map(new Ownership(dataMap), entityUrn)));
mappingHelper.mapToResult(DOMAINS_ASPECT_NAME, this::mapDomains);
mappingHelper.mapToResult(DEPRECATION_ASPECT_NAME, (glossaryTerm, dataMap) ->
glossaryTerm.setDeprecation(DeprecationMapper.map(new Deprecation(dataMap))));
mappingHelper.mapToResult(INSTITUTIONAL_MEMORY_ASPECT_NAME, (dataset, dataMap) ->
Expand All @@ -74,4 +77,9 @@ private void mapGlossaryTermKey(@Nonnull GlossaryTerm glossaryTerm, @Nonnull Dat
glossaryTerm.setName(GlossaryTermUtils.getGlossaryTermName(glossaryTermKey.getName()));
glossaryTerm.setHierarchicalName(glossaryTermKey.getName());
}

private void mapDomains(@Nonnull GlossaryTerm glossaryTerm, @Nonnull DataMap dataMap) {
final Domains domains = new Domains(dataMap);
glossaryTerm.setDomain(DomainAssociationMapper.map(domains, glossaryTerm.getUrn()));
}
}
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,11 @@ type GlossaryTerm implements Entity {
"""
ownership: Ownership

"""
The Domain associated with the glossary term
"""
domain: DomainAssociation

"""
References to internal resources related to the Glossary Term
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SidebarAboutSection } from '../shared/containers/profile/sidebar/Sideba
import GlossaryEntitiesPath from '../../glossary/GlossaryEntitiesPath';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
import { EntityActionItem } from '../shared/entity/EntityActions';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';

/**
* Definition of the DataHub Dataset entity.
Expand Down Expand Up @@ -112,6 +113,12 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
{
component: SidebarOwnerSection,
},
{
component: SidebarDomainSection,
properties: {
hideOwnerType: true,
},
},
]}
getOverrideProperties={this.getOverridePropertiesFromEntity}
customNavBar={<GlossaryEntitiesPath />}
Expand Down Expand Up @@ -139,6 +146,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
name={this.displayName(data)}
description={data?.properties?.description || ''}
owners={data?.ownership?.owners}
domain={data.domain?.domain}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { BookOutlined } from '@ant-design/icons';
import { Deprecation, EntityType, Owner, ParentNodesResult } from '../../../../types.generated';
import { Deprecation, Domain, EntityType, Owner, ParentNodesResult } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { IconStyleType, PreviewType } from '../../Entity';
Expand All @@ -13,6 +13,7 @@ export const Preview = ({
deprecation,
parentNodes,
previewType,
domain,
}: {
urn: string;
name: string;
Expand All @@ -21,6 +22,7 @@ export const Preview = ({
deprecation?: Deprecation | null;
parentNodes?: ParentNodesResult | null;
previewType: PreviewType;
domain?: Domain | undefined;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
return (
Expand All @@ -35,6 +37,7 @@ export const Preview = ({
typeIcon={entityRegistry.getIcon(EntityType.GlossaryTerm, 14, IconStyleType.ACCENT)}
deprecation={deprecation}
parentNodes={parentNodes}
domain={domain}
/>
);
};
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/glossaryTerm.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ query getGlossaryTerm($urn: String!, $start: Int, $count: Int) {
ownership {
...ownershipFields
}
domain {
...entityDomain
}
institutionalMemory {
...institutionalMemoryFields
}
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ fragment searchResultFields on Entity {
parentNodes {
...parentNodesFields
}
domain {
...entityDomain
}
}
... on GlossaryNode {
...glossaryNode
Expand Down
1 change: 1 addition & 0 deletions metadata-models/src/main/resources/entity-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ entities:
- schemaMetadata
- ownership
- deprecation
- domains
- name: glossaryNode
keyAspect: glossaryNodeKey
aspects:
Expand Down