@prefix vpa:            <https://w3id.org/vpa#> .
@prefix dash:        <http://datashapes.org/dash#> .
@prefix dcterms:     <http://purl.org/dc/terms/> .
@prefix era:         <http://data.europa.eu/949/> .
@prefix owl:         <http://www.w3.org/2002/07/owl#> .
@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 skos:        <http://www.w3.org/2004/02/skos/core#> .
@prefix time:        <http://www.w3.org/2006/time#> .
@prefix vann:        <http://purl.org/vocab/vann/> .
@prefix voaf:        <http://purl.org/vocommons/voaf#> .
@prefix xml:         <http://www.w3.org/XML/1998/namespace> .
@prefix xsd:         <http://www.w3.org/2001/XMLSchema#> .
@prefix era-sh: <http://data.europa.eu/949/shapes/> .



## rules for classes
era-sh:RequestingBodyShape a sh:NodeShape ;
        sh:property  era-sh:issues  ;
        sh:targetClass vpa:RequestingBody .


era-sh:CaseShape  a sh:NodeShape ;
        sh:targetClass vpa:Case ;
        sh:property  era-sh:status , era-sh:permissionType , era-sh:concerns , era-sh:constitutes .


era-sh:ScopeShape  a sh:NodeShape ;
        sh:targetClass vpa:Scope ;
        sh:property  era-sh:definesCase .


era-sh:AppropriateBodyShape a sh:NodeShape ;
        sh:targetClass vpa:AppropriateBody ;
        sh:property  era-sh:delivers , era-sh:certifies .



era-sh:OrganisationRoleShape  a sh:NodeShape ;
        sh:targetClass era:OrganisationRole ;
        sh:property  era-sh:grants , era-sh:hasOrganisationRole , era-sh:roleOf , era-sh:requests .


era-sh:EvidenceShape  a sh:NodeShape  ;
        sh:targetClass vpa:Evidence ;
        sh:property  era-sh:submittedFor , era-sh:supportsCase , era-sh:statesCompliance , era-sh:supportsScope , era-sh:member .


era-sh:RestrictionShape  a sh:NodeShape ;
        sh:targetClass vpa:Restriction ;
        sh:property  era-sh:regarding . 


era-sh:Compliance  a  sh:NodeShape  ;
        sh:targetClass vpa:Compliance ;
        sh:property  era-sh:checkedSection , era-sh:withRestriction , era-sh:checkedRequirement , era-sh:isCompliant .


era-sh:RequestShape  a sh:NodeShape ;
        sh:property  era-sh:status , era-sh:requestFor , era-sh:constitutedBy ;
        sh:targetClass vpa:Request .


era-sh:PermissionShape a sh:NodeShape ;
        sh:targetClass vpa:Permission ;
        sh:property  era-sh:hasState , era-sh:valid , era-sh:requestedIn , era-sh:submittedIn , era-sh:permits .


era-sh:RequirementShape  a  sh:NodeShape  ;
        sh:targetClass vpa:Requirement ;
        sh:property  era-sh:section .


era-sh:EvidenceDocumentShape a sh:NodeShape ;
        sh:targetClass vpa:EvidenceDocument ;
        sh:property  era-sh:hasState , era-sh:valid , era-sh:checkedCompliance , era-sh:closes , era-sh:versionNumber , era-sh:withRestriction .



## property shapes 

era-sh:issues 
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Request ;
        sh:path   vpa:issues ;
        sh:nodeKind sh:IRI;
	    sh:severity sh:Violation ;
	    sh:message "This error may be due to having issues range not an URI"@en .


era-sh:section
        rdf:type     sh:PropertyShape ;
        sh:class     skos:Concept ;
        sh:maxCount  1 ;
        sh:path      vpa:section ;
	    sh:severity sh:Violation ;
	    sh:message "This error may be due to having section range not an URI"@en .


era-sh:checkedCompliance
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Compliance ;
        sh:nodeKind sh:IRI ;
        sh:path   vpa:checkedCompliance ;
        sh:severity sh:Violation ;
	    sh:message "This error may be due to not having IRI for checkedcompliance "@en .


era-sh:requests
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Permission ;
        sh:path   vpa:requests .

era-sh:checkedRequirement
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Requirement ;
        sh:nodeKind sh:IRI ;
        sh:severity sh:Violation ;
	    sh:message "This error may be due to not having IRI for checkedRequirement property"@en ;
        sh:path   vpa:checkedRequirement .

era-sh:concerns  rdf:type  sh:PropertyShape ;
        sh:class  vpa:Scope ;
        sh:nodeKind sh:IRI ;
        sh:severity sh:Violation ;
	    sh:message "This error may be due to not having IRI for property concerns"@en ;
        sh:path   vpa:concerns .


era-sh:closes
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Requirement ;
        sh:path   vpa:closes .

era-sh:definesCase
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Case ;
        sh:path   vpa:definesCase .

era-sh:status  rdf:type  sh:PropertyShape ;
        sh:class     skos:Concept ;
        sh:minCount  1 ; # Some applications may need more than one SKOS
        sh:path      vpa:status .

era-sh:hasState  rdf:type  sh:PropertyShape ;
        sh:class     skos:Concept ;
        sh:maxCount  1 ; # Only one state is allowed
        sh:path      vpa:hasState .

era-sh:permits
        rdf:type  sh:PropertyShape ;
        sh:class  skos:Concept ;
        sh:path   vpa:permits .

era-sh:constitutedBy
        rdf:type     sh:PropertyShape ;
        sh:class     vpa:Case ;
        sh:minCount  1 ;
        sh:path      vpa:constitutedBy .

era-sh:certifies
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Requirement ;
        sh:path   vpa:certifies .

era-sh:valid
        rdf:type  sh:PropertyShape ;
        sh:class  time:Interval ;
        sh:path   vpa:valid .

era-sh:versionNumber
        rdf:type     sh:PropertyShape ;
        sh:datatype  xsd:integer ;
        sh:path      vpa:versionNumber .

era-sh:permissionType
        rdf:type  sh:PropertyShape ;
        sh:class  skos:Concept ;
        sh:path   vpa:permissionType .

era-sh:requestedIn
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Request ;
        sh:path   vpa:requestedIn .

era-sh:supportsScope
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Scope ;
        sh:path   vpa:supportsScope .

era-sh:withRestriction
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Restriction ;
        sh:path   vpa:withRestriction .

era-sh:supportsCase
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Case ;
        sh:path   vpa:supportsCase .

era-sh:valid  rdf:type  sh:PropertyShape ;
        sh:class  time:Interval ;
        sh:path   vpa:valid .


era-sh:grants
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Permission ;
        sh:path   vpa:grants .

era-sh:checkedSection
        rdf:type  sh:PropertyShape ;
        sh:class  skos:Concept ;
        sh:path   vpa:checkedSection .

era-sh:submittedFor
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Request ;
        sh:path   vpa:submittedFor .

era-sh:submittedIn
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Case ;
        sh:path   vpa:submittedIn .


era-sh:delivers
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:EvidenceDocument ;
        sh:path   vpa:delivers .

era-sh:regarding
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Requirement ;
        sh:path   vpa:regarding .

## TODO: check the behavior
era-sh:member  rdf:type   sh:PropertyShape ;
        sh:qualifiedMinCount 1 ;
		sh:qualifiedValueShape [ sh:class vpa:EvidenceDocument ] ;
        sh:minCount           1 ;
        sh:severity sh:Violation ;
        sh:message "This error may be due to not having a correct member"@en ;
        sh:path    rdfs:member .

era-sh:requestFor
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Permission ;
        sh:path   vpa:requestFor .

era-sh:withRestriction
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Restriction ;
        sh:path   vpa:withRestriction .


era-sh:statesCompliance
        rdf:type  sh:PropertyShape ;
        sh:class  vpa:Compliance ;
        sh:path   vpa:statesCompliance .

era-sh:isCompliant
        rdf:type     sh:PropertyShape ;
        sh:datatype  xsd:boolean ;
        sh:path      vpa:isCompliant .

era-sh:constitutes  rdf:type  sh:PropertyShape ;
        sh:class  vpa:Request ;
        sh:path   vpa:constitutes .

#todo: constraint to correct skos 
era-sh:hasOrganisationRole
        rdf:type     sh:PropertyShape ;
        sh:class     skos:Concept ;
        sh:maxCount  1 ;
        sh:path      era:hasOrganisationRole .