Module: PublishMyData::SparqlHelper

Defined in:
app/helpers/publish_my_data/sparql_helper.rb

Instance Method Summary collapse

Instance Method Details

#default_prefixesObject



14
15
16
17
18
19
20
# File 'app/helpers/publish_my_data/sparql_helper.rb', line 14

def default_prefixes
  prefix_string = ""
  PublishMyData.prefixes.each do |key, value|
      prefix_string += "PREFIX #{key}: <#{value}>\n"
  end
  prefix_string
end

#default_queryObject



22
23
24
# File 'app/helpers/publish_my_data/sparql_helper.rb', line 22

def default_query()
  default_prefixes + "\nSELECT DISTINCT *\nWHERE {\n  ?s ?p ?o\n}\nLIMIT 20"
end

#default_query_with_graphObject



26
27
28
# File 'app/helpers/publish_my_data/sparql_helper.rb', line 26

def default_query_with_graph
  default_prefixes + "\nSELECT DISTINCT *\nWHERE {\n  GRAPH <%{graph}> {\n    ?s ?p ?o\n  }\n}\nLIMIT 20"
end


3
4
5
6
7
# File 'app/helpers/publish_my_data/sparql_helper.rb', line 3

def link_to_sparql_results_format(text, format, query, pagination_params=nil)
  link_params = {:format => format, :query => query}
  link_params.merge!(:page => pagination_params.page, :per_page => pagination_params.per_page) if pagination_params
  link_to text, link_params
end

#url_for_sparql_results_format(format, query, interpolations = {}) ⇒ Object



9
10
11
12
# File 'app/helpers/publish_my_data/sparql_helper.rb', line 9

def url_for_sparql_results_format(format, query, interpolations={})
  interpolations.merge!(:format => format, :query => query, :only_path => false)
  url_for interpolations
end