Class: DiscoveryIndexer::GeneralMapper
- Inherits:
-
Object
- Object
- DiscoveryIndexer::GeneralMapper
- Defined in:
- lib/discovery-indexer/general_mapper.rb
Instance Attribute Summary collapse
-
#druid ⇒ Object
readonly
Returns the value of attribute druid.
Instance Method Summary collapse
-
#collection_data ⇒ DiscoveryIndexer::Collection
For each collection druid, or [] if no collection druids.
-
#collection_druids ⇒ Array<String>
Array of bare druids from rels-ext isMemberOfCollection in public xml (e.g. [‘oo000oo0000’]).
-
#constituent_data ⇒ DiscoveryIndexer::Collection
For each constituent druid, or [] if no constituent druids.
-
#constituent_druids ⇒ Array<String>
Array of bare druids from rels-ext isConstituentOf in public xml (e.g. [‘oo000oo0000’]).
-
#convert_to_solr_doc ⇒ Hash
Create a Hash representing a Solr doc, with all MODS related fields populated.
-
#initialize(druid) ⇒ GeneralMapper
constructor
Initializes an instance from IndexMapper.
-
#modsxml ⇒ Stanford::Mods::Record
The MODS xml for the druid.
-
#purlxml ⇒ DiscoveryIndexer::Reader::PurlxmlModel
The purlxml model.
Constructor Details
#initialize(druid) ⇒ GeneralMapper
Initializes an instance from IndexMapper
8 9 10 |
# File 'lib/discovery-indexer/general_mapper.rb', line 8 def initialize(druid) @druid = druid end |
Instance Attribute Details
#druid ⇒ Object (readonly)
Returns the value of attribute druid.
4 5 6 |
# File 'lib/discovery-indexer/general_mapper.rb', line 4 def druid @druid end |
Instance Method Details
#collection_data ⇒ DiscoveryIndexer::Collection
Returns for each collection druid, or [] if no collection druids.
22 23 24 25 26 |
# File 'lib/discovery-indexer/general_mapper.rb', line 22 def collection_data @collection_data ||= collection_druids.map do |cdruid| DiscoveryIndexer::Collection.new(cdruid) end end |
#collection_druids ⇒ Array<String>
Returns Array of bare druids from rels-ext isMemberOfCollection in public xml (e.g. [‘oo000oo0000’]).
29 30 31 |
# File 'lib/discovery-indexer/general_mapper.rb', line 29 def collection_druids purlxml.collection_druids end |
#constituent_data ⇒ DiscoveryIndexer::Collection
Returns for each constituent druid, or [] if no constituent druids.
34 35 36 37 38 |
# File 'lib/discovery-indexer/general_mapper.rb', line 34 def constituent_data @constituent_data ||= constituent_druids.map do |cdruid| DiscoveryIndexer::Collection.new(cdruid) end end |
#constituent_druids ⇒ Array<String>
Returns Array of bare druids from rels-ext isConstituentOf in public xml (e.g. [‘oo000oo0000’]).
41 42 43 |
# File 'lib/discovery-indexer/general_mapper.rb', line 41 def constituent_druids purlxml.constituent_druids end |
#convert_to_solr_doc ⇒ Hash
Create a Hash representing a Solr doc, with all MODS related fields populated.
14 15 16 17 18 19 |
# File 'lib/discovery-indexer/general_mapper.rb', line 14 def convert_to_solr_doc solr_doc = {} solr_doc[:id] = druid solr_doc[:title] = modsxml.sw_full_title solr_doc end |
#modsxml ⇒ Stanford::Mods::Record
Returns the MODS xml for the druid.
46 47 48 |
# File 'lib/discovery-indexer/general_mapper.rb', line 46 def modsxml @modsxml ||= DiscoveryIndexer::InputXml::Modsxml.new(druid).load end |
#purlxml ⇒ DiscoveryIndexer::Reader::PurlxmlModel
Returns the purlxml model.
51 52 53 |
# File 'lib/discovery-indexer/general_mapper.rb', line 51 def purlxml @purlxml ||= DiscoveryIndexer::InputXml::Purlxml.new(druid).load end |