Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts for local file migrations. Closes #642. #648

Merged
merged 14 commits into from
Apr 6, 2022
40 changes: 40 additions & 0 deletions migration/v11.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Migrating to gist v11.0

This file gives a quick overview of using the migration utilities provided
by the gist team to help migrate from version v10 of gist. These
utilities should be reviewed before running them to make sure you approve
of the actions prior to using them.

These utilities do not handle everything, in some cases we can only warn you
about changes that were made in gist and you will need to decide how you want
to handle the changes.

## Migration Queries

All of our migration tools are SPARQL queries.

You will note that some files have very similar names. Here is what the suffixes mean:
- `_default.rq` : These queries only work on the default graph
- `_ngraphs.rq` : These queries only work on named graphs
- `.rq` : These queries work on both the default graph and named graphs

## Requirements

These migration scripts are meant to be run using the open source onto_tool
program. Information about onto_tool and how to install it, is available at
(github)[https://github.com/semanticarts/ontology-toolkit].

## Run on local files

NOTE: A known limitation of `onto_tool` is that it does not support named graphs when run against local files.
It does support named graphs when run against a SPARQL endpoint.

Start in this directory.

Put source data files in the ./input/ directory. See the onto_tool documentation for which file formats are supported.

Execute `onto_tool bundle migrate_local.yaml`.

Output files will be created in the ./output/ directory.

Report files will be created in the ./reports/ directory.
25 changes: 25 additions & 0 deletions migration/v11.0/action_rename_default.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
prefix gist: <https://ontologies.semanticarts.com/gist/>

DELETE {
?oldTerm ?sp ?so .
?ps ?oldTerm ?po .
?os ?op ?oldTerm .
}
INSERT {
?newTerm ?sp ?so .
?ps ?newTerm ?po .
?os ?op ?newTerm .
}
where {
values (?oldTerm ?newTerm) {
(gist:ContemporaneousEvent gist:ContemporaryEvent)
(gist:hasOrderedMember gist:hasMember)
}
{
?oldTerm ?sp ?so
} UNION {
?ps ?oldTerm ?po
} UNION {
?os ?op ?oldTerm
}
}
31 changes: 31 additions & 0 deletions migration/v11.0/action_rename_ngraphs.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
prefix gist: <https://ontologies.semanticarts.com/gist/>

DELETE {
graph ?graph {
?oldTerm ?sp ?so .
?ps ?oldTerm ?po .
?os ?op ?oldTerm .
}
}
INSERT {
graph ?graph {
?newTerm ?sp ?so .
?ps ?newTerm ?po .
?os ?op ?newTerm .
}
}
where {
values (?oldTerm ?newTerm) {
(gist:ContemporaneousEvent gist:ContemporaryEvent)
(gist:hasOrderedMember gist:hasMember)
}
graph ?graph {
{
?oldTerm ?sp ?so
} UNION {
?ps ?oldTerm ?po
} UNION {
?os ?op ?oldTerm
}
}
}
44 changes: 44 additions & 0 deletions migration/v11.0/detect_domain_changed.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix sh: <http://www.w3.org/ns/shacl#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
prefix gist: <https://ontologies.semanticarts.com/gist/>

CONSTRUCT {
?report a sh:ValidationReport ;
sh:conforms false ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode ?modified ;
sh:resultMessage ?error ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent <urn:constraint:range-removed-entity>
] .
}
WHERE {
{
select distinct ?modified where {
values ?modified {
gist:usesTimeZoneStandard
}
{
?s ?modified ?o
} UNION {
?s ?p ?modified
} UNION {
?modified ?p ?o
} UNION {
graph ?g { ?s ?modified ?o }
} UNION {
graph ?g { ?s ?p ?modified }
} UNION {
graph ?g { ?modified ?p ?o }
}
}
}
bind(<urn:range-removed-entity-validation-report> as ?report)
bind(CONCAT("WARNING: a rdfs:domain of property gist:",
REPLACE(STR(?modified), '^.*[/#]', ''), " was removed. If you were relying on ",
"inference from the removed domain you will need to address this change." ) as ?error)
}
44 changes: 44 additions & 0 deletions migration/v11.0/detect_domain_changed_default.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix sh: <http://www.w3.org/ns/shacl#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
prefix gist: <https://ontologies.semanticarts.com/gist/>

CONSTRUCT {
?report a sh:ValidationReport ;
sh:conforms false ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode ?modified ;
sh:resultMessage ?error ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent <urn:constraint:range-removed-entity>
] .
}
WHERE {
{
select distinct ?modified where {
values ?modified {
gist:usesTimeZoneStandard
}
{
?s ?modified ?o
} UNION {
?s ?p ?modified
} UNION {
?modified ?p ?o
# } UNION {
# graph ?g { ?s ?modified ?o }
# } UNION {
# graph ?g { ?s ?p ?modified }
# } UNION {
# graph ?g { ?modified ?p ?o }
}
}
}
bind(<urn:range-removed-entity-validation-report> as ?report)
bind(CONCAT("WARNING: a rdfs:domain of property gist:",
REPLACE(STR(?modified), '^.*[/#]', ''), " was removed. If you were relying on ",
"inference from the removed domain you will need to address this change." ) as ?error)
}
75 changes: 75 additions & 0 deletions migration/v11.0/detect_removed.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix sh: <http://www.w3.org/ns/shacl#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
prefix gist: <https://ontologies.semanticarts.com/gist/>

CONSTRUCT {
?report a sh:ValidationReport ;
sh:conforms false ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode ?deleted ;
sh:resultMessage ?error ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent <urn:constraint:removed-entity>
] .
}
WHERE {
{
select distinct ?deleted where {
values ?deleted {
## Time Model Classes
gist:TimeInstant
gist:DateInstant
gist:GreenwichInstant
gist:HumanInstant
gist:LocalInstant
gist:SystemInstant

## Time Model Properties
gist:hasEnd
gist:hasActual
gist:hasActualEnd
gist:hasPlannedEnd
gist:hasDeathDate
gist:hasStart
gist:hasActualStart
gist:hasPlanned
gist:hasBirthDate
gist:hasPlannedStart
gist:epoch
gist:localDate
gist:localDateTime
gist:localTime
gist:universalDate
gist:universalDateTime
gist:universalTime
gist:isSameTimeAs
gist:wasLastModifiedAt

## Misc
# gist:hasOrderedMember
gist:hasBiologicalOffspring
}
{
?s ?deleted ?o
} UNION {
?s ?p ?deleted
} UNION {
?deleted ?p ?o
} UNION {
graph ?g { ?s ?deleted ?o }
} UNION {
graph ?g { ?s ?p ?deleted }
} UNION {
graph ?g { ?deleted ?p ?o }
}
}
}
bind(<urn:deleted-entity-validation-report> as ?report)
bind(CONCAT("Removed entity gist:",
REPLACE(STR(?deleted), '^.*[/#]', ''), " referenced in data. ",
"Review release notes for information about the changes.") as ?error)
}
75 changes: 75 additions & 0 deletions migration/v11.0/detect_removed_default.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix sh: <http://www.w3.org/ns/shacl#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
prefix gist: <https://ontologies.semanticarts.com/gist/>

CONSTRUCT {
?report a sh:ValidationReport ;
sh:conforms false ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode ?deleted ;
sh:resultMessage ?error ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent <urn:constraint:removed-entity>
] .
}
WHERE {
{
select distinct ?deleted where {
values ?deleted {
## Time Model Classes
gist:TimeInstant
gist:DateInstant
gist:GreenwichInstant
gist:HumanInstant
gist:LocalInstant
gist:SystemInstant

## Time Model Properties
gist:hasEnd
gist:hasActual
gist:hasActualEnd
gist:hasPlannedEnd
gist:hasDeathDate
gist:hasStart
gist:hasActualStart
gist:hasPlanned
gist:hasBirthDate
gist:hasPlannedStart
gist:epoch
gist:localDate
gist:localDateTime
gist:localTime
gist:universalDate
gist:universalDateTime
gist:universalTime
gist:isSameTimeAs
gist:wasLastModifiedAt

## Misc
# gist:hasOrderedMember
gist:hasBiologicalOffspring
}
{
?s ?deleted ?o
} UNION {
?s ?p ?deleted
} UNION {
?deleted ?p ?o
# } UNION {
# graph ?g { ?s ?deleted ?o }
# } UNION {
# graph ?g { ?s ?p ?deleted }
# } UNION {
# graph ?g { ?deleted ?p ?o }
}
}
}
bind(<urn:deleted-entity-validation-report> as ?report)
bind(CONCAT("Removed entity gist:",
REPLACE(STR(?deleted), '^.*[/#]', ''), " referenced in data. ",
"Review release notes for information about the changes.") as ?error)
}
45 changes: 45 additions & 0 deletions migration/v11.0/detect_renamed.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix sh: <http://www.w3.org/ns/shacl#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
prefix gist: <https://ontologies.semanticarts.com/gist/>

CONSTRUCT {
?report a sh:ValidationReport ;
sh:conforms false ;
sh:result
[
a sh:ValidationResult ;
sh:focusNode ?renamed ;
sh:resultMessage ?error ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent <urn:constraint:renamed-entity>
] .
}
WHERE {
{
select distinct ?renamed where {
values ?renamed {
gist:hasJurisdictionOver
}
{
?s ?renamed ?o
} UNION {
?s ?p ?renamed
} UNION {
?renamed ?p ?o
} UNION {
graph ?g { ?s ?renamed ?o }
} UNION {
graph ?g { ?s ?p ?renamed }
} UNION {
graph ?g { ?renamed ?p ?o }
}
}
}
bind(<urn:renamed-entity-validation-report> as ?report)
bind(CONCAT("WARNING: incorrectly named property gist:",
REPLACE(STR(?renamed), '^.*[/#]', ''), " was changed to gist:isUnderJurisdictionOf. ",
"The previous name did not match the defintion. We won't autmatically update it ",
Jamie-SA marked this conversation as resolved.
Show resolved Hide resolved
"because you might have applied it based on the name, not the definition." ) as ?error)
}
Loading