Sha256: d66ece8e89556c8ee47e528b0ec7933fc97b42a27b9df3458792340604d77e25

Contents?: true

Size: 1.47 KB

Versions: 16

Compression:

Stored size: 1.47 KB

Contents

module Cul::Scv::Hydra::RisearchMembers

  def self.get_recursive_member_pids(pid, verbose_output=false)

    recursive_member_query =
      'select $child $parent $cmodel from <#ri>
      where
      walk($child <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '> and $child <http://purl.oclc.org/NET/CUL/memberOf> $parent)
      and
      $child <fedora-model:hasModel> $cmodel'

    puts 'Performing query:' if verbose_output
    puts recursive_member_query if verbose_output

    search_response = JSON(Cul::Scv::Fedora.repository.find_by_itql(recursive_member_query, {
      :type => 'tuples',
      :format => 'json',
      :limit => '',
      :stream => 'on'
    }))

    unique_pids = search_response['results'].map{|result| result['child'].gsub('info:fedora/', '') }.uniq

    return unique_pids

  end

  def self.get_direct_member_pids(pid, verbose_output=false)

    direct_member_query =
      'select $pid $cmodel from <#ri>
      where $pid <http://purl.oclc.org/NET/CUL/memberOf> <fedora:' + pid + '>
      and $pid <fedora-model:hasModel> $cmodel'

    puts 'Performing query:' if verbose_output
    puts direct_member_query if verbose_output

    search_response = JSON(Cul::Scv::Fedora.repository.find_by_itql(direct_member_query, {
      :type => 'tuples',
      :format => 'json',
      :limit => '',
      :stream => 'on'
    }))

    unique_pids = search_response['results'].map{|result| result['pid'].gsub('info:fedora/', '') }.uniq

    return unique_pids

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cul_scv_hydra-0.17.1 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.17.0 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.12 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.11 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.10 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.8 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.7 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.6 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.5 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.4 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.3 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.2 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.1 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.16.0 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.15.1 lib/cul_scv_hydra/risearch_members.rb
cul_scv_hydra-0.15.0 lib/cul_scv_hydra/risearch_members.rb