Skip to content

Commit

Permalink
Merge pull request #778 from lblod/BNB-792-rmw-bekrachtigtaanstellingvan
Browse files Browse the repository at this point in the history
GN-5275: RMW mandatee tables - move bekrachtigtAanstellingVan predicate to 'eedafleggingen' table
  • Loading branch information
abeforgit authored Nov 25, 2024
2 parents 954220b + 309000f commit 2406ed1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 deletions.
7 changes: 7 additions & 0 deletions .changeset/silly-owls-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'frontend-gelinkt-notuleren': minor
---

RMW mandatee table adjustments:
- Add `mandaat:bekrachtigtAanstellingVan` predicate to mandatees in 'Eedafleggingen' table (`IVRMW2-LBM-5-eed-leden`)
- Remove `mandaat:bekrachtigtAanstellingVan` predicate from 'Verkiezingen' table (`IVRMW2-LBM-3-verkiezing-leden`)
2 changes: 0 additions & 2 deletions app/components/meeting-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
MANDATARIS_STATUS_EFFECTIEF,
MANDATARIS_STATUS_WAARNEMEND,
} from '../utils/constants';
import { getIdentifier } from '../utils/rdf-utils';
import { BESTUURSFUNCTIE_CODES } from '../config/constants';

/** @typedef {import("../models/agendapunt").default[]} Agendapunt */

Expand Down
78 changes: 37 additions & 41 deletions app/config/mandatee-table-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1414,18 +1414,6 @@ export const mandateeTableConfigRMW = (meeting) => {
return (state) => {
const { doc, schema } = state;
const $pos = doc.resolve(pos);
const decisionUri = findParentNodeClosestToPos($pos, (node) => {
return hasOutgoingNamedNodeTriple(
node.attrs,
RDF('type'),
BESLUIT('Besluit'),
);
})?.node.attrs.subject;
if (!decisionUri) {
throw new Error(
'Could not find decision to sync mandatee table with',
);
}
const bindings = queryResult.results.bindings;
const tableHeader = row(
schema,
Expand All @@ -1439,16 +1427,11 @@ export const mandateeTableConfigRMW = (meeting) => {
true,
);
const rows = bindings.map((binding) => {
const {
mandataris,
persoon_naam,
mandaat_start,
mandaat_einde,
fractie_naam,
} = bindingToObject(binding);
const { persoon_naam, mandaat_start, mandaat_einde, fractie_naam } =
bindingToObject(binding);
return row(schema, [
schema.text(fractie_naam),
resourceNode(schema, mandataris, persoon_naam),
schema.text(persoon_naam),
dateNode(schema, mandaat_start),
dateNode(schema, mandaat_einde),
undefined,
Expand All @@ -1458,23 +1441,9 @@ export const mandateeTableConfigRMW = (meeting) => {
tableHeader,
...rows,
]);
const factory = new SayDataFactory();
const result = transactionCombinator(
state,
replaceContent(state.tr, $pos, content),
)(
bindings.map((binding) => {
return addPropertyToNode({
resource: decisionUri,
property: {
predicate: MANDAAT('bekrachtigtAanstellingVan').full,
object: factory.resourceNode(binding['mandataris'].value),
},
});
}),
);
const transaction = replaceContent(state.tr, $pos, content);
return {
transaction: result.transaction,
transaction,
result: true,
initialState: state,
};
Expand Down Expand Up @@ -1590,7 +1559,7 @@ export const mandateeTableConfigRMW = (meeting) => {
PREFIX person: <http://www.w3.org/ns/person#>
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
SELECT DISTINCT ?persoon ?persoon_naam ?fractie ?fractie_naam WHERE {
SELECT DISTINCT ?mandataris ?persoon ?persoon_naam ?fractie ?fractie_naam WHERE {
?persoon a person:Person.
?persoon persoon:gebruikteVoornaam ?voornaam.
?persoon foaf:familyName ?achternaam.
Expand Down Expand Up @@ -1634,6 +1603,18 @@ export const mandateeTableConfigRMW = (meeting) => {
return (state) => {
const { doc, schema } = state;
const $pos = doc.resolve(pos);
const decisionUri = findParentNodeClosestToPos($pos, (node) => {
return hasOutgoingNamedNodeTriple(
node.attrs,
RDF('type'),
BESLUIT('Besluit'),
);
})?.node.attrs.subject;
if (!decisionUri) {
throw new Error(
'Could not find decision to sync mandatee table with',
);
}
const bindings = queryResult.results.bindings;
const tableHeader = row(
schema,
Expand All @@ -1644,19 +1625,34 @@ export const mandateeTableConfigRMW = (meeting) => {
true,
);
const rows = bindings.map((binding) => {
const { persoon_naam, fractie_naam } = bindingToObject(binding);
const { mandataris, persoon_naam, fractie_naam } =
bindingToObject(binding);
return row(schema, [
schema.text(persoon_naam),
resourceNode(schema, mandataris, persoon_naam),
schema.text(fractie_naam),
]);
});
const content = schema.nodes.table.create(null, [
tableHeader,
...rows,
]);
const transaction = replaceContent(state.tr, $pos, content);
const factory = new SayDataFactory();
const result = transactionCombinator(
state,
replaceContent(state.tr, $pos, content),
)(
bindings.map((binding) => {
return addPropertyToNode({
resource: decisionUri,
property: {
predicate: MANDAAT('bekrachtigtAanstellingVan').full,
object: factory.resourceNode(binding['mandataris'].value),
},
});
}),
);
return {
transaction,
transaction: result.transaction,
result: true,
initialState: state,
};
Expand Down

0 comments on commit 2406ed1

Please sign in to comment.