@prefix ex: <https://example.com/ontology-migration/> .
@prefix new: <https://example.com/person/v2/> .
@prefix old: <https://example.com/person/v1/> .
@prefix om: <https://ontology.inferal.com/modules/ontology-migration/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

old:v1 a owl:Ontology .
new:v2 a owl:Ontology .

ex:person-v1-to-v2
    a om:OntologyMigrationSet ;
    om:sourceOntology old:v1 ;
    om:targetOntology new:v2 ;
    om:hasCase ex:PersonTypeCase ;
    om:targetShapesGraph ex:PersonV2Shapes .

ex:FullNameCase
    a sh:NodeShape ;
    om:caseOf ex:person-v1-to-v2 ;
    sh:targetSubjectsOf old:fullName ;
    om:hasRetractionRule ex:RetractFullName .

ex:RetractPersonType
    a sh:SPARQLRule ;
    om:retractionRuleOf ex:PersonTypeCase ;
    sh:construct """
        PREFIX new: <https://example.com/person/v2/>
        PREFIX old: <https://example.com/person/v1/>
        CONSTRUCT { $this a old:Person }
        WHERE { $this a old:Person, new:Person }
    """ .

ex:PersonTypeCase
    a sh:NodeShape ;
    sh:targetClass old:Person .

ex:RetractFullName
    a sh:SPARQLRule ;
    sh:construct """
        PREFIX new: <https://example.com/person/v2/>
        PREFIX old: <https://example.com/person/v1/>
        CONSTRUCT { $this old:fullName ?name }
        WHERE {
            $this old:fullName ?name ;
                  new:displayName ?name .
        }
    """ .

# This valid rule is deliberately unrelated to the selected migration set and
# must not leak into discovery results.
ex:UnrelatedRule
    a sh:SPARQLRule ;
    rdfs:label "unrelated retraction rule" ;
    rdfs:comment "A valid planner that is not associated with any case in the selected migration set." ;
    sh:construct """
        PREFIX old: <https://example.com/person/v1/>
        CONSTRUCT { $this a old:Person }
        WHERE { $this a old:Person }
    """ .
