Class: DiscoveryIndexer::GeneralMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/discovery-indexer/general_mapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(druid) ⇒ GeneralMapper

Initializes an instance from IndexMapper

Parameters:

  • druid (String)

    e.g. ab123cd4567



8
9
10
# File 'lib/discovery-indexer/general_mapper.rb', line 8

def initialize(druid)
  @druid = druid
end

Instance Attribute Details

#druidObject (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_dataDiscoveryIndexer::Collection

Returns for each collection druid, or [] if no collection druids.

Returns:



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_druidsArray<String>

Returns Array of bare druids from rels-ext isMemberOfCollection in public xml (e.g. [‘oo000oo0000’]).

Returns:

  • (Array<String>)

    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_dataDiscoveryIndexer::Collection

Returns for each constituent druid, or [] if no constituent druids.

Returns:



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_druidsArray<String>

Returns Array of bare druids from rels-ext isConstituentOf in public xml (e.g. [‘oo000oo0000’]).

Returns:

  • (Array<String>)

    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_docHash

Create a Hash representing a Solr doc, with all MODS related fields populated.

Returns:

  • (Hash)

    Hash representing the Solr document



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

#modsxmlStanford::Mods::Record

Returns the MODS xml for the druid.

Returns:

  • (Stanford::Mods::Record)

    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

#purlxmlDiscoveryIndexer::Reader::PurlxmlModel

Returns the purlxml model.

Returns:

  • (DiscoveryIndexer::Reader::PurlxmlModel)

    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