@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 
<freemarker:queryBuilder.ftl> display:hasDataGetter display:customSearchFieldsDataGetter .
<freemarker:queryBuilder.ftl> display:hasDataGetter display:customSearchFiltersDataGetter .
 
display:customSearchFieldsDataGetter
    a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter> ;
    display:saveToVar "searchFields" ;
    display:query """
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX search:   <https://litvinovg.pro/search_ontology#>
    SELECT ?name ?field ?hasFilters
    WHERE {
      ?searchField rdf:type search:searchField .
      ?searchField rdfs:label ?name .
      ?searchField search:indexField ?field .
      BIND (exists { ?filters search:filterFiled  ?searchField } AS ?hasFilters)
    } ORDER BY ?name
     """ .

display:customSearchFiltersDataGetter
    a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter> ;
    display:saveToVar "searchFilters" ;
    display:query """
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX search: <https://litvinovg.pro/search_ontology#>
    SELECT ?name ?field ?id
    WHERE {
      ?searchFilter rdf:type search:filter .
      ?searchFilter rdfs:label ?name .
      ?searchFilter search:id ?id .
      ?searchFilter search:filterFiled ?searchField .
      ?searchField search:indexField ?field .
     
    } ORDER BY ?field ?name
     """ .

