Commit 67ee0bbb1160605e027feefc741fb7461b8f278a

Authored by Victor Costa
1 parent e02f00fd

virtuoso: fix dspace harvest

plugins/virtuoso/lib/virtuoso_plugin/dspace_harvest.rb
... ... @@ -22,12 +22,13 @@ class VirtuosoPlugin::DspaceHarvest
22 22  
23 23 def triplify(record)
24 24 metadata = VirtuosoPlugin::DublinCoreMetadata.new(record.metadata)
25   - puts "triplify #{record.header.identifier}"
  25 + subject_identifier = extract_identifier(record)
  26 + puts "triplify #{subject_identifier}"
26 27  
27 28 settings.ontology_mapping.each do |mapping|
28 29 values = [metadata.extract_field(mapping[:source])].flatten.compact
29 30 values.each do |value|
30   - query = RDF::Virtuoso::Query.insert_data([RDF::URI.new(metadata.identifier), RDF::URI.new(mapping[:target]), value]).graph(RDF::URI.new(@dspace_uri))
  31 + query = RDF::Virtuoso::Query.insert_data([RDF::URI.new(subject_identifier), RDF::URI.new(mapping[:target]), value]).graph(RDF::URI.new(@dspace_uri))
31 32 plugin.virtuoso_client.insert(query)
32 33 end
33 34 end
... ... @@ -85,4 +86,11 @@ class VirtuosoPlugin::DspaceHarvest
85 86 end
86 87 end
87 88  
  89 + protected
  90 +
  91 + def extract_identifier(record)
  92 + parsed_identifier = /oai:(.+):(\d+\/\d+)/.match(record.header.identifier)
  93 + "#{@dspace_uri}/handle/#{parsed_identifier[2]}"
  94 + end
  95 +
88 96 end
... ...
plugins/virtuoso/lib/virtuoso_plugin/dublin_core_metadata.rb
... ... @@ -21,7 +21,7 @@ class VirtuosoPlugin::DublinCoreMetadata
21 21 when 1
22 22 value.first.text
23 23 else
24   - value.map { |v| v.respond_to?(:text) ? v.text : v}
  24 + value.map(&:text)
25 25 end
26 26 end
27 27  
... ...