From 883a2be3e1e6e1efc7abc4a7814bbf458c73a3fc Mon Sep 17 00:00:00 2001 From: Kristof Vandenbroucke Date: Tue, 17 Sep 2024 11:39:39 +0200 Subject: [PATCH] Include NOTES into the values of the `tagValue` is equal to `NOTE` (#69) --- .../lib/enums/TagValues.ts | 3 +++ packages/oslo-converter-uml-ea/package.json | 4 +-- .../lib/utils/assignTags.ts | 26 +++++++++++++------ packages/oslo-extractor-uml-ea/package.json | 2 +- 4 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 packages/oslo-converter-uml-ea/lib/enums/TagValues.ts diff --git a/packages/oslo-converter-uml-ea/lib/enums/TagValues.ts b/packages/oslo-converter-uml-ea/lib/enums/TagValues.ts new file mode 100644 index 0000000..e044f45 --- /dev/null +++ b/packages/oslo-converter-uml-ea/lib/enums/TagValues.ts @@ -0,0 +1,3 @@ +export enum TagValues { + NOTE = 'NOTE', +} diff --git a/packages/oslo-converter-uml-ea/package.json b/packages/oslo-converter-uml-ea/package.json index eafcfdd..dabd2fb 100644 --- a/packages/oslo-converter-uml-ea/package.json +++ b/packages/oslo-converter-uml-ea/package.json @@ -1,6 +1,6 @@ { "name": "@oslo-flanders/ea-converter", - "version": "0.0.21-alpha.0", + "version": "0.0.22-alpha.0", "description": "Transform an Enterprise Architect UML diagram to RDF", "author": "Digitaal Vlaanderen ", "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-converter-uml-ea#readme", @@ -42,7 +42,7 @@ }, "dependencies": { "@oslo-flanders/core": "^0.0.15-alpha.0", - "@oslo-flanders/ea-uml-extractor": "^0.0.20-alpha.0", + "@oslo-flanders/ea-uml-extractor": "^0.0.21-alpha.0", "@oslo-flanders/output-handlers": "^0.0.4-alpha.0", "inversify": "^6.0.1", "n3": "^1.16.2", diff --git a/packages/oslo-extractor-uml-ea/lib/utils/assignTags.ts b/packages/oslo-extractor-uml-ea/lib/utils/assignTags.ts index 8e3cbe8..75b4ef0 100644 --- a/packages/oslo-extractor-uml-ea/lib/utils/assignTags.ts +++ b/packages/oslo-extractor-uml-ea/lib/utils/assignTags.ts @@ -1,3 +1,4 @@ +import { TagValues } from '../../../oslo-converter-uml-ea/lib/enums/TagValues'; import type { EaConnector } from '../types/EaConnector'; import type { EaObject } from '../types/EaObject'; import type { EaTag } from '../types/EaTag'; @@ -15,8 +16,8 @@ export function addEaTagsToElements( objectIdPropertyName: string, tagValueName: string, ): void { - tags.forEach(tag => { - const element = elements.find(x => x.id === tag[objectIdPropertyName]); + tags.forEach((tag) => { + const element = elements.find((x) => x.id === tag[objectIdPropertyName]); if (!element) { // TODO: log message @@ -24,7 +25,12 @@ export function addEaTagsToElements( const eaTag: EaTag = { id: tag.PropertyID, tagName: tag.Property, - tagValue: tag[tagValueName], + // https://vlaamseoverheid.atlassian.net/jira/software/projects/SDTT/issues/SDTT-335 + // If there are NOTES, then the tag value is a note, otherwise it is the tag value. + tagValue: + tag[tagValueName] === TagValues.NOTE + ? tag.Notes + : tag[tagValueName], }; element.tags = element.tags ? [...element.tags, eaTag] : [eaTag]; @@ -41,14 +47,14 @@ export function addRoleTagsToElements( tags: any[], eaConnectors: EaConnector[], ): void { - eaConnectors.forEach(con => { - const connectorRoleTags = tags.filter(x => x.ElementID === con.eaGuid); + eaConnectors.forEach((con) => { + const connectorRoleTags = tags.filter((x) => x.ElementID === con.eaGuid); if (connectorRoleTags.length === 0) { return; } - connectorRoleTags.forEach(roleTag => { + connectorRoleTags.forEach((roleTag) => { const eaRoleTag: EaTag = { id: roleTag.PropertyID, tagName: roleTag.TagValue, @@ -56,11 +62,15 @@ export function addRoleTagsToElements( }; if (roleTag.BaseClass === 'ASSOCIATION_SOURCE') { - con.sourceRoleTags = con.sourceRoleTags ? [...con.sourceRoleTags, eaRoleTag] : [eaRoleTag]; + con.sourceRoleTags = con.sourceRoleTags + ? [...con.sourceRoleTags, eaRoleTag] + : [eaRoleTag]; } if (roleTag.BaseClass === 'ASSOCIATION_TARGET') { - con.destinationRoleTags = con.destinationRoleTags ? [...con.destinationRoleTags, eaRoleTag] : [eaRoleTag]; + con.destinationRoleTags = con.destinationRoleTags + ? [...con.destinationRoleTags, eaRoleTag] + : [eaRoleTag]; } }); }); diff --git a/packages/oslo-extractor-uml-ea/package.json b/packages/oslo-extractor-uml-ea/package.json index bbd03c5..2fa0fb7 100644 --- a/packages/oslo-extractor-uml-ea/package.json +++ b/packages/oslo-extractor-uml-ea/package.json @@ -1,6 +1,6 @@ { "name": "@oslo-flanders/ea-uml-extractor", - "version": "0.0.20-alpha.0", + "version": "0.0.21-alpha.0", "description": "Reads all the information from an Enterprise Architect UML diagram", "author": "Digitaal Vlaanderen ", "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-extract-uml-ea#readme",