From 6b4e345e97d7ba06f3f5a2e3ed4920425e07c2fb Mon Sep 17 00:00:00 2001 From: Dwight Van Lancker Date: Thu, 14 Sep 2023 15:05:04 +0200 Subject: [PATCH] Add assignedUri to rdf:Statement --- .../AttributeConverterHandler.ts | 16 +++++++++++++++- .../lib/JsonLdOutputHandler.ts | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/oslo-converter-uml-ea/lib/converterHandlers/AttributeConverterHandler.ts b/packages/oslo-converter-uml-ea/lib/converterHandlers/AttributeConverterHandler.ts index 4506a30..18954cd 100644 --- a/packages/oslo-converter-uml-ea/lib/converterHandlers/AttributeConverterHandler.ts +++ b/packages/oslo-converter-uml-ea/lib/converterHandlers/AttributeConverterHandler.ts @@ -164,7 +164,7 @@ export class AttributeConverterHandler extends ConverterHandler { ), ); - quads.push(...this.addRangeRdfStatement(attributeInternalId, rangeUriNamedNode, model, rangeLabel, rangeElement)); + quads.push(...this.addRangeRdfStatement(attributeInternalId, rangeUriNamedNode, model, uriRegistry, rangeLabel, rangeElement)); const definitionLiterals = this.getDefinition(object); definitionLiterals.forEach(x => quads.push(this.df.quad(attributeInternalId, ns.rdfs('comment'), x))); @@ -232,6 +232,7 @@ export class AttributeConverterHandler extends ConverterHandler { attributeUri: RDF.NamedNode, rangeUri: RDF.NamedNode, model: DataRegistry, + uriRegistry: UriRegistry, rangeLabel?: string, rangeElement?: EaElement, ): RDF.Quad[] { @@ -256,6 +257,19 @@ export class AttributeConverterHandler extends ConverterHandler { const usageNoteValues = (this.getUsageNote)(rangeElement); usageNoteValues.forEach(x => quads.push(this.df.quad(statementBlankNode, ns.vann('usageNote'), x))); + const assignedUri = uriRegistry.elementIdUriMap.get(rangeElement.id); + if(!assignedUri){ + throw new Error(`[AttributeConverterHandler]: Unable to find the assigned URI for the range (${rangeElement.path}) of attribute.`); + } + + quads.push( + this.df.quad( + statementBlankNode, + ns.example('assignedUri'), + this.df.namedNode(assignedUri.toString()) + ) + ) + const skosCodelist = getTagValue(rangeElement, TagNames.ApCodelist, null); if (skosCodelist) { quads.push( diff --git a/packages/oslo-output-handlers/lib/JsonLdOutputHandler.ts b/packages/oslo-output-handlers/lib/JsonLdOutputHandler.ts index 408ac64..2f0fae5 100644 --- a/packages/oslo-output-handlers/lib/JsonLdOutputHandler.ts +++ b/packages/oslo-output-handlers/lib/JsonLdOutputHandler.ts @@ -249,6 +249,7 @@ export class JsonLdOutputHandler implements IOutputHandler { const statementPredicate = store.findObject(subject, ns.rdf('predicate')); const statementObject = store.findObject(subject, ns.rdf('object')); + const statementAssignedUri = store.findObject(subject, ns.example('assignedUri')); const statementLabels = store.findObjects(subject, ns.rdfs('label')); const statementDefinitions = store.findObjects( subject, @@ -274,6 +275,9 @@ export class JsonLdOutputHandler implements IOutputHandler { object: { '@id': statementObject?.value, }, + ...(statementAssignedUri && { + assignedUri: statementAssignedUri.value, + }), ...(statementLabels.length > 0 && { label: statementLabels.map((x) => ({ '@language': (x).language,