Commit 8f0767ca788fab088b6138d0ba48863e1c12c6d3
1 parent
67ee0bbb
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
virtuoso: fix harvest job
Showing
2 changed files
with
7 additions
and
11 deletions
Show diff stats
plugins/virtuoso/controllers/virtuoso_plugin_admin_controller.rb
| 1 | 1 | class VirtuosoPluginAdminController < AdminController |
| 2 | 2 | |
| 3 | - #validates :dspace_servers, presence: true | |
| 4 | - | |
| 5 | 3 | def index |
| 6 | - settings = params[:settings] | |
| 4 | + settings = params[:settings] | |
| 7 | 5 | settings ||= {} |
| 8 | 6 | @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, settings) |
| 9 | 7 | @harvest_running = VirtuosoPlugin::DspaceHarvest.new(environment).find_job.present? |
| 10 | 8 | if request.post? |
| 11 | - settings[:dspace_servers].delete_if do | server | | |
| 9 | + settings[:dspace_servers].delete_if do | server | | |
| 12 | 10 | server[:dspace_uri].empty? |
| 13 | 11 | end |
| 14 | 12 | @settings.save! | ... | ... |
plugins/virtuoso/lib/virtuoso_plugin/dspace_harvest.rb
| 1 | 1 | #inspired by https://github.com/code4lib/ruby-oai/blob/master/lib/oai/harvester/harvest.rb |
| 2 | 2 | class VirtuosoPlugin::DspaceHarvest |
| 3 | 3 | |
| 4 | - DC_CONVERSION = [:title, :creator, :subject, :description, :date, :type, :identifier, :language, :rights, :format] | |
| 5 | - | |
| 6 | - def initialize(environment, dspace_uri = "") | |
| 4 | + def initialize(environment, dspace_uri = nil) | |
| 7 | 5 | @environment = environment |
| 8 | 6 | @dspace_uri = dspace_uri |
| 9 | 7 | end |
| ... | ... | @@ -69,19 +67,19 @@ class VirtuosoPlugin::DspaceHarvest |
| 69 | 67 | settings.last_harvest = nil |
| 70 | 68 | settings.save! |
| 71 | 69 | end |
| 72 | - job = VirtuosoPlugin::DspaceHarvest::Job.new(@environment.id) | |
| 70 | + job = VirtuosoPlugin::DspaceHarvest::Job.new(@environment.id, @dspace_uri) | |
| 73 | 71 | Delayed::Job.enqueue(job) |
| 74 | 72 | end |
| 75 | 73 | end |
| 76 | 74 | |
| 77 | 75 | def find_job |
| 78 | - Delayed::Job.where(:handler => "--- !ruby/struct:VirtuosoPlugin::DspaceHarvest::Job\nenvironment_id: #{@environment.id}\n") | |
| 76 | + Delayed::Job.where(:handler => "--- !ruby/struct:VirtuosoPlugin::DspaceHarvest::Job\nenvironment_id: #{@environment.id}\ndspace_uri: #{@dspace_uri}\n") | |
| 79 | 77 | end |
| 80 | 78 | |
| 81 | - class Job < Struct.new(:environment_id) | |
| 79 | + class Job < Struct.new(:environment_id, :dspace_uri) | |
| 82 | 80 | def perform |
| 83 | 81 | environment = Environment.find(environment_id) |
| 84 | - harvest = VirtuosoPlugin::DspaceHarvest.new(environment) | |
| 82 | + harvest = VirtuosoPlugin::DspaceHarvest.new(environment, dspace_uri) | |
| 85 | 83 | harvest.run |
| 86 | 84 | end |
| 87 | 85 | end | ... | ... |