const PREFIXES = ` PREFIX besluit: PREFIX skos: PREFIX lblodgeneriek: PREFIX org: PREFIX code: PREFIX adms: PREFIX generiek: PREFIX ere: PREFIX organisatie: PREFIX mu: PREFIX euvoc: PREFIX prov: PREFIX schema: PREFIX locn: PREFIX ext: ` const contextConfig = { addTypes: { scope: 'all', // 'inserts, 'deletes', 'all' or none. To add rdf:type to subjects of inserts, deletes or both exhausitive: false, // true or false: find all types for a subject, even if one is already present in delta }, contextQueries: [ { trigger: { // subjectType or predicateValue subjectType: "org:Site" }, queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ${subject} ext:goesInGraph ?graphOne. ${subject} ext:goesInGraph ?graphTwo. ${subject} ext:goesInGraph ?graphThree. ${subject} ext:goesInGraph ?graphFour. } WHERE { OPTIONAL { GRAPH { ?adminUnitOne org:hasPrimarySite ${subject}. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ?adminUnitTwo org:hasSite ${subject}. } BIND( AS ?graphTwo) } OPTIONAL { GRAPH { ?adminUnitThree org:hasPrimarySite ${subject}. } BIND( AS ?graphThree) } OPTIONAL { GRAPH { ?adminUnitFour org:hasSite ${subject}. } BIND( AS ?graphFour) } }` }, { trigger: { // subjectType or predicateValue subjectType: "schema:ContactPoint" }, queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ${subject} ext:goesInGraph ?graphOne. ${subject} ext:goesInGraph ?graphTwo. } WHERE { OPTIONAL { GRAPH { ?siteOne org:siteAddress ${subject}. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ?siteTwo org:siteAddress ${subject}. } BIND( AS ?graphTwo) } }` }, { trigger: { // subjectType or predicateValue subjectType: "locn:Address" }, queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ${subject} ext:goesInGraph ?graphOne. ${subject} ext:goesInGraph ?graphTwo. } WHERE { OPTIONAL { GRAPH { ?siteOne organisatie:bestaatUit ${subject}. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ?siteTwo organisatie:bestaatUit ${subject}. } BIND( AS ?graphTwo) } }` }, //Predicate triggers to solve out of order deltas { trigger: { // subjectType or predicateValue predicateValue: "org:hasSite" }, //We assume that only administrative units are in the shared graph of OP due to the need of sharing the prefLabel with worships services queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ${subject} ext:goesInGraph ?graphOne. ${subject} ext:goesInGraph ?graphTwo. ?site ?pSite ?oSite. ?contact ?pContact ?oContact. ?address ?pAddress ?oAddress. ?addressContact ?pAddressContact ?oAddressContact. } WHERE { OPTIONAL { GRAPH { ${subject} a ?type. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ${subject} a ?type. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ${subject} a ?type. } BIND( AS ?graphTwo) } ${subject} org:hasSite ?site. ?site ?pSite ?oSite. { ?site org:siteAddress ?contact. ?contact ?pContact ?oContact. ?contact locn:address ?addressContact. ?addressContact ?pAddressContact ?oAddressContact. } UNION { ?site org:siteAddress ?contact. ?contact ?pContact ?oContact. } UNION { ?site organisatie:bestaatUit ?address. ?address ?pAddress ?oAddress. } }` }, { trigger: { // subjectType or predicateValue predicateValue: "org:hasPrimarySite" }, //We assume that only administrative units are in the shared graph of OP due to the need of sharing the prefLabel with worships services queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ${subject} ext:goesInGraph ?graphOne. ${subject} ext:goesInGraph ?graphTwo. ?site ?pSite ?oSite. ?contact ?pContact ?oContact. ?address ?pAddress ?oAddress. ?addressContact ?pAddressContact ?oAddressContact. } WHERE { OPTIONAL { GRAPH { ${subject} a ?type. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ${subject} a ?type. } BIND( AS ?graphOne) } OPTIONAL { GRAPH { ${subject} a ?type. } BIND( AS ?graphTwo) } ${subject} org:hasPrimarySite ?site. ?site ?pSite ?oSite. { ?site org:siteAddress ?contact. ?contact ?pContact ?oContact. ?contact locn:address ?addressContact. ?addressContact ?pAddressContact ?oAddressContact. } UNION { ?site org:siteAddress ?contact. ?contact ?pContact ?oContact. } UNION { ?site organisatie:bestaatUit ?address. ?address ?pAddress ?oAddress. } }` }, { trigger: { // subjectType or predicateValue predicateValue: "org:siteAddress" }, queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ?contact ?pContact ?oContact. ?addressContact ?pAddressContact ?oAddressContact. } WHERE { ${subject} org:siteAddress ?contact. ?contact ?pContact ?oContact. OPTIONAL { ?contact locn:address ?addressContact. ?addressContact ?pAddressContact ?oAddressContact. } }` }, { trigger: { // subjectType or predicateValue predicateValue: "locn:address" }, queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ?addressContact ?pAddressContact ?oAddressContact. } WHERE { ${subject} locn:address ?addressContact. ?addressContact ?pAddressContact ?oAddressContact. }` }, { trigger: { // subjectType or predicateValue predicateValue: "organisatie:bestaatUit" }, queryTemplate: (subject) => ` ${PREFIXES} CONSTRUCT { ?address ?pAddress ?oAddress. } WHERE { ${subject} organisatie:bestaatUit ?address. ?address ?pAddress ?oAddress. }` } ] } module.exports = { contextConfig, PREFIXES };