fix: glossary term incorrect relationship (#12426)

* fix: glossary term incorrect relationship

* revert tier changes
This commit is contained in:
karanh37 2023-07-14 14:40:08 +05:30 committed by GitHub
parent 4c63398736
commit d8e64b4f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 576 additions and 30 deletions

View File

@ -11,6 +11,7 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable max-len */
import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface';
import { ProviderType, Status } from '../generated/entity/data/glossaryTerm'; import { ProviderType, Status } from '../generated/entity/data/glossaryTerm';
@ -451,6 +452,7 @@ export const MOCKED_GLOSSARY_TERMS = [
relatedTerms: [], relatedTerms: [],
references: [], references: [],
version: 0.1, version: 0.1,
type: 'glossaryTerm',
updatedAt: 1682348752125, updatedAt: 1682348752125,
updatedBy: 'karan', updatedBy: 'karan',
reviewers: [], reviewers: [],
@ -610,13 +612,14 @@ export const MOCKED_GLOSSARY_TERMS_TREE = [
name: 'karan', name: 'karan',
type: 'user', type: 'user',
}, },
provider: 'user', provider: ProviderType.User,
references: [], references: [],
relatedTerms: [], relatedTerms: [],
reviewers: [], reviewers: [],
status: 'Draft', status: 'Draft' as Status,
synonyms: [], synonyms: [],
tags: [], tags: [],
type: 'glossaryTerm',
updatedAt: 1682348752125, updatedAt: 1682348752125,
updatedBy: 'karan', updatedBy: 'karan',
version: 0.1, version: 0.1,
@ -658,7 +661,7 @@ export const MOCKED_GLOSSARY_TERMS_TREE = [
name: 'Mobiles', name: 'Mobiles',
type: 'glossaryTerm', type: 'glossaryTerm',
}, },
provider: 'user', provider: ProviderType.User,
references: [{ endpoint: 'https://www.google.com', name: 'google' }], references: [{ endpoint: 'https://www.google.com', name: 'google' }],
relatedTerms: [ relatedTerms: [
{ {
@ -672,9 +675,10 @@ export const MOCKED_GLOSSARY_TERMS_TREE = [
}, },
], ],
reviewers: [], reviewers: [],
status: 'Draft', status: 'Draft' as Status,
synonyms: ['accessory'], synonyms: ['accessory'],
tags: [], tags: [],
type: 'glossaryTerm',
updatedAt: 1682348835466, updatedAt: 1682348835466,
updatedBy: 'karan', updatedBy: 'karan',
version: 0.4, version: 0.4,
@ -704,11 +708,11 @@ export const MOCKED_GLOSSARY_TERMS_TREE = [
name: 'karan', name: 'karan',
type: 'user', type: 'user',
}, },
provider: 'user', provider: ProviderType.User,
references: [{ endpoint: 'https://www.google.com', name: 'google' }], references: [{ endpoint: 'https://www.google.com', name: 'google' }],
relatedTerms: [], relatedTerms: [],
reviewers: [], reviewers: [],
status: 'Draft', status: 'Draft' as Status,
synonyms: ['accessory'], synonyms: ['accessory'],
tags: [], tags: [],
updatedAt: 1682348731309, updatedAt: 1682348731309,
@ -717,6 +721,548 @@ export const MOCKED_GLOSSARY_TERMS_TREE = [
}, },
]; ];
export const MOCKED_GLOSSARY_TERMS_1 = [
{
id: 'e01f0674-4963-43d9-a9eb-0967c63e1385',
name: 'A_bg1',
displayName: '',
description: 'fsff',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1.A_bg1',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: 'd88adce6-4cc3-4088-b436-4630c87307f0',
type: 'glossaryTerm',
name: 'BG1',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1',
description: 'fsff',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/d88adce6-4cc3-4088-b436-4630c87307f0',
},
children: [],
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689250053292,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/e01f0674-4963-43d9-a9eb-0967c63e1385',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
},
{
id: '0471d1f3-d0c8-49b6-a7ee-6ef3a716a6a3',
name: 'A_start',
displayName: '',
description: 'fsggs',
fullyQualifiedName: 'Banking.Term1.Term2f.A_start',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
type: 'glossaryTerm',
name: 'Term2f',
fullyQualifiedName: 'Banking.Term1.Term2f',
description: 'afa',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
},
children: [],
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689250037364,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/0471d1f3-d0c8-49b6-a7ee-6ef3a716a6a3',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
},
{
id: 'd88adce6-4cc3-4088-b436-4630c87307f0',
name: 'BG1',
displayName: '',
description: 'fsff',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
type: 'glossaryTerm',
name: 'Term2f',
fullyQualifiedName: 'Banking.Term1.Term2f',
description: 'afa',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
},
children: [
{
id: 'e01f0674-4963-43d9-a9eb-0967c63e1385',
type: 'glossaryTerm',
name: 'A_bg1',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1.A_bg1',
description: 'fsff',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/e01f0674-4963-43d9-a9eb-0967c63e1385',
},
],
relatedTerms: [],
references: [],
version: 0.2,
updatedAt: 1689247414058,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/d88adce6-4cc3-4088-b436-4630c87307f0',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
changeDescription: {
fieldsAdded: [],
fieldsUpdated: [
{
name: 'parent',
oldValue:
'{"id":"4242d926-8b80-4b03-9dbe-ab7138c45494","type":"glossaryTerm","name":"Term1","fullyQualifiedName":"Banking.Term1","description":"test","displayName":"","deleted":false}',
newValue:
'{"id":"50f1f9ab-50f2-45c5-a1b8-06aa03ece34a","type":"glossaryTerm","name":"Term2f","fullyQualifiedName":"Banking.Term1.Term2f","description":"afa","displayName":"","deleted":false}',
},
],
fieldsDeleted: [],
previousVersion: 0.1,
},
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
},
{
id: '4242d926-8b80-4b03-9dbe-ab7138c45494',
name: 'Term1',
displayName: '',
description: 'test',
fullyQualifiedName: 'Banking.Term1',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
children: [
{
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
type: 'glossaryTerm',
name: 'Term2f',
fullyQualifiedName: 'Banking.Term1.Term2f',
description: 'afa',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
},
],
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689247367690,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/4242d926-8b80-4b03-9dbe-ab7138c45494',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
},
{
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
name: 'Term2f',
displayName: '',
description: 'afa',
fullyQualifiedName: 'Banking.Term1.Term2f',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: '4242d926-8b80-4b03-9dbe-ab7138c45494',
type: 'glossaryTerm',
name: 'Term1',
fullyQualifiedName: 'Banking.Term1',
description: 'test',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/4242d926-8b80-4b03-9dbe-ab7138c45494',
},
children: [
{
id: '0471d1f3-d0c8-49b6-a7ee-6ef3a716a6a3',
type: 'glossaryTerm',
name: 'A_start',
fullyQualifiedName: 'Banking.Term1.Term2f.A_start',
description: 'fsggs',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/0471d1f3-d0c8-49b6-a7ee-6ef3a716a6a3',
},
{
id: 'd88adce6-4cc3-4088-b436-4630c87307f0',
type: 'glossaryTerm',
name: 'BG1',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1',
description: 'fsff',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/d88adce6-4cc3-4088-b436-4630c87307f0',
},
],
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689247376963,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
},
];
export const MOCKED_GLOSSARY_TERMS_TREE_1 = [
{
id: '4242d926-8b80-4b03-9dbe-ab7138c45494',
name: 'Term1',
displayName: '',
description: 'test',
fullyQualifiedName: 'Banking.Term1',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
children: [
{
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
name: 'Term2f',
displayName: '',
description: 'afa',
fullyQualifiedName: 'Banking.Term1.Term2f',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: '4242d926-8b80-4b03-9dbe-ab7138c45494',
type: 'glossaryTerm',
name: 'Term1',
fullyQualifiedName: 'Banking.Term1',
description: 'test',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/4242d926-8b80-4b03-9dbe-ab7138c45494',
},
children: [
{
id: '0471d1f3-d0c8-49b6-a7ee-6ef3a716a6a3',
name: 'A_start',
displayName: '',
description: 'fsggs',
fullyQualifiedName: 'Banking.Term1.Term2f.A_start',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
type: 'glossaryTerm',
name: 'Term2f',
fullyQualifiedName: 'Banking.Term1.Term2f',
description: 'afa',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
},
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689250037364,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/0471d1f3-d0c8-49b6-a7ee-6ef3a716a6a3',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
type: 'glossaryTerm',
},
{
id: 'd88adce6-4cc3-4088-b436-4630c87307f0',
name: 'BG1',
displayName: '',
description: 'fsff',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: '50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
type: 'glossaryTerm',
name: 'Term2f',
fullyQualifiedName: 'Banking.Term1.Term2f',
description: 'afa',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
},
children: [
{
id: 'e01f0674-4963-43d9-a9eb-0967c63e1385',
name: 'A_bg1',
displayName: '',
description: 'fsff',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1.A_bg1',
synonyms: [],
glossary: {
id: '36b9b2b0-e031-4aff-93f3-5e01996cd85e',
type: 'glossary',
name: 'Banking',
fullyQualifiedName: 'Banking',
description: 'Test',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaries/36b9b2b0-e031-4aff-93f3-5e01996cd85e',
},
parent: {
id: 'd88adce6-4cc3-4088-b436-4630c87307f0',
type: 'glossaryTerm',
name: 'BG1',
fullyQualifiedName: 'Banking.Term1.Term2f.BG1',
description: 'fsff',
displayName: '',
deleted: false,
href: 'http://localhost:8585/api/v1/glossaryTerms/d88adce6-4cc3-4088-b436-4630c87307f0',
},
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689250053292,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/e01f0674-4963-43d9-a9eb-0967c63e1385',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
type: 'glossaryTerm',
},
],
relatedTerms: [],
references: [],
version: 0.2,
updatedAt: 1689247414058,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/d88adce6-4cc3-4088-b436-4630c87307f0',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
changeDescription: {
fieldsAdded: [],
fieldsUpdated: [
{
name: 'parent',
oldValue:
'{"id":"4242d926-8b80-4b03-9dbe-ab7138c45494","type":"glossaryTerm","name":"Term1","fullyQualifiedName":"Banking.Term1","description":"test","displayName":"","deleted":false}',
newValue:
'{"id":"50f1f9ab-50f2-45c5-a1b8-06aa03ece34a","type":"glossaryTerm","name":"Term2f","fullyQualifiedName":"Banking.Term1.Term2f","description":"afa","displayName":"","deleted":false}',
},
],
fieldsDeleted: [],
previousVersion: 0.1,
},
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
type: 'glossaryTerm',
},
],
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689247376963,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/50f1f9ab-50f2-45c5-a1b8-06aa03ece34a',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
type: 'glossaryTerm',
},
],
relatedTerms: [],
references: [],
version: 0.1,
updatedAt: 1689247367690,
updatedBy: 'admin',
href: 'http://localhost:8585/api/v1/glossaryTerms/4242d926-8b80-4b03-9dbe-ab7138c45494',
reviewers: [],
owner: {
id: '6c5e77d7-8e4f-4f0e-a746-477702901997',
type: 'user',
name: 'admin',
fullyQualifiedName: 'admin',
deleted: false,
href: 'http://localhost:8585/api/v1/users/6c5e77d7-8e4f-4f0e-a746-477702901997',
},
tags: [],
status: 'Draft' as Status,
deleted: false,
provider: ProviderType.User,
mutuallyExclusive: false,
},
];
export const MOCK_CSV_GLOSSARY_DATA = { export const MOCK_CSV_GLOSSARY_DATA = {
rowData: [ rowData: [
[ [

View File

@ -12,7 +12,9 @@
*/ */
import { import {
MOCKED_GLOSSARY_TERMS, MOCKED_GLOSSARY_TERMS,
MOCKED_GLOSSARY_TERMS_1,
MOCKED_GLOSSARY_TERMS_TREE, MOCKED_GLOSSARY_TERMS_TREE,
MOCKED_GLOSSARY_TERMS_TREE_1,
} from 'mocks/Glossary.mock'; } from 'mocks/Glossary.mock';
import { import {
buildTree, buildTree,
@ -58,6 +60,12 @@ describe('Glossary Utils', () => {
); );
}); });
it('should build the tree correctly when the terms with empty children are received as initial items in array', () => {
expect(buildTree(MOCKED_GLOSSARY_TERMS_1)).toEqual(
MOCKED_GLOSSARY_TERMS_TREE_1
);
});
it('formatRelatedTermOptions - should format related term options correctly', () => { it('formatRelatedTermOptions - should format related term options correctly', () => {
const data = [ const data = [
{ id: 'term1', displayName: 'Term One', type: 'glossaryTerm' }, { id: 'term1', displayName: 'Term One', type: 'glossaryTerm' },

View File

@ -110,34 +110,26 @@ export const getRootLevelGlossaryTerm = (
export const buildTree = (data: GlossaryTerm[]): GlossaryTerm[] => { export const buildTree = (data: GlossaryTerm[]): GlossaryTerm[] => {
const nodes: Record<string, GlossaryTerm> = {}; const nodes: Record<string, GlossaryTerm> = {};
const tree: GlossaryTerm[] = [];
// Sorting children having parent first to avoid duplicates // Create nodes first
const sortedData = [...data].sort((a, b) => { data.forEach((obj) => {
if (a.parent && !b.parent) { nodes[obj.fullyQualifiedName ?? ''] = {
return 1;
} else if (!a.parent && b.parent) {
return -1;
} else {
return 0;
}
});
sortedData.forEach((obj) => {
if (obj.fullyQualifiedName) {
nodes[obj.fullyQualifiedName] = {
...obj, ...obj,
children: obj.children?.length ? [] : undefined, children: obj.children?.length ? [] : undefined,
}; };
const parentNode = });
obj.parent?.fullyQualifiedName && nodes[obj.parent.fullyQualifiedName];
parentNode && // Build the tree structure
nodes[obj.fullyQualifiedName] && const tree: GlossaryTerm[] = [];
parentNode.children?.push( data.forEach((obj) => {
nodes[obj.fullyQualifiedName] as unknown as EntityReference const current = nodes[obj.fullyQualifiedName ?? ''];
); const parent = nodes[obj.parent?.fullyQualifiedName || ''];
parentNode ? null : tree.push(nodes[obj.fullyQualifiedName]);
if (parent && parent.children) {
// converting glossaryTerm to EntityReference
parent.children.push({ ...current, type: 'glossaryTerm' });
} else {
tree.push(current);
} }
}); });