Module: Hyrax::IndexesWorkflow

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

Instance Method Summary collapse

Instance Method Details

#generate_solr_documentObject

Adds thumbnail indexing to the solr document


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

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


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

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


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

def index_workflow_fields(solr_document)
  entity = Sipity::Entity(object)
  solr_document[workflow_role_field] = workflow_roles(entity).map { |role| "#{entity.workflow.permission_template.source_id}-#{entity.workflow.name}-#{role}" }
  solr_document[workflow_state_name_field] = entity.workflow_state.name if entity.workflow_state
rescue Sipity::ConversionError
  nil
end

#workflow_role_fieldObject


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

def workflow_role_field
  "actionable_workflow_roles_ssim"
end

#workflow_roles(entity) ⇒ Object


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

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

#workflow_state_name_fieldObject


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

def workflow_state_name_field
  "workflow_state_name_ssim"
end