package graph_queries

import "fmt"

func hierarchyEdgeQuery(limit int, offset int, includeBNodes bool) string {
	bnodeFilter := ""
	if !includeBNodes {
		bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
	}

	return fmt.Sprintf(`
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?s ?p ?o
WHERE {
  VALUES ?p { rdfs:subClassOf }
  ?s ?p ?o .
  FILTER(!isLiteral(?o))
  %s
}
ORDER BY ?s ?p ?o
LIMIT %d
OFFSET %d
`, bnodeFilter, limit, offset)
}

func hierarchyPredicateQuery(includeBNodes bool) string {
	bnodeFilter := ""
	if !includeBNodes {
		bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?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 .
  FILTER(!isLiteral(?o))
  %s
}
ORDER BY ?p
`, bnodeFilter)
}
