Class: DorIndexing::Indexers::BasicIndexer
- Inherits:
-
Object
- Object
- DorIndexing::Indexers::BasicIndexer
- Defined in:
- lib/dor_indexing/indexers/basic_indexer.rb
Overview
Basic indexing for any object
Instance Attribute Summary collapse
-
#cocina ⇒ Object
readonly
Returns the value of attribute cocina.
-
#workflow_client ⇒ Object
readonly
Returns the value of attribute workflow_client.
Instance Method Summary collapse
- #created_at ⇒ Object
-
#initialize(cocina:, workflow_client:) ⇒ BasicIndexer
constructor
A new instance of BasicIndexer.
- #legacy_apo ⇒ Object
- #legacy_collections ⇒ Object
-
#modified_latest ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength.
-
#to_solr ⇒ Hash
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
- #virtual_object_constituents ⇒ Object
Constructor Details
#initialize(cocina:, workflow_client:) ⇒ BasicIndexer
Returns a new instance of BasicIndexer.
9 10 11 12 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 9 def initialize(cocina:, workflow_client:, **) @cocina = cocina @workflow_client = workflow_client end |
Instance Attribute Details
#cocina ⇒ Object (readonly)
Returns the value of attribute cocina.
7 8 9 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 7 def cocina @cocina end |
#workflow_client ⇒ Object (readonly)
Returns the value of attribute workflow_client.
7 8 9 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 7 def workflow_client @workflow_client end |
Instance Method Details
#created_at ⇒ Object
43 44 45 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 43 def created_at cocina.created.to_datetime.strftime('%FT%TZ') end |
#legacy_apo ⇒ Object
62 63 64 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 62 def legacy_apo "info:fedora/#{cocina.administrative.hasAdminPolicy}" end |
#legacy_collections ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 47 def legacy_collections case cocina.type when Cocina::Models::ObjectType.admin_policy, Cocina::Models::ObjectType.collection [] else Array(cocina.structural&.isMemberOf).map { |col_id| "info:fedora/#{col_id}" } end end |
#modified_latest ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
39 40 41 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 39 def modified_latest cocina.modified.to_datetime.strftime('%FT%TZ') end |
#to_solr ⇒ Hash
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 17 def to_solr {}.tap do |solr_doc| solr_doc[:id] = cocina.externalIdentifier solr_doc['current_version_isi'] = cocina.version # Argo Facet field "Version" solr_doc['obj_label_tesim'] = cocina.label solr_doc['modified_latest_dttsi'] = modified_latest solr_doc['created_at_dttsi'] = created_at # is_member_of_collection_ssim is used by dor-services-app for querying for members of a # collection and it is a facet in Argo solr_doc['is_member_of_collection_ssim'] = legacy_collections solr_doc['is_governed_by_ssim'] = legacy_apo # Argo facet # Used so that DSA can generate public XML whereas a constituent can find the virtual object it is part of. solr_doc['has_constituents_ssim'] = virtual_object_constituents end.merge(DorIndexing::WorkflowFields.for(druid: cocina.externalIdentifier, version: cocina.version, workflow_client:)) .transform_keys(&:to_s) end |
#virtual_object_constituents ⇒ Object
56 57 58 59 60 |
# File 'lib/dor_indexing/indexers/basic_indexer.rb', line 56 def virtual_object_constituents return unless cocina.dro? Array(cocina.structural&.hasMemberOrders).first&.members end |