Class: Dor::IdentifiableIndexer
- Inherits:
-
Object
- Object
- Dor::IdentifiableIndexer
- Includes:
- SolrDocHelper
- Defined in:
- lib/dor/indexers/identifiable_indexer.rb
Constant Summary collapse
- @@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.
8 9 10 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 8 def initialize(resource:) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
7 8 9 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 7 def resource @resource end |
Class Method Details
.reset_cache! ⇒ Object
Clears out the cache of items. Used primarily in testing.
52 53 54 55 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 52 def self.reset_cache! @@collection_hash = {} @@apo_hash = {} end |
Instance Method Details
#identity_metadata_source ⇒ String
Returns calculated value for Solr index.
42 43 44 45 46 47 48 49 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 42 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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dor/indexers/identifiable_indexer.rb', line 18 def to_solr solr_doc = {} resource.assert_content_model solr_doc[Dor::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) 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#' } 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 |