Module: BerkeleyLibrary::TIND::Mapping::FieldCatalogUtil

Includes:
AlmaBase
Included in:
DataFieldsCatalog
Defined in:
lib/berkeley_library/tind/mapping/field_catalog_util.rb

Instance Method Summary collapse

Methods included from AlmaBase

#base_save, #base_tind_record

Instance Method Details

#exluding_fields_with_fast_subject(fields) ⇒ Object

Excluding fields: subfield2 = 'fast' and tag or refered tag(880 fields) started with '6':



10
11
12
# File 'lib/berkeley_library/tind/mapping/field_catalog_util.rb', line 10

def exluding_fields_with_fast_subject(fields)
  fields.reject { |f| excluding_field?(f) }
end

#fields_to_map(fields) ⇒ Object

Defining a list of fields from Alma to be mapped to TIND fields based on collection configuration: 1) BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags 2) BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags



33
34
35
36
37
38
39
40
# File 'lib/berkeley_library/tind/mapping/field_catalog_util.rb', line 33

def fields_to_map(fields)
  including_defined = !BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags.empty?
  excluding_defined = !BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags.empty?
  return [] if including_defined && excluding_defined # not allow to define both including and excluding tags
  return fields unless including_defined || excluding_defined # Neither including nor excluding tags are defined
  return fields_included(fields) if including_defined # including tags defined
  return fields_exclued(fields) if excluding_defined  # excluding tags defined
end

#prepare_group(from_fields) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/berkeley_library/tind/mapping/field_catalog_util.rb', line 14

def prepare_group(from_fields)
  datafields_hash = { normal: [], pre_tag: [], pre_tag_subfield: [] }
  from_fields.each do |f|
    # a regular field tag, or a tag value from 880 field captured from subfield6
    tag = origin_mapping_tag(f)
    next unless tag

    rule = rules[Util.tag_symbol(tag)]

    assign_field(rule, f, datafields_hash)
  end

  datafields_hash
end