Skip to content

Commit

Permalink
Merge pull request #7 from avalonmediasystem/hydra10
Browse files Browse the repository at this point in the history
Hydra10
  • Loading branch information
cjcolvar authored Mar 13, 2017
2 parents bcefb17 + 1dd1f63 commit 5a1de58
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
7 changes: 3 additions & 4 deletions lib/avalon/workflow/workflow_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 13 additions & 17 deletions lib/avalon/workflow/workflow_datastream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}})
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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?
Expand All @@ -165,16 +161,16 @@ def to_solr(solr_doc=SolrDocument.new)

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
Expand Down
2 changes: 1 addition & 1 deletion lib/avalon/workflow/workflow_model_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5a1de58

Please sign in to comment.