Class: ArchivistsToolkit

Inherits:
Object
  • Object
show all
Defined in:
backend/app/lib/user_defined_field_migrator.rb

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ ArchivistsToolkit

Returns a new instance of ArchivistsToolkit.



386
387
388
389
390
391
392
393
394
# File 'backend/app/lib/user_defined_field_migrator.rb', line 386

def initialize(db)
  @db = db

  @key_set = {}
  @value_set = {}
  @missing_user_defined_fields = {}

  preload_instances
end

Instance Method Details

#find_matching_containers(column, record_ids, top_container) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'backend/app/lib/user_defined_field_migrator.rb', line 397

def find_matching_containers(column, record_ids, top_container)
  record_ids.map do |record_id|

    if column == :resourceId
      resource_id = record_id
      resource_component_id = nil
    elsif :resourceComponentId
      resource_id = nil
      resource_component_id = record_id
    else
      raise "Unrecognized column: #{column}"
    end

    if top_container.barcode
      barcode = top_container.barcode
      indicator = nil
    else
      barcode = nil
      indicator = top_container.indicator
    end

    search_key = InstanceKey.new(resource_id, resource_component_id, barcode, indicator)
    search_key_bytes = search_key.to_bytes

    value = @key_set[search_key_bytes]
    if value
      @value_set[value]
    elsif @missing_user_defined_fields[search_key_bytes]
      :no_data # No problem here.  There was just no data to load.
    else
      Log.debug("Not found: #{search_key.inspect}")
      nil
    end

  end.compact.uniq
end