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

@@ -4,6 +4,8 @@ import (
"context"
"fmt"
"strings"
"visualizador_instanciados/backend_go/queryscope"
)
func subclassesQuery(selectedNodes []NodeRef, includeBNodes bool) string {
@@ -26,20 +28,33 @@ func subclassesQuery(selectedNodes []NodeRef, includeBNodes bool) string {
}
values := strings.Join(valuesTerms, " ")
pattern := queryscope.NamedGraph(fmt.Sprintf(`
{
VALUES ?sel { %s }
VALUES ?p { rdfs:subClassOf }
?s ?p ?sel .
BIND(?sel AS ?o)
}
UNION
{
VALUES ?sel { %s }
VALUES ?p { <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> }
?s ?p ?sel .
BIND(?sel AS ?o)
}
`, values, values))
return fmt.Sprintf(`
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?s ?p ?o
WHERE {
VALUES ?sel { %s }
VALUES ?p { rdfs:subClassOf }
?s ?p ?sel .
BIND(?sel AS ?o)
%s
FILTER(!isLiteral(?o))
FILTER(?s != ?o)
%s
}
`, values, bnodeFilter)
`, pattern, bnodeFilter)
}
func runSubclasses(ctx context.Context, q Querier, idx Index, selectedIDs []uint32, includeBNodes bool) (Result, error) {