33
44module Ingestors
55 class OaiPmhIngestor < Ingestor
6- DUMMY_URL = 'https://example.com'
7-
86 attr_reader :verbose
97
108 def self . config
@@ -24,7 +22,7 @@ def read(source_url)
2422 false
2523 end
2624
27- read_oai_default ( client ) unless found_bioschemas
25+ read_oai_dublin_core ( client ) unless found_bioschemas
2826 end
2927
3028 def ns
@@ -34,29 +32,27 @@ def ns
3432 }
3533 end
3634
37- def read_oai_default ( client )
35+ def read_oai_dublin_core ( client )
3836 count = 0
3937 client . list_records . full . each do |record |
40- read_dublin_core ( record . metadata . to_s )
38+ xml_string = record . metadata . to_s
39+ doc = Nokogiri ::XML ( xml_string )
40+
41+ types = doc . xpath ( '//dc:type' , ns ) . map ( &:text )
42+ # this event detection heuristic captures in particular
43+ # - http://purl.org/dc/dcmitype/Event (the standard way of typing an event in dublin core)
44+ # - https://schema.org/Event
45+ if types . any? { |t | t . downcase . include? 'event' }
46+ read_dublin_core_event ( doc )
47+ else
48+ read_dublin_core_material ( doc )
49+ end
50+
4151 count += 1
4252 end
4353 @messages << "found #{ count } records"
4454 end
4555
46- def read_dublin_core ( xml_string )
47- doc = Nokogiri ::XML ( xml_string )
48-
49- types = doc . xpath ( '//dc:type' , ns ) . map ( &:text )
50- # this event detection heuristic captures in particular
51- # - http://purl.org/dc/dcmitype/Event (the standard way of typing an event in dublin core)
52- # - https://schema.org/Event
53- if types . any? { |t | t . downcase . include? 'event' }
54- read_dublin_core_event ( doc )
55- else
56- read_dublin_core_material ( doc )
57- end
58- end
59-
6056 def read_dublin_core_material ( xml_doc )
6157 material = OpenStruct . new
6258 material . title = xml_doc . at_xpath ( '//dc:title' , ns ) &.text
@@ -205,6 +201,7 @@ def parse_bioschemas(content)
205201 end
206202
207203 # ---- This is copied unchanged from bioschemas_ingestor.rb and needs to be refactored. ----
204+ # note that also attr_reader :verbose is probably related to this
208205
209206 # If duplicate resources have been extracted, prefer ones with the most metadata.
210207 def deduplicate ( resources )
0 commit comments