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

feat(globaltags to glossaryterm): add globaltags property to glossaryterm and glossarynode entities #12209

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.linkedin.datahub.graphql.types.glossary;

import static com.linkedin.metadata.Constants.FORMS_ASPECT_NAME;
import static com.linkedin.metadata.Constants.GLOBAL_TAGS_ASPECT_NAME;
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_ENTITY_NAME;
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_INFO_ASPECT_NAME;
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_KEY_ASPECT_NAME;
Expand Down Expand Up @@ -46,6 +47,7 @@ public class GlossaryNodeType
ImmutableSet.of(
GLOSSARY_NODE_KEY_ASPECT_NAME,
GLOSSARY_NODE_INFO_ASPECT_NAME,
GLOBAL_TAGS_ASPECT_NAME,
OWNERSHIP_ASPECT_NAME,
STRUCTURED_PROPERTIES_ASPECT_NAME,
FORMS_ASPECT_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.linkedin.datahub.graphql.Constants.*;
import static com.linkedin.metadata.Constants.*;
import static com.linkedin.metadata.Constants.GLOBAL_TAGS_ASPECT_NAME;

import com.google.common.collect.ImmutableSet;
import com.linkedin.common.urn.Urn;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class GlossaryTermType
GLOSSARY_RELATED_TERM_ASPECT_NAME,
INSTITUTIONAL_MEMORY_ASPECT_NAME,
OWNERSHIP_ASPECT_NAME,
GLOBAL_TAGS_ASPECT_NAME,
STATUS_ASPECT_NAME,
BROWSE_PATHS_ASPECT_NAME,
DOMAINS_ASPECT_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.linkedin.common.DisplayProperties;
import com.linkedin.common.Forms;
import com.linkedin.common.GlobalTags;
import com.linkedin.common.Ownership;
import com.linkedin.common.urn.Urn;
import com.linkedin.data.DataMap;
Expand All @@ -20,6 +21,7 @@
import com.linkedin.datahub.graphql.types.form.FormsMapper;
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.entity.EntityResponse;
import com.linkedin.entity.EnvelopedAspectMap;
import com.linkedin.glossary.GlossaryNodeInfo;
Expand Down Expand Up @@ -63,6 +65,9 @@ public GlossaryNode apply(
entity.setStructuredProperties(
StructuredPropertiesMapper.map(
context, new StructuredProperties(dataMap), entityUrn))));
mappingHelper.mapToResult(
GLOBAL_TAGS_ASPECT_NAME,
(dataset, dataMap) -> mapGlobalTags(context, dataset, dataMap, entityUrn));
mappingHelper.mapToResult(
FORMS_ASPECT_NAME,
((entity, dataMap) ->
Expand Down Expand Up @@ -106,4 +111,15 @@ private void mapGlossaryNodeKey(@Nonnull GlossaryNode glossaryNode, @Nonnull Dat
glossaryNode.getProperties().setName(glossaryNodeKey.getName());
}
}

private static void mapGlobalTags(
@Nullable final QueryContext context,
@Nonnull GlossaryNode glossaryNode,
@Nonnull DataMap dataMap,
@Nonnull final Urn entityUrn) {
com.linkedin.datahub.graphql.generated.GlobalTags globalTags =
GlobalTagsMapper.map(context, new GlobalTags(dataMap), entityUrn);
glossaryNode.setGlobalTags(globalTags);
glossaryNode.setTags(globalTags);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.linkedin.common.Deprecation;
import com.linkedin.common.Forms;
import com.linkedin.common.GlobalTags;
import com.linkedin.common.InstitutionalMemory;
import com.linkedin.common.Ownership;
import com.linkedin.common.urn.Urn;
Expand All @@ -23,6 +24,7 @@
import com.linkedin.datahub.graphql.types.glossary.GlossaryTermUtils;
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;
Expand Down Expand Up @@ -92,6 +94,9 @@ public GlossaryTerm apply(
entity.setStructuredProperties(
StructuredPropertiesMapper.map(
context, new StructuredProperties(dataMap), entityUrn))));
mappingHelper.mapToResult(
GLOBAL_TAGS_ASPECT_NAME,
(dataset, dataMap) -> mapGlobalTags(context, dataset, dataMap, entityUrn));
mappingHelper.mapToResult(
FORMS_ASPECT_NAME,
((entity, dataMap) ->
Expand Down Expand Up @@ -124,4 +129,15 @@ private void mapDomains(
final Domains domains = new Domains(dataMap);
glossaryTerm.setDomain(DomainAssociationMapper.map(context, domains, glossaryTerm.getUrn()));
}

private static void mapGlobalTags(
@Nullable final QueryContext context,
@Nonnull GlossaryTerm glossaryTerm,
@Nonnull DataMap dataMap,
@Nonnull final Urn entityUrn) {
com.linkedin.datahub.graphql.generated.GlobalTags globalTags =
GlobalTagsMapper.map(context, new GlobalTags(dataMap), entityUrn);
glossaryTerm.setGlobalTags(globalTags);
glossaryTerm.setTags(globalTags);
}
}
22 changes: 22 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2353,6 +2353,17 @@ type GlossaryTerm implements Entity {
The forms associated with the Dataset
"""
forms: Forms

"""
Tags on the GlossaryTerm
"""
tags: GlobalTags

"""
Deprecated, use tags field instead
Tags associated with the field
"""
globalTags: GlobalTags @deprecated
}

"""
Expand Down Expand Up @@ -2511,6 +2522,17 @@ type GlossaryNode implements Entity {
Display properties for the glossary node
"""
displayProperties: DisplayProperties

"""
Tags on the GlossaryNode
"""
tags: GlobalTags

"""
Deprecated, use tags field instead
Tags associated with the field
"""
globalTags: GlobalTags @deprecated
}

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ChildrenTab from './ChildrenTab';
import { Preview } from './preview/Preview';
import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
import SidebarStructuredPropsSection from '../shared/containers/profile/sidebar/StructuredProperties/SidebarStructuredPropsSection';
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';

class GlossaryNodeEntity implements Entity<GlossaryNode> {
type: EntityType = EntityType.GlossaryNode;
Expand Down Expand Up @@ -101,6 +102,13 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
{
component: SidebarOwnerSection,
},
{
component: SidebarTagsSection,
properties: {
hasTags: true,
hasTerms: false,
},
},
{
component: SidebarStructuredPropsSection,
},
Expand Down Expand Up @@ -128,6 +136,7 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
name={this.displayName(data)}
description={data?.properties?.description || ''}
owners={data?.ownership?.owners}
tags={data.tags ?? undefined}
/>
);
};
Expand All @@ -149,6 +158,7 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
EntityCapabilityType.OWNERS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
EntityCapabilityType.TAGS,
]);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { FolderOutlined } from '@ant-design/icons';
import { EntityType, Owner, ParentNodesResult } from '../../../../types.generated';
import { EntityType, GlobalTags, Owner, ParentNodesResult } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';

Expand All @@ -10,12 +10,14 @@ export const Preview = ({
description,
owners,
parentNodes,
tags,
}: {
urn: string;
name: string;
description?: string | null;
owners?: Array<Owner> | null;
parentNodes?: ParentNodesResult | null;
tags?: GlobalTags;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
return (
Expand All @@ -28,6 +30,7 @@ export const Preview = ({
logoComponent={<FolderOutlined style={{ fontSize: '20px' }} />}
type={entityRegistry.getEntityName(EntityType.GlossaryNode)}
parentEntities={parentNodes?.nodes}
tags={tags}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { EntityActionItem } from '../shared/entity/EntityActions';
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
import { PageRoutes } from '../../../conf/Global';
import SidebarStructuredPropsSection from '../shared/containers/profile/sidebar/StructuredProperties/SidebarStructuredPropsSection';
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';

/**
* Definition of the DataHub Dataset entity.
Expand Down Expand Up @@ -124,6 +125,13 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
{
component: SidebarOwnerSection,
},
{
component: SidebarTagsSection,
properties: {
hasTags: true,
hasTerms: false,
},
},
{
component: SidebarDomainSection,
properties: {
Expand Down Expand Up @@ -156,6 +164,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
description={data?.properties?.description || ''}
owners={data?.ownership?.owners}
domain={data.domain?.domain}
tags={data.tags ?? undefined}
/>
);
};
Expand All @@ -181,6 +190,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
EntityCapabilityType.OWNERS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
EntityCapabilityType.TAGS,
]);
};

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, Domain, EntityType, Owner, ParentNodesResult } from '../../../../types.generated';
import { Deprecation, Domain, EntityType, GlobalTags, Owner, ParentNodesResult } from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { IconStyleType, PreviewType } from '../../Entity';
Expand All @@ -16,6 +16,7 @@ export const Preview = ({
parentNodes,
previewType,
domain,
tags,
}: {
urn: string;
name: string;
Expand All @@ -25,6 +26,7 @@ export const Preview = ({
parentNodes?: ParentNodesResult | null;
previewType: PreviewType;
domain?: Domain | undefined;
tags?: GlobalTags;
}): JSX.Element => {
const entityRegistry = useEntityRegistry();
return (
Expand All @@ -44,6 +46,7 @@ export const Preview = ({
entityTitleSuffix={
<UrlButton href={getRelatedEntitiesUrl(entityRegistry, urn)}>View Related Entities</UrlButton>
}
tags={tags}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,49 @@ export const SidebarTagsSection = ({ properties, readOnly }: Props) => {

return (
<div>
<span id={ENTITY_PROFILE_TAGS_ID}>
<SidebarHeader title="Tags" />
<TagTermGroup
editableTags={
properties?.customTagPath
? getNestedValue(entityData, properties?.customTagPath)
: entityData?.globalTags
}
canAddTag={canAddTag}
canRemove
showEmptyMessage
entityUrn={mutationUrn}
entityType={entityType}
refetch={refetch}
readOnly={readOnly}
fontSize={12}
/>
</span>
<StyledDivider />
<span id={ENTITY_PROFILE_GLOSSARY_TERMS_ID}>
<SidebarHeader title="Glossary Terms" />
<TagTermGroup
editableGlossaryTerms={
properties?.customTermPath
? getNestedValue(entityData, properties?.customTermPath)
: entityData?.glossaryTerms
}
canAddTerm={canAddTerm}
canRemove
showEmptyMessage
entityUrn={mutationUrn}
entityType={entityType}
refetch={refetch}
readOnly={readOnly}
fontSize={12}
/>
</span>
{canAddTag && (
<span id={ENTITY_PROFILE_TAGS_ID}>
<SidebarHeader title="Tags" />
<TagTermGroup
editableTags={
properties?.customTagPath
? getNestedValue(entityData, properties?.customTagPath)
: entityData?.globalTags
}
canAddTag={canAddTag}
canRemove
showEmptyMessage
entityUrn={mutationUrn}
entityType={entityType}
refetch={refetch}
readOnly={readOnly}
fontSize={12}
/>
</span>
)}
{canAddTerm && (
<>
<StyledDivider />
<span id={ENTITY_PROFILE_GLOSSARY_TERMS_ID}>
<SidebarHeader title="Glossary Terms" />
<TagTermGroup
editableGlossaryTerms={
properties?.customTermPath
? getNestedValue(entityData, properties?.customTermPath)
: entityData?.glossaryTerms
}
canAddTerm={canAddTerm}
canRemove
showEmptyMessage
entityUrn={mutationUrn}
entityType={entityType}
refetch={refetch}
readOnly={readOnly}
fontSize={12}
/>
</span>
</>
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppstoreOutlined, FileOutlined, UnorderedListOutlined } from '@ant-design/icons';
import { SidebarTagsSection } from '@app/entityV2/shared/containers/profile/sidebar/SidebarTagsSection';
import React from 'react';
import { BookmarksSimple } from '@phosphor-icons/react';
import { useGetGlossaryNodeQuery } from '../../../graphql/glossaryNode.generated';
Expand Down Expand Up @@ -129,6 +130,7 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
{
component: SidebarOwnerSection,
},
{ component: SidebarTagsSection },
{
component: SidebarStructuredProperties,
},
Expand Down Expand Up @@ -193,6 +195,7 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
EntityCapabilityType.OWNERS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
EntityCapabilityType.TAGS,
]);
};

Expand Down
Loading
Loading