uw_catalog 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,13 +22,14 @@ module UwCatalog
22
22
  bibs
23
23
  end
24
24
 
25
- def self.get_item_from_hash(d)
26
- item = Item.new({:id => d[:item_id], :item_enum=>d[:item_enum],
27
- :copy_number=>d[:copy_number], :on_reserve=>d[:on_reserve],
28
- :item_status=>d[:item_status],
29
- :item_barcode=>d[:item_barcode],
30
- :item_status_date=>d[:item_status_date], :current_due_date=>d[:current_due_date],
31
- :hold_recall_status_date=>d[:hold_recall_status_date]})
25
+ def self.get_availability_data(bibid)
26
+ ret = Array.new
27
+ begin
28
+ data_hash = get_availability_data_hash(bibid)
29
+ parse_availability_data_hash(data_hash)
30
+ rescue => e
31
+ throw UwCatalogError.new("#{e.class}: #{e.message}")
32
+ end
32
33
  end
33
34
 
34
35
  def self.get_availability_data_hash(bibid)
@@ -38,11 +39,11 @@ module UwCatalog
38
39
  def self.parse_availability_data_hash(data_hash)
39
40
  ret = Array.new
40
41
  data_hash.each do |d|
41
- loc_id = d[:location_id]
42
- location = d[:location]
42
+ loc_id = d[:location_id]
43
+ location = d[:location]
43
44
  if !d[:temp_location].nil?
44
- loc_id = d[:temp_location_id]
45
- location = d[:temp_location]
45
+ loc_id = d[:temp_location_id]
46
+ location = d[:temp_location]
46
47
  end
47
48
 
48
49
  loc = Location.new({:id => loc_id, :location => location})
@@ -62,20 +63,23 @@ module UwCatalog
62
63
  end
63
64
  if (!d[:item_id].nil?)
64
65
  item = get_item_from_hash(d)
65
- holding.add_item(item)
66
+ holding.add_item(item)
66
67
  end
67
68
  end
68
69
  ret
69
70
  end
70
71
 
71
- def self.get_availability_data(bibid)
72
- ret = Array.new
73
- begin
74
- data_hash = get_availability_data_hash(bibid)
75
- parse_availability_data_hash(data_hash)
76
- rescue => e
77
- throw UwCatalogError.new("#{e.class}: #{e.message}")
78
- end
72
+
73
+ private
74
+
75
+
76
+ def self.get_item_from_hash(d)
77
+ item = Item.new({:id => d[:item_id], :item_enum=>d[:item_enum],
78
+ :copy_number=>d[:copy_number], :on_reserve=>d[:on_reserve],
79
+ :item_status=>d[:item_status], :item_type_id=>d[:item_type_id],
80
+ :item_barcode=>d[:item_barcode],
81
+ :item_status_date=>d[:item_status_date], :current_due_date=>d[:current_due_date],
82
+ :hold_recall_status_date=>d[:hold_recall_status_date]})
79
83
  end
80
84
 
81
85
  def self.get_items_data_hash(bibid)
@@ -1,6 +1,5 @@
1
1
  module UwCatalog
2
2
  class Holding
3
- @@date_format = "%B %d, %Y"
4
3
  attr_accessor :id, :call_number, :item_enum, :perm_location_id, :perm_location, :items
5
4
 
6
5
  def initialize(h=Hash.new)
@@ -12,22 +11,28 @@ module UwCatalog
12
11
  self.id == another_holding.id
13
12
  end
14
13
 
15
- def get_copies
16
- if items.nil?
17
- return Array.new
18
- end
19
- copies = items.collect {|c| c.copy_number}.uniq
20
- end
21
-
22
- def self.get_item_rank(item)
23
- status_guide = VoyagerItemStatus.status_guide(item.item_status.to_i)
24
- status_guide[:rank]
14
+ def library_has
15
+ ret = Hash.new
16
+ marc = HoldingMarc.new(@id)
17
+ val = marc.bound_copies
18
+ ret[:bound_copies] = val unless (val.nil? or val.empty?)
19
+ val = marc.indexes
20
+ ret[:indexes] = val unless (val.nil? or val.empty?)
21
+ val = marc.supplements
22
+ ret[:supplements] = val unless (val.nil? or val.empty?)
23
+ ret
25
24
  end
26
25
 
27
- def self.override_status(item)
28
- (16 == item.item_status.to_i)
29
- end
26
+ def get_items_display(concise = false)
27
+ ret = Hash.new
28
+ return ret unless items.size > 0
30
29
 
30
+ status_list = item_statuses(concise)
31
+ ret[:status] = status_list
32
+
33
+ ret
34
+ end
35
+
31
36
  def add_item(item)
32
37
  idx = items.index(item)
33
38
  if idx.nil?
@@ -47,30 +52,23 @@ module UwCatalog
47
52
  end
48
53
  end
49
54
 
50
- def library_has
51
- ret = Hash.new
52
- marc = HoldingMarc.new(@id)
53
- val = marc.bound_copies
54
- ret[:bound_copies] = val unless (val.nil? or val.empty?)
55
- val = marc.indexes
56
- ret[:indexes] = val unless (val.nil? or val.empty?)
57
- val = marc.supplements
58
- ret[:supplements] = val unless (val.nil? or val.empty?)
59
- ret
55
+ private
56
+
57
+ def get_copies
58
+ if items.nil?
59
+ return Array.new
60
+ end
61
+ copies = items.collect {|c| c.copy_number}.uniq
60
62
  end
61
-
62
- def get_items_display(concise = false)
63
- ret = Hash.new
64
- return ret unless items.size > 0
65
-
66
- ret.merge!(library_has)
67
-
68
- status_list = item_statuses(concise)
69
- ret[:status] = status_list
70
-
71
- ret
63
+
64
+ def self.override_status(item)
65
+ (16 == item.item_status.to_i)
66
+ end
67
+
68
+ def self.get_item_rank(item)
69
+ status_guide = VoyagerItemStatus.status_guide(item.item_status.to_i)
70
+ status_guide[:rank]
72
71
  end
73
-
74
72
 
75
73
  def item_statuses(concise)
76
74
  status_list = Array.new
@@ -80,14 +78,17 @@ module UwCatalog
80
78
  status_available, status_text = get_status(item)
81
79
  status_list << {:item_id => item.id, :status_text => status_text,
82
80
  :available => status_available, :copy_number=> item.copy_number,
83
- :item_enum => item.item_enum}
81
+ :item_enum => item.item_enum, :item_type_id => item.item_type_id,
82
+ :noloan => (item.item_type_id == 2)}
84
83
  end
85
84
 
86
85
  if (concise)
87
86
  total_count = status_list.size
88
87
  status_list.keep_if{|i| i[:available] == false}.compact
89
88
  if (total_count > 0 && status_list.size == 0)
89
+ #reset status list to aggregated view with no specific item data
90
90
  status_list << {:status_text => 'Available', :available => true}
91
+ status_list[0][:noloan] = (items.select{|i| i.item_type_id ==2 }.size == items.size)
91
92
  end
92
93
  end
93
94
 
@@ -101,13 +102,15 @@ module UwCatalog
101
102
 
102
103
  ret = status_text
103
104
  status_date = nil
105
+ date_format = "%B %d, %Y"
106
+
104
107
  if status_guide[:display_date]
105
108
  case item.item_status.to_i
106
109
  when 2, 3
107
- status_date = item.current_due_date.strftime(@@date_format) unless item.current_due_date.nil?
110
+ status_date = item.current_due_date.strftime(date_format) unless item.current_due_date.nil?
108
111
  status_text = "#{status_text}, Due on #{status_date}"
109
112
  else
110
- status_date = item.item_status_date.strftime(@@date_format) unless item.item_status_date.nil?
113
+ status_date = item.item_status_date.strftime(date_format) unless item.item_status_date.nil?
111
114
  status_text = "#{status_text} #{status_date}"
112
115
  end
113
116
  end
@@ -1,10 +1,10 @@
1
1
  module UwCatalog
2
2
  class HoldingMarc
3
3
 
4
- @@year_captions = ['(year)', '(Year)', 'year', '(year covered)']
5
- @@month_captions = ['(month)', 'mo']
6
- @@day_captions = ['(day)']
7
- @@season_captions = ['(season)']
4
+ YEAR_CAPTIONS = ['(year)', '(Year)', 'year', '(year covered)']
5
+ MONTH_CAPTIONS = ['(month)', 'mo']
6
+ DAY_CAPTIONS = ['(day)']
7
+ SEASON_CAPTIONS = ['(season)']
8
8
 
9
9
  attr_reader :holding_id, :record
10
10
 
@@ -33,23 +33,14 @@ module UwCatalog
33
33
  supplements_internal
34
34
  end
35
35
 
36
-
36
+ private
37
37
 
38
38
  def new_issues
39
39
  issues_received(0)
40
40
  end
41
41
 
42
42
  def issues_received(category)
43
- sql = "select serial_issues.enumchron " +
44
- "from line_item_copy_status " +
45
- "inner join subscription on line_item_copy_status.line_item_id = subscription.line_item_id " +
46
- "inner join component on subscription.subscription_id = component.subscription_id " +
47
- "inner join serial_issues on component.component_id = serial_issues.component_id " +
48
- "inner join issues_received on issues_received.issue_id = serial_issues.issue_id and component.component_id = issues_received.component_id " +
49
- "where line_item_copy_status.mfhd_id = ? " +
50
- "and component.category = ? " +
51
- "and serial_issues.received = 1 " +
52
- "and issues_received.opac_suppressed = 1"
43
+ sql = VoyagerSql.get_issues_recieved_sql
53
44
  repository(:UW).adapter.select(sql, @holding_id, category)
54
45
  end
55
46
 
@@ -62,8 +53,7 @@ module UwCatalog
62
53
 
63
54
  def marc_stream
64
55
  marc_stream = ''
65
- sql = "select mfhd_data.record_segment from mfhd_master, mfhd_data where mfhd_master.mfhd_id=? and " +
66
- " mfhd_master.mfhd_id = mfhd_data.mfhd_id"
56
+ sql = VoyagerSql.get_marc_stream_sql
67
57
  mfhd_data_segments = repository(:UW).adapter.select(sql, @holding_id)
68
58
  mfhd_data_segments.each do |segment|
69
59
  marc_stream << segment
@@ -235,10 +225,10 @@ module UwCatalog
235
225
 
236
226
  # Locate the chronology subfields
237
227
  field.subfields.each do |subfield|
238
- caption_and_pattern[field['8']][:chronology][:year] = subfield.code if @@year_captions.include?(subfield.value)
239
- caption_and_pattern[field['8']][:chronology][:month] = subfield.code if @@month_captions.include?(subfield.value)
240
- caption_and_pattern[field['8']][:chronology][:day] = subfield.code if @@day_captions.include?(subfield.value)
241
- caption_and_pattern[field['8']][:chronology][:season] = subfield.code if @@season_captions.include?(subfield.value)
228
+ caption_and_pattern[field['8']][:chronology][:year] = subfield.code if YEAR_CAPTIONS.include?(subfield.value)
229
+ caption_and_pattern[field['8']][:chronology][:month] = subfield.code if MONTH_CAPTIONS.include?(subfield.value)
230
+ caption_and_pattern[field['8']][:chronology][:day] = subfield.code if DAY_CAPTIONS.include?(subfield.value)
231
+ caption_and_pattern[field['8']][:chronology][:season] = subfield.code if SEASON_CAPTIONS.include?(subfield.value)
242
232
  end
243
233
 
244
234
  # Unless the chronology data is in subfield $a...
@@ -1,7 +1,7 @@
1
1
  module UwCatalog
2
2
  class Item
3
3
  attr_accessor :id, :item_enum, :copy_number, :on_reserve, :item_status,
4
- :item_barcode,
4
+ :item_barcode, :item_type_id,
5
5
  :item_status_date, :current_due_date, :hold_recall_status_date
6
6
 
7
7
  def initialize(h=Hash.new)
@@ -1,3 +1,3 @@
1
1
  module UwCatalog
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  module UwCatalog
2
2
  class VoyagerItemStatus
3
- @@item_statuses =
3
+ ITEM_STATUSES =
4
4
  {
5
5
  0 => { :voyager_identifer => 0, :available => false, :forward_status => "Unknown", :display_date => false, :rank => 25 },
6
6
  1 => { :voyager_identifer => 1, :available => true, :forward_status => "Available", :display_date => false, :rank => 20 },
@@ -30,7 +30,7 @@ module UwCatalog
30
30
  25 => { :voyager_identifer => 25, :available => false, :forward_status => "Requested", :display_date => true, :rank => 17 }
31
31
  }
32
32
  def self.status_guide(status_code)
33
- @@item_statuses[status_code]
33
+ ITEM_STATUSES[status_code]
34
34
  end
35
35
 
36
36
  def available?(itemStatusCode)
@@ -34,8 +34,8 @@ module UwCatalog
34
34
  ", circ_transactions, hold_recall_items " +
35
35
  "where bib_mfhd.bib_id=? " +
36
36
  "and bib_mfhd.mfhd_id=mfhd_master.mfhd_id " +
37
- "and mfhd_master.location_id=hloc.location_id " +
38
37
  "and mfhd_master.suppress_in_opac='N' " +
38
+ "and mfhd_master.location_id=hloc.location_id " +
39
39
  "and hloc.suppress_in_opac='N' " +
40
40
  "and mfhd_master.mfhd_id=mfhd_item.mfhd_id " +
41
41
  "and mfhd_item.item_id=item.item_id " +
@@ -76,5 +76,24 @@ module UwCatalog
76
76
  "and not exists (select 'x' from mfhd_item mi where mi.mfhd_id = mfhd_master.mfhd_id)"
77
77
  end
78
78
 
79
+ def self.get_issues_recieved_sql()
80
+ "select serial_issues.enumchron " +
81
+ "from line_item_copy_status " +
82
+ "inner join subscription on line_item_copy_status.line_item_id = subscription.line_item_id " +
83
+ "inner join component on subscription.subscription_id = component.subscription_id " +
84
+ "inner join serial_issues on component.component_id = serial_issues.component_id " +
85
+ "inner join issues_received on issues_received.issue_id = serial_issues.issue_id " +
86
+ "and component.component_id = issues_received.component_id " +
87
+ "where line_item_copy_status.mfhd_id = ? " +
88
+ "and component.category = ? " +
89
+ "and serial_issues.received = 1 " +
90
+ "and issues_received.opac_suppressed = 1"
91
+ end
92
+
93
+ def self.get_marc_stream_sql()
94
+ "select mfhd_data.record_segment from mfhd_master, mfhd_data " +
95
+ "where mfhd_master.mfhd_id=? " +
96
+ "and mfhd_master.mfhd_id = mfhd_data.mfhd_id"
97
+ end
79
98
  end
80
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uw_catalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake