Sha256: 1e6b9de3a2abb055fd209019b1060c0c5066808b21931c4cda76c7dffdd25037

Contents?: true

Size: 1017 Bytes

Versions: 5

Compression:

Stored size: 1017 Bytes

Contents

module PublishMyData
  class DatasetRenderParams

    def initialize(resource)
      @resource = resource
      @dataset = resource.as_dataset
    end

    def render_params(opts={})

      if opts[:is_html]
        @types = RdfType.where('?s a ?uri').graph(@dataset.data_graph_uri).resources
        @dataset.eager_load_object_triples!(:labels_only => true) # for the owner URI label
        @type_resource_counts = {}
        @resources_count = 0
        @types.each do |t|
          count_query = "SELECT ?uri WHERE { GRAPH <#{@dataset.data_graph_uri.to_s}> { ?uri a <#{t.uri.to_s}> } }"
          @type_resource_counts[t.uri.to_s] = SparqlQuery.new(count_query).count
          @resources_count += @type_resource_counts[t.uri.to_s]
        end
      end

      {
        template: 'publish_my_data/datasets/show', locals: {
          dataset: @dataset,
          types: @types,
          type_resource_counts: @type_resource_counts,
          resources_count: @resources_count
        }
      }
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
publish_my_data-0.0.25 lib/publish_my_data/render_params/dataset_render_params.rb
publish_my_data-0.0.24 lib/publish_my_data/render_params/dataset_render_params.rb
publish_my_data-0.0.23 lib/publish_my_data/render_params/dataset_render_params.rb
publish_my_data-0.0.22 lib/publish_my_data/render_params/dataset_render_params.rb
publish_my_data-0.0.21 lib/publish_my_data/render_params/dataset_render_params.rb