diff --git a/config/migrations/2023/20231205094344-mandaat-date-to-datetime.sparql b/config/migrations/2023/20231205094344-mandaat-date-to-datetime.sparql new file mode 100644 index 0000000..6e81b83 --- /dev/null +++ b/config/migrations/2023/20231205094344-mandaat-date-to-datetime.sparql @@ -0,0 +1,151 @@ +PREFIX mandaat: +PREFIX ch: +PREFIX ere: +PREFIX xsd: +DELETE { + GRAPH ?g { + ?s mandaat:start ?o . + } +} +INSERT { + GRAPH ?g { + ?s mandaat:start ?converteddate . + } +} +WHERE { + GRAPH ?g { + ?s mandaat:start ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). +} +; +DELETE { + GRAPH ?g { + ?s mandaat:einde ?o . + } + } + INSERT { + GRAPH ?g { + ?s mandaat:einde ?converteddate . + } + } + WHERE { + GRAPH ?g { + ?s mandaat:einde ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). + } +; +DELETE { + GRAPH ?g { + ?s mandaat:bindingStart ?o . + } + } + INSERT { + GRAPH ?g { + ?s mandaat:bindingStart ?converteddate . + } + } + WHERE { + GRAPH ?g { + ?s mandaat:bindingStart ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). + } +; +DELETE { + GRAPH ?g { + ?s mandaat:bindingEinde ?o . + } + } + INSERT { + GRAPH ?g { + ?s mandaat:bindingEinde ?converteddate . + } + } + WHERE { + GRAPH ?g { + ?s mandaat:bindingEinde ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). + } +; +DELETE { + GRAPH ?g { + ?s ch:startdatum ?o . + } +} +INSERT { + GRAPH ?g { + ?s ch:startdatum ?converteddate . + } +} +WHERE { + GRAPH ?g { + ?s ch:startdatum ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). +} +; +DELETE { + GRAPH ?g { + ?s ch:eindedatum ?o . + } + } + INSERT { + GRAPH ?g { + ?s ch:eindedatum ?converteddate . + } + } + WHERE { + GRAPH ?g { + ?s ch:eindedatum ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). + } +; + DELETE { + GRAPH ?g { + ?s ere:geplandeEinddatumAanstelling ?o . + } + } + INSERT { + GRAPH ?g { + ?s ere:geplandeEinddatumAanstelling ?converteddate . + } + } + WHERE { + GRAPH ?g { + ?s ere:geplandeEinddatumAanstelling ?o . + } + VALUES ?g { + + + } + BIND(IF(strlen(str(?o)) = 10, strdt(concat(str(?o), 'T02:00:00'), xsd:dateTime), ?o) as ?converteddate). + } + ; \ No newline at end of file diff --git a/config/reasoner/dl2op/main-info/mapping.n3 b/config/reasoner/dl2op/main-info/mapping.n3 index ec1a9a1..326b028 100644 --- a/config/reasoner/dl2op/main-info/mapping.n3 +++ b/config/reasoner/dl2op/main-info/mapping.n3 @@ -67,54 +67,113 @@ PREFIX ere: ?s persoon:gebruikteVoornaam ?o }. -# Test -# ex:s "2019-01-01T19:32:52+00:00"^^xsd:dateTime. -{ - ?s mandaat:start ?startDateTime. - # use backward arrow rule defined below - ?startDateTime :dateFromDateTime ?startDate. - { - ?s mandaat:start ?startDateTime - } e:becomes { - ?s mandaat:start ?startDate - }. -} => { - ?s mandaat:start ?startDate -}. +# Test # ex:s "2019-02-01T10:32:52+00:00"^^xsd:dateTime. { - ?s mandaat:einde ?eindeDateTime. + ?s mandaat:bindingEinde ?eindeDate. # use backward arrow rule defined below - ?eindeDateTime :dateFromDateTime ?eindeDate. + ?eindeDate :dateTimeFromDate ?eindeDateTime. { - ?s mandaat:einde ?eindeDateTime + ?s mandaat:bindingEinde ?eindeDate } e:becomes { - ?s mandaat:einde ?eindeDate + ?s mandaat:bindingEinde ?eindeDateTime }. } => { - ?s mandaat:einde ?eindeDate + ?s mandaat:bindingEinde ?eindeDateTime }. +{ + ?s mandaat:bindingStart ?startDate. + # use backward arrow rule defined below + ?startDate :dateTimeFromDate ?startDateTime. + { + ?s mandaat:bindingStart ?startDate + } e:becomes { + ?s mandaat:bindingStart ?startDateTime + }. +} => { + ?s mandaat:bindingStart ?startDateTime +}. +{ + ?s ch:startdatum ?startDate. + # use backward arrow rule defined below + ?startDate :dateTimeFromDate ?startDateTime. + { + ?s ch:startdatum ?startDate + } e:becomes { + ?s ch:startdatum ?startDateTime + }. +} => { + ?s ch:startdatum ?startDateTime +}. + +{ + ?s mandaat:start ?startDate. + # use backward arrow rule defined below + ?startDate :dateTimeFromDate ?startDateTime. + { + ?s mandaat:start ?startDate + } e:becomes { + ?s mandaat:start ?startDateTime + }. +} => { + ?s mandaat:start ?startDateTime +}. + +{ + ?s mandaat:einde ?eindeDate. + # use backward arrow rule defined below + ?eindeDate :dateTimeFromDate ?eindeDateTime. + { + ?s mandaat:einde ?eindeDate + } e:becomes { + ?s mandaat:einde ?eindeDateTime + }. +} => { + ?s mandaat:einde ?eindeDateTime +}. + +{ + ?s ch:eindedatum ?endDate. + # use backward arrow rule defined below + ?endDate :dateTimeFromDate ?endDateTime. + { + ?s ch:eindedatum ?endDate + } e:becomes { + ?s ch:eindedatum ?endDateTime + }. +} => { + ?s ch:eindedatum ?endDateTime +}. + +{ + ?s ere:geplandeEinddatumAanstelling ?endDate. + # use backward arrow rule defined below + ?endDate :dateTimeFromDate ?endDateTime. + { + ?s ere:geplandeEinddatumAanstelling ?endDate + } e:becomes { + ?s ere:geplandeEinddatumAanstelling ?endDateTime + }. +} => { + ?s ere:geplandeEinddatumAanstelling ?endDateTime +}. # Backward arrow rule is like a function call. -# Removes time info in the returned date -# The user in DL selects a date via the UI. -# These dates are persisted as midnight dateTimes in UTC. -# Meaning that 1st of July is stored as -# "2022-06-30T22:00:00Z"^^xsd:dateTime -# and 1 December -# "2022-11-30T23:00:00Z"^^xsd:dateTime -# So, the following rule adds 2 hours to the datetime, and then takes the date part of the UTC date time -# to come to the date that the DL user selected (in CE(S)T) +# Removes the timezone indicator "Z" from incoming datetimes +# To make sure all datetimes have the same convention we now save them as +# datetime without the timezone indicator +# We use "T02:00:00" as time indicator to work around a virtuoso bug that +# results in datetimes being converted to a date when using "T00:00:00" { - ?dateTime :dateFromDateTime ?date -} <= { - (?dateTimeLiteral xsd:dateTime) log:dtlit ?dateTime. - (?dateTime "PT2H"^^xsd:dayTimeDuration) func:add-dayTimeDuration-to-dateTime ?localDateTime. - (?localDateTimeLiteral xsd:dateTime) log:dtlit ?localDateTime. - (?localDateTimeLiteral 0 11) func:substring ?dateLiteral. - (?dateLiteral xsd:date) log:dtlit ?date. + ?date :dateTimeFromDate ?dateTime +} +<= +{ + ( ?date 1 10 ) string:substring ?dateSolo . + (?dateSolo "T02:00:00") string:concatenation ?datePlusTime. + (?datePlusTime xsd:dateTime) log:dtlit ?dateTime . }. diff --git a/config/reasoner/dl2op/main/mapping.n3 b/config/reasoner/dl2op/main/mapping.n3 index 0f79ceb..a0fa3ba 100644 --- a/config/reasoner/dl2op/main/mapping.n3 +++ b/config/reasoner/dl2op/main/mapping.n3 @@ -67,81 +67,102 @@ PREFIX lblodlg: }. # Test -# ex:s "2019-01-01T19:32:52+00:00"^^xsd:dateTime. -{ - ?s mandaat:start ?startDateTime. - # use backward arrow rule defined below - ?startDateTime :dateFromDateTime ?startDate. - { - ?s mandaat:start ?startDateTime - } e:becomes { - ?s mandaat:start ?startDate - }. -} => { - ?s mandaat:start ?startDate -}. - # ex:s "2019-02-01T10:32:52+00:00"^^xsd:dateTime. { - ?s mandaat:einde ?eindeDateTime. + ?s mandaat:bindingEinde ?eindeDate. # use backward arrow rule defined below - ?eindeDateTime :dateFromDateTime ?eindeDate. + ?eindeDate :dateTimeFromDate ?eindeDateTime. { - ?s mandaat:einde ?eindeDateTime + ?s mandaat:bindingEinde ?eindeDate } e:becomes { + ?s mandaat:bindingEinde ?eindeDateTime + }. +} => { + ?s mandaat:bindingEinde ?eindeDateTime +}. + +{ + ?s mandaat:start ?startDate. + # use backward arrow rule defined below + ?startDate :dateTimeFromDate ?startDateTime. + { + ?s mandaat:start ?startDate + } e:becomes { + ?s mandaat:start ?startDateTime + }. +} => { + ?s mandaat:start ?startDateTime +}. + +{ + ?s mandaat:einde ?eindeDate. + # use backward arrow rule defined below + ?eindeDate :dateTimeFromDate ?eindeDateTime. + { ?s mandaat:einde ?eindeDate + } e:becomes { + ?s mandaat:einde ?eindeDateTime }. } => { - ?s mandaat:einde ?eindeDate + ?s mandaat:einde ?eindeDateTime }. { - ?s mandaat:bindingStart ?bindingStartDateTime. + ?s mandaat:bindingStart ?startDate. # use backward arrow rule defined below - ?bindingStartDateTime :dateFromDateTime ?bindingStartDate. + ?startDate :dateTimeFromDate ?startDateTime. { - ?s mandaat:bindingStart ?bindingStartDateTime + ?s mandaat:bindingStart ?startDate } e:becomes { - ?s mandaat:bindingStart ?bindingStartDate + ?s mandaat:bindingStart ?startDateTime }. } => { - ?s mandaat:bindingStart ?bindingStartDate + ?s mandaat:bindingStart ?startDateTime }. { - ?s mandaat:bindingEinde ?bindingEindeDateTime. + ?s ch:startdatum ?startDate. # use backward arrow rule defined below - ?bindingEindeDateTime :dateFromDateTime ?bindingEindeDate. + ?startDate :dateTimeFromDate ?startDateTime. { - ?s mandaat:bindingEinde ?bindingEindeDateTime + ?s ch:startdatum ?startDate } e:becomes { - ?s mandaat:bindingEinde ?bindingEindeDate + ?s ch:startdatum ?startDateTime }. } => { - ?s mandaat:bindingEinde ?bindingEindeDate + ?s ch:startdatum ?startDateTime }. +{ + ?s ch:eindedatum ?endDate. + # use backward arrow rule defined below + ?endDate :dateTimeFromDate ?endDateTime. + { + ?s ch:eindedatum ?endDate + } e:becomes { + ?s ch:eindedatum ?endDateTime + }. +} => { + ?s ch:eindedatum ?endDateTime +}. + + # Backward arrow rule is like a function call. -# Removes time info in the returned date -# The user in DL selects a date via the UI. -# These dates are persisted as midnight dateTimes in UTC. -# Meaning that 1st of July is stored as -# "2022-06-30T22:00:00Z"^^xsd:dateTime -# and 1 December -# "2022-11-30T23:00:00Z"^^xsd:dateTime -# So, the following rule adds 2 hours to the datetime, and then takes the date part of the UTC date time -# to come to the date that the DL user selected (in CE(S)T) +# Removes the timezone indicator "Z" from incoming datetimes +# To make sure all datetimes have the same convention we now save them as +# datetime without the timezone indicator +# We use "T02:00:00" as time indicator to work around a virtuoso bug that +# results in datetimes being converted to a date when using "T00:00:00" { - ?dateTime :dateFromDateTime ?date -} <= { - (?dateTimeLiteral xsd:dateTime) log:dtlit ?dateTime. - (?dateTime "PT2H"^^xsd:dayTimeDuration) func:add-dayTimeDuration-to-dateTime ?localDateTime. - (?localDateTimeLiteral xsd:dateTime) log:dtlit ?localDateTime. - (?localDateTimeLiteral 0 11) func:substring ?dateLiteral. - (?dateLiteral xsd:date) log:dtlit ?date. + ?date :dateTimeFromDate ?dateTime +} +<= +{ + ( ?date 1 10 ) string:substring ?dateSolo . + (?dateSolo "T02:00:00") string:concatenation ?datePlusTime. + (?datePlusTime xsd:dateTime) log:dtlit ?dateTime . }. - # ex:orgA besluit:classificatie . { { diff --git a/config/reasoner/dl2op/private-info/mapping.n3 b/config/reasoner/dl2op/private-info/mapping.n3 index 82bebd9..c410991 100644 --- a/config/reasoner/dl2op/private-info/mapping.n3 +++ b/config/reasoner/dl2op/private-info/mapping.n3 @@ -66,54 +66,99 @@ PREFIX xsd: # Test # ex:s "2019-01-01T19:32:52+00:00"^^xsd:dateTime. { - ?s mandaat:start ?startDateTime. + ?s mandaat:bindingStart ?startDate. # use backward arrow rule defined below - ?startDateTime :dateFromDateTime ?startDate. + ?startDate :dateTimeFromDate ?startDateTime. { - ?s mandaat:start ?startDateTime + ?s mandaat:bindingStart ?startDate } e:becomes { - ?s mandaat:start ?startDate + ?s mandaat:bindingStart ?startDateTime }. } => { - ?s mandaat:start ?startDate + ?s mandaat:bindingStart ?startDateTime }. -# ex:s "2019-02-01T10:32:52+00:00"^^xsd:dateTime. { - ?s mandaat:einde ?eindeDateTime. + ?s mandaat:bindingEinde ?eindeDate. # use backward arrow rule defined below - ?eindeDateTime :dateFromDateTime ?eindeDate. + ?eindeDate :dateTimeFromDate ?eindeDateTime. { - ?s mandaat:einde ?eindeDateTime + ?s mandaat:bindingEinde ?eindeDate } e:becomes { - ?s mandaat:einde ?eindeDate + ?s mandaat:bindingEinde ?eindeDateTime }. } => { - ?s mandaat:einde ?eindeDate + ?s mandaat:bindingEinde ?eindeDateTime }. +{ + ?s mandaat:start ?startDate. + # use backward arrow rule defined below + ?startDate :dateTimeFromDate ?startDateTime. + { + ?s mandaat:start ?startDate + } e:becomes { + ?s mandaat:start ?startDateTime + }. +} => { + ?s mandaat:start ?startDateTime +}. + +{ + ?s mandaat:einde ?eindeDate. + # use backward arrow rule defined below + ?eindeDate :dateTimeFromDate ?eindeDateTime. + { + ?s mandaat:einde ?eindeDate + } e:becomes { + ?s mandaat:einde ?eindeDateTime + }. +} => { + ?s mandaat:einde ?eindeDateTime +}. + +{ + ?s ch:startdatum ?startDate. + # use backward arrow rule defined below + ?startDate :dateTimeFromDate ?startDateTime. + { + ?s ch:startdatum ?startDate + } e:becomes { + ?s ch:startdatum ?startDateTime + }. +} => { + ?s ch:startdatum ?startDateTime +}. + +{ + ?s ch:eindedatum ?endDate. + # use backward arrow rule defined below + ?endDate :dateTimeFromDate ?endDateTime. + { + ?s ch:eindedatum ?endDate + } e:becomes { + ?s ch:eindedatum ?endDateTime + }. +} => { + ?s ch:eindedatum ?endDateTime +}. # Backward arrow rule is like a function call. -# Removes time info in the returned date -# The user in DL selects a date via the UI. -# These dates are persisted as midnight dateTimes in UTC. -# Meaning that 1st of July is stored as -# "2022-06-30T22:00:00Z"^^xsd:dateTime -# and 1 December -# "2022-11-30T23:00:00Z"^^xsd:dateTime -# So, the following rule adds 2 hours to the datetime, and then takes the date part of the UTC date time -# to come to the date that the DL user selected (in CE(S)T) +# Removes the timezone indicator "Z" from incoming datetimes +# To make sure all datetimes have the same convention we now save them as +# datetime without the timezone indicator +# We use "T02:00:00" as time indicator to work around a virtuoso bug that +# results in datetimes being converted to a date when using "T00:00:00" { - ?dateTime :dateFromDateTime ?date -} <= { - (?dateTimeLiteral xsd:dateTime) log:dtlit ?dateTime. - (?dateTime "PT2H"^^xsd:dayTimeDuration) func:add-dayTimeDuration-to-dateTime ?localDateTime. - (?localDateTimeLiteral xsd:dateTime) log:dtlit ?localDateTime. - (?localDateTimeLiteral 0 11) func:substring ?dateLiteral. - (?dateLiteral xsd:date) log:dtlit ?date. + ?date :dateTimeFromDate ?dateTime +} +<= +{ + ( ?date 1 10 ) string:substring ?dateSolo . + (?dateSolo "T02:00:00") string:concatenation ?datePlusTime. + (?datePlusTime xsd:dateTime) log:dtlit ?dateTime . }. - # ex:orgA besluit:classificatie . { { diff --git a/config/resources/domain.json b/config/resources/domain.json index 1bc4628..702679b 100644 --- a/config/resources/domain.json +++ b/config/resources/domain.json @@ -92,11 +92,11 @@ "super": ["agents"], "attributes": { "agent-start-date": { - "type": "date", + "type": "datetime", "predicate": "ch:startdatum" }, "agent-end-date": { - "type": "date", + "type": "datetime", "predicate": "ch:eindedatum" } }, @@ -140,11 +140,11 @@ "super": ["agents-in-position"], "attributes": { "start-date": { - "type": "date", + "type": "datetime", "predicate": "mandaat:start" }, "end-date": { - "type": "date", + "type": "datetime", "predicate": "mandaat:einde" } }, @@ -188,7 +188,7 @@ "super": ["mandatories"], "attributes": { "expected-end-date": { - "type": "date", + "type": "datetime", "predicate": "ere:geplandeEinddatumAanstelling" }, "reason-stopped": {