Skip to content
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

Shacl validation regarding the versioned object. #1283

Open
xdxxxdx opened this issue May 13, 2024 · 2 comments
Open

Shacl validation regarding the versioned object. #1283

xdxxxdx opened this issue May 13, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@xdxxxdx
Copy link

xdxxxdx commented May 13, 2024

Describe the bug

@prefix ldes: <https://w3id.org/ldes#> .
@prefix custom: <http://example.org/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix tree: <https://w3id.org/tree#>.
@prefix sh:   <http://www.w3.org/ns/shacl#> .
@prefix server: <http://localhost:8080/> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix kbo: <http://localhost:8080/kbo/> .
@prefix legal: <http://www.w3.org/ns/legal#> .
@base <http://localhost:8080> .

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 xdxxxdx added the bug Something isn't working label May 13, 2024
@xdxxxdx xdxxxdx changed the title Shacl validation regarding versioned object. Shacl validation regarding the versioned object. May 13, 2024
@xdxxxdx
Copy link
Author

xdxxxdx commented May 13, 2024

As mentioned in #1267, don't know how this case is going to be tackled.

@brechtvdv
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants