-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new version of handling besluit information #45
base: master
Are you sure you want to change the base?
Changes from all commits
8f3d1d8
3efdc16
54540a6
2a180cd
c973638
6f1fe42
f93e979
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bit confused about these http vs https prefixes, both seem to be in use in our application. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,15 @@ PREFIX euro: <http://data.europa.eu/m8g/> | |
PREFIX euvoc: <http://publications.europa.eu/ontology/euvoc#> | ||
PREFIX ext: <http://mu.semte.ch/vocabularies/ext/> | ||
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | ||
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#> | ||
PREFIX generiek: <http://data.vlaanderen.be/ns/generiek#> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this generiek prefix, if I look in the app, sometimes we seem to use |
||
PREFIX lblodlg: <https://data.lblod.info/vocabularies/leidinggevenden/> | ||
PREFIX locn: <http://www.w3.org/ns/locn#> | ||
PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#> | ||
PREFIX mu: <http://mu.semte.ch/vocabularies/core/> | ||
PREFIX org: <http://www.w3.org/ns/org#> | ||
PREFIX organisatie: <https://data.vlaanderen.be/ns/organisatie#> | ||
PREFIX person: <http://www.w3.org/ns/person#> | ||
PREFIX persoon: <https://data.vlaanderen.be/ns/persoon#> | ||
PREFIX persoon: <http://data.vlaanderen.be/ns/persoon#> | ||
PREFIX prov: <http://www.w3.org/ns/prov#> | ||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
PREFIX regorg: <https://www.w3.org/ns/regorg#> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { | ||
copySimpleInstanceToGraph, | ||
getBeleidsdomeinTriplesInStagingGraph, | ||
getGraphsWhereInstanceExists, | ||
insertTriplesInGraph, | ||
} from '../../data-access/mandatees-decisions'; | ||
import { MandatarisFullInfo, Triple } from '../../types'; | ||
import { createMandatarisBesluitNotification } from '../../util/create-notification'; | ||
import { getUuidForUri } from '../../util/uuid-for-uri'; | ||
|
||
export async function copyBeleidsdomeinInfo( | ||
mandatarisFullInfo: MandatarisFullInfo, | ||
) { | ||
const beleidsDomeinen = mandatarisFullInfo.triples | ||
.filter( | ||
(triple) => | ||
triple.predicate.value === | ||
'http://data.vlaanderen.be/ns/mandaat#beleidsdomein', | ||
) | ||
.map((triple) => triple.object.value); | ||
|
||
for (const beleidsDomein of beleidsDomeinen) { | ||
await copyBeleidsDomein( | ||
mandatarisFullInfo, | ||
beleidsDomein, | ||
mandatarisFullInfo.graph, | ||
); | ||
} | ||
} | ||
|
||
async function copyBeleidsDomein( | ||
mandatarisFullInfo: MandatarisFullInfo, | ||
beleidsDomein: string, | ||
graph: string, | ||
): Promise<void> { | ||
const graphsForBeleidsDomein = | ||
await getGraphsWhereInstanceExists(beleidsDomein); | ||
const inAppropriateGraph = graphsForBeleidsDomein.find((g) => | ||
['http://mu.semte.ch/graphs/public', graph].includes(g.graph.value), | ||
); | ||
if (graphsForBeleidsDomein.length === 0) { | ||
await createBeleidsDomein(beleidsDomein, graph); | ||
await createMandatarisBesluitNotification({ | ||
title: 'Beleidsdomein aangemaakt', | ||
description: | ||
'Een nieuw beleidsdomein werd aangemaakt op basis van de informatie in het Besluit.', | ||
type: 'info', | ||
info: mandatarisFullInfo, | ||
}); | ||
} else if (!inAppropriateGraph) { | ||
await copySimpleInstanceToGraph(beleidsDomein, graph); | ||
} else { | ||
// beleidsdomein exists in an appropriate graph. nothing to do | ||
} | ||
} | ||
|
||
async function createBeleidsDomein(beleidsdomeinUri: string, graph: string) { | ||
const triplesForBeleidsdomein = | ||
await getBeleidsdomeinTriplesInStagingGraph(beleidsdomeinUri); | ||
const id = await getUuidForUri(beleidsdomeinUri, { | ||
allowCheckingUri: true, | ||
allowGenerateUuid: true, | ||
}); | ||
const extraTriples: Triple[] = [ | ||
{ | ||
subject: { | ||
value: beleidsdomeinUri, | ||
type: 'uri', | ||
}, | ||
predicate: { | ||
value: 'http://mu.semte.ch/vocabularies/core/uuid', | ||
type: 'uri', | ||
}, | ||
object: { | ||
value: id, | ||
type: 'string', | ||
}, | ||
}, | ||
{ | ||
subject: { | ||
value: beleidsdomeinUri, | ||
type: 'uri', | ||
}, | ||
predicate: { | ||
value: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', | ||
type: 'uri', | ||
}, | ||
object: { | ||
value: 'http://mu.semte.ch/vocabularies/ext/BeleidsdomeinCode', | ||
type: 'uri', | ||
}, | ||
}, | ||
{ | ||
subject: { | ||
value: beleidsdomeinUri, | ||
type: 'uri', | ||
}, | ||
predicate: { | ||
value: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', | ||
type: 'uri', | ||
}, | ||
object: { | ||
value: 'http://www.w3.org/2004/02/skos/core#Concept', | ||
type: 'uri', | ||
}, | ||
}, | ||
{ | ||
subject: { | ||
value: beleidsdomeinUri, | ||
type: 'uri', | ||
}, | ||
predicate: { | ||
value: 'http://www.w3.org/2004/02/skos/core#inScheme', | ||
type: 'uri', | ||
}, | ||
object: { | ||
value: 'http://data.vlaanderen.be/id/conceptscheme/BeleidsdomeinCode', | ||
type: 'uri', | ||
}, | ||
}, | ||
{ | ||
subject: { | ||
value: beleidsdomeinUri, | ||
type: 'uri', | ||
}, | ||
predicate: { | ||
value: 'http://www.w3.org/2004/02/skos/core#topConceptOf', | ||
type: 'uri', | ||
}, | ||
object: { | ||
value: 'http://data.vlaanderen.be/id/conceptscheme/BeleidsdomeinCode', | ||
type: 'uri', | ||
}, | ||
}, | ||
]; | ||
const allTriples = [...triplesForBeleidsdomein, ...extraTriples]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this potentially give duplicate triples? Or is virtuoso smart enough to only write identical triples once? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In hindsight not a problem, since |
||
await insertTriplesInGraph(allTriples, graph); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably remove this when actually merging this I guess?