Commit 67ee0bbb1160605e027feefc741fb7461b8f278a
1 parent
e02f00fd
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
virtuoso: fix dspace harvest
Showing
2 changed files
with
11 additions
and
3 deletions
Show diff stats
plugins/virtuoso/lib/virtuoso_plugin/dspace_harvest.rb
| @@ -22,12 +22,13 @@ class VirtuosoPlugin::DspaceHarvest | @@ -22,12 +22,13 @@ class VirtuosoPlugin::DspaceHarvest | ||
| 22 | 22 | ||
| 23 | def triplify(record) | 23 | def triplify(record) |
| 24 | metadata = VirtuosoPlugin::DublinCoreMetadata.new(record.metadata) | 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 | settings.ontology_mapping.each do |mapping| | 28 | settings.ontology_mapping.each do |mapping| |
| 28 | values = [metadata.extract_field(mapping[:source])].flatten.compact | 29 | values = [metadata.extract_field(mapping[:source])].flatten.compact |
| 29 | values.each do |value| | 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 | plugin.virtuoso_client.insert(query) | 32 | plugin.virtuoso_client.insert(query) |
| 32 | end | 33 | end |
| 33 | end | 34 | end |
| @@ -85,4 +86,11 @@ class VirtuosoPlugin::DspaceHarvest | @@ -85,4 +86,11 @@ class VirtuosoPlugin::DspaceHarvest | ||
| 85 | end | 86 | end |
| 86 | end | 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 | end | 96 | end |
plugins/virtuoso/lib/virtuoso_plugin/dublin_core_metadata.rb
| @@ -21,7 +21,7 @@ class VirtuosoPlugin::DublinCoreMetadata | @@ -21,7 +21,7 @@ class VirtuosoPlugin::DublinCoreMetadata | ||
| 21 | when 1 | 21 | when 1 |
| 22 | value.first.text | 22 | value.first.text |
| 23 | else | 23 | else |
| 24 | - value.map { |v| v.respond_to?(:text) ? v.text : v} | 24 | + value.map(&:text) |
| 25 | end | 25 | end |
| 26 | end | 26 | end |
| 27 | 27 |