# Optional mappings from the C4 architecture ontology (c4.ttl) and its data module (c4-data.ttl) to other vocabularies.
#
# Load this file only if you want the cross-links; neither c4.ttl nor c4-data.ttl imports it.
#
# Every mapping is a SKOS mapping property (skos:closeMatch, skos:relatedMatch, skos:broadMatch) or
# rdfs:seeAlso, never owl:equivalentClass or owl:equivalentProperty. An equivalence would make a reasoner
# merge the two terms and carry every axiom of one over to the other: schema:SoftwareApplication would
# inherit the C4 disjointness axioms, and every schema.org application in a merged graph would become a
# c4:SoftwareSystem. The SKOS mapping properties are annotations: they tell a reader (or a mapping tool)
# that the terms are close, and change nothing else.
#
#   closeMatch   close enough to use one for the other in most applications, not formally the same
#   broadMatch   the other term is broader
#   relatedMatch related, but not interchangeable
#
# The data module is mapped the same way, and for one more reason: c4d: describes how a system keeps data, while CSVW,
# SHACL, OWL and RDFS describe data (or constrain it) directly. A c4d:Table is close to a csvw:Schema, but an equivalence
# would make every CSVW table schema a C4 entity that must live in an element of an architecture; c4d:Field and
# sh:PropertyShape, or c4d:Entity and owl:Class, are related only: an OWL reasoner told they were equivalent would treat
# every table as a class and every column as a property of its rows.

@prefix c4:      <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix schema:  <https://schema.org/> .
@prefix skos:    <http://www.w3.org/2004/02/skos/core#> .
@prefix prov:    <http://www.w3.org/ns/prov#> .
@prefix c4d:     <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-data#> .
@prefix csvw:    <http://www.w3.org/ns/csvw#> .
@prefix sh:      <http://www.w3.org/ns/shacl#> .
@prefix dcat:    <http://www.w3.org/ns/dcat#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix vann:    <http://purl.org/vocab/vann/> .
@prefix c4us:    <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-stories#> .
@prefix oa:      <http://www.w3.org/ns/oa#> .

<https://caviri.github.io/c4-model-agentic-plugin/ontology/alignments.ttl>
    a owl:Ontology ;
    dcterms:title "Alignments of the C4 architecture ontology"@en ;
    dcterms:description "SKOS mappings from c4: terms to schema.org, Dublin Core, PROV-O and SKOS terms, plus pointers to the Structurizr DSL; and from c4d: terms (the data module) to CSVW, SHACL, OWL and RDFS, DCAT, PROV-O and schema.org. Optional; nothing in c4.ttl or c4-data.ttl depends on it."@en ;
    dcterms:creator "caviri" ;
    dcterms:license <https://www.apache.org/licenses/LICENSE-2.0> ;
    owl:versionInfo "0.1.0" ;
    rdfs:seeAlso <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4> , <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-data> .

skos:closeMatch   a owl:AnnotationProperty .
skos:broadMatch   a owl:AnnotationProperty .
skos:relatedMatch a owl:AnnotationProperty .
skos:scopeNote    a owl:AnnotationProperty .
dcterms:title       a owl:AnnotationProperty .
dcterms:description a owl:AnnotationProperty .
dcterms:creator     a owl:AnnotationProperty .
dcterms:license     a owl:AnnotationProperty .

# ---- classes

c4:SoftwareSystem
    skos:closeMatch schema:SoftwareApplication ;
    skos:scopeNote "schema:SoftwareApplication describes a product to install or use; a C4 software system is a unit of ownership and value made of containers."@en .

c4:Container
    skos:relatedMatch schema:SoftwareApplication ;
    skos:scopeNote "A C4 container is often a separately deployed application, but a data store is a container too."@en .

c4:CodeElement
    skos:relatedMatch schema:SoftwareSourceCode .

c4:Person
    skos:relatedMatch prov:Agent , schema:Audience ;
    skos:scopeNote "A C4 person is a role or persona that uses a system; prov:Agent is whatever bears responsibility for an activity, schema:Audience an intended group of users."@en .

c4:Model
    skos:broadMatch schema:CreativeWork .

c4:Scenario
    rdfs:seeAlso <https://docs.structurizr.com/dsl/language> ;
    skos:scopeNote "The Structurizr DSL calls this a dynamic view."@en .

# ---- properties

c4:uses
    skos:relatedMatch dcterms:requires ;
    skos:scopeNote "dcterms:requires is a dependency between resources; c4:uses is a runtime interaction (a person uses a system without requiring it)."@en .

c4:hasStep
    skos:closeMatch schema:step .

c4:summary
    skos:closeMatch schema:disambiguatingDescription .

c4:note
    skos:closeMatch skos:note .

c4:technology
    skos:relatedMatch schema:programmingLanguage , schema:runtimePlatform .

c4:primaryActor
    skos:relatedMatch schema:agent .

# ---- the data module (c4d:): classes

c4d:Schema
    skos:relatedMatch csvw:TableGroup , owl:Ontology ;
    skos:broadMatch dcterms:Standard ;
    skos:scopeNote "CSVW describes the tables of one relational schema together as a csvw:TableGroup; a schema of kind ontology describes an owl:Ontology (it does not replace it). In DCAT a distribution points at the schema its data follows with dcterms:conformsTo, whose range dcterms:Standard is broader."@en .

c4d:Entity
    skos:relatedMatch owl:Class , rdfs:Class , sh:NodeShape , schema:Class ;
    skos:scopeNote "An entity of kind class describes an ontology class and names it with c4d:represents; a SHACL node shape constrains the instances of a class. Both are close to an entity of another schema, none is the same thing: the entity is how one store keeps such records."@en .

c4d:Table
    skos:closeMatch csvw:Schema ;
    skos:relatedMatch csvw:Table ;
    skos:scopeNote "A csvw:Schema is a table's schema (its columns, primary key and foreign keys), which is what a c4d:Table describes; a csvw:Table is a table of data (a CSV file) that follows one."@en .

c4d:Enumeration
    skos:relatedMatch schema:Enumeration ;
    skos:scopeNote "Also close to an OWL class given by owl:oneOf, and to the list of a sh:in constraint."@en .

c4d:Field
    skos:closeMatch csvw:Column ;
    skos:relatedMatch sh:PropertyShape , rdf:Property , schema:Property .

c4d:Relation
    skos:relatedMatch csvw:ForeignKey ;
    skos:scopeNote "Of the relation kinds, ref is close to a CSVW foreign key, extends to rdfs:subClassOf (or JSON Schema allOf), maps to skos:closeMatch between the terms two schemas store, assoc to an owl:ObjectProperty; contains has no common RDF term."@en .

# ---- the data module: properties

c4d:livesIn
    skos:relatedMatch dcat:servesDataset ;
    skos:scopeNote "The other way round: a DCAT data service serves a dataset; here a schema lives in the element (a data store, a container) that holds or produces its data."@en .

c4d:definedBy
    skos:relatedMatch rdfs:isDefinedBy ;
    skos:scopeNote "rdfs:isDefinedBy names the vocabulary a term belongs to; c4d:definedBy names the code that defines an entity."@en .

c4d:hasEntity
    skos:relatedMatch csvw:table .

c4d:hasField
    skos:relatedMatch csvw:column , sh:property .

c4d:references
    skos:relatedMatch csvw:foreignKey ;
    skos:scopeNote "CSVW states a foreign key on the table schema (csvw:foreignKey with csvw:columnReference and csvw:reference); c4d:references goes from the referencing field to what it references, across stores too."@en .

c4d:isPrimaryKey
    skos:relatedMatch csvw:primaryKey .

c4d:isRequired
    skos:closeMatch csvw:required ;
    skos:relatedMatch sh:minCount .

c4d:isMultiValued
    skos:relatedMatch csvw:separator , sh:maxCount .

c4d:defaultValue
    skos:closeMatch csvw:default .

c4d:declaredType
    skos:relatedMatch csvw:datatype , sh:datatype ;
    skos:scopeNote "c4d:declaredType is the type as the source writes it (TEXT, number[], iat:Label), never interpreted."@en .

c4d:allowedValue
    skos:relatedMatch sh:in , owl:oneOf .

c4d:represents
    skos:scopeNote "Deliberately not mapped to owl:sameAs, owl:equivalentClass or owl:equivalentProperty: the entity or field describes how a store keeps the term, it is not the term."@en .

c4d:namespace
    skos:closeMatch vann:preferredNamespaceUri .

c4d:format
    skos:relatedMatch dcterms:format .

c4d:reads
    skos:relatedMatch prov:used ;
    skos:scopeNote "A step that reads an entity uses it, in PROV-O terms, if the step is read as an activity."@en .

c4d:writes
    skos:relatedMatch prov:generated .

# ---- the user stories module (c4us:)

c4us:UserStory
    skos:relatedMatch schema:CreativeWork ;
    skos:scopeNote "A user story is a requirement told for a person (as a …, I want …, so that …), checked by acceptance criteria; schema.org has no closer class."@en .

c4us:Persona
    skos:closeMatch schema:Audience ;
    skos:scopeNote "A persona is a kind of person the stories are told for, like an audience; when the architecture shows that person, c4us:portrays links it to the c4:Person."@en .

c4us:Note
    skos:closeMatch oa:Annotation , schema:Comment ;
    skos:scopeNote "A reader's note annotates a screen view (its target) with a comment and pins; a Web Annotation would put the pins in selectors."@en .

c4us:Pin
    skos:relatedMatch oa:FragmentSelector .

c4us:ScreenView
    skos:closeMatch schema:ImageObject ;
    skos:scopeNote "Deliberately not typed schema:ImageObject in the data: the core's image shapes (one owner by schema:image, an order) are for the explorer's pictures."@en .

c4us:comment
    skos:closeMatch schema:text .

c4us:altText
    skos:closeMatch c4:altText .

c4us:illustrative
    skos:closeMatch c4:illustrative .

c4us:goal
    skos:closeMatch c4:goal .

c4us:trigger
    skos:closeMatch c4:trigger .

c4us:precondition
    skos:closeMatch c4:precondition .

c4us:outcome
    skos:closeMatch c4:outcome .

# Deployment (c4:DeploymentEnvironment, c4:DeploymentNode, c4:InfrastructureNode, c4:ContainerInstance,
# c4:SoftwareSystemInstance, c4:DeploymentRelationship): they follow UML deployment diagrams and ArchiMate's technology
# layer (Node, Device, System Software), which have no RDF vocabulary to map to here; a deployment node is a kind of
# place where software runs, nothing in schema.org, PROV or DCAT says that, so no mapping is given.
