Skip to content

Commit

Permalink
fix: select srcGraph and srcCommit once
Browse files Browse the repository at this point in the history
  • Loading branch information
blake-regalia committed Jan 31, 2024
1 parent b5ff341 commit 16979c2
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions src/main/kotlin/org/openmbee/flexo/mms/routes/gsp/ModelLoad.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fun Route.loadModel() {
// compute the delta
run {
val selectQueryString = """
select distinct ?srcGraph {
select distinct ?srcGraph ?srcCommit {
graph mor-graph:Metadata {
# select the latest commit from the current named ref
?srcRef mms:commit ?srcCommit .
Expand Down Expand Up @@ -261,29 +261,9 @@ fun Route.loadModel() {

val sourceGraphIri = bindings[0].jsonObject["srcGraph"]!!.jsonObject["value"]!!.jsonPrimitive.content

val updateString = genDiffUpdate("", localConditions, """
graph mor-graph:Metadata {
# select the latest commit from the current named ref
?srcRef mms:commit ?srcCommit .
# get the latest snapshot associated with the source commit
?srcCommit ^mms:commit/mms:snapshot ?srcSnapshot .
{
# prefer the model snapshot
?srcSnapshot a mms:Model ;
mms:graph ?srcGraph .
} union {
# settle for staging...
?srcSnapshot a mms:Staging ;
mms:graph ?srcGraph .
# ...if model is not available
filter not exists {
?srcCommit ^mms:commit/mms:snapshot/a mms:Model .
}
}
}
""")
val sourceCommitri = bindings[0].jsonObject["srcCommit"]!!.jsonObject["value"]!!.jsonPrimitive.content

val updateString = genDiffUpdate("", localConditions, "")

executeSparqlUpdate(updateString) {
prefixes(prefixes)
Expand All @@ -300,6 +280,9 @@ fun Route.loadModel() {

// use explicit srcGraph
"srcGraph" to sourceGraphIri,

// use explicit srcCommit
"srcCommit" to sourceCommitri,
)
}
}
Expand Down

0 comments on commit 16979c2

Please sign in to comment.