International-Data-Spaces-Association / InformationModel

The Information Model of the International Data Spaces implements the IDS reference architecture as an extensible, machine readable and technology independent data model.
Apache License 2.0
61 stars 35 forks source link

Extend SHACL shapes to allow both direct and indirect references #505

Closed JohannesLipp closed 2 years ago

JohannesLipp commented 2 years ago

As we are extended type handling in the code generation, we can now support both indirect and direct references.

Please properly cover this in the information model by replacing existing sh:nodeKind sh:IRI ; statements in SHACL with sh:or ( [ sh:class ids:XXX ; ] [ sh:nodeKind sh:IRI ; ] ) ; for the respective class.

Concrete steps to solve this could include:

  1. Check out the latest develop branch
  2. Use Notepad++'s "Find in Files" function (in regular expressions mode) to search for sh:nodeKind sh:IRI (should yield about 62 results). Repeat the following steps for each result:
    1. Find the respective property marked via sh:path (e.g., sh:path ids:provider)
    2. Look up that property (e.g., via searching for ^ids:provider with regex in "Find in Files")
    3. Evaluate the range of the property (e.g., rdfs:range ids:Participant)
    4. In the SHACL shape (cf. step 3), replace nodeKind with an OR (e.g., sh:or ( [ sh:class ids:Participant ; ] [ sh:nodeKind sh:IRI ; ] ) ;

Note that some do not require any change (e.g., ids:accessURL, which indeed points to an xsd:anyURI) and some already contain hints via comments (e.g., #sh:class ids:Agent ;) - please ensure to still double-check these instead of blindly relying on the comments.

JohannesLipp commented 2 years ago

We set this issue ON HOLD, until @sebbader reports a fix/finding in #509 . Thank you!

HaydarAk commented 2 years ago

We need to specify the default value for each sh:or .

Suggestion Use the sh:order property inside the sh:or constraint. So for example the deafult value should be the entry with sh:order 1 .

You should use the current instance (e.g. sh:nodeKind IRI vs sh:class ... ) as the default value.

Example:

shapes:RuleShape
    a sh:NodeShape ;
    sh:targetClass ids:Rule ;

    sh:property [
        a sh:PropertyShape ;
        sh:path ids:assignee ;
        sh:or (
        [
            sh:nodeKind sh:IRI ;
            sh:order 1;
        ]
        [ 
            sh:class ids:Participant ;
            sh:order 2;
        ]
        );
        sh:minCount 0 ;
        sh:severity sh:Violation ;
        sh:message "<https://raw.githubusercontent.com/International-Data-Spaces-Association/InformationModel/master/testing/contract/RuleShape.ttl> (RuleShape): An ids:Rule must have at maximum one ids:Participant linked through the ids:assignee property."@en ;
    ] ;.
JohannesLipp commented 2 years ago

@lcomet We cleared all open problems and this issue can be tackled from now one :)

sebbader commented 2 years ago

See for an example here: https://github.com/International-Data-Spaces-Association/InformationModel/blob/6323200b0d39f5becf0c6395c65c2caf419b1e99/testing/infrastructure/InfrastructureComponentShape.ttl#L40

lcomet commented 2 years ago

@JohannesLipp @HaydarAk I implemented the required changes int the branch extendSHACLShapes-enhancement For more details about the specific changes and additional notes, please refer to the document Implementation Extend SHACL shapes