Informatievlaanderen / VSDS-LDESServer4J

Linked Data Event Streams Server for Java
https://informatievlaanderen.github.io/VSDS-LDESServer4J
European Union Public License 1.2
10 stars 10 forks source link

Shacl validation regarding the versioned object. #1283

Open xdxxxdx opened 6 months ago

xdxxxdx commented 6 months ago

Describe the bug

server:kbo a ldes:EventStream ; ldes:timestampPath dcterms:issued; ldes:versionOfPath dcterms:isVersionOf ; ldes:createVersions false ; tree:shape kbo:shape .

kbo:shape a sh:NodeShape.

**To Reproduce**
Steps to reproduce the behavior:
1. run

curl --location 'http://localhost:8080/kbo' \ --header 'Content-Type: application/turtle' \ --data-raw '@prefix geo: http://www.opengis.net/ont/geosparql# . @prefix kbo: https://kbopub.economie.fgov.be/kbo# . @prefix legal: http://www.w3.org/ns/legal# . @prefix locn: https://www.w3.org/ns/locn# . @prefix org: http://www.w3.org/ns/org# . @prefix terms: http://purl.org/dc/terms/ . @prefix xsd: http://www.w3.org/2001/XMLSchema# .

kbo:0403053608.2022.11 a legal:legalEntity, kbo:Enterprise ; terms:isVersionOf kbo:0403053608 ; terms:issued "2021-01-01T00:00:00Z"^^xsd:date ; legal:companyStatus kbo:JuridicalSituation_000 ; legal:companyType kbo:JuridicalForm_014 ; legal:legalName "U C B" ; legal:registeredAddress kbo:6a4b10066ee5f892c094 ; kbo:activity kbo:2003_74151, kbo:2003_74879, kbo:2008_21201, kbo:2008_64200, kbo:2008_82990 ; kbo:establishment kbo:2142567276 ; kbo:status kbo:Status_AC .

kbo:2003_74151 a kbo:Activity ; legal:companyActivity kbo:Nace2003_74151 ; kbo:classification kbo:Classification_MAIN .

kbo:2003_74879 a kbo:Activity ; legal:companyActivity kbo:Nace2003_74879 ; kbo:classification kbo:Classification_MAIN .

kbo:2008_21201 a kbo:Activity ; legal:companyActivity kbo:Nace2008_21201 ; kbo:classification kbo:Classification_SECO .

kbo:2008_64200 a kbo:Activity ; legal:companyActivity kbo:Nace2008_64200 ; kbo:classification kbo:Classification_MAIN .

kbo:2008_82990 a kbo:Activity ; legal:companyActivity kbo:Nace2008_82990 ; kbo:classification kbo:Classification_MAIN .

kbo:2142567276 a org:Site, kbo:Establishment ; terms:issued "1998-02-01"^^xsd:date ; locn:Address kbo:6a4b10066ee5f892c094 .

kbo:Status_AC a kbo:Code ; kbo:codeDescription "Actif"@FR, "Actief"@NL ; kbo:codeValue "AC" .

kbo:6a4b10066ee5f892c094 a locn:Address ; geo:asWKT "POINT (4.275721857227438 50.8176796)"^^geo:wktLiteral ; kbo:addressType kbo:TypeOfAddress_BAET, kbo:TypeOfAddress_REGO ; locn:fullAddress "Researchdreef 60, 1070 Anderlecht, Belgium" ; locn:poBox "None" ; locn:postCode "1070" ; locn:postName "Anderlecht" .

'

**Expected behavior**
Server takes the member, and the `tree:member ` is only subject of ` terms:isVersionOf ` means `kbo:0403053608.2022.11`

**Current behavior**
Server returns

@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# . @prefix rdfs: http://www.w3.org/2000/01/rdf-schema# . @prefix sh: http://www.w3.org/ns/shacl# . @prefix xsd: http://www.w3.org/2001/XMLSchema# .

[ rdf:type sh:ValidationReport; sh:conforms false; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#0403053608.2022.11; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2142567276; sh:resultMessage "Object of statement with predicate: http://purl.org/dc/terms/issued should be a literal of type http://www.w3.org/2001/XMLSchema#dateTime"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_82990; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_64200; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_21201; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#Status_AC; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#6a4b10066ee5f892c094; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_64200; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_21201; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#Status_AC; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2003_74151; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2003_74151; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_64200; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#Status_AC; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2003_74879; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#0403053608.2022.11; sh:resultMessage "Object of statement with predicate: http://purl.org/dc/terms/issued should be a literal of type http://www.w3.org/2001/XMLSchema#dateTime"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2003_74879; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2003_74879; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_82990; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2142567276; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#6a4b10066ee5f892c094; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2142567276; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2003_74151; sh:resultMessage "Member must have exactly 1 statement with versionOf path: http://purl.org/dc/terms/isVersionOf as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_21201; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#6a4b10066ee5f892c094; sh:resultMessage "Only 1 member is allowed per request on collection with version creation disabled"; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ]; sh:result [ rdf:type sh:ValidationResult; sh:focusNode https://kbopub.economie.fgov.be/kbo#2008_82990; sh:resultMessage "Member must have exactly 1 statement with timestamp path: http://purl.org/dc/terms/issued as predicate."; sh:resultSeverity sh:Violation; sh:sourceConstraintComponent sh:SPARQLConstraintComponent ] ] .


The member is rejected.
xdxxxdx commented 6 months ago

As mentioned in https://github.com/Informatievlaanderen/VSDS-LDESServer4J/issues/1267, don't know how this case is going to be tackled.

brechtvdv commented 5 months ago

Maybe we should document how embedding other objects can be tackled now (and in the future).

What could work now, using blank nodes:

kbo:0403053608.2022.11 a legal:legalEntity ;
             kbo:activity [
                    a kbo:Activity ;
                    dcterms:isVersionOf kbo:2003_74151 .
             ] .

server:kbo tree:member kbo:0403053608.2022.11 .

OR Add the embedded object as explicit version to the LDES:

kbo:0403053608.2022.11 a legal:legalEntity ;
             kbo:activity kbo:2003_74151_2021-01-01T00:00:00Z .

kbo:2003_74151_2021-01-01T00:00:00Z a kbo:Activity ;
                    dcterms:isVersionOf kbo:2003_74151 ;
                    prov:generatedAtTime "2021-01-01T00:00:00Z"^^xsd:dateTime .

server:kbo tree:member kbo:0403053608.2022.11 , kbo:2003_74151_2021-01-01T00:00:00Z .

What should work in the future IMO: