Skip to content

Commit 22d8ae8

Browse files
committed
feat(globaltags to glossaryterm): add globaltags property to glossaryterm and glossarynode entities
1 parent 73dce9e commit 22d8ae8

File tree

12 files changed

+90
-1
lines changed

12 files changed

+90
-1
lines changed

datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/glossary/GlossaryNodeType.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.linkedin.datahub.graphql.types.glossary;
22

33
import static com.linkedin.metadata.Constants.FORMS_ASPECT_NAME;
4+
import static com.linkedin.metadata.Constants.GLOBAL_TAGS_ASPECT_NAME;
45
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_ENTITY_NAME;
56
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_INFO_ASPECT_NAME;
67
import static com.linkedin.metadata.Constants.GLOSSARY_NODE_KEY_ASPECT_NAME;
@@ -33,6 +34,7 @@ public class GlossaryNodeType
3334
ImmutableSet.of(
3435
GLOSSARY_NODE_KEY_ASPECT_NAME,
3536
GLOSSARY_NODE_INFO_ASPECT_NAME,
37+
GLOBAL_TAGS_ASPECT_NAME,
3638
OWNERSHIP_ASPECT_NAME,
3739
STRUCTURED_PROPERTIES_ASPECT_NAME,
3840
FORMS_ASPECT_NAME);

datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/glossary/GlossaryTermType.java

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.linkedin.datahub.graphql.Constants.*;
44
import static com.linkedin.metadata.Constants.*;
5+
import static com.linkedin.metadata.Constants.GLOBAL_TAGS_ASPECT_NAME;
56

67
import com.google.common.collect.ImmutableSet;
78
import com.linkedin.common.urn.Urn;
@@ -54,6 +55,7 @@ public class GlossaryTermType
5455
GLOSSARY_RELATED_TERM_ASPECT_NAME,
5556
INSTITUTIONAL_MEMORY_ASPECT_NAME,
5657
OWNERSHIP_ASPECT_NAME,
58+
GLOBAL_TAGS_ASPECT_NAME,
5759
STATUS_ASPECT_NAME,
5860
BROWSE_PATHS_ASPECT_NAME,
5961
DOMAINS_ASPECT_NAME,

datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/glossary/mappers/GlossaryNodeMapper.java

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static com.linkedin.metadata.Constants.*;
55

66
import com.linkedin.common.Forms;
7+
import com.linkedin.common.GlobalTags;
78
import com.linkedin.common.Ownership;
89
import com.linkedin.common.urn.Urn;
910
import com.linkedin.data.DataMap;
@@ -18,6 +19,7 @@
1819
import com.linkedin.datahub.graphql.types.form.FormsMapper;
1920
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
2021
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
22+
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
2123
import com.linkedin.entity.EntityResponse;
2224
import com.linkedin.entity.EnvelopedAspectMap;
2325
import com.linkedin.glossary.GlossaryNodeInfo;
@@ -61,6 +63,9 @@ public GlossaryNode apply(
6163
entity.setStructuredProperties(
6264
StructuredPropertiesMapper.map(
6365
context, new StructuredProperties(dataMap), entityUrn))));
66+
mappingHelper.mapToResult(
67+
GLOBAL_TAGS_ASPECT_NAME,
68+
(dataset, dataMap) -> mapGlobalTags(context, dataset, dataMap, entityUrn));
6469
mappingHelper.mapToResult(
6570
FORMS_ASPECT_NAME,
6671
((entity, dataMap) ->
@@ -99,4 +104,15 @@ private void mapGlossaryNodeKey(@Nonnull GlossaryNode glossaryNode, @Nonnull Dat
99104
glossaryNode.getProperties().setName(glossaryNodeKey.getName());
100105
}
101106
}
107+
108+
private static void mapGlobalTags(
109+
@Nullable final QueryContext context,
110+
@Nonnull GlossaryNode glossaryNode,
111+
@Nonnull DataMap dataMap,
112+
@Nonnull final Urn entityUrn) {
113+
com.linkedin.datahub.graphql.generated.GlobalTags globalTags =
114+
GlobalTagsMapper.map(context, new GlobalTags(dataMap), entityUrn);
115+
glossaryNode.setGlobalTags(globalTags);
116+
glossaryNode.setTags(globalTags);
117+
}
102118
}

datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/types/glossary/mappers/GlossaryTermMapper.java

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.linkedin.common.Deprecation;
77
import com.linkedin.common.Forms;
8+
import com.linkedin.common.GlobalTags;
89
import com.linkedin.common.InstitutionalMemory;
910
import com.linkedin.common.Ownership;
1011
import com.linkedin.common.urn.Urn;
@@ -23,6 +24,7 @@
2324
import com.linkedin.datahub.graphql.types.glossary.GlossaryTermUtils;
2425
import com.linkedin.datahub.graphql.types.mappers.ModelMapper;
2526
import com.linkedin.datahub.graphql.types.structuredproperty.StructuredPropertiesMapper;
27+
import com.linkedin.datahub.graphql.types.tag.mappers.GlobalTagsMapper;
2628
import com.linkedin.domain.Domains;
2729
import com.linkedin.entity.EntityResponse;
2830
import com.linkedin.entity.EnvelopedAspectMap;
@@ -92,6 +94,9 @@ public GlossaryTerm apply(
9294
entity.setStructuredProperties(
9395
StructuredPropertiesMapper.map(
9496
context, new StructuredProperties(dataMap), entityUrn))));
97+
mappingHelper.mapToResult(
98+
GLOBAL_TAGS_ASPECT_NAME,
99+
(dataset, dataMap) -> mapGlobalTags(context, dataset, dataMap, entityUrn));
95100
mappingHelper.mapToResult(
96101
FORMS_ASPECT_NAME,
97102
((entity, dataMap) ->
@@ -124,4 +129,15 @@ private void mapDomains(
124129
final Domains domains = new Domains(dataMap);
125130
glossaryTerm.setDomain(DomainAssociationMapper.map(context, domains, glossaryTerm.getUrn()));
126131
}
132+
133+
private static void mapGlobalTags(
134+
@Nullable final QueryContext context,
135+
@Nonnull GlossaryTerm glossaryTerm,
136+
@Nonnull DataMap dataMap,
137+
@Nonnull final Urn entityUrn) {
138+
com.linkedin.datahub.graphql.generated.GlobalTags globalTags =
139+
GlobalTagsMapper.map(context, new GlobalTags(dataMap), entityUrn);
140+
glossaryTerm.setGlobalTags(globalTags);
141+
glossaryTerm.setTags(globalTags);
142+
}
127143
}

datahub-graphql-core/src/main/resources/entity.graphql

+12
Original file line numberDiff line numberDiff line change
@@ -2268,6 +2268,12 @@ type GlossaryTerm implements Entity {
22682268
The forms associated with the Dataset
22692269
"""
22702270
forms: Forms
2271+
2272+
"""
2273+
Tags used for searching the data platform instance
2274+
"""
2275+
tags: GlobalTags
2276+
globalTags: GlobalTags
22712277
}
22722278

22732279
"""
@@ -2421,6 +2427,12 @@ type GlossaryNode implements Entity {
24212427
The forms associated with the Dataset
24222428
"""
24232429
forms: Forms
2430+
2431+
"""
2432+
Tags used for searching the data platform instance
2433+
"""
2434+
tags: GlobalTags
2435+
globalTags: GlobalTags
24242436
}
24252437

24262438
"""

datahub-web-react/src/app/entity/glossaryNode/GlossaryNodeEntity.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ChildrenTab from './ChildrenTab';
1313
import { Preview } from './preview/Preview';
1414
import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab';
1515
import SidebarStructuredPropsSection from '../shared/containers/profile/sidebar/StructuredProperties/SidebarStructuredPropsSection';
16+
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';
1617

1718
class GlossaryNodeEntity implements Entity<GlossaryNode> {
1819
type: EntityType = EntityType.GlossaryNode;
@@ -101,6 +102,13 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
101102
{
102103
component: SidebarOwnerSection,
103104
},
105+
{
106+
component: SidebarTagsSection,
107+
properties: {
108+
hasTags: true,
109+
hasTerms: false,
110+
},
111+
},
104112
{
105113
component: SidebarStructuredPropsSection,
106114
},
@@ -128,6 +136,7 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
128136
name={this.displayName(data)}
129137
description={data?.properties?.description || ''}
130138
owners={data?.ownership?.owners}
139+
globalTags={data.globalTags}
131140
/>
132141
);
133142
};
@@ -149,6 +158,7 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
149158
EntityCapabilityType.OWNERS,
150159
EntityCapabilityType.DEPRECATION,
151160
EntityCapabilityType.SOFT_DELETE,
161+
EntityCapabilityType.TAGS
152162
]);
153163
};
154164

datahub-web-react/src/app/entity/glossaryTerm/GlossaryTermEntity.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { EntityActionItem } from '../shared/entity/EntityActions';
1919
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
2020
import { PageRoutes } from '../../../conf/Global';
2121
import SidebarStructuredPropsSection from '../shared/containers/profile/sidebar/StructuredProperties/SidebarStructuredPropsSection';
22+
import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection';
2223

2324
/**
2425
* Definition of the DataHub Dataset entity.
@@ -124,6 +125,13 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
124125
{
125126
component: SidebarOwnerSection,
126127
},
128+
{
129+
component: SidebarTagsSection,
130+
properties: {
131+
hasTags: true,
132+
hasTerms: false,
133+
},
134+
},
127135
{
128136
component: SidebarDomainSection,
129137
properties: {
@@ -156,6 +164,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
156164
description={data?.properties?.description || ''}
157165
owners={data?.ownership?.owners}
158166
domain={data.domain?.domain}
167+
globalTags={data.globalTags}
159168
/>
160169
);
161170
};
@@ -181,6 +190,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
181190
EntityCapabilityType.OWNERS,
182191
EntityCapabilityType.DEPRECATION,
183192
EntityCapabilityType.SOFT_DELETE,
193+
EntityCapabilityType.TAGS
184194
]);
185195
};
186196

datahub-web-react/src/app/entity/shared/containers/profile/sidebar/SidebarTagsSection.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export const SidebarTagsSection = ({ properties, readOnly }: Props) => {
5050
fontSize={12}
5151
/>
5252
</span>
53-
<StyledDivider />
53+
{canAddTerm && (
54+
<>
55+
<StyledDivider />
5456
<span id={ENTITY_PROFILE_GLOSSARY_TERMS_ID}>
5557
<SidebarHeader title="Glossary Terms" />
5658
<TagTermGroup
@@ -69,6 +71,8 @@ export const SidebarTagsSection = ({ properties, readOnly }: Props) => {
6971
fontSize={12}
7072
/>
7173
</span>
74+
</>
75+
)}
7276
</div>
7377
);
7478
};

datahub-web-react/src/graphql/glossaryNode.graphql

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ query getGlossaryNode($urn: String!) {
3737
forms {
3838
...formsFields
3939
}
40+
globalTags {
41+
...globalTagsFields
42+
}
4043
children: relationships(input: { types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000 }) {
4144
total
4245
relationships {

datahub-web-react/src/graphql/glossaryTerm.graphql

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ query getGlossaryTerm($urn: String!, $start: Int, $count: Int) {
6363
domain {
6464
...entityDomain
6565
}
66+
globalTags {
67+
...globalTagsFields
68+
}
6669
institutionalMemory {
6770
...institutionalMemoryFields
6871
}

datahub-web-react/src/graphql/search.graphql

+9
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ fragment autoCompleteFields on Entity {
150150
... on GlossaryTerm {
151151
name
152152
hierarchicalName
153+
globalTags {
154+
...globalTagsFields
155+
}
153156
properties {
154157
name
155158
}
@@ -723,6 +726,9 @@ fragment searchResultsWithoutSchemaField on Entity {
723726
parentNodes {
724727
...parentNodesFields
725728
}
729+
globalTags {
730+
...globalTagsFields
731+
}
726732
domain {
727733
...entityDomain
728734
}
@@ -737,6 +743,9 @@ fragment searchResultsWithoutSchemaField on Entity {
737743
parentNodes {
738744
...parentNodesFields
739745
}
746+
globalTags {
747+
...globalTagsFields
748+
}
740749
structuredProperties {
741750
properties {
742751
...structuredPropertiesFields

metadata-models/src/main/resources/entity-registry.yml

+2
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ entities:
270270
- ownership
271271
- deprecation
272272
- domains
273+
- globalTags
273274
- status
274275
- browsePaths
275276
- structuredProperties
@@ -282,6 +283,7 @@ entities:
282283
- glossaryNodeInfo
283284
- institutionalMemory
284285
- ownership
286+
- globalTags
285287
- status
286288
- structuredProperties
287289
- forms

0 commit comments

Comments
 (0)