backend: support external SPARQL and named-graph snapshots

This commit is contained in:
Oxy8
2026-04-06 13:36:08 -03:00
parent 696844f341
commit 44c1d3eaa6
25 changed files with 1695 additions and 243 deletions

View File

@@ -1,6 +1,10 @@
package graph_queries
import "fmt"
import (
"fmt"
"visualizador_instanciados/backend_go/queryscope"
)
func hierarchyEdgeQuery(limit int, offset int, includeBNodes bool) string {
bnodeFilter := ""
@@ -8,20 +12,31 @@ func hierarchyEdgeQuery(limit int, offset int, includeBNodes bool) string {
bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
}
pattern := queryscope.NamedGraph(`
{
VALUES ?p { rdfs:subClassOf }
?s ?p ?o .
}
UNION
{
VALUES ?p { rdf:type }
?s ?p ?o .
}
`)
return fmt.Sprintf(`
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?s ?p ?o
SELECT DISTINCT ?s ?p ?o
WHERE {
VALUES ?p { rdfs:subClassOf }
?s ?p ?o .
%s
FILTER(!isLiteral(?o))
%s
}
ORDER BY ?s ?p ?o
LIMIT %d
OFFSET %d
`, bnodeFilter, limit, offset)
`, pattern, bnodeFilter, limit, offset)
}
func hierarchyPredicateQuery(includeBNodes bool) string {
@@ -30,16 +45,27 @@ func hierarchyPredicateQuery(includeBNodes bool) string {
bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
}
pattern := queryscope.NamedGraph(`
{
VALUES ?p { rdfs:subClassOf }
?s ?p ?o .
}
UNION
{
VALUES ?p { rdf:type }
?s ?p ?o .
}
`)
return fmt.Sprintf(`
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?p
WHERE {
VALUES ?p { rdfs:subClassOf }
?s ?p ?o .
%s
FILTER(!isLiteral(?o))
%s
}
ORDER BY ?p
`, bnodeFilter)
`, pattern, bnodeFilter)
}