From bde4656f4f543e9eb4edd68fae3db26169debef9 Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Fri, 1 Jul 2016 14:16:16 -0400 Subject: [PATCH 1/4] Use Hydra 10 style datastream declaration --- lib/avalon/workflow/workflow_model_mixin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/avalon/workflow/workflow_model_mixin.rb b/lib/avalon/workflow/workflow_model_mixin.rb index 2f5fa1e..ecdbedd 100644 --- a/lib/avalon/workflow/workflow_model_mixin.rb +++ b/lib/avalon/workflow/workflow_model_mixin.rb @@ -18,7 +18,7 @@ module Avalon::Workflow module WorkflowModelMixin def self.included(klazz) - klazz.has_metadata name: 'workflow', type: WorkflowDatastream + klazz.has_subresource 'workflow', class_name: 'WorkflowDatastream' end end end From 1cdd3749f9bc887113a9d782ce15125628cc7695 Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Thu, 18 Aug 2016 10:36:13 -0400 Subject: [PATCH 2/4] Fix to_solr method signature --- lib/avalon/workflow/workflow_datastream.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/avalon/workflow/workflow_datastream.rb b/lib/avalon/workflow/workflow_datastream.rb index 215411c..8ef86c0 100644 --- a/lib/avalon/workflow/workflow_datastream.rb +++ b/lib/avalon/workflow/workflow_datastream.rb @@ -140,12 +140,8 @@ def self.xml_template builder.doc end - def prefix - "" - end - - def to_solr(solr_doc=SolrDocument.new) - super(solr_doc) + def to_solr(solr_doc=Hash.new, opts = {}) + super(solr_doc, opts) solr_value = case last_completed_step.first when blank? From 58ecc74460df0508ba8e25efdd199fb6f9978e6c Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Fri, 26 Aug 2016 11:36:38 -0400 Subject: [PATCH 3/4] Fix FlashHash.stringify_keys issues by not reusing the FlashHash but using a Hash instead --- lib/avalon/workflow/workflow_controller_behavior.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/avalon/workflow/workflow_controller_behavior.rb b/lib/avalon/workflow/workflow_controller_behavior.rb index c15bbbb..b760297 100644 --- a/lib/avalon/workflow/workflow_controller_behavior.rb +++ b/lib/avalon/workflow/workflow_controller_behavior.rb @@ -67,15 +67,14 @@ def update respond_to do |format| format.html do - flash[:error] = context[:error] - flash[:notice] = context[:notice] + flashes = { error: context[:error], notice: context[:notice]} if model_object.errors.present? flash[:error] = 'There are errors with your submission. Please correct them before continuing.' render :edit elsif model_object.workflow.published? && model_object.workflow.current?(@active_step) - redirect_to(polymorphic_path(model_object), flash: flash) + redirect_to(polymorphic_path(model_object), flash: flashes) else - redirect_to(get_redirect_path(@active_step, model_object), flash: flash) + redirect_to(get_redirect_path(@active_step, model_object), flash: flashes) end end end From 1dd1f63b8110809c42141952890934b9f0f8041e Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Fri, 26 Aug 2016 12:22:24 -0400 Subject: [PATCH 4/4] Use Rails.logger instead of bare logger --- lib/avalon/workflow/workflow_datastream.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/avalon/workflow/workflow_datastream.rb b/lib/avalon/workflow/workflow_datastream.rb index 8ef86c0..7bf5be4 100644 --- a/lib/avalon/workflow/workflow_datastream.rb +++ b/lib/avalon/workflow/workflow_datastream.rb @@ -35,7 +35,7 @@ def published= publication_status def last_completed_step= active_step active_step = active_step.first if active_step.is_a? Array unless HYDRANT_STEPS.exists? active_step - logger.warn "Unrecognized step : #{active_step}" + Rails.logger.warn "Unrecognized step : #{active_step}" end # Set it anyways for now. Need to come up with a more robust warning @@ -45,7 +45,7 @@ def last_completed_step= active_step def origin= source unless ['batch', 'web', 'console'].include? source - logger.warn "Unrecognized origin : #{source}" + Rails.logger.warn "Unrecognized origin : #{source}" update_values({[{:origin=>"0"}]=>{"0"=>"unknown"}}) else update_values({[{:origin=>"0"}]=>{"0"=>source}}) @@ -99,11 +99,11 @@ def advance lcs = (last_completed_step.is_a? Array) ? last_completed_step.first : last_completed_step if (lcs.blank? or not HYDRANT_STEPS.exists?(lcs)) - logger.warn "<< Step #{lcs} invalid, defaulting to first step >>" + Rails.logger.warn "<< Step #{lcs} invalid, defaulting to first step >>" self.last_completed_step = HYDRANT_STEPS.first.step elsif (not HYDRANT_STEPS.last?(lcs)) next_step = HYDRANT_STEPS.next(lcs).step - logger.debug "<< Advancing to the next step - #{next_step} >>" + Rails.logger.debug "<< Advancing to the next step - #{next_step} >>" self.last_completed_step = next_step end end @@ -114,9 +114,9 @@ def publish end def update_status(active_step=nil) - logger.debug "<< UPDATE_INGEST_STATUS >>" + Rails.logger.debug "<< UPDATE_INGEST_STATUS >>" active_step = active_step || last_completed_step.first - logger.debug "<< COMPLETED : #{completed?(active_step)} >>" + Rails.logger.debug "<< COMPLETED : #{completed?(active_step)} >>" if current?(active_step) and not published? advance @@ -125,7 +125,7 @@ def update_status(active_step=nil) if HYDRANT_STEPS.last? active_step and completed? active_step publish end - logger.debug "<< PUBLISHED : #{published?} >>" + Rails.logger.debug "<< PUBLISHED : #{published?} >>" end def self.xml_template @@ -161,16 +161,16 @@ def to_solr(solr_doc=Hash.new, opts = {}) protected def reset_values - logger.debug "<< BEFORE_SAVE (IngestStatus) >>" - logger.debug "<< last_completed_step => #{last_completed_step} >>" + Rails.logger.debug "<< BEFORE_SAVE (IngestStatus) >>" + Rails.logger.debug "<< last_completed_step => #{last_completed_step} >>" if published.nil? - logger.debug "<< Default published flag = false >>" + Rails.logger.debug "<< Default published flag = false >>" published = false end if last_completed_step.nil? - logger.debug "<< Default step = #{HYDRANT_STEPS.first.step} >>" + Rails.logger.debug "<< Default step = #{HYDRANT_STEPS.first.step} >>" last_completed_step = HYDRANT_STEPS.first.step end end