Class: BerkeleyLibrary::TIND::Mapping::SingleRule
- Inherits:
-
Object
- Object
- BerkeleyLibrary::TIND::Mapping::SingleRule
- Includes:
- Util
- Defined in:
- lib/berkeley_library/tind/mapping/single_rule.rb
Overview
TODO: ADD CSV VALIDATION, WHEN NEED ADD A NEW MAPPING CSV FILE
- not empty row
- a subfield name can appear in either normal mapping or combine mapping, not both
- single map has the same amount of from names and to names
- Combine mappping should have tree columns, validate more?
- Combine from_subfield, to_subfield should have values, no empty
- Tag from row[:map_if_no_this_tag_subfield_existed]), row[:map_if_no_this_tag_existed] # This tag should be the same as destination tag
- In single map csv, one row cannot have both "map_if_no_this_tag_existed" (245) and ":map_if_no_this_tag_subfield_existed" (245__b) because tag in these two column are identical
- csv file validation - a row should have coulumns: tag origin and destintation ? single rule
- Validating these column names
- csv file validation - a row should have coulumns: tag origin and destintation ? single rule
- validating headers
- Formats for some of the columns
Instance Attribute Summary collapse
-
#combined_rules ⇒ Object
readonly
Returns the value of attribute combined_rules.
-
#indicator ⇒ Object
readonly
Returns the value of attribute indicator.
-
#pre_existed_tag ⇒ Object
readonly
Returns the value of attribute pre_existed_tag.
-
#pre_existed_tag_subfield ⇒ Object
readonly
Returns the value of attribute pre_existed_tag_subfield.
-
#single_rule_hash ⇒ Object
readonly
Returns the value of attribute single_rule_hash.
-
#single_rule_subfield_excluded_hash ⇒ Object
readonly
Returns the value of attribute single_rule_subfield_excluded_hash.
-
#subfields_order ⇒ Object
readonly
Returns the value of attribute subfields_order.
-
#tag_destination ⇒ Object
readonly
Returns the value of attribute tag_destination.
-
#tag_origin ⇒ Object
readonly
Returns the value of attribute tag_origin.
Instance Method Summary collapse
-
#initialize(row) ⇒ SingleRule
constructor
A new instance of SingleRule.
-
#rules_with_same_subfield_name(row) ⇒ Object
1.
Methods included from Util
alma_datafield, collection_config_correct?, concatenation_symbol, csv_rows, datafield, from_xml, indicator, order_subfields, qualified_alma_record?, remove_extra_symbol, subfield, subfield_hash, symbols, tag_symbol
Methods included from AlmaBase
Constructor Details
#initialize(row) ⇒ SingleRule
Returns a new instance of SingleRule.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 31 def initialize(row) @tag_origin = row[:tag_origin] @tag_destination = row[:tag_destination] @indicator = Util.indicator(row[:new_indecator]) @pre_existed_tag = row[:map_if_no_this_tag_existed] @pre_existed_tag_subfield = existed_tag_subfield(row[:map_if_no_this_tag_subfield_existed]) # This tag should be the same as destination tag @single_rule_hash = single_map_dic(row[:subfield_single_from], row[:subfield_single_to]) @single_rule_subfield_excluded_hash = single_map_subfield_excluded_dic @combined_rules = rules_with_same_subfield_name(row) @subfields_order = order(row[:order]) end |
Instance Attribute Details
#combined_rules ⇒ Object (readonly)
Returns the value of attribute combined_rules.
28 29 30 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 28 def combined_rules @combined_rules end |
#indicator ⇒ Object (readonly)
Returns the value of attribute indicator.
23 24 25 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 23 def indicator @indicator end |
#pre_existed_tag ⇒ Object (readonly)
Returns the value of attribute pre_existed_tag.
24 25 26 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 24 def pre_existed_tag @pre_existed_tag end |
#pre_existed_tag_subfield ⇒ Object (readonly)
Returns the value of attribute pre_existed_tag_subfield.
25 26 27 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 25 def pre_existed_tag_subfield @pre_existed_tag_subfield end |
#single_rule_hash ⇒ Object (readonly)
Returns the value of attribute single_rule_hash.
26 27 28 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 26 def single_rule_hash @single_rule_hash end |
#single_rule_subfield_excluded_hash ⇒ Object (readonly)
Returns the value of attribute single_rule_subfield_excluded_hash.
27 28 29 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 27 def single_rule_subfield_excluded_hash @single_rule_subfield_excluded_hash end |
#subfields_order ⇒ Object (readonly)
Returns the value of attribute subfields_order.
29 30 31 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 29 def subfields_order @subfields_order end |
#tag_destination ⇒ Object (readonly)
Returns the value of attribute tag_destination.
22 23 24 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 22 def tag_destination @tag_destination end |
#tag_origin ⇒ Object (readonly)
Returns the value of attribute tag_origin.
21 22 23 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 21 def tag_origin @tag_origin end |
Instance Method Details
#rules_with_same_subfield_name(row) ⇒ Object
- Return an array of combined rules, an item in the array is an array of rules which have the same 'to subfield name'
- An example: [[["a,b,c,d", "b", "--"],["o,p,q", "b", ""]],[["x,y,z", "a", "--"]]]
46 47 48 49 50 51 52 |
# File 'lib/berkeley_library/tind/mapping/single_rule.rb', line 46 def rules_with_same_subfield_name(row) rules = all_combined_rules(row) identical_to_subfield_names = unique_tosubfield_names(rules) identical_to_subfield_names.each_with_object([]) do |name, result| result << rules_with_sametosubfield(name, rules) end end |