Module: Hyrax::IndexesWorkflow

Included in:
WorkIndexer
Defined in:
app/indexers/hyrax/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



10
11
12
13
14
15
# File 'app/indexers/hyrax/indexes_workflow.rb', line 10

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

Parameters:

  • solr_document (Hash)

    the solr document to add the field to



19
20
21
# File 'app/indexers/hyrax/indexes_workflow.rb', line 19

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

Parameters:

  • solr_document (Hash)

    the solr document to add the field to



25
26
27
28
29
30
31
# File 'app/indexers/hyrax/indexes_workflow.rb', line 25

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.permission_template.admin_set_id}-#{entity.workflow.name}-#{role}" }
  solr_document[workflow_state_name_field] = entity.workflow_state.name if entity.workflow_state
end

#workflow_role_fieldObject



37
38
39
# File 'app/indexers/hyrax/indexes_workflow.rb', line 37

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

#workflow_roles(entity) ⇒ Object



41
42
43
# File 'app/indexers/hyrax/indexes_workflow.rb', line 41

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

#workflow_state_name_fieldObject



33
34
35
# File 'app/indexers/hyrax/indexes_workflow.rb', line 33

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