Module: CurationConcerns::IndexesWorkflow

Included in:
WorkIndexer
Defined in:
app/indexers/curation_concerns/indexes_workflow.rb

Constant Summary collapse

STORED_BOOL =
Solrizer::Descriptor.new(:boolean, :stored, :indexed)

Instance Method Summary collapse

Instance Method Details

#generate_solr_documentObject

Adds thumbnail indexing to the solr document



5
6
7
8
9
10
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 5

def generate_solr_document
  super.tap do |solr_doc|
    index_suppressed(solr_doc)
    index_workflow_fields(solr_doc)
  end
end

#index_suppressed(solr_document) ⇒ Object

Write the suppressed status into the solr_document



14
15
16
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 14

def index_suppressed(solr_document)
  solr_document[suppressed_field] = object.suppressed?
end

#index_workflow_fields(solr_document) ⇒ Object

Write the workflow roles and state so one can see where the document moves to next



20
21
22
23
24
25
26
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 20

def index_workflow_fields(solr_document)
  return unless object.persisted?
  entity = PowerConverter.convert_to_sipity_entity(object)
  return if entity.nil?
  solr_document[workflow_role_field] = workflow_roles(entity).map { |role| "#{entity.workflow.name}-#{role}" }
  solr_document[workflow_state_name_field] = entity.workflow_state.name if entity.workflow_state
end

#suppressed_fieldObject



40
41
42
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 40

def suppressed_field
  @suppressed_field ||= Solrizer.solr_name('suppressed', STORED_BOOL)
end

#workflow_role_fieldObject



32
33
34
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 32

def workflow_role_field
  @workflow_role_field ||= Solrizer.solr_name('actionable_workflow_roles', :symbol)
end

#workflow_roles(entity) ⇒ Object



36
37
38
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 36

def workflow_roles(entity)
  CurationConcerns::Workflow::PermissionQuery.scope_roles_associated_with_the_given_entity(entity: entity)
end

#workflow_state_name_fieldObject



28
29
30
# File 'app/indexers/curation_concerns/indexes_workflow.rb', line 28

def workflow_state_name_field
  @workflow_state_name_field ||= Solrizer.solr_name('workflow_state_name', :symbol)
end