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"
if sunspot?
searchable :if => :index? do
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
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
.issn unless .nil?
end
string :isbn, :stored => true do
.isbn unless .nil?
end
string :lccn, :stored => true do
.lccn unless .nil?
end
end
end
end
end
|