Files
visualizador_instanciados/backend_go/graph_queries/default.go

76 lines
1.3 KiB
Go

package graph_queries
import (
"fmt"
"visualizador_instanciados/backend_go/queryscope"
)
func defaultEdgeQuery(limit int, offset int, includeBNodes bool) string {
bnodeFilter := ""
if !includeBNodes {
bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
}
pattern := queryscope.NamedGraph(`
{
VALUES ?p { rdf:type }
?s ?p ?o .
}
UNION
{
VALUES ?p { rdfs:subClassOf }
?s ?p ?o .
}
`)
return fmt.Sprintf(`
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT ?s ?p ?o
WHERE {
%s
FILTER(!isLiteral(?o))
%s
}
ORDER BY ?s ?p ?o
LIMIT %d
OFFSET %d
`, pattern, bnodeFilter, limit, offset)
}
func defaultPredicateQuery(includeBNodes bool) string {
bnodeFilter := ""
if !includeBNodes {
bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
}
pattern := queryscope.NamedGraph(`
{
VALUES ?p { rdf:type }
?s ?p ?o .
}
UNION
{
VALUES ?p { rdfs:subClassOf }
?s ?p ?o .
}
`)
return fmt.Sprintf(`
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT ?p
WHERE {
%s
FILTER(!isLiteral(?o))
%s
}
ORDER BY ?p
`, pattern, bnodeFilter)
}