app/helpers/cornell_catalog_helper.rb
# condensed has holding info, keyed by holding id as string
# items is an array of hashes of item info
# add the item info to the condensed info
# notes, and summary holdings are indexed by holding id to add to proper item blob in holdings list.
# over_locs indexed by mid -- array of holding notes, like Shelved at xxx, or Temporarily Shelved at
# when either perm_location or temp_location in item overrides Holding location.
#
condensed has holding info, keyed by holding id as string
items is an array of hashes of item info
add the item info to the condensed info
notes, and summary holdings are indexed by holding id to add to proper item blob in holdings list.
over_locs indexed by mid -- array of holding notes, like Shelved at xxx, or Temporarily Shelved at
when either perm_location or temp_location in item overrides Holding location.
condensed has holding info keyed by holding id as string items is an array of hashes of item info add the item info to the condensed info notes and summary holdings are indexed by holding id to add to proper item blob in holdings list . over_locs indexed by mid -- array of holding notes like Shelved at xxx or Temporarily Shelved at when either perm_location or temp_location in item overrides Holding location .
def parse_item_info(condensed,items,notes_by_mid,sumh_by_mid,grouped,bibid,response,over_locs,orders_by_mid)
	    items_by_mid = {}
	    if false
	    condn_by_mid = {}
	    condensed.each_key  do |lk|
	      condensed[lk]["holding_id"].each  do |hk|
		condn_by_mid[hk] = lk
	      end
	    end
	    end
	    items.each do |iinfo|
	      hk = iinfo['mfhd_id']
	      curi = ""
	      if (!condensed[hk].nil? && !condensed[hk]["current_issues"].nil?)
	       curi = condensed[hk]["current_issues"]
	      end
	      indx = ""
	      if (!condensed[hk].nil? && !condensed[hk]["indexes"].blank?)
	       indx = condensed[hk]["indexes"]
	      end
	      supl = ""
	      supl1 = ""
	      supl2 = ""
	      if (!condensed[hk].nil? && !condensed[hk]["supplements"].blank?)
	       supl1 = condensed[hk]["supplements"]
	      end
	      if (!condensed[hk].nil? && !condensed[hk]["supplemental_holdings_desc"].blank?)
	       supl2 = condensed[hk]["supplemental_holdings_desc"]
	      end
	      if (!supl1.blank? || !supl2.blank?)
	       supl = "Supplements: " +supl1+supl2
	      end
	      items_by_mid[hk] = {"items"=> {}, "notes"=>notes_by_mid[hk], "summary_holdings"=>sumh_by_mid[hk],
		"current_issues"=>curi,"supplements" => supl , "indexes"=> indx }
	    end
	    items_by_mid.each_key do |hk|
	      next if  hk.nil?
	      next if  items_by_mid[hk].nil?
	      next if  condensed[hk].nil?
	      condensed[hk]["copies"] << items_by_mid[hk]
	      if !over_locs[hk].blank?
		condensed[hk]["copies"][0]["temp_locations"]  = over_locs[hk]
	      end
	      condensed[hk]["copies"][0]["items"]  = grouped[hk]["items"] unless  grouped[hk].nil?
	    end
	    condensed.each_key do |hk|
	      if  condensed[hk.to_s]["copies"].blank?
		condensed[hk.to_s]["copies"] =
		  [{"items"=>{"Not Available"=>{"status"=>"none", "count"=>0}}, "notes"=>nil, "summary_holdings"=>nil,"orders" => nil}]
	      end
	      condensed[hk.to_s]["copies"][0]["orders"] =  orders_by_mid[hk.to_s] unless orders_by_mid[hk.to_s].blank?
	    end
	    condensed
	  end
def parse_item_info ( condensed , items , notes_by_mid , sumh_by_mid , grouped , bibid , response , over_locs , orders_by_mid ) items_by_mid = { } if false condn_by_mid = { } condensed . each_key do | lk | condensed [ lk ] [ "holding_id" ] . each do | hk | condn_by_mid [ hk ] = lk end end end items . each do | iinfo | hk = iinfo [ 'mfhd_id' ] curi = "" if ( ! condensed [ hk ] . nil? && ! condensed [ hk ] [ "current_issues" ] . nil? ) curi = condensed [ hk ] [ "current_issues" ] end indx = "" if ( ! condensed [ hk ] . nil? && ! condensed [ hk ] [ "indexes" ] . blank? ) indx = condensed [ hk ] [ "indexes" ] end supl = "" supl1 = "" supl2 = "" if ( ! condensed [ hk ] . nil? && ! condensed [ hk ] [ "supplements" ] . blank? ) supl1 = condensed [ hk ] [ "supplements" ] end if ( ! condensed [ hk ] . nil? && ! condensed [ hk ] [ "supplemental_holdings_desc" ] . blank? ) supl2 = condensed [ hk ] [ "supplemental_holdings_desc" ] end if ( ! supl1 . blank? || ! supl2 . blank? ) supl = "Supplements: " + supl1 + supl2 end items_by_mid [ hk ] = { "items" => { } , "notes" => notes_by_mid [ hk ] , "summary_holdings" => sumh_by_mid [ hk ] , "current_issues" => curi , "supplements" => supl , "indexes" => indx } end items_by_mid . each_key do | hk | next if hk . nil? next if items_by_mid [ hk ] . nil? next if condensed [ hk ] . nil? condensed [ hk ] [ "copies" ] << items_by_mid [ hk ] if ! over_locs [ hk ] . blank? condensed [ hk ] [ "copies" ] [ 0 ] [ "temp_locations" ] = over_locs [ hk ] end condensed [ hk ] [ "copies" ] [ 0 ] [ "items" ] = grouped [ hk ] [ "items" ] unless grouped [ hk ] . nil? end condensed . each_key do | hk | if condensed [ hk . to_s ] [ "copies" ] . blank? condensed [ hk . to_s ] [ "copies" ] = [ { "items" => { "Not Available" => { "status" => "none" , "count" => 0 } } , "notes" => nil , "summary_holdings" => nil , "orders" => nil } ] end condensed [ hk . to_s ] [ "copies" ] [ 0 ] [ "orders" ] = orders_by_mid [ hk . to_s ] unless orders_by_mid [ hk . to_s ] . blank? end condensed end
condensed has holding info, keyed by holding id as string
items is an array of hashes of item info
add the item info to the condensed info
notes, and summary holdings are indexed by holding id to add to proper item blob in holdings list.
condensed has holding info keyed by holding id as string items is an array of hashes of item info add the item info to the condensed info notes and summary holdings are indexed by holding id to add to proper item blob in holdings list .
# needed this when condensed was organized by library name. # now it is keyed by holding id. # condensed by holding id (mid ), to find which condensed entry contains a particular mid # value  at the index is a library 'displayname'. ##Rails.logger.debug "\nes287_debug condensed key lk  = #{lk}" #condn_by_mid = create_dn_by_mid(bibid,response) ###Rails.logger.debug "\nes287_debug line:(#{__LINE__})items this condn by mid = "+ condn_by_mid.inspect # TODO -- there may be notes on a holding record, #  but no items attached to that holding.  if that is true, this does not work. #  need to detect this condition, and correct for that. #  example bound withs, like 531286, or RMC things with no item records # insert item info into correct place into condensed array ##Rails.logger.debug "\nes287_debug File:#{__FILE__}:line:#{__LINE__} items_by_mid  = #{items_by_mid.inspect}" ##Rails.logger.debug "\nes287_debug File:#{__FILE__}:line:#{__LINE__} condensed  = #{condensed.inspect}" ##Rails.logger.debug "\nes287_debug File:#{__FILE__}:line:(#{__LINE__}) hk  = #{hk}" #condensed[condn_by_mid[hk]]["copies"] << items_by_mid[hk] ##Rails.logger.debug "\nes287_debug line:(#{__LINE__}) over_locs[hk]  = #{over_locs[hk]}" #condensed[condn_by_mid[hk]]["copies"][0]["temp_locations"]  = over_locs[hk] ##Rails.logger.debug "\nes287_debug line:(#{__LINE__}) hk  = #{hk}" #condensed[hk.to_s]["copies"] = [{"items" =>{} ,"orders" => [] } ]
condensed
<not_specific>
items
<not_specific>
notes_by_mid
<not_specific>
sumh_by_mid
<not_specific>
grouped
<not_specific>
bibid
<not_specific>
response
<not_specific>
over_locs
<not_specific>
orders_by_mid
<not_specific>