# ==========================================================================
#  W23  The citation rule as a shape
# ==========================================================================
#
#  FROM      Chapter and Verse
#            https://www.semantechs.co.uk/articles/chapter-and-verse/
#
#  CHECKS
#    Every claim or conclusion points to what it was derived from (the
#    Genealogical Proof Standard's citation rule); everyone has a name of some
#    kind; a parent link's kind, if given, is one we know.
#
#  HOW IT WORKS
#    The claims are RDF 1.2 reifiers, and the shapes target them like any other
#    node: anything that rdf:reifies a triple must have prov:wasDerivedFrom.
#    The data conforms. The point of the example is what happens when it does
#    not.
#
#  DIAGRAM
#    fam:censusSays   rdf:reifies <<( thomas birthDate "abt 1872" )>>   wasDerivedFrom census1911   ok
#    fam:thomasBirth  (the conclusion)    wasDerivedFrom the three claims it weighed               ok
#
#  WHAT TO TAKE AWAY
#    - A rule from a profession's standard becomes a shape, and every claim in
#      the tree is held to it.
#
#  TRY IT
#    Add a claim with no source -- fam:rumour rdf:reifies <<( fam:thomas
#    schema:birthPlace "Leeds" )>> . -- and validate again: one violation.
#
#  DATA      family.ttl
#  LOAD IT   https://semantechs.co.uk/turtle-editor-viewer/?dot=https%3A%2F%2Fwww.semantechs.co.uk%2Farticles%2Fshow-your-working%2Fdemos%2F09-chapter-and-verse%2Ffamily.ttl&shapes=https%3A%2F%2Fwww.semantechs.co.uk%2Farticles%2Fshow-your-working%2Fdemos%2F09-chapter-and-verse%2Fw23-family-shapes.ttl
#  SPEC      RDF 1.2 Concepts, triple terms and reification
#            https://www.w3.org/TR/rdf12-concepts/
#  REPORTS   conforms -- 0 violations, 0 warnings, 0 info; 7 shapes
# ==========================================================================

@prefix sh:     <http://www.w3.org/ns/shacl#> .
@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix prov:   <http://www.w3.org/ns/prov#> .
@prefix schema: <http://schema.org/> .
@prefix fam:    <https://example.org/family/> .
@prefix shp:    <https://example.org/shapes/> .

shp:EverythingHasASource a sh:NodeShape ;
    sh:targetSubjectsOf rdf:reifies ;
    sh:property [
        sh:path prov:wasDerivedFrom ; sh:minCount 1 ;
        sh:message "A claim or conclusion must say what it was derived from." ] .

shp:PersonHasAName a sh:NodeShape ;
    sh:targetClass schema:Person ;
    sh:or ( [ sh:path schema:givenName ; sh:minCount 1 ] [ sh:path schema:familyName ; sh:minCount 1 ] ) ;
    sh:message "Everyone needs a given name or a surname." .

shp:KnownLinkKind a sh:NodeShape ;
    sh:targetSubjectsOf fam:linkKind ;
    sh:property [
        sh:path fam:linkKind ; sh:in ( fam:_birth fam:_adopted fam:_foster fam:_sealed ) ;
        sh:message "A parent link is birth, adopted, foster or sealed." ] .
