Skip to content

uom data conversion explanation and queries #1071

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

Merged
merged 15 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions migration/v13.0/queries/checkAspects.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# sanity check: see if you have found all of the Aspects returned by this query
#
# some possibilities:
#
# - Aspect defined but never used
# - Aspect used by pattern not included in the queries (investigate and write custom queries)

select ?possibleAspect
where {

{
?possibleAspect (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:first))+ gist:Magnitude .

filter(?possibleAspect != gist:ReferenceValue)
}
union
{
?possibleAspect rdfs:subClassOf+ gist:Aspect .
}

}
order by ?possibleAspect
50 changes: 50 additions & 0 deletions migration/v13.0/queries/findAspects1-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# find existing Aspects that are represented as either:
#
# - a property of a Magnitude
# - or the value of a property of a Magnitude
#
# use this query iteratively as follows:
#
# - run the query
# - pick a few lines of output
# - update the upper section of the query with concepts that do NOT involve an Aspect
# - update the lower section of the query (filter not exists) with properties and values that DO represent Aspects
# - repeat
#
# this iterative process accounts for every property and value associated with a Magnitude
# when the query returns no results, every row of the original output has been accounted for

select distinct ?magnitudeProperty ?magnitudePropertyValue

where {

?magnitude gist:hasUnitOfMeasure ?unit ;
?magnitudeProperty ?magnitudePropertyValue ;
.

filter(?magnitudeProperty not in ( # properties that do not involve an Aspect
gist:hasUnitOfMeasure,
gist:numericValue,
skos:definition,
skos:scopeNote,
skos:prefLabel,
rdfs:isDefinedBy
))

filter(?magnitudePropertyValue not in ( # values that do not represent Aspects
gist:Magnitude,
owl:Thing,
owl:NamedIndividual
))


filter not exists {

values (?magnitudeProperty ?magnitudePropertyValue) { # property/value pairs with a property or value that represents an Aspect

(rdf:type gist:Duration) # sample value

}
}
}
order by ?magnitudeProperty ?magnitudePropertyValue
66 changes: 66 additions & 0 deletions migration/v13.0/queries/findAspects2-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# find existing Aspects that are represented as either:
#
# - a property of a Thing with a Magnitude or
# - the value of the property
#
# use this query iteratively as follows:
#
# - run the query
# - pick a few lines of output
# - update the upper section of the query with concepts that do NOT involve an Aspect
# - update the lower section of the query (filter not exists) with properties and values that DO represent Aspects
# - repeat
#
# this iterative process accounts for every property and value associated with a Magnitude
# when the query returns no results, every row of the original output has been accounted for

select distinct ?thingProperty ?thingPropertyValue

where {

?magnitude gist:hasUnitOfMeasure ?unit .

?thing gist:hasMagnitude ?magnitude ;
?thingProperty ?thingPropertyValue ;
.

filter(?thingProperty not in ( # properties that do not involve an Aspect
gist:conformsTo,
gist:containedText,
gist:description,
gist:hasGoal,
gist:hasMagnitude,
gist:hasPart,
gist:hasPhysicalLocation,
gist:isAffectedBy,
gist:isConnectedTo,
gist:isDirectPartOf,
gist:isPartOf,
gist:name,
gist:plannedEndDate,
gist:plannedStartDate,
rdfs:comment,
rdfs:isDefinedBy,
skos:altLabel,
skos:definition,
skos:scopeNote,
skos:prefLabel
))

filter(?thingPropertyValue not in ( # values that do not represent Aspects

owl:NamedIndividual,
owl:Thing

))

filter not exists {

values (?thingProperty ?thingPropertyValue) { # property/value pairs with a property or value that represents an Aspect

# (gist:isCategorizedBy ex:_Category_area) # sample value, commented out

}
}
}
order by ?thingProperty ?thingPropertyValue
17 changes: 17 additions & 0 deletions migration/v13.0/queries/findAspects3-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# find existing Aspects that are represented as a property with a Magnitude as object
# (e.g. hasArea)
#

select distinct ?thingToMagnitudeProperty

where {

?magnitude gist:hasUnitOfMeasure ?unit .

?thing ?thingToMagnitudeProperty ?magnitude .

filter (?thingToMagnitudeProperty != gist:hasMagnitude)

}
order by ?thingToMagnitudeProperty

7 changes: 7 additions & 0 deletions migration/v13.0/queries/findAspects4-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# find Aspects that are the subject of gist:isAspectOf

select ?aspect

where { ?aspect gist:isAspectOf ?x .}

order by ?aspect
71 changes: 71 additions & 0 deletions migration/v13.0/queries/findAspects5-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# find Aspects that are represented within the name of a Magnitude or Thing with a Magnitude
#
# fill in the upper section with values from the previous 4 queries
#
# the use this query iteratively as follows:
#
# - run the query
# - pick a few lines of output
# - update the lower section of the query with strings embedded in Magnitude IRI or Thing IRI that represent an Aspect
# - repeat
#
# this iterative process accounts for every Magnitude and Thing with a Magnitude
# when the query returns no results, every row of the original output has been accounted for

select distinct ?magnitude ?thing

where {

?magnitude gist:hasUnitOfMeasure ?unit .

optional {?thing gist:hasMagnitude ?magnitude . }

filter not exists {

?magnitude ?magnitudeProperty ?magnitudePropertyValue .

############# copy values from findAspects1.rq ###################
values (?magnitudeProperty ?magnitudePropertyValue) { # pairs where the property or the value represents a Magnitude

(rdf:type gist:Balance) # sample value
}
}

filter not exists { # filter out things for which an Aspect has been identified

?thing ?thingProperty ?thingPropertyValue .

############## copy values from findAspects2.rq ###################
values (?thingProperty ?thingPropertyValue) { # more pairs with a property or value that represents an Aspect

(rdf:type gist:Balance) # sample value
}

}

filter not exists { # filter out properties that represent an Aspect and have a Magnitude as object

?thing ?thingToMagnitudeProperty ?magnitude .

############## copy values from findAspects3.rq ###################
values ?thingToMagnitudeProperty {

# ex:hasArea # sample value, commented out

}

}

filter not exists { # filter out cases where an Aspect has the property gist:isAspectOf

{?aspect gist:isAspectOf ?magnitude .} union {?aspect gist:isAspectOf ?thing.}

}


####### in this section, include substrings of a Magnitude IRI or Thing IRI that represent an Aspect ####

# filter(!contains(str(?magnitude), "/BillingRate/")) # sample value, commented out

}
order by ?magnitude ?thing
12 changes: 12 additions & 0 deletions migration/v13.0/queries/findMagnitudesWithNoAspect.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# find Magnitudes with no gist:hasAspect

select ?magnitude

where {

?magnitude gist:hasUnitOfMeasure ?unit . # to identify magnitudes

filter not exists {?magnitude gist:hasAspect ?anything .}

}
order by ?magnitude
12 changes: 12 additions & 0 deletions migration/v13.0/queries/findUnits.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# find units of measure
# note: older versions of gist included some individuals that had units
# to remove these, incude filter(!contains(str(?s), "gist"))

select distinct ?unit

where {

?s gist:hasUnitOfMeasure ?unit .

}
order by ?unit
40 changes: 40 additions & 0 deletions migration/v13.0/queries/insertAspects1-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# insert new Aspects into the graph, where the old Aspect was represented as a property of a Magnitude, or its value

# test
select distinct ?magnitude ?aspect ?newAspect
# select distinct ?magnitude ?magnitudeProperty ?magnitudePropertyValue ?newAspect
# select distinct ?magnitude ?magnitudeProperty ?newAspect

# update the graph
# insert {graph ?g { ?magnitude gist:hasAspect ?newAspect . }}

where {

graph ?g {
?magnitude gist:hasUnitOfMeasure ?unit ;
?magnitudeProperty ?magnitudePropertyValue ;
.
filter not exists {?magnitude gist:hasAspect ?anything . } # to prevent duplicates (idempotent)
}

{
################ copy ?magnitudePropertyValue from findAspects1 #################

values (?magnitudePropertyValue ?newAspect) {
(gist:Duration gistd:_Aspect_duration) # sample value

}
bind(?magnitudePropertyValue as ?aspect)
}

union
{
################ copy values from findAspects1 #################

values ?magnitudeProperty {

}

bind(?magnitudeProperty as ?aspect)
}
}
49 changes: 49 additions & 0 deletions migration/v13.0/queries/insertAspects2-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# insert Aspects represented by a property or property value of a Thing with a Magnitude
#
# copy the values statements from the lower section of findAspects2 (the filter-not-exists)

# test
select distinct ?magnitude ?aspect ?newAspect

# update graph
# insert {graph ?g {?magnitude gist:hasAspect ?newAspect .}}


where {

graph ?g {

?magnitude gist:hasUnitOfMeasure ?unit .

?thing gist:hasMagnitude ?magnitude ;
?thingProperty ?thingPropertyValue ;
.

filter not exists {?magnitude gist:hasAspect ?anything . } # to prevent duplicates (idempotent)
}

{
################ copy values from findAspects2 #################
values (?thingPropertyValue ?newAspect) {

# (gist:Duration gistd:_Aspect_duration) # sample value, commented out

}

bind(?thingPropertyValue as ?aspect)
}

union
{
################ copy from findAspects2 #################
values ?thingProperty {


}

bind(?thingProperty as ?aspect)
}

}
# order by ?magnitude ?newAspect

30 changes: 30 additions & 0 deletions migration/v13.0/queries/insertAspects3-template.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# insert Aspects, where the Aspect is represented as a property with a Magnitude as object
# (e.g. hasArea)

# test
select distinct ?thingToMagnitudeProperty ?newAspect

# update graph
# insert {graph ?g {?magnitude gist:hasAspect ?newAspect . }}

where {

graph ?g {

?magnitude gist:hasUnitOfMeasure ?unit .
?thing ?thingToMagnitudeProperty ?magnitude .

filter not exists {?magnitude gist:hasAspect ?anything . } # to prevent duplicates (idempotent)
}

################ include the values returned by findAspects3 #################

values (?thingToMagnitudeProperty ?newAspect) {

# (gist:hasCurrentBalance gistd:_Aspect_financial_balance) # sample value, commented out

}

}
# order by ?magnitude ?newAspect

Loading