{% import "macros/renderers.html" as renderers %} {# select the graphs to fingerprint: either the ones grom the config file or all from the endpoint #} {% macro select_graphs() -%} {# caller_ is a workaround necessary to handle two levels of callers #} {% set caller_ = caller %} {# if there are some graphs defined in the configuration, then select those #} {% if conf.selected_graphs %} {% for graph in conf.selected_graphs | unique | list %} {% if graph %} {{ caller_(graph) }} {% else %} {{ caller_(None) }} {% endif %} {% endfor %} {% else %} {# if no graphs are defined in the configurations, then select all the graphs in the endpoint #} {% set select_query = "select distinct ?graph {graph ?graph {?s ?p []}} ORDER BY ?graph" %} {% if conf.is_data_from_file or false %} {% set content, error = from_rdf_file(conf.default_file_path).with_query(select_query).fetch_tabular() %} {% else %} {% set content, error = from_endpoint(conf.default_endpoint).with_query(select_query).fetch_tabular() %} {% endif %} {# Fingerpring the gefault graph before going to named graphs #} {{ caller_(None) }} {% call renderers.render_fetch_results(content, error) %} {% if not content.empty %} {% for row in content.itertuples() %} {{ caller_(row.graph) }} {% endfor %} {% endif %} {% endcall %} {% endif %} {%- endmacro %} {# select distinct classes is the given graph #} {% macro select_distinct_classes(graph=None) -%} {% set from_statement = 'FROM <'~graph~'>' if graph and not conf.is_data_from_file else '' %} {% set select_query = "SELECT DISTINCT ?cls "~from_statement~" WHERE {?c a ?cls} ORDER BY ?cls" %} {% if conf.is_data_from_file or false %}
true
{% set content, error = from_rdf_file(conf.default_file_path).with_query(select_query).fetch_tabular() %}erer
{% else %} {% set content, error = from_endpoint(conf.default_endpoint).with_query(select_query).fetch_tabular() %} {% endif %} {% set caller_ = caller %} {% call renderers.render_fetch_results(content, error) %} {% if not content.empty %} {% for row in content.itertuples() %} {{ caller_(row.cls) }} {% endfor %} {% endif %} {% endcall %} {%- endmacro %} {# select distinct property given a class and graph #} {% macro select_distinct_property(class, graph=None) -%} {% set from_statement = 'FROM <'~graph~'>' if graph and not conf.is_data_from_file else '' %} {% set select_query = "SELECT DISTINCT ?property \n"~from_statement~" WHERE{ VALUES ?subject_class { <"~class~"> } ?subject a ?subject_class; ?property ?object . } ORDER BY ?property" %} {% if conf.is_data_from_file or false %} {% set content, error = from_rdf_file(conf.default_file_path).with_query(select_query).fetch_tabular() %} {% else %} {% set content, error = from_endpoint(conf.default_endpoint).with_query(select_query).fetch_tabular() %} {% endif %} {% set caller_ = caller %} {% call renderers.render_fetch_results(content, error) %} {% if not content.empty %} {% for row in content.itertuples() %} {{ caller_(row.property) }} {% endfor %} {% endif %} {% endcall %} {%- endmacro %} {# fingerprint a given class propeorty pattern in a given graph. If the class of the propoerty is not provided the fingerprint will be provided for the propoerty with all classes or for the class with all properties #} {% macro fingerprint_pattern(graph=None, class=None, property=None) -%} {% set from_statement = 'FROM <'~graph~'>' if graph and not conf.is_data_from_file else '' %} {% set property_statement = '<'~property~'>' if property else 'undef' %} {% set class_statement = '<'~class~'>' if class else 'undef' %} {% set select_query = "PREFIX rdf: