Method: ContentDm::Harvester#get_records

Defined in:
lib/contentdm/harvester.rb

#get_records(collection, opts = {}) ⇒ Object

Return an array of all the Records in a given collection



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/contentdm/harvester.rb', line 75

def get_records(collection, opts = {})
  max = opts[:max].to_i
  token = "#{collection}:#{opts[:from].to_s}:#{opts[:until].to_s}:qdc:#{opts[:first].to_i || 0}"
  result = []
  until token.nil? or ((max > 0) and (result.length >= max))
    args = { :verb => 'ListRecords', :resumptionToken => token.to_s }
    response = get_response(args)
    token = response.search('/xmlns:OAI-PMH/xmlns:ListRecords/xmlns:resumptionToken/text()', response.namespaces).first
    result += parse_records(response)
  end
  if result.length > max
    result = result[0..max-1]
  end
  result.collect { |record|
    Record.new(record, { :base_uri => @base_uri, :collection => collection })
  }
end