Skip to content

Commit

Permalink
Add assignedUri to rdf:Statement
Browse files Browse the repository at this point in the history
  • Loading branch information
ddvlanck committed Sep 14, 2023
1 parent 3447d1f commit 6b4e345
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class AttributeConverterHandler extends ConverterHandler<EaAttribute> {
),
);

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)));
Expand Down Expand Up @@ -232,6 +232,7 @@ export class AttributeConverterHandler extends ConverterHandler<EaAttribute> {
attributeUri: RDF.NamedNode,
rangeUri: RDF.NamedNode,
model: DataRegistry,
uriRegistry: UriRegistry,
rangeLabel?: string,
rangeElement?: EaElement,
): RDF.Quad[] {
Expand All @@ -256,6 +257,19 @@ export class AttributeConverterHandler extends ConverterHandler<EaAttribute> {
const usageNoteValues = <RDF.Literal[]>(<any>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(
Expand Down
4 changes: 4 additions & 0 deletions packages/oslo-output-handlers/lib/JsonLdOutputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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': (<RDF.Literal>x).language,
Expand Down

0 comments on commit 6b4e345

Please sign in to comment.