Module: Sfx4::Abstract::AzTitle

Included in:
Local::AzTitle
Defined in:
app/models/sfx4/abstract/az_title.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/sfx4/abstract/az_title.rb', line 16

def self.included(klass)
  klass.class_eval do
    self.table_name = 'AZ_TITLE'
    self.primary_key = 'AZ_TITLE_ID'

    belongs_to  :kb_object,
                :foreign_key => 'OBJECT_ID',
                :class_name => "Sfx4::Global::KbObject"

    has_many  :az_title_searches,
              :foreign_key => 'AZ_TITLE_ID',
              :class_name => "#{klass.to_s.deconstantize}::AzTitleSearch"

    has_many  :az_letter_groups,
              :foreign_key => 'AZ_TITLE_ID',
              :class_name => "#{klass.to_s.deconstantize}::AzLetterGroup"

    has_one   :az_extra_info,
              :primary_key => 'OBJECT_ID',
              :foreign_key => 'OBJECT_ID',
              :class_name => "#{klass.to_s.deconstantize}::AzExtraInfo"

    # Only add Sunspot code if Umlaut is configured for Sunspot.
    if sunspot?
      searchable :if => :index? do
        # Indexed fields
        text :title do
          [self.TITLE_DISPLAY, self.TITLE_SORT].concat(az_title_searches.map{|az_title_search| az_title_search.TITLE_SEARCH}).uniq
        end
        string :title_exact, :multiple => true do
          [self.TITLE_DISPLAY, self.TITLE_SORT].concat(az_title_searches.map{|az_title_search| az_title_search.TITLE_SEARCH}).uniq
        end
        string :letter_group, :multiple => true do
          az_letter_groups.collect{ |az_letter_group|
            (az_letter_group.AZ_LETTER_GROUP_NAME.match(/[0-9]/)) ? 
              "0-9" : az_letter_group.AZ_LETTER_GROUP_NAME }
        end
        string :title_sort do
          self.TITLE_SORT
        end
        # Stored strings.
        string :object_id, :stored => true do
          self.OBJECT_ID
        end
        string :title_display, :stored => true do
          self.TITLE_DISPLAY
        end
        string :issn, :stored => true do
          az_extra_info.issn unless az_extra_info.nil?
        end
        string :isbn, :stored => true do
          az_extra_info.isbn unless az_extra_info.nil?
        end
        string :lccn, :stored => true do
          az_extra_info.lccn unless az_extra_info.nil?
        end
      end
    end
  end
end

Instance Method Details

#index?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'app/models/sfx4/abstract/az_title.rb', line 77

def index?
  self.AZ_PROFILE.eql? UmlautController.umlaut_config.lookup!("search.sfx_az_profile", "default")
end

#to_context_object(context_object) ⇒ Object

This code isn’t used anywhere at the moment, but is kept around for posterities sake.



82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/models/sfx4/abstract/az_title.rb', line 82

def to_context_object(context_object)
  ctx = OpenURL::ContextObject.new
  # Start out wtih everything in search, to preserve date/vol/etc
  ctx.import_context_object(context_object)
  # Put SFX object id in rft.object_id, that's what SFX does.
  ctx.referent.('object_id', self.OBJECT_ID.to_s )
  ctx.referent.("jtitle", self.TITLE_DISPLAY || "Unknown Title")
  ctx.referent.("issn", az_extra_info.issn ) unless az_extra_info.nil? or az_extra_info.issn.blank?
  ctx.referent.("isbn", az_extra_info.isbn) unless az_extra_info.nil? or az_extra_info.isbn.blank?
  ctx.referent.add_identifier("info:lccn/#{az_extra_info.lccn}") unless az_extra_info.nil? or az_extra_info.lccn.blank?
  return ctx
end