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

@prefix skos:	<http://www.w3.org/2004/02/skos/core#> .
@prefix pav:	<http://purl.org/pav/> .
@prefix dc:	<http://purl.org/dc/elements/1.1/> .
@prefix vs:     <http://www.w3.org/2003/06/sw-vocab-status/ns#> .
@prefix vann:   <http://purl.org/vocab/vann/> .
@prefix foaf:   <http://xmlns.com/foaf/0.1/> .

@prefix imf-m: <https://ns.imfid.org/imf-m/id/> .
@prefix shp: <https://ns.imfid.org/imf-m/shapes/model-grammar#> .
@prefix ex:	<http://example.com#> .
@prefix pca-plm:    <http://rds.posccaesar.org/ontology/plm/rdl/> .
@prefix ottr:        <http://ns.ottr.xyz/0.4/> .
@prefix o-rdf:       <http://tpl.ottr.xyz/rdf/0.1/> .
@prefix o-rdfs:       <http://tpl.ottr.xyz/rdfs/0.2/> .
@prefix o-owl-ax:    <http://tpl.ottr.xyz/owl/axiom/0.1/> .
@prefix o-owl-ma:    <http://tpl.ottr.xyz/owl/macro/0.1/> .
@prefix o-owl-rstr:  <http://tpl.ottr.xyz/owl/restriction/0.1/> .
@prefix o-owl-dec:  <http://tpl.ottr.xyz/owl/declaration/0.1/> .



<https://ns.imfid.org/imf-m/shapes/model-grammar> a owl:Ontology ;
    owl:versionIRI <https://ns.imfid.org/imf-m/shapes/0.2.0/model-grammar> ;
    owl:versionInfo "0.2.0" ;
    owl:priorVersion <https://ns.imfid.org/imf-m/shapes/0.1.0/main> ;
    skos:prefLabel "IMF Model Grammar -- SHACL" ;
    dc:description "This shapes graph can be used to validate IMF Model RDF data against the grammar for IMF Models." ;
    pav:createdBy [ foaf:name "Martin G. Skjæveland" ] ;
    pav:createdOn "2023-06-30T00:00:00"^^xsd:dateTime ;
    owl:imports 
      <http://shipshape.dyreriket.xyz/std-vocabulary-elements.ttl> ,
      <https://ns.imfid.org/imf-m/shapes/0.2.0/terms-grammar> ;
    sh:entailment <http://www.w3.org/ns/entailment/RDFS> ;
    sh:shapesGraph 
      <http://shipshape.dyreriket.xyz/std-vocabulary-elements.ttl> ,
      <http://www.w3.org/ns/shacl-shacl#> ,
      <https://ns.imfid.org/imf-m/shapes/0.2.0/terms-grammar> ;
    skos:editorialNote """Result of validation against specified sh:shapesGraph:
Result of validating RDF data <out/shacl/imf-model-grammar.shacl.ttl> against SHACL shape <http://www.w3.org/ns/shacl-shacl#>:
2023-06-30
Conforms


Result of validating RDF data <out/shacl/imf-model-grammar.shacl.ttl> against SHACL shape <http://shipshape.dyreriket.xyz/std-vocabulary-elements.ttl>:
2023-06-30
Conforms


Result of validating RDF data <out/shacl/imf-model-grammar.shacl.ttl> against SHACL shape <http://ns.imfid.org/20230630/imf-terms-grammar.shacl.ttl>:
2023-06-30
Node=<http://shipshape.dyreriket.xyz#ANY_NODE>
  Value: <http://ns.imfid.org/imf#MetadataShape>
  Message: Unrecognised IMF vocabulary element. Check spelling.

    """
.

shp:ModelShape a sh:NodeShape ;
  sh:targetClass imf-m:Model ;
  sh:targetSubjectsOf imf-m:hasElement ;
  sh:property 
    [ sh:path imf-m:hasElement ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Model contains no Elements." ] .
shp:MetadataShape a sh:NodeShape ;
  sh:deactivated true ;
  sh:targetClass imf-m:Element , imf-m:Block , imf-m:Terminal ;
  sh:property 
    [ sh:path skos:prefLabel ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element has no prefLabel." ] ,
    [ sh:path dc:description ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element has no description." ] ,
    [ sh:path pav:version    ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element has no version number." ] ,
    [ sh:path pav:createdOn  ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element has no created timestamp." ] ,
    [ sh:path pav:createdBy  ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element has no creator." ] .

shp:ElementShape a sh:NodeShape ;
  sh:targetClass imf-m:Element , imf-m:Block , imf-m:Terminal ;
  sh:property
    [ sh:path imf-m:purpose ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element has no purpose." ] ,
    [ sh:path imf-m:partOf ; sh:maxCount 1 ; sh:message "The Element has more than one parent."  ] ,
    [ sh:deactivated true ; sh:path [ sh:inversePath imf-m:hasElement ] ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Element is not contained in a Model." ]
.
shp:BlockShape a sh:NodeShape ;
  sh:targetClass imf-m:Block ;
  sh:targetSubjectsOf imf-m:hasTerminal, imf-m:hasInputTerminal, imf-m:hasOutputTerminal ;
  sh:property 
    [ sh:path imf-m:hasTerminal ; sh:class imf-m:Terminal ; sh:message "The Block has a Terminal which is not a Terminal." ] ,
    [ sh:path [ sh:alternativePath ( imf-m:hasTerminal imf-m:hasInputTerminal imf-m:hasOutputTerminal ) ] ; 
        sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Block has no Terminals." ] ,     
    [ sh:path imf-m:partOf  ; sh:class imf-m:Block ; sh:message "The Block has a part which is not a Block." ] ,
    [ sh:path imf-m:hasPart ; sh:class imf-m:Block ; sh:message "The Block is part of a non-Block." ]
.
shp:TerminalShape a sh:NodeShape ;
  sh:targetClass imf-m:Terminal , imf-m:InputTerminal , imf-m:OutputTerminal ;
  sh:targetSubjectsOf imf-m:connectedTo , imf-m:medium , imf-m:hasTerminalQualifier ;
  sh:targetObjectsOf imf-m:hasTerminal, imf-m:connectedTo ;
  sh:property 
    [ sh:path imf-m:partOf ; sh:maxCount 1 ; sh:class imf-m:Terminal ; sh:message "The Terminal has more than one parent." ] ,
    [ sh:path imf-m:connectedTo ; sh:maxCount 1 ; sh:class imf-m:Terminal ; sh:message "The Terminal is connected to more than one Terminal." ] ,
    [ sh:path imf-m:connectedTo ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Terminal has no connection (to a different Terminal)." ] , 
    #[ sh:path imf-m:hasTerminalQualifier ; sh:maxCount 1 ; sh:in ( imf-m:inputFlow imf-m:outputFlow ) ] ,
    [ sh:path imf-m:medium ; sh:maxCount 1 ; sh:message "The Terminal has more than one medium." ]  ,
    [ sh:path imf-m:medium ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Terminal has no medium." ]
.
shp:BreakdownPointShape a sh:NodeShape ;
  sh:targetClass imf-m:BreakdownPoint ;
  sh:targetSubjectsOf imf-m:thePart , imf-m:theWhole ;
  sh:property 
    [ sh:path imf-m:thePart  ; sh:minCount 1 ; sh:maxCount 1 ; sh:class imf-m:Element ; sh:message "The Breakdown Point must have exactly one part." ] ,
    [ sh:path imf-m:theWhole ; sh:minCount 1 ; sh:maxCount 1 ; sh:class imf-m:Element ; sh:message "The Breakdown Point must have exactly one whole." ] 
.
shp:ConnectionPointShape a sh:NodeShape ;
  sh:targetClass imf-m:ConnectionPoint ;
  sh:targetSubjectsOf imf-m:theConnected , imf-m:theInput , imf-m:theOutput ;
  sh:property 
    [ sh:path imf-m:theInput  ; sh:maxCount 1 ; sh:class imf-m:Element ; sh:message "The Connection Point has more than one input." ] ,
    [ sh:path imf-m:theOutput ; sh:maxCount 1 ; sh:class imf-m:Element ; sh:message "The Connection Point has more than one output." ] ,
    [ sh:path imf-m:theConnected ; sh:maxCount 2 ; sh:class imf-m:Element ; sh:message "The Connection Point has more than two connected." ]
.
shp:AspectElementShape a sh:NodeShape ;
  sh:targetClass imf-m:AspectElement ;
  sh:targetSubjectsOf imf-m:hasAspect ;
  sh:property 
    [ sh:path imf-m:hasAspect ; sh:minCount 1 ; sh:maxCount 1 ; sh:class imf-m:Aspect ; sh:message "The AspectElement must have exactly one Aspect." ] 
.
shp:AttributeShape a sh:NodeShape ;
  sh:targetClass imf-m:Attribute ;
  sh:targetObjectsOf imf-m:hasAttribute ;
  sh:targetSubjectsOf imf-m:predicate, imf-m:uom, imf-m:hasAttributeQualifier ;
  sh:property 
    [ sh:path imf-m:predicate ; sh:minCount 1 ; sh:maxCount 1 ; sh:message "The Attribute must have exactly one predicate." ] ,
    [ sh:path imf-m:value ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Attribute has no value." ] ,
    [ sh:path imf-m:uom ; sh:maxCount 1 ] , 
    [ sh:path imf-m:hasAttributeQualifier ; sh:maxCount 1 ; sh:class imf-m:RegularityQualifier ; sh:message "The Attribute has more than one regularity qualifier." ] , 
    [ sh:path imf-m:hasAttributeQualifier ; sh:maxCount 1 ; sh:class imf-m:RangeQualifier ; sh:message "The Attribute has more than one range qualifier." ] , 
    [ sh:path imf-m:hasAttributeQualifier ; sh:maxCount 1 ; sh:class imf-m:ProvenanceQualifier ; sh:message "The Attribute has more than one provenance qualifier." ] , 
    [ sh:path imf-m:hasAttributeQualifier ; sh:maxCount 1 ; sh:class imf-m:ScopeQualifier ; sh:message "The Attribute has more than one scope qualifier." ] ,
    [ sh:path imf-m:hasAttributeQualifier ; sh:minCount 1 ; sh:severity sh:Warning ; sh:message "The Attribute has no qualifier." ] 
.
#imf-m:AttributeGroupShape a sh:NodeShape ;
#  sh:targetClass imf-m:AttributeGroup ;
#  sh:targetObjectsOf imf-m:hasAttributeGroup ;
#  sh:property 
#    [ sh:path imf-m:hasAttribute ; sh:minCount 1 ; sh:message "AttributeGroup has no Attributes." ]
#.
