package graph_queries

import "fmt"

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

	return fmt.Sprintf(`
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

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

func typesOnlyPredicateQuery(includeBNodes bool) string {
	bnodeFilter := ""
	if !includeBNodes {
		bnodeFilter = "FILTER(!isBlank(?s) && !isBlank(?o))"
	}

	return fmt.Sprintf(`
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT DISTINCT ?p
WHERE {
  VALUES ?p { rdf:type }
  ?s ?p ?o .
  ?o rdf:type owl:Class .
  FILTER(!isLiteral(?o))
  %s
}
ORDER BY ?p
`, bnodeFilter)
}
