Class: Dor::IdentifiableIndexer
- Inherits:
-
Object
- Object
- Dor::IdentifiableIndexer
- Includes:
- SolrDocHelper
- Defined in:
- lib/dor/indexers/identifiable_indexer.rb
Constant Summary collapse
- INDEX_VERSION_FIELD =
'dor_services_version_ssi'
- NS_HASH =
{ 'hydra' => 'http://projecthydra.org/ns/relations#', 'fedora' => 'info:fedora/fedora-system:def/relations-external#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' }.freeze
- @@collection_hash =
Module-level variables, shared between ALL mixin includers (and ALL their includers/extenders)! used for caching found values
{}
- @@apo_hash =
{}
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Class Method Summary collapse
-
.reset_cache! ⇒ Object
Clears out the cache of items.
Instance Method Summary collapse
-
#identity_metadata_source ⇒ String
Calculated value for Solr index.
-
#initialize(resource:) ⇒ IdentifiableIndexer
constructor
A new instance of IdentifiableIndexer.
-
#to_solr ⇒ Hash
The partial solr document for identifiable concerns.
Methods included from SolrDocHelper
Constructor Details
#initialize(resource:) ⇒ IdentifiableIndexer
Returns a new instance of IdentifiableIndexer.
13 14 15 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 13 def initialize(resource:) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
12 13 14 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 12 def resource @resource end |
Class Method Details
.reset_cache! ⇒ Object
Clears out the cache of items. Used primarily in testing.
54 55 56 57 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 54 def self.reset_cache! @@collection_hash = {} @@apo_hash = {} end |
Instance Method Details
#identity_metadata_source ⇒ String
Returns calculated value for Solr index.
44 45 46 47 48 49 50 51 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 44 def if resource.identityMetadata.otherId('catkey').first || resource.identityMetadata.otherId('barcode').first 'Symphony' else 'DOR' end end |
#to_solr ⇒ Hash
Returns the partial solr document for identifiable concerns.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 23 def to_solr solr_doc = {} solr_doc[INDEX_VERSION_FIELD] = Dor::VERSION solr_doc['indexed_at_dtsi'] = Time.now.utc.xmlschema resource.datastreams.values.each do |ds| add_solr_value(solr_doc, 'ds_specs', ds.datastream_spec_string, :string, [:symbol]) unless ds.new? end add_solr_value(solr_doc, 'title_sort', resource.label, :string, [:stored_sortable]) rels_doc = Nokogiri::XML(resource.datastreams['RELS-EXT'].content) apos = rels_doc.search('//rdf:RDF/rdf:Description/hydra:isGovernedBy', NS_HASH) collections = rels_doc.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection', NS_HASH) (solr_doc, apos, @@apo_hash, 'apo_title', 'nonhydrus_apo_title', 'hydrus_apo_title') (solr_doc, collections, @@collection_hash, 'collection_title', 'nonhydrus_collection_title', 'hydrus_collection_title') solr_doc['public_dc_relation_tesim'] ||= solr_doc['collection_title_tesim'] if solr_doc['collection_title_tesim'] solr_doc['metadata_source_ssi'] = solr_doc end |