@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf:   <http://xmlns.com/foaf/0.1/> .
@prefix schema: <http://schema.org/> .
@prefix st:     <https://w3id.org/shapetrees#> .
@prefix eprel:  <../vocab#> .
@prefix shex:   <eprel.shex#> .

# The wrapper's resources as Solid shape trees (W3C Solid CG draft,
# https://github.com/shapetrees/specification). Each st:shape is a shape in
# eprel.shex, which is generated from the SHACL in this directory.
#
# Containment here is LDP containment (ldp:contains), which is not always URI
# nesting: product/ contains group/{code}/products, because EPREL has no
# cross-group listing and the per-group containers are the only way down to a
# product. Links to resources described in OTHER documents (a product's group,
# a supplier's example product) are st:references, and in the ShEx those
# values are plain IRIs.
#
# The collection trees are roots: the wrapper root itself is not a container.
# A tree's rdfs:label is the fixed name of the one resource it matches, per
# the spec, so it is a plain string; the trees have no language-tagged labels.

<> a foaf:Document ;
    rdfs:label "Linked EPREL shape trees"@en , "Linked-EPREL-Shape-Trees"@de .

# ---- Products -------------------------------------------------------------

<#ProductCollectionTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    rdfs:label "product" ;
    st:shape shex:ContainerShape ;
    st:contains <#GroupProductsTree> .

# group/{url_code}/products, paged: the pages are documents of this one
# container, not members of it.
<#GroupProductsTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    st:shape shex:ContainerShape ;
    st:contains <#ProductTree> .

<#ProductTree>
    a st:ShapeTree ;
    st:expectsType st:Resource ;
    st:shape shex:ProductShape ;
    st:references
        [ st:referencesShapeTree <#GroupTree> ; st:viaPredicate eprel:productGroup ] ,
        [ st:referencesShapeTree <#ActTree> ; st:viaPredicate eprel:implementingAct ] ,
        [ st:referencesShapeTree <#SupplierTree> ; st:viaPredicate schema:manufacturer ] ,
        [ st:referencesShapeTree st:NonRDFResourceTree ; st:viaPredicate eprel:uploadedLabel ] .

# ---- Product groups -------------------------------------------------------

<#GroupCollectionTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    rdfs:label "group" ;
    st:shape shex:ContainerShape ;
    st:contains <#GroupTree> .

<#GroupTree>
    a st:ShapeTree ;
    st:expectsType st:Resource ;
    st:shape shex:ConceptShape ;
    st:references
        [ st:referencesShapeTree <#GroupProductsTree> ; st:viaPredicate eprel:products ] .

# ---- Implementing acts ----------------------------------------------------

<#ActCollectionTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    rdfs:label "act" ;
    st:shape shex:ContainerShape ;
    st:contains <#ActTree> .

<#ActTree>
    a st:ShapeTree ;
    st:expectsType st:Resource ;
    st:shape shex:ConceptShape .

# ---- Codelists ------------------------------------------------------------

# The two concept schemes have no shape yet, in SHACL or ShEx.
<#CodelistCollectionTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    rdfs:label "cl" ;
    st:shape shex:ContainerShape ;
    st:contains st:ResourceTree .

# ---- Suppliers ------------------------------------------------------------

# Partial by construction: only the suppliers this instance has learned.
<#SupplierCollectionTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    rdfs:label "supplier" ;
    st:shape shex:ContainerShape ;
    st:contains <#SupplierTree> .

<#SupplierTree>
    a st:ShapeTree ;
    st:expectsType st:Resource ;
    st:shape shex:SupplierShape ;
    st:references
        [ st:referencesShapeTree <#ProductTree> ; st:viaPredicate eprel:exampleProduct ] .

# ---- Shapes ---------------------------------------------------------------

# The SHACL and this file are RDF; eprel.shex is not.
<#ShapesCollectionTree>
    a st:ShapeTree ;
    st:expectsType st:Container ;
    rdfs:label "shapes" ;
    st:shape shex:ContainerShape ;
    st:contains st:ResourceTree , st:NonRDFResourceTree .
