@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix vann:    <http://purl.org/vocab/vann/> .
@prefix cc:      <http://creativecommons.org/ns#> .
@prefix sh:      <http://www.w3.org/ns/shacl#> .
@prefix arch:    <https://meta.linked.archi/core#> .
@prefix zach:    <https://meta.linked.archi/zachman#> .
@prefix :        <https://meta.linked.archi/zachman/shapes#> .

<https://meta.linked.archi/zachman/shapes#>
    rdf:type                      owl:Ontology ;
    owl:imports                   <https://meta.linked.archi/core#> ;
    cc:license                    "http://creativecommons.org/licenses/by/4.0/" ;
    vann:preferredNamespaceUri    "https://meta.linked.archi/zachman/shapes#" ;
    vann:preferredNamespacePrefix "zachsh" ;
    dcterms:title                 "Zachman Framework SHACL Shapes"@en ;
    dcterms:description           '''SHACL validation shapes for artifacts classified using the Zachman
Framework taxonomy. Validates that artifacts using Zachman classification have
at least one perspective (row) and one interrogative (column), and warns about
potential inconsistencies between cell-level and axis-level classification.'''@en ;
    dcterms:created               "2026-05-18"^^xsd:date ;
    dcterms:modified              "2026-05-18"^^xsd:date ;
    dcterms:creator               "Kalin Maldzhanski"^^xsd:string ;
    dcterms:publisher             "Linked.Archi"@en, <https://linked.archi> ;
    owl:versionIRI                <https://meta.linked.archi/zachman/shapes/0.1.0#> ;
    owl:versionInfo               "0.1.0"@en ;
.


## =============================================================================
## Shape: Artifact with Zachman Perspective must also have Interrogative
## =============================================================================

:ArtifactWithPerspectiveShape
    a               sh:NodeShape ;
    sh:targetSubjectsOf arch:viewpointFromPerspective ;
    skos:prefLabel  "Artifact with Zachman Perspective"@en ;
    sh:description  '''An artifact classified by a Zachman perspective (row) should also be
classified by at least one Zachman interrogative (column) to form a complete
cell reference.'''@en ;
    sh:severity     sh:Warning ;
    sh:property [
        sh:path     arch:viewpointCoversAspect ;
        sh:minCount 1 ;
        sh:message  "Artifact has a Zachman perspective (row) but no interrogative (column). Consider adding arch:viewpointCoversAspect to complete the classification."@en ;
    ] ;
.


## =============================================================================
## Shape: Artifact with Zachman Interrogative must also have Perspective
## =============================================================================

:ArtifactWithInterrogativeShape
    a               sh:NodeShape ;
    sh:targetSubjectsOf arch:viewpointCoversAspect ;
    skos:prefLabel  "Artifact with Zachman Interrogative"@en ;
    sh:description  '''An artifact classified by a Zachman interrogative (column) should also be
classified by at least one Zachman perspective (row) to form a complete
cell reference.'''@en ;
    sh:severity     sh:Warning ;
    sh:property [
        sh:path     arch:viewpointFromPerspective ;
        sh:minCount 1 ;
        sh:message  "Artifact has a Zachman interrogative (column) but no perspective (row). Consider adding arch:viewpointFromPerspective to complete the classification."@en ;
    ] ;
.


## =============================================================================
## Shape: Zachman Cell classification consistency
## =============================================================================

:CellClassificationConsistencyShape
    a               sh:NodeShape ;
    sh:targetSubjectsOf arch:classifiedByFrameworkCell ;
    skos:prefLabel  "Zachman Cell Classification Consistency"@en ;
    sh:description  '''When an artifact is classified directly by a Zachman cell, validates that
any explicit perspective or interrogative classification is consistent with
the cell's own row and column.'''@en ;
    sh:severity     sh:Warning ;
    sh:sparql [
        sh:message  "Artifact is classified by cell {?cell} but has an interrogative {?aspect} that does not match the cell's interrogative {?cellInterrogative}."@en ;
        sh:select '''
            PREFIX zach: <https://meta.linked.archi/zachman#>
            PREFIX arch: <https://meta.linked.archi/core#>
            SELECT $this ?cell ?aspect ?cellInterrogative
            WHERE {
                $this arch:classifiedByFrameworkCell ?cell .
                $this arch:viewpointCoversAspect ?aspect .
                ?cell zach:hasInterrogative ?cellInterrogative .
                FILTER (?aspect != ?cellInterrogative)
            }
        ''' ;
    ] ;
    sh:sparql [
        sh:message  "Artifact is classified by cell {?cell} but has a perspective {?perspective} that does not match the cell's perspective {?cellPerspective}."@en ;
        sh:select '''
            PREFIX zach: <https://meta.linked.archi/zachman#>
            PREFIX arch: <https://meta.linked.archi/core#>
            SELECT $this ?cell ?perspective ?cellPerspective
            WHERE {
                $this arch:classifiedByFrameworkCell ?cell .
                $this arch:viewpointFromPerspective ?perspective .
                ?cell zach:hasPerspective ?cellPerspective .
                FILTER (?perspective != ?cellPerspective)
            }
        ''' ;
    ] ;
.


## =============================================================================
## Shape: Perspective value must be a valid Zachman perspective
## =============================================================================

:ValidPerspectiveShape
    a               sh:NodeShape ;
    sh:targetSubjectsOf arch:viewpointFromPerspective ;
    skos:prefLabel  "Valid Zachman Perspective Value"@en ;
    sh:description  "Validates that the perspective value is one of the six Zachman perspectives."@en ;
    sh:severity     sh:Violation ;
    sh:property [
        sh:path     arch:viewpointFromPerspective ;
        sh:in       ( zach:ExecutivePerspective
                      zach:BusinessManagementPerspective
                      zach:ArchitectPerspective
                      zach:EngineerPerspective
                      zach:TechnicianPerspective
                      zach:EnterprisePerspective ) ;
        sh:message  "arch:viewpointFromPerspective must reference a valid Zachman perspective (ExecutivePerspective, BusinessManagementPerspective, ArchitectPerspective, EngineerPerspective, TechnicianPerspective, or EnterprisePerspective)."@en ;
    ] ;
.


## =============================================================================
## Shape: Interrogative value must be a valid Zachman interrogative
## =============================================================================

:ValidInterrogativeShape
    a               sh:NodeShape ;
    sh:targetSubjectsOf arch:viewpointCoversAspect ;
    skos:prefLabel  "Valid Zachman Interrogative Value"@en ;
    sh:description  "Validates that the interrogative/aspect value is one of the six Zachman interrogatives."@en ;
    sh:severity     sh:Warning ;
    sh:property [
        sh:path     arch:viewpointCoversAspect ;
        sh:in       ( zach:What zach:How zach:Where zach:Who zach:When zach:Why ) ;
        sh:message  "arch:viewpointCoversAspect should reference a valid Zachman interrogative (What, How, Where, Who, When, or Why)."@en ;
    ] ;
.


## =============================================================================
## Shape: Cell value must be a valid Zachman cell
## =============================================================================

:ValidCellShape
    a               sh:NodeShape ;
    sh:targetSubjectsOf arch:classifiedByFrameworkCell ;
    skos:prefLabel  "Valid Zachman Cell Value"@en ;
    sh:description  "Validates that the cell value is one of the 36 Zachman cells."@en ;
    sh:severity     sh:Violation ;
    sh:property [
        sh:path     arch:classifiedByFrameworkCell ;
        sh:class    skos:Concept ;
        sh:message  "arch:classifiedByFrameworkCell must reference a valid Zachman cell concept."@en ;
    ] ;
    sh:sparql [
        sh:message  "arch:classifiedByFrameworkCell value {?cell} is not a narrower concept of zach:ZachmanCell."@en ;
        sh:select '''
            PREFIX zach: <https://meta.linked.archi/zachman#>
            PREFIX arch: <https://meta.linked.archi/core#>
            PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
            SELECT $this ?cell
            WHERE {
                $this arch:classifiedByFrameworkCell ?cell .
                FILTER NOT EXISTS { ?cell skos:broader zach:ZachmanCell }
            }
        ''' ;
    ] ;
.
