@prefix sh:   <http://www.w3.org/ns/shacl#> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct:  <http://purl.org/dc/terms/> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix empx: <https://empower-x.io/ns/rulebook#> .
@prefix shp:  <https://empower-x.io/shapes/offer#> .

# EMPOWER-X offer metadata profile, version 1.0 (draft).
# Checks the publication checklist (Publish an offer, R6.1, R6.2) on the DCAT-AP view of an offer.
# Checks a machine cannot do (the licence is approved in writing; the data is real) stay with the operator's review.

shp:OfferShape a sh:NodeShape ;
    sh:targetClass dcat:Dataset, dcat:DataService ;
    sh:property [ sh:path dct:title ; sh:minCount 1 ; sh:minLength 5 ;
        sh:message "1. Every offer has a title." ] ;
    sh:property [ sh:path dct:description ; sh:minCount 1 ; sh:minLength 40 ;
        sh:message "1. Every offer has a real description (at least 40 characters)." ] ;
    sh:property [ sh:path dct:publisher ; sh:minCount 1 ; sh:nodeKind sh:IRI ;
        sh:message "2. The provider is named (publisher)." ] ;
    sh:property [ sh:path empx:dataHolder ; sh:minCount 1 ; sh:nodeKind sh:IRI ;
        sh:message "2. The data holder is named." ] ;
    sh:property [ sh:path empx:licenceStatus ; sh:minCount 1 ; sh:maxCount 1 ; sh:in ( empx:LicenceApproved empx:LicencePending ) ;
        sh:message "3. The licence status is 'approved' or 'Licence pending'." ] ;
    sh:property [ sh:path empx:accessLevel ; sh:minCount 1 ; sh:maxCount 1 ;
        sh:in ( empx:Open empx:Participants empx:Restricted empx:ComputeToDataOnly ) ;
        sh:message "5. Exactly one access level: Open, Participants, Restricted or Compute-to-data only." ] ;
    sh:property [ sh:path empx:containsPersonalData ; sh:minCount 1 ; sh:maxCount 1 ; sh:datatype xsd:boolean ;
        sh:message "6. The personal-data flag is set (true or false)." ] ;
    sh:property [ sh:path dct:conformsTo ; sh:minCount 1 ;
        sh:message "10. The data model and version are stated (conformsTo)." ] ;
    sh:property [ sh:path dct:accrualPeriodicity ; sh:minCount 1 ;
        sh:message "11. The update frequency is stated." ] ;
    sh:property [ sh:path empx:knownLimitations ; sh:minCount 1 ;
        sh:message "11. Known limitations are stated (write 'None known' if there are none)." ] ;
    sh:property [ sh:path dcat:distribution ; sh:node shp:DistributionShape ] .

shp:LicensedShape a sh:NodeShape ;
    sh:targetSubjectsOf empx:licenceStatus ;
    sh:or (
        [ sh:path empx:licenceStatus ; sh:hasValue empx:LicencePending ]
        [ sh:path dct:license ; sh:minCount 1 ; sh:nodeKind sh:IRI ; sh:pattern "^https://" ]
    ) ;
    sh:message "3-4. An approved licence has a public https link; otherwise the status is 'Licence pending'." .

shp:DistributionShape a sh:NodeShape ;
    sh:property [ sh:path dcat:accessURL ; sh:minCount 1 ; sh:nodeKind sh:IRI ;
        sh:pattern "^https://node\\.empower-x\\.io/" ;
        sh:message "8. Endpoints point to the production node (https://node.empower-x.io/)." ] .

shp:ComputeShape a sh:NodeShape ;
    sh:targetSubjectsOf empx:accessLevel ;
    sh:or (
        [ sh:path empx:accessLevel ; sh:not [ sh:hasValue empx:ComputeToDataOnly ] ]
        [ sh:and (
            [ sh:path empx:approvedAlgorithm ; sh:minCount 1 ]
            [ sh:path empx:outboundNetworkAccess ; sh:minCount 1 ; sh:maxCount 1 ; sh:datatype xsd:boolean ] ) ]
    ) ;
    sh:message "7. Compute-to-data offers list approved algorithms and state outbound network access." .
