Module: Hyrax::WorkflowIndexer

Included in:
Indexers::PcdmObjectIndexer
Defined in:
app/indexers/concerns/hyrax/workflow_indexer.rb

Instance Method Summary collapse

Instance Method Details

#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



15
16
17
18
19
20
21
# File 'app/indexers/concerns/hyrax/workflow_indexer.rb', line 15

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

#to_solrObject

Write the workflow roles and state into the solr_document

Parameters:

  • solr_document (Hash)

    the solr document to add the fields to



7
8
9
10
11
# File 'app/indexers/concerns/hyrax/workflow_indexer.rb', line 7

def to_solr
  super.tap do |solr_doc|
    index_workflow_fields(solr_doc)
  end
end

#workflow_roles(entity) ⇒ Array<String>

Get the workflow roles for the entity

Parameters:

  • entity (Sipity::Entity)

    the entity to get the workflow roles for

Returns:

  • (Array<String>)

    the workflow roles for the entity



26
27
28
# File 'app/indexers/concerns/hyrax/workflow_indexer.rb', line 26

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