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
62 changes: 62 additions & 0 deletions migration/v11.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Migrating to gist v11.0

See also, additional documentation in the file `docs/MajorVersionMigration.md`.

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

`*` the handling of these queries will be dependent upon which Triplestore
you are using and how it was configured. Some Triplestores will only use
triples in the default graph, some will use all triples in all 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:
```shell
onto_tool bundle migrate_local.yaml
```

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

Report files will be created in the ./reports/ directory.

## Run on a SPARQL Endpoint

You will need to tell onto_tool the URL of your SPARQL endpoint. You can do that
by editing the migration_endpoint.yaml file, or you can put it into the command
line execution like this:

```shell
onto_tool bundle -v user USER -v password PWD
-v endpoint ENDPOINT-URI
[ -v update_endpoint UPDATE-URI ]
-v report REPORT-DIR migrate_endpoint.yaml
```
27 changes: 27 additions & 0 deletions migration/v11.0/action_rename_default.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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)
(gist:baseConversionFactor gist:conversionFactor)
(gist:standardConversionFactor gist:conversionFactor)
}
{
?oldTerm ?sp ?so
} UNION {
?ps ?oldTerm ?po
} UNION {
?os ?op ?oldTerm
}
}
33 changes: 33 additions & 0 deletions migration/v11.0/action_rename_ngraphs.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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)
(gist:baseConversionFactor gist:conversionFactor)
(gist:standardConversionFactor gist:conversionFactor)
}
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)
}
Loading