diff --git a/config/ldes-delta-pusher/dispatch.ts b/config/ldes-delta-pusher/dispatch.ts index ba852e3..42feb68 100644 --- a/config/ldes-delta-pusher/dispatch.ts +++ b/config/ldes-delta-pusher/dispatch.ts @@ -7,14 +7,40 @@ export default async function dispatch(changesets: Changeset[]) { const subjects = new Set(changeset.inserts.map((insert) => insert.subject.value)); for (const subject of subjects) { const { results: { bindings } } = await query(` - PREFIX org: - CONSTRUCT { - ${sparqlEscapeUri(subject)} a org:Organization; - ?p ?o. - } - WHERE { - ${sparqlEscapeUri(subject)} a org:Organization; - ?p ?o. + PREFIX skos: + PREFIX code: + PREFIX org: + PREFIX adms: + + CONSTRUCT { + ?organization a org:Organization; + adms:identifier ?identifier; + org:hasPrimarySite ?site. + ?site org:siteAddress ?siteAddress. + ?siteAddress ?p ?o. + } WHERE { + { + VALUES ?organization { ${sparqlEscapeUri(subject)} } + ?organization a org:Organization; + adms:identifier ?identifier; + org:hasPrimarySite ?site. + ?site org:siteAddress ?siteAddress. + ?siteAddress ?p ?o. + } UNION { + VALUES ?site { ${sparqlEscapeUri(subject)} } + ?organization a org:Organization; + adms:identifier ?identifier; + org:hasPrimarySite ?site. + ?site org:siteAddress ?siteAddress. + ?siteAddress ?p ?o. + } UNION { + VALUES ?siteAddress { ${sparqlEscapeUri(subject)} } + ?organization a org:Organization; + adms:identifier ?identifier; + org:hasPrimarySite ?site. + ?site org:siteAddress ?siteAddress. + ?siteAddress ?p ?o. + } } `); if(bindings.length){