diff --git a/Gemfile b/Gemfile index 48bd19a5..30e6525f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ # frozen_string_literal: true source 'https://rubygems.org' -git_source(:github){|repo_name| "https://github.com/#{repo_name}" } +git_source(:github){ |repo_name| "https://github.com/#{repo_name}" } ruby '2.7.4' @@ -10,4 +10,5 @@ gem 'facets', require: false # Specify your gem's dependencies in collectionspace-mapper.gemspec gem 'collectionspace-client', tag: 'v0.10.0', git: 'https://github.com/collectionspace/collectionspace-client.git' gem 'collectionspace-refcache', tag: 'v0.7.7', git: 'https://github.com/collectionspace/collectionspace-refcache.git' + gemspec diff --git a/collectionspace-mapper.gemspec b/collectionspace-mapper.gemspec index 5a357960..6d0eed94 100644 --- a/collectionspace-mapper.gemspec +++ b/collectionspace-mapper.gemspec @@ -1,6 +1,6 @@ # frozen_string_literal: true -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'collectionspace/mapper/version' @@ -10,12 +10,12 @@ Gem::Specification.new do |spec| spec.authors = ['Kristina Spurgin'] spec.email = ['kristina.spurgin@lyrasis.org'] - spec.summary = %q{Generic mapper turns hash of data into CollectionSpace XML} + spec.summary = 'Generic mapper turns hash of data into CollectionSpace XML' spec.homepage = 'https://github.com/lyrasis/collectionspace-mapper' spec.license = 'MIT' spec.required_ruby_version = '>= 2.7.4' - + # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host. if spec.respond_to?(:metadata) @@ -26,12 +26,12 @@ Gem::Specification.new do |spec| spec.metadata['changelog_uri'] = 'https://github.com/lyrasis/collectionspace-mapper' else raise 'RubyGems 2.0 or newer is required to protect against ' \ - 'public gem pushes.' + 'public gem pushes.' end # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do + spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject{ |f| f.match(%r{^(test|spec|features)/}) } end spec.bindir = 'exe' @@ -45,12 +45,14 @@ Gem::Specification.new do |spec| spec.add_dependency 'xxhash', '>= 0.4.0' spec.add_development_dependency 'bundler', '>= 2.1.2' + spec.add_development_dependency 'byebug' + spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'rake', '>= 13.0.1' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'rubocop', '~> 1.18.3' # Uncomment these if you need to use the scripts in utils/benchmarking - #spec.add_development_dependency 'ruby-prof', '~> 1.4.3' - #spec.add_development_dependency 'time_up', '~> 0.0.7' + # spec.add_development_dependency 'ruby-prof', '~> 1.4.3' + # spec.add_development_dependency 'time_up', '~> 0.0.7' end diff --git a/doc/batch_configuration.adoc b/doc/batch_configuration.adoc index 283ba3d9..f9acdbf3 100644 --- a/doc/batch_configuration.adoc +++ b/doc/batch_configuration.adoc @@ -24,7 +24,6 @@ A JSON config hash may be passed to a new `Mapper::DataHandler` to control vario "response_mode": "verbose", "strip_id_values": true, "multiple_recs_found": "fail", - "check_terms" : true, "check_record_status" : true, "force_defaults": false, "date_format": "month day year", @@ -118,22 +117,6 @@ While it is possible to use this setting to batch update existing records that d - *Data type*: string - *Allowed values*: `fail`, `use_first` -== check_terms - -If `true`, looks up each term via `collectionspace-refcache`. If found, uses existing refname. If not found, searches for term via cspace-services API and uses existing refname if found. If term not found in refcache or services API, builds a new refname, uses that in the record, adds it to refcache, and returns the term with `found=false` in `Response::Terms`. - -If `false`, never searches services API for the term. Uses refcache refname if it exists, otherwise builds a new refname and adds it to refcache. Returns all terms with `found=false` in `Response::Terms`. - -[NOTE] -==== -Set this to false only if you are certain no terms from your data exist in CollectionSpace, and all of the terms need to be created as new. Otherwise, you may end up with duplicate terms being added to CollectionSpace, due to the fact that `collectionspace-mapper` does not generate exactly the same hashed short identifier value for use in the refname as the CollectionSpace application does. -==== - -- *Required?:* yes -- *Defaults to:* true -- *Data type*: boolean -- *Allowed values*: `true`, `false` - == check_record_status If `true`, looks up each record via cspace-services API and sets `Response.record_status` to `:exists` if the record is found, or `:new` if it is not. diff --git a/lib/collectionspace/mapper.rb b/lib/collectionspace/mapper.rb index 98a9077a..befe90d4 100644 --- a/lib/collectionspace/mapper.rb +++ b/lib/collectionspace/mapper.rb @@ -36,6 +36,7 @@ module Errors class UnprocessableDataError < StandardError UnprocessableDataError = CollectionSpace::Mapper::Errors::UnprocessableDataError attr_reader :input + def initialize(message, input) super(message) @input = input @@ -76,6 +77,5 @@ def merge_default_values(data, batchconfig) def term_key(term) "#{term[:refname].type}-#{term[:refname].subtype}-#{term[:refname].display_name}" end - end end diff --git a/lib/collectionspace/mapper/authority_hierarchy_prepper.rb b/lib/collectionspace/mapper/authority_hierarchy_prepper.rb index a52218ed..9086ffa0 100644 --- a/lib/collectionspace/mapper/authority_hierarchy_prepper.rb +++ b/lib/collectionspace/mapper/authority_hierarchy_prepper.rb @@ -54,9 +54,7 @@ def transform_terms end @response.split_data.each do |field, value| - unless @response.transformed_data.key?(field) - @response.transformed_data[field] = value - end + @response.transformed_data[field] = value unless @response.transformed_data.key?(field) end end diff --git a/lib/collectionspace/mapper/authority_transformer.rb b/lib/collectionspace/mapper/authority_transformer.rb index c8587d46..82572423 100644 --- a/lib/collectionspace/mapper/authority_transformer.rb +++ b/lib/collectionspace/mapper/authority_transformer.rb @@ -4,10 +4,8 @@ module CollectionSpace module Mapper - # transforms authority display name into RefName class AuthorityTransformer < Transformer - def initialize(opts) super @type = opts[:transform][0] @@ -16,8 +14,7 @@ def initialize(opts) @csclient = opts[:recmapper].csclient end - def transform(value) - end + def transform(value); end end end end diff --git a/lib/collectionspace/mapper/behrensmeyer_transformer.rb b/lib/collectionspace/mapper/behrensmeyer_transformer.rb index 7c9e026a..ac3b4257 100644 --- a/lib/collectionspace/mapper/behrensmeyer_transformer.rb +++ b/lib/collectionspace/mapper/behrensmeyer_transformer.rb @@ -4,11 +4,9 @@ module CollectionSpace module Mapper - # transforms digit into full Behrensmeyer scale vocabulary term class BehrensmeyerTransformer < Transformer - def transform(value) - end + def transform(value); end end end end diff --git a/lib/collectionspace/mapper/boolean_transformer.rb b/lib/collectionspace/mapper/boolean_transformer.rb index 6623b5fb..ad407162 100644 --- a/lib/collectionspace/mapper/boolean_transformer.rb +++ b/lib/collectionspace/mapper/boolean_transformer.rb @@ -4,7 +4,6 @@ module CollectionSpace module Mapper - # transforms a variety of binary values into Boolean string values for CS class BooleanTransformer < Transformer def transform(value) diff --git a/lib/collectionspace/mapper/column_mapping.rb b/lib/collectionspace/mapper/column_mapping.rb index 55066239..3c5768de 100644 --- a/lib/collectionspace/mapper/column_mapping.rb +++ b/lib/collectionspace/mapper/column_mapping.rb @@ -10,6 +10,7 @@ module Mapper class ColumnMapping attr_reader :recmapper, :data_type, :fieldname, :in_repeating_group, :is_group, :namespace, :opt_list_values, :repeats, :source_type, :transforms, :xpath + def initialize(mapping_hash, recmapper) @recmapper = recmapper mapping_hash.each do |key, value| diff --git a/lib/collectionspace/mapper/column_mappings.rb b/lib/collectionspace/mapper/column_mappings.rb index 7b6f4ce2..d44f1a4c 100644 --- a/lib/collectionspace/mapper/column_mappings.rb +++ b/lib/collectionspace/mapper/column_mappings.rb @@ -10,6 +10,7 @@ class ColumnMappings extend Forwardable attr_reader :config + def_delegators :@all, :each, :length, :map, :reject!, :select def initialize(opts = {}) diff --git a/lib/collectionspace/mapper/column_value.rb b/lib/collectionspace/mapper/column_value.rb index 013cba6a..f14794fa 100644 --- a/lib/collectionspace/mapper/column_value.rb +++ b/lib/collectionspace/mapper/column_value.rb @@ -2,7 +2,6 @@ module CollectionSpace module Mapper - # represents a row of data from a CSV. class ColumnValue def initialize(column:, value:, recmapper:, mapping:) diff --git a/lib/collectionspace/mapper/config.rb b/lib/collectionspace/mapper/config.rb index 361de03d..15a95934 100644 --- a/lib/collectionspace/mapper/config.rb +++ b/lib/collectionspace/mapper/config.rb @@ -4,15 +4,15 @@ module CollectionSpace module Mapper - # This is the default config, which is modified for object or authority hierarchy, # or non-hierarchichal relationships via module extension # :reek:InstanceVariableAssumption - instance variables are set during initialization class Config attr_reader :delimiter, :subgroup_delimiter, :response_mode, :strip_id_values, :multiple_recs_found, :force_defaults, - :check_record_status, :check_terms, :date_format, :two_digit_year_handling, :transforms, :default_values, - :record_type - # todo: move default config in here + :check_record_status, :date_format, :two_digit_year_handling, :transforms, :default_values, + :record_type + + # TODO: move default config in here include Tools::Symbolizable DEFAULT_CONFIG = {delimiter: '|', @@ -20,21 +20,22 @@ class Config response_mode: 'normal', strip_id_values: true, multiple_recs_found: 'fail', - check_terms: true, check_record_status: true, force_defaults: false, date_format: 'month day year', - two_digit_year_handling: 'coerce' - } + two_digit_year_handling: 'coerce'} class ConfigKeyMissingError < StandardError attr_reader :keys + def initialize(message, keys) super(message) @keys = keys end end + class ConfigResponseModeError < StandardError; end + class UnhandledConfigFormatError < StandardError; end def initialize(opts = {}) @@ -57,7 +58,7 @@ def initialize(opts = {}) end def hash - config = self.to_h + config = to_h config = symbolize(config) transforms = config[:transforms] return config unless transforms @@ -97,13 +98,13 @@ def set_instance_variables(hash) def validate begin has_required_attributes - rescue ConfigKeyMissingError => err - err.keys.each{ |key| instance_variable_set("@#{key}", DEFAULT_CONFIG[key]) } + rescue ConfigKeyMissingError => e + e.keys.each{ |key| instance_variable_set("@#{key}", DEFAULT_CONFIG[key]) } end begin valid_response_mode - rescue ConfigResponseModeError => err + rescue ConfigResponseModeError => e replacement_value = DEFAULT_CONFIG[:response_mode] @response_mode = replacement_value end @@ -112,16 +113,14 @@ def validate def valid_response_mode valid = %w[normal verbose] unless valid.any?(@response_mode) - raise ConfigResponseModeError.new("Invalid response_mode value in config: #{@response_mode}") + raise ConfigResponseModeError, "Invalid response_mode value in config: #{@response_mode}" end end def has_required_attributes required_keys = DEFAULT_CONFIG.keys remaining_keys = required_keys - hash.keys - unless remaining_keys.empty? - raise ConfigKeyMissingError.new('Config missing key', remaining_keys) - end + raise ConfigKeyMissingError.new('Config missing key', remaining_keys) unless remaining_keys.empty? end def special_defaults @@ -130,4 +129,3 @@ def special_defaults end end end - diff --git a/lib/collectionspace/mapper/data_handler.rb b/lib/collectionspace/mapper/data_handler.rb index 6b3eecc6..fbede43f 100644 --- a/lib/collectionspace/mapper/data_handler.rb +++ b/lib/collectionspace/mapper/data_handler.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper - # given a RecordMapper hash and a data hash, returns CollectionSpace XML document class DataHandler # this is an accessor rather than a reader until I refactor away the hideous @@ -32,7 +31,7 @@ def process(data) end def prep(data) - response = CollectionSpace::Mapper::setup_data(data, @mapper.batchconfig) + response = CollectionSpace::Mapper.setup_data(data, @mapper.batchconfig) if response.valid? case @mapper.record_type when 'authorityhierarchy' @@ -74,7 +73,7 @@ def service_type end def validate(data) - response = CollectionSpace::Mapper::setup_data(data, @mapper.batchconfig) + response = CollectionSpace::Mapper.setup_data(data, @mapper.batchconfig) validator.validate(response) end @@ -116,12 +115,12 @@ def xpath_hash # populate parent of all non-top xpaths h.each do |xpath, ph| - if xpath['/'] - keys = h.keys - [xpath] - keys = keys.select{ |k| xpath[k] } - keys = keys.sort{ |a, b| b.length <=> a.length } - ph[:parent] = keys[0] unless keys.empty? - end + next unless xpath['/'] + + keys = h.keys - [xpath] + keys = keys.select{ |k| xpath[k] } + keys = keys.sort{ |a, b| b.length <=> a.length } + ph[:parent] = keys[0] unless keys.empty? end # populate children @@ -145,13 +144,15 @@ def xpath_hash if v.size > 1 puts "WARNING: #{xpath} has fields with different :in_repeating_group values (#{v}). Defaulting to treating NOT as a group" end - ph[:is_group] = -true if ct == 1 && v == ['as part of larger repeating group'] && ph[:mappings][0].repeats == 'y' + if ct == 1 && v == ['as part of larger repeating group'] && ph[:mappings][0].repeats == 'y' + ph[:is_group] = + true + end end # populate is_subgroup subgroups = [] - h.each{ |k, v| subgroups << v[:subgroups] } + h.each{ |_k, v| subgroups << v[:subgroups] } subgroups = subgroups.flatten.uniq h.keys.each{ |k| h[k][:is_subgroup] = true if subgroups.include?(k) } h @@ -186,7 +187,7 @@ def set_record_status(response) status = searchresult[:status] response.record_status = status return if status == :new - + response.csid = searchresult[:csid] response.uri = searchresult[:uri] response.refname = searchresult[:refname] @@ -202,10 +203,10 @@ def tag_terms(result) return if terms.empty? terms.select{ |t| !t[:found] }.each do |term| - @new_terms[CollectionSpace::Mapper::term_key(term)] = nil + @new_terms[CollectionSpace::Mapper.term_key(term)] = nil end terms.select{ |t| t[:found] }.each do |term| - term[:found] = false if @new_terms.key?(CollectionSpace::Mapper::term_key(term)) + term[:found] = false if @new_terms.key?(CollectionSpace::Mapper.term_key(term)) end result.terms = terms diff --git a/lib/collectionspace/mapper/data_mapper.rb b/lib/collectionspace/mapper/data_mapper.rb index bdd81af9..f504b56d 100644 --- a/lib/collectionspace/mapper/data_mapper.rb +++ b/lib/collectionspace/mapper/data_mapper.rb @@ -5,6 +5,7 @@ module Mapper class DataMapper attr_reader :handler, :xphash attr_accessor :doc, :response + def initialize(response, handler, xphash) @response = response @handler = handler @@ -122,15 +123,16 @@ def populate_simple_field_data(field_name, data, parent) def populate_group_field_data(index, data, parent) data.each do |field, values| - if values[index] - child = Nokogiri::XML::Node.new(field, @doc) - if values[index].is_a?(Hash) - map_structured_date(child, values[index]) - else values[index] - child.content = values[index] - end - parent.add_child(child) + next unless values[index] + + child = Nokogiri::XML::Node.new(field, @doc) + if values[index].is_a?(Hash) + map_structured_date(child, values[index]) + else + values[index] + child.content = values[index] end + parent.add_child(child) end end @@ -177,7 +179,7 @@ def map_group(xpath, targetnode, thisdata) end def even_subgroup_field_values?(data) - data.values.map(&:flatten).map(&:length).uniq.length == 1 ? true : false + data.values.map(&:flatten).map(&:length).uniq.length == 1 end def add_uneven_subgroup_warning(parent_path:, intervening_path:, subgroup:) @@ -204,7 +206,7 @@ def add_too_many_subgroups_warning(parent_path:, intervening_path:, subgroup:) def group_accommodates_subgroup?(groupdata, subgroupdata) sg_max_length = subgroupdata.values.map(&:length).max - sg_max_length <= groupdata.length ? true : false + sg_max_length <= groupdata.length end # EXAMPLE: creates empty titleTranslationSubGroupList as a child of titleGroup @@ -222,7 +224,7 @@ def create_intermediate_subgroup_hierarchy(grp, subgroup_path) # returns the count of field values for the subgroup field with the mosty values # we need to know this in order to create enough empty subgroup elements to hold the data def maximum_subgroup_values(data) - data.map{ |field, values| subgroup_value_count(values) }.flatten.max + data.map{ |_field, values| subgroup_value_count(values) }.flatten.max end def subgroup_value_count(values) @@ -250,12 +252,16 @@ def map_subgroup(xphash, thisdata) groups[i] = {parent: p, data: {}} end - add_uneven_subgroup_warning(parent_path: parent_path, - intervening_path: subgroup_path, - subgroup: subgroup) unless even_subgroup_field_values?(thisdata) - add_too_many_subgroups_warning(parent_path: parent_path, - intervening_path: subgroup_path, - subgroup: subgroup) unless group_accommodates_subgroup?(groups, thisdata) + unless even_subgroup_field_values?(thisdata) + add_uneven_subgroup_warning(parent_path: parent_path, + intervening_path: subgroup_path, + subgroup: subgroup) + end + unless group_accommodates_subgroup?(groups, thisdata) + add_too_many_subgroups_warning(parent_path: parent_path, + intervening_path: subgroup_path, + subgroup: subgroup) + end thisdata.each{ |field, subgroups| assign_subgroup_values_to_group_hash_data(groups, field, subgroups) } @@ -263,7 +269,7 @@ def map_subgroup(xphash, thisdata) max_ct = maximum_subgroup_values(thisdata) - groups.each do |i, data| + groups.each do |i, _data| max_ct.times do target = @doc.xpath("//#{parent_path}/#{subgroup_path.join('/')}") target[i].add_child(Nokogiri::XML::Node.new(subgroup, @doc)) diff --git a/lib/collectionspace/mapper/data_prepper.rb b/lib/collectionspace/mapper/data_prepper.rb index e5f986d3..5cc3d7de 100644 --- a/lib/collectionspace/mapper/data_prepper.rb +++ b/lib/collectionspace/mapper/data_prepper.rb @@ -5,16 +5,15 @@ module Mapper class DataPrepper attr_reader :data, :handler, :config, :cache, :client attr_accessor :response, :xphash + def initialize(data, handler) @handler = handler @config = @handler.mapper.batchconfig @cache = @handler.mapper.termcache @client = @handler.mapper.csclient - @response = CollectionSpace::Mapper::setup_data(data, @config) + @response = CollectionSpace::Mapper.setup_data(data, @config) drop_empty_fields - if @response.valid? - process_xpaths - end + process_xpaths if @response.valid? end def prep @@ -29,12 +28,12 @@ def prep end def split_data - @xphash.each{ |xpath, hash| do_splits(hash) } + @xphash.each{ |_xpath, hash| do_splits(hash) } @response.split_data end def transform_data - @xphash.each{ |xpath, hash| do_transforms(hash) } + @xphash.each{ |_xpath, hash| do_transforms(hash) } @response.transformed_data end @@ -44,14 +43,14 @@ def transform_date_fields end def handle_term_fields - @xphash.each{ |xpath, hash| do_term_handling(hash) } + @xphash.each{ |_xpath, hash| do_term_handling(hash) } @response.warnings.flatten! @response.errors.flatten! @response.transformed_data end def check_data - @xphash.each{ |xpath, hash| check_data_quality(hash) } + @xphash.each{ |_xpath, hash| check_data_quality(hash) } @response.warnings.flatten! @response.warnings end @@ -76,7 +75,7 @@ def push_errors_and_warnings end def drop_empty_fields - @response.merged_data = @response.merged_data.delete_if{ |k, v| v.blank? } + @response.merged_data = @response.merged_data.delete_if{ |_k, v| v.blank? } end def process_xpaths @@ -89,7 +88,7 @@ def process_xpaths @xphash = mappings.map{ |mapper| mapper.fullpath }.uniq # hash with xpath as key and xpath info hash from DataHandler as value @xphash = @xphash.map{ |xpath| [xpath, @handler.mapper.xpath[xpath].clone] }.to_h - @xphash.each do |xpath, hash| + @xphash.each do |_xpath, hash| hash[:mappings] = hash[:mappings].select do |mapping| mapping.fieldname == 'shortIdentifier' || @response.merged_data.key?(mapping.datacolumn) end @@ -117,7 +116,7 @@ def do_non_group_splits(xphash) next if data.nil? || data.empty? @response.split_data[column] = non_group_splitter(mapping, data) - #mapping.repeats == 'y' ? CollectionSpace::Mapper::SimpleSplitter.new(data, config).result : [data.strip] + # mapping.repeats == 'y' ? CollectionSpace::Mapper::SimpleSplitter.new(data, config).result : [data.strip] end end @@ -153,7 +152,7 @@ def do_subgroup_splits(xphash) @response.split_data[column] = CollectionSpace::Mapper::SubgroupSplitter.new(data, config).result end end - + def do_transforms(xphash) splitdata = @response.split_data targetdata = @response.transformed_data @@ -162,17 +161,17 @@ def do_transforms(xphash) data = splitdata.fetch(column, nil) next if data.blank? - if mapping.transforms.blank? - targetdata[column] = data - else - targetdata[column] = data.map do |d| - if d.is_a?(String) - transform_value(d, mapping.transforms, column) - else - d.map{ |val| transform_value(val, mapping.transforms, column) } - end - end - end + targetdata[column] = if mapping.transforms.blank? + data + else + data.map do |d| + if d.is_a?(String) + transform_value(d, mapping.transforms, column) + else + d.map{ |val| transform_value(val, mapping.transforms, column) } + end + end + end end end @@ -189,7 +188,7 @@ def transform_value(value, transforms, column) vt.result end - def do_date_transforms(xpath, xphash) + def do_date_transforms(_xpath, xphash) sourcedata = @response.transformed_data xphash[:mappings].each do |mapping| @@ -242,8 +241,6 @@ def get_source_type(source_type_string) source_type_string.to_sym when 'vocabulary' source_type_string.to_sym - else - nil end end @@ -255,10 +252,12 @@ def structured_date_transform(data) @cache, @handler.mapper.batchconfig).mappable else - d.map{ |v| CollectionSpace::Mapper::Tools::Dates::CspaceDate.new(v, - @client, - @cache, - @handler.mapper.batchconfig).mappable } + d.map do |v| + CollectionSpace::Mapper::Tools::Dates::CspaceDate.new(v, + @client, + @cache, + @handler.mapper.batchconfig).mappable + end end end end @@ -271,10 +270,12 @@ def unstructured_date_transform(data) @cache, @handler.mapper.batchconfig).stamp else - d.map{ |v| CollectionSpace::Mapper::Tools::Dates::CspaceDate.new(v, - @client, - @cache, - @handler.mapper.batchconfig).stamp } + d.map do |v| + CollectionSpace::Mapper::Tools::Dates::CspaceDate.new(v, + @client, + @cache, + @handler.mapper.batchconfig).stamp + end end end end @@ -322,12 +323,12 @@ def combine_data_values(xpath, xphash) elsif chk.empty? next else - raise StandardError.new('Mixed class types in multi-authority field set') + raise StandardError, 'Mixed class types in multi-authority field set' end end end - @response.combined_data[xpath].select{ |fieldname, val| val.blank? }.keys.each do |fieldname| + @response.combined_data[xpath].select{ |_fieldname, val| val.blank? }.keys.each do |fieldname| @response.combined_data[xpath].delete(fieldname) unless fieldname == 'shortIdentifier' @xphash[xpath][:mappings].delete_if{ |mapping| mapping.fieldname == fieldname } diff --git a/lib/collectionspace/mapper/data_quality_checker.rb b/lib/collectionspace/mapper/data_quality_checker.rb index 43466a28..8e9dd0cc 100644 --- a/lib/collectionspace/mapper/data_quality_checker.rb +++ b/lib/collectionspace/mapper/data_quality_checker.rb @@ -4,6 +4,7 @@ module CollectionSpace module Mapper class DataQualityChecker attr_reader :mapping, :data, :warnings, :terms + def initialize(mapping, data) @mapping = mapping @column = mapping.datacolumn @@ -77,4 +78,3 @@ def check_opt_list_val(val) end end end - diff --git a/lib/collectionspace/mapper/data_splitter.rb b/lib/collectionspace/mapper/data_splitter.rb index 76dceac9..72477277 100644 --- a/lib/collectionspace/mapper/data_splitter.rb +++ b/lib/collectionspace/mapper/data_splitter.rb @@ -4,6 +4,7 @@ module CollectionSpace module Mapper class DataSplitter attr_reader :data, :result + def initialize(data, config) @data = data.strip @config = config diff --git a/lib/collectionspace/mapper/data_validator.rb b/lib/collectionspace/mapper/data_validator.rb index f6e46e76..869669f0 100644 --- a/lib/collectionspace/mapper/data_validator.rb +++ b/lib/collectionspace/mapper/data_validator.rb @@ -69,6 +69,7 @@ class DataValidator class IdFieldNotInMapperError < StandardError; end attr_reader :mapper, :cache, :required_fields + def initialize(record_mapper, cache) @mapper = record_mapper @cache = cache @@ -82,7 +83,7 @@ def initialize(record_mapper, cache) end def validate(data) - response = CollectionSpace::Mapper::setup_data(data) + response = CollectionSpace::Mapper.setup_data(data) if response.valid? data = response.merged_data.transform_keys!(&:downcase) res = check_required_fields(data) unless @required_fields.empty? @@ -118,11 +119,11 @@ def check_required_fields(data) @required_fields.each do |field, columns| if columns.length == 1 checkfield = SingleColumnRequiredField.new(field, columns) - errs << checkfield.missing_message if !checkfield.present_in?(data) + errs << checkfield.missing_message unless checkfield.present_in?(data) errs << checkfield.empty_message if checkfield.present_in?(data) && !checkfield.populated_in?(data) elsif columns.length > 1 checkfield = MultiColumnRequiredField.new(field, columns) - errs << checkfield.missing_message if !checkfield.present_in?(data) + errs << checkfield.missing_message unless checkfield.present_in?(data) errs << checkfield.empty_message if checkfield.present_in?(data) && !checkfield.populated_in?(data) end end @@ -131,4 +132,3 @@ def check_required_fields(data) end end end - diff --git a/lib/collectionspace/mapper/date_stamp_transformer.rb b/lib/collectionspace/mapper/date_stamp_transformer.rb index 39699d15..2a28def9 100644 --- a/lib/collectionspace/mapper/date_stamp_transformer.rb +++ b/lib/collectionspace/mapper/date_stamp_transformer.rb @@ -4,11 +4,9 @@ module CollectionSpace module Mapper - # converts date string to CS date stamp class DateStampTransformer < Transformer - def transform(value) - end + def transform(value); end end end end diff --git a/lib/collectionspace/mapper/downcase_transformer.rb b/lib/collectionspace/mapper/downcase_transformer.rb index c87aea3b..66238074 100644 --- a/lib/collectionspace/mapper/downcase_transformer.rb +++ b/lib/collectionspace/mapper/downcase_transformer.rb @@ -4,11 +4,9 @@ module CollectionSpace module Mapper - # downcases field values class DowncaseTransformer < Transformer - def transform(value) - end + def transform(value); end end end end diff --git a/lib/collectionspace/mapper/find_replace_operation.rb b/lib/collectionspace/mapper/find_replace_operation.rb index 1e3e828c..4962059c 100644 --- a/lib/collectionspace/mapper/find_replace_operation.rb +++ b/lib/collectionspace/mapper/find_replace_operation.rb @@ -2,7 +2,6 @@ module CollectionSpace module Mapper - # a single find/replace operation -- one step in a FindReplaceTransformer class FindReplaceOperation def initialize(opts) @@ -19,7 +18,7 @@ def perform(value) def self.create(opts) case opts[:type] when 'plain' - self.new(opts) + new(opts) when 'regex' RegexFindReplaceOperation.new(opts) end diff --git a/lib/collectionspace/mapper/find_replace_transformer.rb b/lib/collectionspace/mapper/find_replace_transformer.rb index 88ab1c56..95dec545 100644 --- a/lib/collectionspace/mapper/find_replace_transformer.rb +++ b/lib/collectionspace/mapper/find_replace_transformer.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper - # carries out a find/replace operation on a given value class FindReplaceTransformer < Transformer def initialize(transform:) diff --git a/lib/collectionspace/mapper/group_column_value.rb b/lib/collectionspace/mapper/group_column_value.rb index 155f4a8a..212edca6 100644 --- a/lib/collectionspace/mapper/group_column_value.rb +++ b/lib/collectionspace/mapper/group_column_value.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper - # a column value destined for a field in a repeating field group class GroupColumnValue < ColumnValue include Repeatable diff --git a/lib/collectionspace/mapper/group_multival_column_value.rb b/lib/collectionspace/mapper/group_multival_column_value.rb index a48ad894..b52ca070 100644 --- a/lib/collectionspace/mapper/group_multival_column_value.rb +++ b/lib/collectionspace/mapper/group_multival_column_value.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper - # a column value destined for a single/non-subgrouped repeating field within a repeating field group class GroupMultivalColumnValue < ColumnValue include Subgroupable diff --git a/lib/collectionspace/mapper/identifiers/authority_short_identifier.rb b/lib/collectionspace/mapper/identifiers/authority_short_identifier.rb index 85e19f4f..116dd98d 100644 --- a/lib/collectionspace/mapper/identifiers/authority_short_identifier.rb +++ b/lib/collectionspace/mapper/identifiers/authority_short_identifier.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper module Identifiers - class AuthorityShortIdentifier < ShortIdentifier def initialize(**opts) super @@ -24,4 +23,3 @@ def hashed_term end end end - diff --git a/lib/collectionspace/mapper/identifiers/short_identifier.rb b/lib/collectionspace/mapper/identifiers/short_identifier.rb index e3147f22..16ba145d 100644 --- a/lib/collectionspace/mapper/identifiers/short_identifier.rb +++ b/lib/collectionspace/mapper/identifiers/short_identifier.rb @@ -3,7 +3,6 @@ module CollectionSpace module Mapper module Identifiers - class ShortIdentifier def initialize(term:) @term = term @@ -22,4 +21,3 @@ def prepped_term end end end - diff --git a/lib/collectionspace/mapper/multival_column_value.rb b/lib/collectionspace/mapper/multival_column_value.rb index 64457ed0..4ff738fc 100644 --- a/lib/collectionspace/mapper/multival_column_value.rb +++ b/lib/collectionspace/mapper/multival_column_value.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper - # a column value destined for a multivalue field nested directly under a namespace element class MultivalColumnValue < ColumnValue include Repeatable diff --git a/lib/collectionspace/mapper/non_hierarchical_relationship_prepper.rb b/lib/collectionspace/mapper/non_hierarchical_relationship_prepper.rb index 748ce314..fa9227a4 100644 --- a/lib/collectionspace/mapper/non_hierarchical_relationship_prepper.rb +++ b/lib/collectionspace/mapper/non_hierarchical_relationship_prepper.rb @@ -7,12 +7,13 @@ module CollectionSpace module Mapper class NonHierarchicalRelationshipPrepper < CollectionSpace::Mapper::DataPrepper include CollectionSpace::Mapper::TermSearchable - attr_reader :errors, :warnings, :responses + attr_reader :errors, :warnings, :responses, :type, :subtype def initialize(data, handler) super @cache = @handler.mapper.termcache @types = [@response.merged_data['item1_type'], @response.merged_data['item2_type']] + @subtype = '' @errors = [] @warnings = [] @responses = [] @@ -65,16 +66,19 @@ def clear_unmapped_mappings @handler.mapper.mappings.reject!{ |mapping| to_clear.include?(mapping.fieldname) } end + def get_rec_csid(id, type) + instance_variable_set(:@type, type) + obj_csid(id, type) + end + def transform_terms %w[item1_id item2_id].each_with_index do |field, i| - transformed = @response.split_data[field].map{ |id| obj_csid(id, @types[i]) } + transformed = @response.split_data[field].map{ |id| get_rec_csid(id, @types[i]) } @response.transformed_data[field] = transformed end @response.split_data.each do |field, value| - unless @response.transformed_data.key?(field) - @response.transformed_data[field] = value - end + @response.transformed_data[field] = value unless @response.transformed_data.key?(field) end end end diff --git a/lib/collectionspace/mapper/object_hierarchy_data_prepper.rb b/lib/collectionspace/mapper/object_hierarchy_data_prepper.rb index 59198d0e..22044cea 100644 --- a/lib/collectionspace/mapper/object_hierarchy_data_prepper.rb +++ b/lib/collectionspace/mapper/object_hierarchy_data_prepper.rb @@ -7,12 +7,13 @@ module CollectionSpace module Mapper class ObjectHierarchyPrepper < CollectionSpace::Mapper::DataPrepper include CollectionSpace::Mapper::TermSearchable - attr_reader :errors, :warnings, :type + attr_reader :errors, :warnings, :type, :subtype def initialize(data, handler) super @cache = @handler.mapper.termcache @type = @response.merged_data['subjectdocumenttype'] + @subtype = '' @errors = [] @warnings = [] end @@ -53,9 +54,7 @@ def transform_terms end @response.split_data.each do |field, value| - unless @response.transformed_data.key?(field) - @response.transformed_data[field] = value - end + @response.transformed_data[field] = value unless @response.transformed_data.key?(field) end end diff --git a/lib/collectionspace/mapper/record_mapper.rb b/lib/collectionspace/mapper/record_mapper.rb index bf9cc6d6..e5ef66bc 100644 --- a/lib/collectionspace/mapper/record_mapper.rb +++ b/lib/collectionspace/mapper/record_mapper.rb @@ -4,7 +4,6 @@ module CollectionSpace module Mapper - # Represents a JSON RecordMapper containing the config, field mappings, and template # for transforming a hash of data into CollectionSpace XML # The RecordMapper bundles up all the info needed by various other classes in order diff --git a/lib/collectionspace/mapper/regex_find_replace_operation.rb b/lib/collectionspace/mapper/regex_find_replace_operation.rb index f9fe5204..1656a6e2 100644 --- a/lib/collectionspace/mapper/regex_find_replace_operation.rb +++ b/lib/collectionspace/mapper/regex_find_replace_operation.rb @@ -2,7 +2,6 @@ module CollectionSpace module Mapper - # a single find/replace operation -- one step in a FindReplaceTransformer class RegexFindReplaceOperation < FindReplaceOperation def perform(value) diff --git a/lib/collectionspace/mapper/response.rb b/lib/collectionspace/mapper/response.rb index 97ee071a..3eb615fc 100644 --- a/lib/collectionspace/mapper/response.rb +++ b/lib/collectionspace/mapper/response.rb @@ -6,6 +6,7 @@ class Response attr_reader :orig_data attr_accessor :split_data, :merged_data, :transformed_data, :combined_data, :doc, :errors, :warnings, :identifier, :terms, :record_status, :csid, :uri, :refname + def initialize(data_hash) @orig_data = data_hash @merged_data = {} @@ -48,4 +49,3 @@ def add_multi_rec_found_warning(num_found) end end end - diff --git a/lib/collectionspace/mapper/row_data.rb b/lib/collectionspace/mapper/row_data.rb index c874e0f2..f1a45567 100644 --- a/lib/collectionspace/mapper/row_data.rb +++ b/lib/collectionspace/mapper/row_data.rb @@ -2,11 +2,11 @@ module CollectionSpace module Mapper - # represents a row of data from a CSV. # ends up having some responsibility for coordinating the processing of the row class RowData attr_reader :columns + def initialize(datahash, recmapper) @recmapper = recmapper @columns = datahash.map do |column, value| diff --git a/lib/collectionspace/mapper/row_fields.rb b/lib/collectionspace/mapper/row_fields.rb index 86fb7a17..4ad01e31 100644 --- a/lib/collectionspace/mapper/row_fields.rb +++ b/lib/collectionspace/mapper/row_fields.rb @@ -5,8 +5,7 @@ module Mapper # aggregate class to work with all of a RecordMapper's CollectionSpace fields in an # Arrayish-fashion class RowFields - def initialize() - end + def initialize; end end end end diff --git a/lib/collectionspace/mapper/structured_date_transformer.rb b/lib/collectionspace/mapper/structured_date_transformer.rb index da6505c8..6c134d4c 100644 --- a/lib/collectionspace/mapper/structured_date_transformer.rb +++ b/lib/collectionspace/mapper/structured_date_transformer.rb @@ -4,11 +4,9 @@ module CollectionSpace module Mapper - # converts date string to CS structured date XML snippet class StructuredDateTransformer < Transformer - def transform(value) - end + def transform(value); end end end end diff --git a/lib/collectionspace/mapper/subgroup_column_value.rb b/lib/collectionspace/mapper/subgroup_column_value.rb index d22c4aff..4113387c 100644 --- a/lib/collectionspace/mapper/subgroup_column_value.rb +++ b/lib/collectionspace/mapper/subgroup_column_value.rb @@ -5,7 +5,6 @@ module CollectionSpace module Mapper - # a column value destined for repeating subgroups of fields within a repeating field group class SubgroupColumnValue < ColumnValue include Subgroupable diff --git a/lib/collectionspace/mapper/term_handler.rb b/lib/collectionspace/mapper/term_handler.rb index c75a6f23..d7a207ce 100644 --- a/lib/collectionspace/mapper/term_handler.rb +++ b/lib/collectionspace/mapper/term_handler.rb @@ -10,6 +10,7 @@ class TermHandler attr_reader :result, :terms, :warnings, :errors, :column, :source_type, :type, :subtype attr_accessor :value + def initialize(mapping:, data:, client:, cache:, mapper:) @mapping = mapping @data = data @@ -39,11 +40,11 @@ def initialize(mapping:, data:, client:, cache:, mapper:) private def handle_terms - if @data.first.is_a?(String) - @result = @data.map{ |val| handle_term(val) } - else - @result = @data.map{ |arr| arr.map{ |val| handle_term(val)} } - end + @result = if @data.first.is_a?(String) + @data.map{ |val| handle_term(val) } + else + @data.map{ |arr| arr.map{ |val| handle_term(val) } } + end end def handle_term(val) @@ -59,41 +60,61 @@ def handle_term(val) } if in_cache?(val) - refname_urn = cached_term(val) + refname_urn = cached_term(val, :refname) if refname_urn add_found_term(refname_urn, term_report) added = true end + elsif cached_as_unknown?(val) + refname_urn = add_known_unknown_term(val, term_report) + added = true else # not in cache - if @config.check_terms - refname_urn = searched_term(val) - if refname_urn - add_found_term(refname_urn, term_report) - added = true - end + refname_urn = searched_term(val, :refname) + if refname_urn + add_found_term(refname_urn, term_report) + added = true end end - unless added - refname_obj = CollectionSpace::Mapper::Tools::RefName.new( - source_type: source_type, - type: type, - subtype: subtype, - term: val, - cache: @cache) - @terms << term_report.merge({found: false, refname: refname_obj}) - @cache.put(type, subtype, val, refname_obj.urn) - refname_urn = refname_obj.urn - end - refname_urn + return refname_urn if added + + add_new_unknown_term(val, term_report) end def add_found_term(refname_urn, term_report) refname_obj = CollectionSpace::Mapper::Tools::RefName.new(urn: refname_urn) - found = @config.check_terms ? true : false + found = true @terms << term_report.merge({found: found, refname: refname_obj}) end + + # the next two methods need to be updated when not-found terms become blocking errors instead + # of warnings. At that point, we no longer want to generate and store a refname for the + # term, since it will not be mapped. + # at the point of switching error, the termtype and termsubtype parameters can be removed from + # cached_term + def add_new_unknown_term(val, term_report) + refname_obj = CollectionSpace::Mapper::Tools::RefName.new( + source_type: source_type, + type: type, + subtype: subtype, + term: val, + cache: @cache + ) + + @terms << term_report.merge({found: false, refname: refname_obj}) + refname_url = refname_obj.urn + @cache.put('unknownvalue', type_subtype, val, {refname: refname_url, csid: nil}) + refname_url + end + + def add_known_unknown_term(val, term_report) + refname_url = cached_term(val, :refname, 'unknownvalue', "#{type}/#{subtype}") + # refname_url = @cache.get('unknownvalue', type_subtype, val)[:refname] + refname_obj = CollectionSpace::Mapper::Tools::RefName.new(urn: refname_url) + @terms << term_report.merge({found: false, refname: refname_obj}) + add_missing_record_error('term', val) + refname_url + end end end end - diff --git a/lib/collectionspace/mapper/term_searchable.rb b/lib/collectionspace/mapper/term_searchable.rb index 27330aca..9d7552f1 100644 --- a/lib/collectionspace/mapper/term_searchable.rb +++ b/lib/collectionspace/mapper/term_searchable.rb @@ -4,187 +4,204 @@ module CollectionSpace module Mapper module TermSearchable def in_cache?(val) - @cache.exists?(type, subtype, val) + return true if @cache.exists?(type, subtype, val) + return true if @cache.exists?(type, subtype, case_swap(val)) + + false end - def cached_term(val) - @cache.get(type, subtype, val, search: false) + # returns whether value is cached as an unknownvalue + def cached_as_unknown?(val) + return true if @cache.exists?('unknownvalue', type_subtype, val) + return true if @cache.exists?('unknownvalue', type_subtype, case_swap(val)) + + false end - def get_vocabulary_term(vocab:, term:) - result = @cache.get('vocabularies', vocab, term, search: true) - return result unless result.nil? + private def type_subtype + "#{type}/#{subtype}" + end - if has_caps?(term) - @cache.get('vocabularies', vocab, term.downcase, search: true) - else - @cache.get('vocabularies', vocab, term.capitalize, search: true) - end + # returns refName of cached term + def cached_term(val, return_key = :refname, termtype = type, termsubtype = subtype) + returned = @cache.get(termtype, termsubtype, val, search: false) + return convert_cached_value(returned)[return_key] if returned + + returned = @cache.get(termtype, termsubtype, case_swap(val), search: false) + return convert_cached_value(returned)[return_key] if returned end - def has_caps?(string) - string.match?(/[A-Z]/) ? true : false + private def convert_cached_value(cache_response) + return cache_response if cache_response.is_a?(Hash) + + instance_eval(cache_response) end - def searched_term(val) - begin - response = @client.find( - type: type, - subtype: subtype, - value: val, - field: search_field - ) - rescue StandardError => e - puts e.message - else - response_term_refname(response) - end + # returns refName of searched (term) + def searched_term(val, return_key = :refname) + response = term_search_response(val) + + rec = rec_from_response('term', val, response) + return nil unless rec + + cache_value = {refname: rec['refName'], csid: rec['csid']} + @cache.put(type, subtype, val, cache_value) + cache_value[return_key] end - def obj_csid(objnum, type) - csid = @cache.get(type, '', objnum) - csid ? extract_refname_csid(csid) : lookup_obj_csid(objnum, type) + private def case_swap(string) + string.match?(/[A-Z]/) ? string.downcase : string.capitalize + end + + private def term_search_response(val) + as_is = get_term_response(val) + return as_is if term_response_usable?(as_is) + + get_term_response(case_swap(val)) end - def extract_refname_csid(urn) - urn.match(/:id\((.*?)\)/)[1] + private def get_term_response(val) + response = @client.find( + type: type, + subtype: subtype, + value: val, + field: search_field + ) + rescue StandardError => e + puts e.message + nil + else + parse_response(response) end - - def lookup_obj_csid(objnum, type) + + private def parse_response(response) + parsed = response.parsed['abstract_common_list'] + rescue StandardError => e + puts e.message + nil + else + parsed + end + + def obj_csid(objnum, type) + cached = @cache.get(type, '', objnum, search: false) + return convert_cached_value(cached)[:csid] if cached + + lookup_obj_or_procedure_csid(objnum, type) + end + + def lookup_obj_or_procedure_csid(objnum, type) + category = 'object_or_procedure' response = @client.find(type: type, value: objnum) if response.result.success? - result = response.parsed['abstract_common_list'] - term_ct = result['totalItems'].to_i - case term_ct - when 0 - errors << { - category: :no_records_found_with_objnum, - field: '', - type: type, - subtype: '', - value: objnum, - message: "#{term_ct} records found." - } - csid = nil - when 1 - csid = result['list_item']['csid'] - else - rec = result['list_item'][0] - using_uri = "#{@client.config.base_uri}#{rec['uri']}" - csid = rec['csid'] - warnings << { - category: :multiple_records_found_with_objnum, - field: '', - type: type, - subtype: '', - value: objnum, - message: "#{term_ct} records found. Using #{using_uri}" - } - end - - return csid if csid.nil? - - @cache.put(type, '', objnum, csid) - return csid + rec = rec_from_response(category, objnum, parse_response(response)) + return nil unless rec + + csid = rec['csid'] + @cache.put(type, '', objnum, {refname: rec['refName'], csid: csid}) + csid else errors << { - category: :unsuccessful_csid_lookup_for_objnum, + category: "unsuccessful_csid_lookup_for_#{category}".to_sym, field: '', subtype: '', type: type, value: objnum, message: "Problem with search for #{objnum}." } - return nil + nil end end def term_csid(term) - # This is currently working though it returns the cached refname urn instead of CSID - # if a term is cached. There's a lot of stuff to clean up/fix/test better here so - # I'm leaving this for now to get the bugfix in - csid = cached_term(term) - return csid unless csid.nil? + cached = cached_term(term, :csid) + return cached if cached - field = CollectionSpace::Service.get(type: type)[:term] + searched_term(term, :csid) + end - response = @client.find(type: type, subtype: subtype, field: field, value: term) - if response.result.success? - result = response.parsed['abstract_common_list'] - term_ct = result['totalItems'].to_i - case term_ct - when 0 - errors << { - category: :no_records_found_for_term, - field: '', - type: type, - subtype: subtype, - value: term, - message: "#{term_ct} records found." - } - csid = nil - when 1 - csid = result['list_item']['csid'] - else - rec = result['list_item'][0] - using_uri = "#{@client.config.base_uri}#{rec['uri']}" - csid = rec['csid'] - warnings << { - category: :multiple_records_found_for_term, - field: '', - type: type, - subtype: subtype, - value: term, - message: "#{term_ct} records found. Using #{using_uri}" - } - end - - return csid if csid.nil? - - @cache.put(type, subtype, term, csid) - return csid - else + private def term_response_usable?(response) + ct = response_item_count(response) + return false unless ct + return false if ct == 0 + + true + end + + private def response_item_count(response) + ct = response.dig('totalItems') + return ct.to_i if ct + + nil + end + + private def add_missing_record_error(category, val) + datacolumn = column ||= 'data' + + errors << { + category: "no_records_found_for_#{category}".to_sym, + field: '', + type: '', + subtype: '', + value: val, + message: "#{val} (#{type_subtype} in #{datacolumn} column)" + } + end + + private def rec_from_response(category, val, response) + term_ct = response_item_count(response) + + unless term_ct errors << { - category: :unsuccessful_csid_lookup_for_term, + category: "unsuccessful_csid_lookup_for_#{category}".to_sym, field: '', type: type, subtype: subtype, - value: term, - message: "Problem with search for #{term}" + value: val, + message: "Problem with search for #{val}" } return nil end - end - def response_term_refname(response) - term_ct = response.parsed.dig('abstract_common_list', 'totalItems') - return nil if term_ct.nil? - - if term_ct.to_i == 1 - refname = response.parsed.dig('abstract_common_list', 'list_item', 'refName') - elsif term_ct.to_i > 1 - rec = response.parsed.dig('abstract_common_list', 'list_item')[0] + case term_ct + when 0 + add_missing_record_error(category, val) + rec = nil + when 1 + rec = response['list_item'] + else + rec = response['list_item'][0] using_uri = "#{@client.config.base_uri}#{rec['uri']}" - refname = rec['refName'] warnings << { - category: :multiple_records_found_for_term, - field: column, + category: "multiple_records_found_for_#{category}".to_sym, + field: '', type: type, subtype: subtype, - value: value, + value: val, message: "#{term_ct} records found. Using #{using_uri}" } end - refname + + rec + end + + private def search_field + field = CollectionSpace::Service.get(type: type)[:term] + rescue StandardError => e + puts e.message + else + field end - def search_field - begin - field = CollectionSpace::Service.get(type: type)[:term] - rescue StandardError => e - puts e.message + # added toward refactoring that isn't done yet + def get_vocabulary_term(vocab:, term:) + result = @cache.get('vocabularies', vocab, term, search: true) + return result unless result.nil? + + if has_caps?(term) + @cache.get('vocabularies', vocab, term.downcase, search: true) else - field + @cache.get('vocabularies', vocab, term.capitalize, search: true) end end end diff --git a/lib/collectionspace/mapper/tools/dates.rb b/lib/collectionspace/mapper/tools/dates.rb index 6de3caba..3c1c5fe7 100644 --- a/lib/collectionspace/mapper/tools/dates.rb +++ b/lib/collectionspace/mapper/tools/dates.rb @@ -36,7 +36,7 @@ def initialize(date_string, client, cache, config) service_parseable_month_formats = [ '^\w+ \d{4}$', - '^\d{4} \w+$', + '^\d{4} \w+$' ].map{ |f| Regexp.new(f) } other_month_formats = [ @@ -49,8 +49,7 @@ def initialize(date_string, client, cache, config) elsif date_string == THE_BOMB @timestamp = date_string blow_up_date - elsif - date_formats.any?{ |re| @date_string.match?(re) } + elsif date_formats.any?{ |re| @date_string.match?(re) } try_chronic_parse(@date_string) @timestamp ? create_mappable_date : try_services_query elsif two_digit_year_date_formats.any?{ |re| @date_string.match?(re) } @@ -78,23 +77,23 @@ def coerced_year_date val = @date_string.gsub('/', '-').split('-') yr = val.pop this_year = Time.now.year.to_s - this_year_century = this_year[0,2] - this_year_last_two = this_year[2,2].to_i - - if yr.to_i > this_year_last_two - val << "#{this_year_century.to_i - 1}#{yr}" - else - val << "#{this_year_century}#{yr}" - end + this_year_century = this_year[0, 2] + this_year_last_two = this_year[2, 2].to_i + + val << if yr.to_i > this_year_last_two + "#{this_year_century.to_i - 1}#{yr}" + else + "#{this_year_century}#{yr}" + end val.join('-') end def try_chronic_parse(string) - if @config.date_format == 'day month year' - @timestamp = Chronic.parse(string, endian_precedence: :little) - else - @timestamp = Chronic.parse(string) - end + @timestamp = if @config.date_format == 'day month year' + Chronic.parse(string, endian_precedence: :little) + else + Chronic.parse(string) + end end def create_mappable_passthrough @@ -172,24 +171,23 @@ def try_services_query @mappable = fix_services_scalars(result) else @mappable = {'dateDisplayDate' => date_string, - 'scalarValuesComputed' => 'false' - } + 'scalarValuesComputed' => 'false'} end end def fix_services_scalars(services_result) new_hash = {} services_result.each do |k, v| - if k.end_with?('ScalarValue') - new_hash[k] = "#{v}#{@timestamp_suffix}" - else - new_hash[k] = v - end + new_hash[k] = if k.end_with?('ScalarValue') + "#{v}#{@timestamp_suffix}" + else + v + end end new_hash end - def map(doc, parentnode, groupname) + def map(_doc, _parentnode, _groupname) @parser_result.each do |datefield, value| value = DateTime.parse(value).iso8601(3).sub('+00:00', 'Z') if datefield['ScalarValue'] end diff --git a/lib/collectionspace/mapper/tools/record_status_service.rb b/lib/collectionspace/mapper/tools/record_status_service.rb index 07158f51..a0c77b50 100644 --- a/lib/collectionspace/mapper/tools/record_status_service.rb +++ b/lib/collectionspace/mapper/tools/record_status_service.rb @@ -4,6 +4,7 @@ module CollectionSpace module Mapper class MultipleCsRecordsFoundError < StandardError attr_reader :message + def initialize(count) @message = "#{count} matching records found in CollectionSpace. Cannot determine which to update." end @@ -16,7 +17,7 @@ class RecordStatusService def initialize(client, mapper) @client = client @mapper = mapper - @is_authority = @mapper.config.service_type == 'authority' ? true : false + @is_authority = @mapper.config.service_type == 'authority' service = get_service @search_field = @is_authority ? service[:term] : service[:field] @ns_prefix = service[:ns_prefix] @@ -30,11 +31,11 @@ def initialize(client, mapper) # collectionspace-client code. # Tests in examples/search.rb def lookup(value) - if @ns_prefix == 'relations' - response = @client.find_relation(subject_csid: value[:sub], object_csid: value[:obj]) - else - response = lookup_non_relationship(value) - end + response = if @ns_prefix == 'relations' + @client.find_relation(subject_csid: value[:sub], object_csid: value[:obj]) + else + lookup_non_relationship(value) + end ct = count_results(response) if ct == 0 @@ -42,18 +43,18 @@ def lookup(value) elsif ct == 1 reportable_result(response.parsed[@response_top][@response_nested]) elsif ct > 1 - raise CollectionSpace::Mapper::MultipleCsRecordsFoundError.new(ct) unless use_first? + raise CollectionSpace::Mapper::MultipleCsRecordsFoundError, ct unless use_first? item = response.parsed[@response_top][@response_nested].first num_found = response.parsed[@response_top][@response_nested].length - reportable_result(item).merge({ multiple_recs_found: num_found}) + reportable_result(item).merge({multiple_recs_found: num_found}) end end private def reportable_result(item = nil) - return { status: :new } unless item + return {status: :new} unless item { status: :existing, @@ -62,7 +63,7 @@ def reportable_result(item = nil) refname: item['refName'] } end - + def lookup_non_relationship(value) @client.find( type: @mapper.config.service_path, @@ -77,11 +78,9 @@ def use_first? false end - + def count_results(response) - unless response.result.success? - raise CollectionSpace::RequestError, response.result.body - end + raise CollectionSpace::RequestError, response.result.body unless response.result.success? response.parsed[@response_top]['totalItems'].to_i end diff --git a/lib/collectionspace/mapper/tools/refname.rb b/lib/collectionspace/mapper/tools/refname.rb index fc6fbe71..80708eed 100644 --- a/lib/collectionspace/mapper/tools/refname.rb +++ b/lib/collectionspace/mapper/tools/refname.rb @@ -4,7 +4,7 @@ module CollectionSpace module Mapper module Tools class RefNameArgumentError < ArgumentError - def initialize(msg='Arguments requires either :urn OR :source_type, :type, :subtype, :term, :cache values') + def initialize(msg = 'Arguments requires either :urn OR :source_type, :type, :subtype, :term, :cache values') super end end @@ -24,7 +24,7 @@ def initialize(args) new_from_urn elsif args_given == term_args cache = args[:cache] - @domain = cache.domain.sub(/https?:\/\//, '').sub('/cspace-services', '') + @domain = cache.domain.sub(%r{https?://}, '').sub('/cspace-services', '') @type = args[:type] @subtype = args[:subtype] @display_name = args[:term] @@ -43,7 +43,6 @@ def build_urn end def new_from_term - @identifier = CollectionSpace::Mapper::Identifiers::ShortIdentifier.new(term: @display_name).value end @@ -52,9 +51,9 @@ def new_from_authority_term end def new_from_urn - if /^urn:cspace:([^:]+):([^:]+):name\(([^\)]+)\):item:name\(([^\)]+)\)'/.match?(@urn) + if /^urn:cspace:([^:]+):([^:]+):name\(([^)]+)\):item:name\(([^)]+)\)'/.match?(@urn) term_parts_from_urn - elsif /^urn:cspace:([^:]+):([^:]+):id\(([^\)]+)\)(.*)/.match?(@urn) + elsif /^urn:cspace:([^:]+):([^:]+):id\(([^)]+)\)(.*)/.match?(@urn) non_term_parts_from_urn else raise CS::Mapper::Tools::UnparseableUrnError @@ -62,7 +61,7 @@ def new_from_urn end def term_parts_from_urn - parts = @urn.match(/^urn:cspace:([^:]+):([^:]+):name\(([^\)]+)\):item:name\(([^\)]+)\)'/) + parts = @urn.match(/^urn:cspace:([^:]+):([^:]+):name\(([^)]+)\):item:name\(([^)]+)\)'/) @domain = parts[1] @type = parts[2] @subtype = parts[3] @@ -71,7 +70,7 @@ def term_parts_from_urn end def non_term_parts_from_urn - parts = @urn.match(/^urn:cspace:([^:]+):([^:]+):id\(([^\)]+)\)(.*)/) + parts = @urn.match(/^urn:cspace:([^:]+):([^:]+):id\(([^)]+)\)(.*)/) @domain = parts[1] @type = parts[2] @subtype = nil diff --git a/lib/collectionspace/mapper/tools/symbolizable.rb b/lib/collectionspace/mapper/tools/symbolizable.rb index 44228739..955fea88 100644 --- a/lib/collectionspace/mapper/tools/symbolizable.rb +++ b/lib/collectionspace/mapper/tools/symbolizable.rb @@ -11,7 +11,7 @@ def symbolize(hash) end def symbolize_transforms(transforms) - transforms.each do |field, fieldtransform| + transforms.each do |_field, fieldtransform| fieldtransform.transform_keys!(&:to_sym) next unless replacements?(fieldtransform) @@ -30,4 +30,3 @@ def replacements?(fieldtransform) end end end - diff --git a/lib/collectionspace/mapper/transformer.rb b/lib/collectionspace/mapper/transformer.rb index f6a30e8c..2313e0c2 100644 --- a/lib/collectionspace/mapper/transformer.rb +++ b/lib/collectionspace/mapper/transformer.rb @@ -2,18 +2,16 @@ module CollectionSpace module Mapper - # parent class of the data value Transformer class hierarchy class Transformer attr_reader :precedence, :warnings - def initialize(opts = {}) + def initialize(_opts = {}) @precedence = lookup_precedence @warnings = [] end - def transform(value) - end + def transform(value); end def <=>(other) @precedence <=> other.precedence @@ -35,7 +33,7 @@ def lookup_precedence ].find_index(self.class) end - def self.create(type:, transform: {}, recmapper:) + def self.create(type:, recmapper:, transform: {}) case type.to_sym when :authority AuthorityTransformer.new(transform: transform, recmapper: recmapper) diff --git a/lib/collectionspace/mapper/transformers.rb b/lib/collectionspace/mapper/transformers.rb index 5d972058..ce98f9c8 100644 --- a/lib/collectionspace/mapper/transformers.rb +++ b/lib/collectionspace/mapper/transformers.rb @@ -2,7 +2,6 @@ module CollectionSpace module Mapper - # aggregate representation of transformers associated with a ColumnMapping (queue) # Performs a factory function by creating the appropriate individual Transformers for a given # ColumnMapping based on data_type diff --git a/lib/collectionspace/mapper/value_transformer.rb b/lib/collectionspace/mapper/value_transformer.rb index 01994d61..f68d1072 100644 --- a/lib/collectionspace/mapper/value_transformer.rb +++ b/lib/collectionspace/mapper/value_transformer.rb @@ -5,6 +5,7 @@ module Mapper class ValueTransformer include TermSearchable attr_reader :orig, :result, :warnings, :errors + def initialize(value, transforms, prepper) @value = value @orig = @value.clone @@ -31,14 +32,14 @@ def initialize(value, transforms, prepper) 't' => 'true', 'f' => 'false' } - + def process_replacements return if @value.empty? @transforms[:replacements].each do |rule| find = rule[:find] replace = rule[:replace] - + case rule[:type] when :plain @value = @value.gsub(find, replace) @@ -69,7 +70,7 @@ def process_boolean @value = BOOLEAN_LOOKUP[chkval] return end - + @value = 'false' @warnings << { category: :boolean_value_transform, @@ -99,4 +100,3 @@ def process_behrensmeyer end end end - diff --git a/lib/collectionspace/mapper/version.rb b/lib/collectionspace/mapper/version.rb index 8bcbd0b2..95e22855 100644 --- a/lib/collectionspace/mapper/version.rb +++ b/lib/collectionspace/mapper/version.rb @@ -2,6 +2,6 @@ module CollectionSpace module Mapper - VERSION = '2.5.2' + VERSION = '3.0.0' end end diff --git a/lib/collectionspace/mapper/vocabulary_transformer.rb b/lib/collectionspace/mapper/vocabulary_transformer.rb index d438236c..0416fba8 100644 --- a/lib/collectionspace/mapper/vocabulary_transformer.rb +++ b/lib/collectionspace/mapper/vocabulary_transformer.rb @@ -4,10 +4,8 @@ module CollectionSpace module Mapper - # transforms vocabulary term into RefName class VocabularyTransformer < Transformer - def initialize(opts) super @type = 'vocabularies' @@ -17,8 +15,7 @@ def initialize(opts) @csclient = mapper.csclient end - def transform(value) - end + def transform(value); end end end end diff --git a/lib/collectionspace/mapper/xml_template.rb b/lib/collectionspace/mapper/xml_template.rb index 18fbf616..783d3f7e 100644 --- a/lib/collectionspace/mapper/xml_template.rb +++ b/lib/collectionspace/mapper/xml_template.rb @@ -2,7 +2,6 @@ module CollectionSpace module Mapper - # The XML document structure for a given record type. # Knows the structure as a Hash provided by initial JSON record mapper # Provides a blank XML document with all namespace and field group elements @@ -36,9 +35,9 @@ def create_record_namespace_nodes(xml) def process_group(xml, grouppath) @docstructure.dig(*grouppath).keys.each do |key| thispath = grouppath.clone.append(key) - xml.send(key){ + xml.send(key) do process_group(xml, thispath) - } + end end end end diff --git a/spec/anthro_helpers.rb b/spec/anthro_helpers.rb index a4dae142..fcbf8d58 100644 --- a/spec/anthro_helpers.rb +++ b/spec/anthro_helpers.rb @@ -27,159 +27,159 @@ def anthro_object_mapper def populate_anthro(cache) terms = [ ['conceptauthorities', 'archculture', 'Blackfoot', - "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(archculture):item:name(Blackfoot1576172504869)'Blackfoot'"], + {refname: "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(archculture):item:name(Blackfoot1576172504869)'Blackfoot'", csid: '1111-2222-3333-4444'}], ['conceptauthorities', 'concept', 'Birds', - "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(concept):item:name(Birds918181)'Birds'"], + {refname: "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(concept):item:name(Birds918181)'Birds'", csid: '1111-2222-3333-4444'}], ['conceptauthorities', 'ethculture', 'Batak', - "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(ethculture):item:name(Batak1576172496916)'Batak'"], + {refname: "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(ethculture):item:name(Batak1576172496916)'Batak'", csid: '1111-2222-3333-4444'}], ['conceptauthorities', 'ethculture', 'Got', - "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(ethculture):item:name(Got1599824429903)'Got'"], + {refname: "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(ethculture):item:name(Got1599824429903)'Got'", csid: '1111-2222-3333-4444'}], ['conceptauthorities', 'ethculture', 'Hero', - "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(ethculture):item:name(Hero1599824418804)'Hero'"], + {refname: "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(ethculture):item:name(Hero1599824418804)'Hero'", csid: '1111-2222-3333-4444'}], ['conceptauthorities', 'material_ca', 'Feathers', - "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(material_ca):item:name(Feathers918181)'Feathers'"], + {refname: "urn:cspace:anthro.collectionspace.org:conceptauthorities:name(material_ca):item:name(Feathers918181)'Feathers'", csid: '1111-2222-3333-4444'}], ['orgauthorities', 'organization', 'Hola', - "urn:cspace:anthro.collectionspace.org:orgauthorities:name(organization):item:name(Hola1599824351945)'Hola'"], + {refname: "urn:cspace:anthro.collectionspace.org:orgauthorities:name(organization):item:name(Hola1599824351945)'Hola'", csid: '1111-2222-3333-4444'}], ['orgauthorities', 'organization', 'Organization 1', - "urn:cspace:anthro.collectionspace.org:orgauthorities:name(organization):item:name(Organization11587136583004)'Organization 1'"], + {refname: "urn:cspace:anthro.collectionspace.org:orgauthorities:name(organization):item:name(Organization11587136583004)'Organization 1'", csid: '1111-2222-3333-4444'}], ['orgauthorities', 'organization', 'chores', - "urn:cspace:anthro.collectionspace.org:orgauthorities:name(organization):item:name(chores1599824370125)'chores'"], + {refname: "urn:cspace:anthro.collectionspace.org:orgauthorities:name(organization):item:name(chores1599824370125)'chores'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Ann Analyst', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(AnnAnalyst1594848799340)'Ann Analyst'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(AnnAnalyst1594848799340)'Ann Analyst'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Gabriel Solares', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(GabrielSolares1594848906847)'Gabriel Solares'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(GabrielSolares1594848906847)'Gabriel Solares'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Tegla', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(Tegla1599824325923)'Tegla'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(Tegla1599824325923)'Tegla'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Tom', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(Tom1599824331955)'Tom'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(Tom1599824331955)'Tom'", csid: '1111-2222-3333-4444'}], ['placeauthorities', 'place', 'Early', - "urn:cspace:anthro.collectionspace.org:placeauthorities:name(place):item:name(Early1599824413345)'Early'"], + {refname: "urn:cspace:anthro.collectionspace.org:placeauthorities:name(place):item:name(Early1599824413345)'Early'", csid: '1111-2222-3333-4444'}], ['placeauthorities', 'place', 'Local', - "urn:cspace:anthro.collectionspace.org:placeauthorities:name(place):item:name(Local1599824385298)'Local'"], + {refname: "urn:cspace:anthro.collectionspace.org:placeauthorities:name(place):item:name(Local1599824385298)'Local'", csid: '1111-2222-3333-4444'}], ['placeauthorities', 'place', 'York County, Pennsylvania', - "urn:cspace:anthro.collectionspace.org:placeauthorities:name(place):item:name(YorkCountyPennsylvania)'York County, Pennsylvania'"], + {refname: "urn:cspace:anthro.collectionspace.org:placeauthorities:name(place):item:name(YorkCountyPennsylvania)'York County, Pennsylvania'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'agerange', 'adolescent 26-75%', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(agerange):item:name(adolescent_26_75)'adolescent 26-75%'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(agerange):item:name(adolescent_26_75)'adolescent 26-75%'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'agerange', 'adult 0-25%', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(agerange):item:name(adult_0_25)'adult 0-25%'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(agerange):item:name(adult_0_25)'adult 0-25%'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'annotationtype', 'image made', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(annotationtype):item:name(image_made)'image made'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(annotationtype):item:name(image_made)'image made'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'annotationtype', 'type', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(annotationtype):item:name(type)'type'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(annotationtype):item:name(type)'type'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', '0 - no cracking or flaking on bone surface', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(0)'0 - no cracking or flaking on bone surface'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(0)'0 - no cracking or flaking on bone surface'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', '1 - longitudinal and/or mosaic cracking present on surface', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(1)'1 - longitudinal and/or mosaic cracking present on surface'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(1)'1 - longitudinal and/or mosaic cracking present on surface'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', '2 - longitudinal cracks, exfoliation on surface', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(2)'2 - longitudinal cracks, exfoliation on surface'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(2)'2 - longitudinal cracks, exfoliation on surface'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', '3 - fibrous texture, extensive exfoliation', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(3)'3 - fibrous texture, extensive exfoliation'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(3)'3 - fibrous texture, extensive exfoliation'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', '5 - bone crumbling in situ, large splinters', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(5)'5 - bone crumbling in situ, large splinters'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(5)'5 - bone crumbling in situ, large splinters'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'bodyside', 'midline', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(bodyside):item:name(midline)'midline'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(bodyside):item:name(midline)'midline'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'inventorystatus', 'accessioned', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(inventorystatus):item:name(accessioned)'accessioned'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(inventorystatus):item:name(accessioned)'accessioned'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'inventorystatus', 'unknown', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(inventorystatus):item:name(unknown)'unknown'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(inventorystatus):item:name(unknown)'unknown'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'Chinese', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(zho)'Chinese'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(zho)'Chinese'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'English', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(eng)'English'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(eng)'English'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'French', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(fra)'French'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(fra)'French'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'German', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(deu)'German'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(deu)'German'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'Spanish', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'limitationlevel', 'recommendation', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationlevel):item:name(recommendation)'recommendation'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationlevel):item:name(recommendation)'recommendation'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'limitationlevel', 'restriction', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationlevel):item:name(restriction)'restriction'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationlevel):item:name(restriction)'restriction'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'limitationtype', 'lending', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationtype):item:name(lending)'lending'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationtype):item:name(lending)'lending'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'limitationtype', 'publication', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationtype):item:name(publication)'publication'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(limitationtype):item:name(publication)'publication'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'mortuarytreatment', 'burned/unburned bone mixture', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(burnedunburnedbonemixture)'burned/unburned bone mixture'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(burnedunburnedbonemixture)'burned/unburned bone mixture'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'mortuarytreatment', 'enbalmed', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(enbalmed)'enbalmed'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(enbalmed)'enbalmed'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'mortuarytreatment', 'excarnated', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(excarnated)'excarnated'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(excarnated)'excarnated'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'mortuarytreatment', 'mummified', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(mummified)'mummified'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(mummified)'mummified'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpracategory', 'not subject to NAGPRA', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpracategory):item:name(nonNagpra)'not subject to NAGPRA'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpracategory):item:name(nonNagpra)'not subject to NAGPRA'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpracategory', 'subject to NAGPRA (unspec.)', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpracategory):item:name(subjectToNAGPRA)'subject to NAGPRA (unspec.)'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpracategory):item:name(subjectToNAGPRA)'subject to NAGPRA (unspec.)'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpraclaimtype', 'affiliated human skeletal remains (HSR)', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(affiliatedHsr)'affiliated human skeletal remains (HSR)'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(affiliatedHsr)'affiliated human skeletal remains (HSR)'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpraclaimtype', 'needs further research', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(needsFurtherResearch)'needs further research'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(needsFurtherResearch)'needs further research'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpraclaimtype', 'not subject to NAGPRA', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(nonNagpra)'not subject to NAGPRA'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(nonNagpra)'not subject to NAGPRA'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpraclaimtype', 'object of cultural patrimony', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(objectOfCulturalPatrimony)'object of cultural patrimony'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(objectOfCulturalPatrimony)'object of cultural patrimony'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'nagpraclaimtype', 'unassociated funerary object (UFO)', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(ufo)'unassociated funerary object (UFO)'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(nagpraclaimtype):item:name(ufo)'unassociated funerary object (UFO)'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'prodpeoplerole', 'designed after', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(prodpeoplerole):item:name(designedAfter)'designed after'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(prodpeoplerole):item:name(designedAfter)'designed after'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'prodpeoplerole', 'traditional makers', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(prodpeoplerole):item:name(traditionalMakers)'traditional makers'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(prodpeoplerole):item:name(traditionalMakers)'traditional makers'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'publishto', 'DPLA', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(publishto):item:name(dpla)'DPLA'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(publishto):item:name(dpla)'DPLA'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'publishto', 'Omeka', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(publishto):item:name(omeka)'Omeka'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(publishto):item:name(omeka)'Omeka'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'cranialdeformationcategory', 'other (describe)', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(cranialdeformationcategory):item:name(other)'other (describe)'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(cranialdeformationcategory):item:name(other)'other (describe)'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'cranialdeformationcategory', 'tabular', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(cranialdeformationcategory):item:name(tabular)'tabular'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(cranialdeformationcategory):item:name(tabular)'tabular'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'cranialdeformationcategory', 'circumferential', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(cranialdeformationcategory):item:name(circumferential)'circumferential'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(cranialdeformationcategory):item:name(circumferential)'circumferential'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationcertainty', 'possible trepanation', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationcertainty):item:name(possible)'possible trepanation'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationcertainty):item:name(possible)'possible trepanation'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationcertainty', 'clear evidence of trepanation', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationcertainty):item:name(clear)'clear evidence of trepanation'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationcertainty):item:name(clear)'clear evidence of trepanation'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationtechnique', 'grooving', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationtechnique):item:name(grooving)'grooving'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationtechnique):item:name(grooving)'grooving'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationtechnique', 'grooving', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationtechnique):item:name(grooving)'grooving'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationtechnique):item:name(grooving)'grooving'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationhealing', 'possible healing', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationhealing):item:name(possible)'possible healing'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationhealing):item:name(possible)'possible healing'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationhealing', 'no healing', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationhealing):item:name(none)'no healing'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationhealing):item:name(none)'no healing'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'trepanationhealing', 'definite evidence for healing', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationhealing):item:name(definite)'definite evidence for healing'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(trepanationhealing):item:name(definite)'definite evidence for healing'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'mortuarytreatment', 'excarnated', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(excarnated)'excarnated'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(mortuarytreatment):item:name(excarnated)'excarnated'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', '3 - fibrous texture, extensive exfoliation', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(3)'3 - fibrous texture, extensive exfoliation'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(3)'3 - fibrous texture, extensive exfoliation'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'osteocompleteness', 'mandible only', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(osteocompleteness):item:name(mandible)'mandible only'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(osteocompleteness):item:name(mandible)'mandible only'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'behrensmeyer', - '4 - coarsely fibrous texture, splinters of bone loose on the surface, open cracks', "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(4)'4 - coarsely fibrous texture, splinters of bone loose on the surface, open cracks'"], + '4 - coarsely fibrous texture, splinters of bone loose on the surface, open cracks', {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(behrensmeyer):item:name(4)'4 - coarsely fibrous texture, splinters of bone loose on the surface, open cracks'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dentitionscore', 'not applicable', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dentitionscore):item:name(notapplicable)'not applicable'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dentitionscore):item:name(notapplicable)'not applicable'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'sniper', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(sniper1599821165616)'sniper'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(sniper1599821165616)'sniper'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'fullclip', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(fullclip1599821193344)'fullclip'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(fullclip1599821193344)'fullclip'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'fullclip', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(fullclip1599821140041)'fullclip'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(fullclip1599821140041)'fullclip'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'praya', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(praya1599821095120)'praya'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(praya1599821095120)'praya'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'jijoe', - "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(jijoe1599821246989)'jijoe'"], + {refname: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(jijoe1599821246989)'jijoe'", csid: '1111-2222-3333-4444'}] ] populate(cache, terms) end diff --git a/spec/bonsai_helpers.rb b/spec/bonsai_helpers.rb index 22958b3d..3a705217 100644 --- a/spec/bonsai_helpers.rb +++ b/spec/bonsai_helpers.rb @@ -22,27 +22,27 @@ def bonsai_cache def populate_bonsai(cache) terms = [ ['orgauthorities', 'organization', 'Bonsai Museum', - "urn:cspace:bonsai.collectionspace.org:orgauthorities:name(organization):item:name(BonsaiMuseum1598919439027)'Bonsai Museum'"], + {refname: "urn:cspace:bonsai.collectionspace.org:orgauthorities:name(organization):item:name(BonsaiMuseum1598919439027)'Bonsai Museum'", csid: '1111-2222-3333-4444'}], ['orgauthorities', 'organization', 'Bonsai Store', - "urn:cspace:bonsai.collectionspace.org:orgauthorities:name(organization):item:name(BonsaiStore1598920297843)'Bonsai Store'"], + {refname: "urn:cspace:bonsai.collectionspace.org:orgauthorities:name(organization):item:name(BonsaiStore1598920297843)'Bonsai Store'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Ann Authorizer', - "urn:cspace:bonsai.collectionspace.org:personauthorities:name(person):item:name(AnnAuthorizer1598919551068)'Ann Authorizer'"], + {refname: "urn:cspace:bonsai.collectionspace.org:personauthorities:name(person):item:name(AnnAuthorizer1598919551068)'Ann Authorizer'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Debbie Depositor', - "urn:cspace:bonsai.collectionspace.org:personauthorities:name(person):item:name(DebbieDepositor1598919493867)'Debbie Depositor'"], + {refname: "urn:cspace:bonsai.collectionspace.org:personauthorities:name(person):item:name(DebbieDepositor1598919493867)'Debbie Depositor'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Priscilla Plantsale', - "urn:cspace:bonsai.collectionspace.org:personauthorities:name(person):item:name(PriscillaPlantsale1598920259864)'Priscilla Plantsale'"], + {refname: "urn:cspace:bonsai.collectionspace.org:personauthorities:name(person):item:name(PriscillaPlantsale1598920259864)'Priscilla Plantsale'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'currency', 'Canadian Dollar', - "urn:cspace:bonsai.collectionspace.org:vocabularies:name(currency):item:name(CAD)'Canadian Dollar'"], + {refname: "urn:cspace:bonsai.collectionspace.org:vocabularies:name(currency):item:name(CAD)'Canadian Dollar'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:anthro.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'deaccessionapprovalgroup', 'collection committee', - "urn:cspace:bonsai.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(collection_committee)'collection committee'"], + {refname: "urn:cspace:bonsai.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(collection_committee)'collection committee'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'deaccessionapprovalstatus', 'approved', - "urn:cspace:bonsai.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(approved)'approved'"], + {refname: "urn:cspace:bonsai.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(approved)'approved'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'deaccessionapprovalstatus', 'not required', - "urn:cspace:bonsai.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(not_required)'not required'"], + {refname: "urn:cspace:bonsai.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(not_required)'not required'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'disposalmethod', 'public auction', - "urn:cspace:bonsai.collectionspace.org:vocabularies:name(disposalmethod):item:name(public_auction)'public auction'"], + {refname: "urn:cspace:bonsai.collectionspace.org:vocabularies:name(disposalmethod):item:name(public_auction)'public auction'", csid: '1111-2222-3333-4444'}] ] populate(cache, terms) end diff --git a/spec/botgarden_helpers.rb b/spec/botgarden_helpers.rb index e02b0aed..3acc6ac2 100644 --- a/spec/botgarden_helpers.rb +++ b/spec/botgarden_helpers.rb @@ -22,61 +22,61 @@ def botgarden_cache def populate_botgarden(cache) terms = [ ['citationauthorities', 'citation', 'FNA Volume 19', - "urn:cspace:botgarden.collectionspace.org:citationauthorities:name(citation):item:name(FNAVolume191599238760383)'FNA Volume 19'"], + {refname: "urn:cspace:botgarden.collectionspace.org:citationauthorities:name(citation):item:name(FNAVolume191599238760383)'FNA Volume 19'", csid: '1111-2222-3333-4444'}], ['citationauthorities', 'citation', 'Sp. Pl. 2: 899. 1753', - "urn:cspace:botgarden.collectionspace.org:citationauthorities:name(citation):item:name(SpPl289917531599238184211)'Sp. Pl. 2: 899. 1753'"], + {refname: "urn:cspace:botgarden.collectionspace.org:citationauthorities:name(citation):item:name(SpPl289917531599238184211)'Sp. Pl. 2: 899. 1753'", csid: '1111-2222-3333-4444'}], ['citationauthorities', 'worldcat', 'Bull. Torrey Bot. Club', - "urn:cspace:botgarden.collectionspace.org:citationauthorities:name(worldcat):item:name(BullTorreyBotClub331599245358364)'Bull. Torrey Bot. Club 33'"], + {refname: "urn:cspace:botgarden.collectionspace.org:citationauthorities:name(worldcat):item:name(BullTorreyBotClub331599245358364)'Bull. Torrey Bot. Club 33'", csid: '1111-2222-3333-4444'}], ['conceptauthorities', 'concept', 'Official', - "urn:cspace:botgarden.collectionspace.org:conceptauthorities:name(concept):item:name(Official1599737276242)'Official'"], + {refname: "urn:cspace:botgarden.collectionspace.org:conceptauthorities:name(concept):item:name(Official1599737276242)'Official'", csid: '1111-2222-3333-4444'}], ['locationauthorities', 'location', 'Corner', - "urn:cspace:botgarden.collectionspace.org:locationauthorities:name(location):item:name(Corner1599737289184)'Corner'"], + {refname: "urn:cspace:botgarden.collectionspace.org:locationauthorities:name(location):item:name(Corner1599737289184)'Corner'", csid: '1111-2222-3333-4444'}], ['orgauthorities', 'organization', 'FVA', - "urn:cspace:botgarden.collectionspace.org:orgauthorities:name(organization):item:name(FVA1599246022216)'FVA'"], + {refname: "urn:cspace:botgarden.collectionspace.org:orgauthorities:name(organization):item:name(FVA1599246022216)'FVA'", csid: '1111-2222-3333-4444'}], ['personauthorities', 'person', 'Linnaeus, Carl', - "urn:cspace:botgarden.collectionspace.org:personauthorities:name(person):item:name(LinnaeusCarl1599238374086)'Linnaeus, Carl'"], + {refname: "urn:cspace:botgarden.collectionspace.org:personauthorities:name(person):item:name(LinnaeusCarl1599238374086)'Linnaeus, Carl'", csid: '1111-2222-3333-4444'}], ['taxonomyauthority', 'taxon', 'Domestic', - "urn:cspace:botgarden.collectionspace.org:taxonomyauthority:name(taxon):item:name(Domestic1599750187683)'Domestic'"], + {refname: "urn:cspace:botgarden.collectionspace.org:taxonomyauthority:name(taxon):item:name(Domestic1599750187683)'Domestic'", csid: '1111-2222-3333-4444'}], ['taxonomyauthority', 'taxon', 'Tropez', - "urn:cspace:botgarden.collectionspace.org:taxonomyauthority:name(taxon):item:name(Tropez1599750195530)'Tropez'"], + {refname: "urn:cspace:botgarden.collectionspace.org:taxonomyauthority:name(taxon):item:name(Tropez1599750195530)'Tropez'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'cuttingtype', 'hardwood', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(cuttingtype):item:name(hardwood)'hardwood'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(cuttingtype):item:name(hardwood)'hardwood'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'dateera', 'CE', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'durationunit', 'Days', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(durationunit):item:name(days)'Days'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(durationunit):item:name(days)'Days'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'durationunit', 'Hours', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(durationunit):item:name(hours)'Hours'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(durationunit):item:name(hours)'Hours'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'English', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(languages):item:name(eng)'English'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(languages):item:name(eng)'English'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'French', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(languages):item:name(fra)'French'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(languages):item:name(fra)'French'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'languages', 'Latin', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(languages):item:name(lat)'Latin'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(languages):item:name(lat)'Latin'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'potsize', '1 gal. pot', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(potsize):item:name(OneGalPot)'1 gal. pot'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(potsize):item:name(OneGalPot)'1 gal. pot'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'propActivityType', 'benlate and captan', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propActivityType):item:name(benlateAndCaptan)'benlate and captan'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propActivityType):item:name(benlateAndCaptan)'benlate and captan'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'propChemicals', 'benlate and physan', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propChemicals):item:name(benlateAndPhysan)'benlate and physan'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propChemicals):item:name(benlateAndPhysan)'benlate and physan'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'propConditions', 'glass cover', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propConditions):item:name(glassCover)'glass cover'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propConditions):item:name(glassCover)'glass cover'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'propHormones', 'hormone', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propHormones):item:name(hormone)'hormone'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propHormones):item:name(hormone)'hormone'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'propPlantType', 'bulbs', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propPlantType):item:name(bulbs)'bulbs'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propPlantType):item:name(bulbs)'bulbs'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'propreason', 'conservation', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propreason):item:name(conservation)'conservation'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(propreason):item:name(conservation)'conservation'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'proptype', 'Division', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(proptype):item:name(division)'Division'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(proptype):item:name(division)'Division'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'scarstrat', 'boiling water', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(scarstrat):item:name(boilingwater)'boiling water'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(scarstrat):item:name(boilingwater)'boiling water'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'scarstrat', 'cold strat', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(scarstrat):item:name(coldstrat)'cold strat'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(scarstrat):item:name(coldstrat)'cold strat'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'taxontermflag', 'invalid', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(taxontermflag):item:name(invalid)'invalid'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(taxontermflag):item:name(invalid)'invalid'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'taxontermflag', 'valid', - "urn:cspace:botgarden.collectionspace.org:vocabularies:name(taxontermflag):item:name(valid)'valid'"], + {refname: "urn:cspace:botgarden.collectionspace.org:vocabularies:name(taxontermflag):item:name(valid)'valid'", csid: '1111-2222-3333-4444'}] ] populate(cache, terms) end diff --git a/spec/collectionspace/mapper/column_mapping_spec.rb b/spec/collectionspace/mapper/column_mapping_spec.rb index ad9cec41..6c3bf914 100644 --- a/spec/collectionspace/mapper/column_mapping_spec.rb +++ b/spec/collectionspace/mapper/column_mapping_spec.rb @@ -27,10 +27,12 @@ end describe '#fullpath' do - let(:hash) { { + let(:hash) do + { namespace: 'collectionobjects_common', - xpath: ['otherNumberList', 'otherNumber'], - } } + xpath: %w[otherNumberList otherNumber] + } + end it 'returns full xpath to target CollectionSpace field' do expected = 'collectionobjects_common/otherNumberList/otherNumber' expect(mapping.fullpath).to eq(expected) diff --git a/spec/collectionspace/mapper/column_mappings_spec.rb b/spec/collectionspace/mapper/column_mappings_spec.rb index cbe63da9..bb314631 100644 --- a/spec/collectionspace/mapper/column_mappings_spec.rb +++ b/spec/collectionspace/mapper/column_mappings_spec.rb @@ -3,74 +3,78 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::ColumnMappings do - let(:mappings) { [ - {fieldname: 'objectNumber', - transforms: {}, - source_type: 'na', - source_name: nil, - namespace: 'collectionobjects_common', - xpath: [], - data_type: 'string', - repeats: 'n', - in_repeating_group: 'n/a', - opt_list_values: [], - datacolumn: 'objectNumber', - required: 'y'}, - {fieldname: 'numberOfObjects', - transforms: {}, - source_type: 'na', - source_name: nil, - namespace: 'collectionobjects_common', - xpath: [], - data_type: 'integer', - repeats: 'n', - in_repeating_group: 'n/a', - opt_list_values: [], - datacolumn: 'numberOfObjects', - required: 'n'}, - {fieldname: 'numberValue', - transforms: {}, - source_type: 'na', - source_name: nil, - namespace: 'collectionobjects_common', - xpath: ['otherNumberList', 'otherNumber'], - data_type: 'string', - repeats: 'n', - in_repeating_group: 'y', - opt_list_values: [], - datacolumn: 'numberValue', - required: 'n'}, - {fieldname: 'numberType', - transforms: {}, - source_type: 'optionlist', - source_name: 'numberTypes', - namespace: 'collectionobjects_common', - xpath: ['otherNumberList', 'otherNumber'], - data_type: 'string', - repeats: 'n', - in_repeating_group: 'y', - opt_list_values: ['lender', 'obsolete', 'previous', 'serial', 'unknown'], - datacolumn: 'numberType', - required: 'n'}, - {datacolumn: 'otherRequired', - required: 'y'} - ] } + let(:mappings) do + [ + {fieldname: 'objectNumber', + transforms: {}, + source_type: 'na', + source_name: nil, + namespace: 'collectionobjects_common', + xpath: [], + data_type: 'string', + repeats: 'n', + in_repeating_group: 'n/a', + opt_list_values: [], + datacolumn: 'objectNumber', + required: 'y'}, + {fieldname: 'numberOfObjects', + transforms: {}, + source_type: 'na', + source_name: nil, + namespace: 'collectionobjects_common', + xpath: [], + data_type: 'integer', + repeats: 'n', + in_repeating_group: 'n/a', + opt_list_values: [], + datacolumn: 'numberOfObjects', + required: 'n'}, + {fieldname: 'numberValue', + transforms: {}, + source_type: 'na', + source_name: nil, + namespace: 'collectionobjects_common', + xpath: %w[otherNumberList otherNumber], + data_type: 'string', + repeats: 'n', + in_repeating_group: 'y', + opt_list_values: [], + datacolumn: 'numberValue', + required: 'n'}, + {fieldname: 'numberType', + transforms: {}, + source_type: 'optionlist', + source_name: 'numberTypes', + namespace: 'collectionobjects_common', + xpath: %w[otherNumberList otherNumber], + data_type: 'string', + repeats: 'n', + in_repeating_group: 'y', + opt_list_values: %w[lender obsolete previous serial unknown], + datacolumn: 'numberType', + required: 'n'}, + {datacolumn: 'otherRequired', + required: 'y'} + ] + end let(:recordmapper){ instance_double('CS::Mapper::RecordMapper') } let(:mapperconfig){ instance_double('CS::Mapper::RecordMapperConfig') } let(:mappingsobj){ dc = described_class.new(mappings: mappings, mapper: recordmapper) } - let(:added_field) { { - fieldname: 'addedField', - namespace: 'persons_common', - data_type: 'string', - xpath: [], - required: 'not in input data', - repeats: 'n', - in_repeating_group: 'n/a', - datacolumn: 'addedfield' - } } + let(:added_field) do + { + fieldname: 'addedField', + namespace: 'persons_common', + data_type: 'string', + xpath: [], + required: 'not in input data', + repeats: 'n', + in_repeating_group: 'n/a', + datacolumn: 'addedfield' + } + end before do allow(recordmapper).to receive(:config).and_return(mapperconfig) @@ -94,32 +98,34 @@ end context 'when initialized from media RecordMapper' do - let(:mappings) { [ - {fieldname: 'identificationNumber', - transforms: {}, - source_type: 'na', - source_name: nil, - namespace: 'media_common', - xpath: [], - data_type: 'string', - repeats: 'n', - in_repeating_group: 'n/a', - opt_list_values: [], - datacolumn: 'identificationNumber', - required: 'y'}, - {fieldname: 'title', - transforms: {}, - source_type: 'na', - source_name: nil, - namespace: 'media_common', - xpath: [], - data_type: 'string', - repeats: 'n', - in_repeating_group: 'n/a', - opt_list_values: [], - datacolumn: 'title', - required: 'n'} - ] } + let(:mappings) do + [ + {fieldname: 'identificationNumber', + transforms: {}, + source_type: 'na', + source_name: nil, + namespace: 'media_common', + xpath: [], + data_type: 'string', + repeats: 'n', + in_repeating_group: 'n/a', + opt_list_values: [], + datacolumn: 'identificationNumber', + required: 'y'}, + {fieldname: 'title', + transforms: {}, + source_type: 'na', + source_name: nil, + namespace: 'media_common', + xpath: [], + data_type: 'string', + repeats: 'n', + in_repeating_group: 'n/a', + opt_list_values: [], + datacolumn: 'title', + required: 'n'} + ] + end it 'adds mediaFileURI to mappings' do allow(mapperconfig).to receive(:common_namespace).and_return('media_common') @@ -158,4 +164,3 @@ end end end - diff --git a/spec/collectionspace/mapper/column_value_spec.rb b/spec/collectionspace/mapper/column_value_spec.rb index bfe2d90a..8a8c5830 100644 --- a/spec/collectionspace/mapper/column_value_spec.rb +++ b/spec/collectionspace/mapper/column_value_spec.rb @@ -3,19 +3,23 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::ColumnValue do - let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json'} + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:recmapper){ get_record_mapper_object(mapperpath, core_cache) } let(:mapping){ recmapper.mappings.lookup(colname) } - let(:colval) { described_class.new(column: colname, - value: colvalue, - recmapper: recmapper, - mapping: mapping) } + let(:colval) do + described_class.new(column: colname, + value: colvalue, + recmapper: recmapper, + mapping: mapping) + end describe '.create' do - let(:creator) { described_class.create(column: colname, - value: colvalue, - recmapper: recmapper, - mapping: mapping) } + let(:creator) do + described_class.create(column: colname, + value: colvalue, + recmapper: recmapper, + mapping: mapping) + end context 'given core collectionobject collection value' do let(:colname){ 'collection' } @@ -67,4 +71,3 @@ end end end - diff --git a/spec/collectionspace/mapper/config_spec.rb b/spec/collectionspace/mapper/config_spec.rb index 2ccfc1a0..a64644a0 100644 --- a/spec/collectionspace/mapper/config_spec.rb +++ b/spec/collectionspace/mapper/config_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::Config do - let(:configstr) { '{ + let(:configstr) do + '{ "delimiter": ";", "subgroup_delimiter": "^^", "response_mode": "verbose", @@ -29,15 +30,18 @@ "collection": "library-collection" } }' - } - let(:with_string) { described_class.new(config: configstr) } - let(:confighash) { JSON.parse(configstr) } - let(:with_hash) { described_class.new(config: confighash) } - let(:with_nothing) { described_class.new } - let(:with_array) { described_class.new(config: [2, 3]) } - let(:expected_hash) { {:delimiter=>";", :subgroup_delimiter=>"^^", :response_mode=>"verbose", :strip_id_values=>true, :multiple_recs_found=>'fail', :force_defaults=>false, :check_record_status=>true, :check_terms=>true, :date_format=>"month day year", :two_digit_year_handling=>"convert to four digit", :transforms=>{"collection"=>{:special=>["downcase_value"], :replacements=>[{:find=>" ", :replace=>"-", :type=>"plain"}]}}, :default_values=>{"publishto"=>"DPLA;Omeka", "collection"=>"library-collection"}} } - let(:invalid_response) { {response_mode: 'mouthy'} } - let(:with_invalid_response) { described_class.new(config: invalid_response) } + end + let(:with_string){ described_class.new(config: configstr) } + let(:confighash){ JSON.parse(configstr) } + let(:with_hash){ described_class.new(config: confighash) } + let(:with_nothing){ described_class.new } + let(:with_array){ described_class.new(config: [2, 3]) } + let(:expected_hash) do + {delimiter: ';', subgroup_delimiter: '^^', response_mode: 'verbose', strip_id_values: true, + multiple_recs_found: 'fail', force_defaults: false, check_record_status: true, check_terms: true, date_format: 'month day year', two_digit_year_handling: 'convert to four digit', transforms: {'collection' => {special: ['downcase_value'], replacements: [{find: ' ', replace: '-', type: 'plain'}]}}, default_values: {'publishto' => 'DPLA;Omeka', 'collection' => 'library-collection'}} + end + let(:invalid_response){ {response_mode: 'mouthy'} } + let(:with_invalid_response){ described_class.new(config: invalid_response) } context 'when initialized with JSON string' do it 'is created' do @@ -147,5 +151,3 @@ # end # end end - - diff --git a/spec/collectionspace/mapper/data_handler_spec.rb b/spec/collectionspace/mapper/data_handler_spec.rb index 2e8b2248..922590b1 100644 --- a/spec/collectionspace/mapper/data_handler_spec.rb +++ b/spec/collectionspace/mapper/data_handler_spec.rb @@ -3,86 +3,83 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::DataHandler do - before(:all) do - @anthro_client = anthro_client - @anthro_cache = anthro_cache - @anthro_object_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json') - @anthro_object_handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_object_mapper, - client: @anthro_client, - cache: @anthro_cache) - @anthro_place_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_place-local.json') - @anthro_place_handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_place_mapper, - client: @anthro_client, - cache: @anthro_cache) - - @bonsai_client = bonsai_client - @bonsai_cache = bonsai_cache - @bonsai_conservation_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json') - @bonsai_conservation_handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @bonsai_conservation_mapper, - client: @bonsai_client, - cache: @bonsai_cache) -end + let(:client){ core_client } + let(:cache){ core_cache_search } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } + let(:mapper){ get_json_record_mapper(mapperpath) } + let(:config){ {delimiter: '|'} } + let(:handler) do + CollectionSpace::Mapper::DataHandler.new(record_mapper: mapper, + client: client, + cache: cache, + config: config) + end - # todo: why are these making services api calls? - context 'when config has check_terms = false', services_call: true do - before(:all) do - @client = core_client - @cache = core_cache_search - @mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json') - @config = '{"check_terms": false}' - @handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @mapper, - client: @client, - cache: @cache, - config: @config) - @data = {'objectNumber' => '20CS.001.0002', - 'numberOfObjects' => '1', - 'title' => 'Rainbow', - 'titleLanguage' => 'English', - 'namedCollection' => 'Test Collection', - 'collection' => 'rando'} - @data2 = {'objectNumber' => '20CS.001.0001', - 'numberOfObjects' => '1', - 'numberValue' => '123456|98765', - 'numberType' => 'lender|obsolete', - 'title' => 'A Man| A Woman', - 'titleLanguage' => 'English| Klingon', - 'namedCollection' => 'Test collection', - 'collection' => 'permanent collection'} - end - it 'returns found = false for all terms, even if they exist in client' do - res = @handler.process(@data) - not_found = res.terms.reject{ |t| t[:found] } - expect(not_found.length).to eq(2) + # these make services api calls to find terms not in cache + context 'with some terms found and some terms not found', services_call: true do + let(:result){ handler.process(data).terms.reject{ |t| t[:found] } } + + context 'with terms in instance but not in cache' do + let(:data) do + { + 'objectNumber' => '20CS.001.0002', + 'titleLanguage' => 'English', # vocabulary, in instance, in cache + 'namedCollection' => 'Test Collection' # authority, in instance (caseswapped), not in cache + } + end + + it 'returns expected found values' do + res = handler.process(data) + not_found = res.terms.reject{ |t| t[:found] } + expect(not_found.length).to eq(0) + end end - it 'returns found = false for all terms, even if they exist in client' do - res = @handler.process(@data2) - not_found = res.terms.reject{ |t| t[:found] } - expect(not_found.length).to eq(3) + + context 'with terms in instance but not in cache, and not in instance' do + let(:data) do + { + 'objectNumber' => '20CS.001.0001', + 'titleLanguage' => 'English| Klingon', # English is in cache; Klingon is not in instance or cache + 'namedCollection' => 'Test collection' # In instance (caseswapped) + } + end + + it 'returns expected found values' do + res = handler.process(data) + not_found = res.terms.reject{ |t| t[:found] } + expect(not_found.length).to eq(1) + end end end it 'tags all un-found terms as such', services_call: true do data1 = { 'objectNumber' => '1', - 'publishTo' => 'Wordpress', # vocabulary - not in cache - 'namedCollection' => 'nc', # authority - not in cache + 'publishTo' => 'All', # vocabulary - in instance, not in cache + 'namedCollection' => 'QA TARGET Work' # authority - in instance, not in cache } data2 = { 'objectNumber' => '2', - 'publishTo' => 'Wordpress', # vocabulary - now in cache - 'namedCollection' => 'nc', # authority - now in cache - 'contentConceptAssociated' => 'Birds' # authority, in cache + 'publishTo' => 'All', # vocabulary - now in cache + 'namedCollection' => 'QA TARGET Work', # authority - now in cache + 'contentConceptAssociated' => 'Birds' # authority - not in instance, not in cache } - @anthro_object_handler.process(data1) - result = @anthro_object_handler.process(data2).terms.select{ |t| t[:found] == false } - expect(result.length).to eq(2) + + handler.process(data1) + result = handler.process(data2).terms.select{ |t| t[:found] == false } + expect(result.length).to eq(1) end describe '#is_authority' do context 'anthro profile' do + let(:client){ anthro_client } + let(:cache){ anthro_cache } + context 'place record' do + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_place-local.json' } + it 'adds a xphash entry for shortIdentifier' do - result = @anthro_place_handler.mapper.xpath['places_common'][:mappings].select do |mapping| + result = handler.mapper.xpath['places_common'][:mappings].select do |mapping| mapping.fieldname == 'shortIdentifier' end expect(result.length).to eq(1) @@ -93,9 +90,13 @@ describe '#service_type' do let(:servicetype){ handler.service_type } + context 'anthro profile' do + let(:client){ anthro_client } + let(:cache){ anthro_cache } + context 'collectionobject record' do - let(:handler){ @anthro_object_handler } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json' } it 'returns object' do expect(servicetype).to eq('object') @@ -103,7 +104,7 @@ end context 'place record' do - let(:handler){ @anthro_place_handler } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_place-local.json' } it 'returns authority' do expect(servicetype).to eq('authority') @@ -112,8 +113,11 @@ end context 'bonsai profile' do + let(:client){ bonsai_client } + let(:cache){ bonsai_cache } + context 'conservation record' do - let(:handler){ @bonsai_conservation_handler } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json' } it 'returns procedure' do expect(servicetype).to eq('procedure') @@ -122,74 +126,97 @@ end end + # @anthro_object_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json') + # @anthro_object_handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_object_mapper, + # client: @anthro_client, + # cache: @anthro_cache) + # @anthro_place_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_place-local.json') + # @anthro_place_handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_place_mapper, + # client: @anthro_client, + # cache: @anthro_cache) + + # @bonsai_client = bonsai_client + # @bonsai_cache = bonsai_cache + # @bonsai_conservation_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json') + # @bonsai_conservation_handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @bonsai_conservation_mapper, + # client: @bonsai_client, + # cache: @bonsai_cache) + # end + describe '#xpath_hash' do + let(:result){ handler.mapper.xpath[xpath] } + context 'anthro profile' do + let(:client){ anthro_client } + let(:cache){ anthro_cache } + context 'collectionobject record' do + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json' } + context 'xpath ending with commingledRemainsGroup' do - before(:all) do - xpath = 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup' - @h = @anthro_object_handler.mapper.xpath[xpath] - end + let(:xpath){ 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup' } + it 'is_group = true' do - expect(@h[:is_group]).to be true + expect(result[:is_group]).to be true end it 'is_subgroup = false' do - expect(@h[:is_subgroup]).to be false + expect(result[:is_subgroup]).to be false end it 'includes mortuaryTreatment as subgroup' do - xpath = 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup/mortuaryTreatmentGroupList/mortuaryTreatmentGroup' - expect(@h[:children]).to eq([xpath]) - end - - xit 'has mortuaryTreatment listed as only child' do + child_xpath = 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup/mortuaryTreatmentGroupList/mortuaryTreatmentGroup' + expect(result[:children]).to eq([child_xpath]) end end context 'xpath ending with mortuaryTreatmentGroup' do - before(:all) do - xpath = 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup/mortuaryTreatmentGroupList/mortuaryTreatmentGroup' - @h = @anthro_object_handler.mapper.xpath[xpath] + let(:xpath) do + 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup/mortuaryTreatmentGroupList/mortuaryTreatmentGroup' end + it 'is_group = true' do - expect(@h[:is_group]).to be true + expect(result[:is_group]).to be true end it 'is_subgroup = true' do - expect(@h[:is_subgroup]).to be true + expect(result[:is_subgroup]).to be true end it 'parent is xpath ending with commingledRemainsGroup' do ppath = 'collectionobjects_anthro/commingledRemainsGroupList/commingledRemainsGroup' - expect(@h[:parent]).to eq(ppath) + expect(result[:parent]).to eq(ppath) end end context 'xpath ending with collectionobjects_nagpra' do - before(:all) do - @h = @anthro_object_handler.mapper.xpath['collectionobjects_nagpra'] - end + let(:xpath){ 'collectionobjects_nagpra' } + it 'has 5 children' do - expect(@h[:children].size).to eq(5) + expect(result[:children].size).to eq(5) end end end end + context 'bonsai profile' do - context 'conservation record type' do + let(:client){ bonsai_client } + let(:cache){ bonsai_cache } + + context 'conservation record' do + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json' } + context 'xpath ending with fertilizersToBeUsed' do + let(:xpath){ 'conservation_livingplant/fertilizationGroupList/fertilizationGroup/fertilizersToBeUsed' } it 'is a repeating group' do - h = @bonsai_conservation_handler.mapper.xpath - res = h['conservation_livingplant/fertilizationGroupList/fertilizationGroup/fertilizersToBeUsed'][:is_group] - expect(res).to be true + expect(result[:is_group]).to be true end end + context 'xpath ending with conservators' do + let(:xpath){ 'conservation_common/conservators' } it 'is a repeating group' do - h = @bonsai_conservation_handler.mapper.xpath - res = h['conservation_common/conservators'][:is_group] - expect(res).to be false + expect(result[:is_group]).to be false end end end @@ -199,120 +226,124 @@ describe '#validate' do it 'returns CollectionSpace::Mapper::Response object' do data = {'objectNumber' => '123'} - result = @anthro_object_handler.validate(data) + result = handler.validate(data) expect(result).to be_a(CollectionSpace::Mapper::Response) end end describe '#check_fields' do - before(:all) do - @data = { - 'conservationNumber' => '123', - 'status' => 'good', - 'conservator' => 'Someone' - } - end - it 'returns expected hash' do - expect = { - known_fields: %w[conservationnumber status], - unknown_fields: %w[conservator] - } + let(:result){ handler.check_fields(data) } + context 'bonsai profile' do + let(:client){ bonsai_client } + let(:cache){ bonsai_cache } + + context 'conservation record' do + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json' } + let(:data) do + { + 'conservationNumber' => '123', + 'status' => 'good', + 'conservator' => 'Someone' + } + end + + it 'returns expected hash' do + expected = { + known_fields: %w[conservationnumber status], + unknown_fields: %w[conservator] + } + expect(result).to eq(expected) + end + end end end describe '#prep' do - before(:all) do - @data = {'objectNumber' => '123'} - end + let(:data){ {'objectNumber' => '123'} } + it 'can be called with response from validation' do - vresult = @anthro_object_handler.validate(@data) - result = @anthro_object_handler.prep(vresult).response + vresult = handler.validate(data) + result = handler.prep(vresult).response expect(result).to be_a(CollectionSpace::Mapper::Response) end + it 'can be called with just data' do - result = @anthro_object_handler.prep(@data).response + result = handler.prep(data).response expect(result).to be_a(CollectionSpace::Mapper::Response) end + context 'when response_mode = normal' do - it 'returned response to include detailed data transformation info needed for mapping' do - result = @anthro_object_handler.prep(@data).response + let(:config){ {response_mode: 'normal'} } + + it 'returned response includes detailed data transformation info needed for mapping' do + result = handler.prep(data).response + expect(result.transformed_data).not_to be_empty end end + context 'when response_mode = verbose' do + let(:config){ {response_mode: 'verbose'} } + it 'returned response includes detailed data transformation info' do - config = {response_mode: 'verbose'} - handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_object_mapper, - client: @anthro_client, - cache: @anthro_cache, - config: config) - result = handler.prep(@data).response + result = handler.prep(data).response expect(result.transformed_data).not_to be_empty end end end describe '#process', services_call: true do - before(:all) do - @data = {'objectNumber' => '123'} - end + let(:data){ {'objectNumber' => '123'} } + it 'can be called with response from validation' do - vresult = @anthro_object_handler.validate(@data) - result = @anthro_object_handler.process(vresult) + vresult = handler.validate(data) + result = handler.process(vresult) expect(result).to be_a(CollectionSpace::Mapper::Response) end + it 'can be called with just data' do - result = @anthro_object_handler.process(@data) + result = handler.process(data) expect(result).to be_a(CollectionSpace::Mapper::Response) end + context 'when response_mode = normal' do it 'returned response omits detailed data transformation info' do - result = @anthro_object_handler.process(@data) + result = handler.process(data) expect(result.transformed_data).to be_empty end end + context 'when response_mode = verbose' do + let(:config){ {response_mode: 'verbose'} } + it 'returned response includes detailed data transformation info' do - config = {response_mode: 'verbose'} - handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_object_mapper, - client: @anthro_client, - cache: @anthro_cache, - config: config) - result = handler.process(@data) + result = handler.process(data) expect(result.transformed_data).not_to be_empty end end end describe '#map', services_call: true do - before(:all) do - @data = {'objectNumber' => '123'} - prepper = CollectionSpace::Mapper::DataPrepper.new(@data, @anthro_object_handler) - prep_response = @anthro_object_handler.prep(@data).response - @result = @anthro_object_handler.map(prep_response, prepper.xphash) - end + let(:data){ {'objectNumber' => '123'} } + let(:prepper){ CollectionSpace::Mapper::DataPrepper.new(data, handler) } + let(:prepped){ handler.prep(data).response } + let(:result){ handler.map(prepped, prepper.xphash) } it 'returns CollectionSpace::Mapper::Response object' do - expect(@result).to be_a(CollectionSpace::Mapper::Response) + expect(result).to be_a(CollectionSpace::Mapper::Response) end it 'the CollectionSpace::Mapper::Response object doc attribute is a Nokogiri XML Document' do - expect(@result.doc).to be_a(Nokogiri::XML::Document) + expect(result.doc).to be_a(Nokogiri::XML::Document) end context 'when response_mode = normal' do it 'returned response omits detailed data transformation info' do - expect(@result.transformed_data).to be_empty + expect(result.transformed_data).to be_empty end end context 'when response_mode = verbose' do + let(:config){ {'response_mode' => 'verbose'} } it 'returned response includes detailed data transformation info' do - config = {'response_mode' => 'verbose'} - handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: @anthro_object_mapper, - client: @anthro_client, - cache: @anthro_cache, - config: config) - prepper = CollectionSpace::Mapper::DataPrepper.new(@data, handler) - result = handler.map(handler.prep(@data).response, prepper.xphash) expect(result.transformed_data).not_to be_empty end end diff --git a/spec/collectionspace/mapper/data_mapper_core_spec.rb b/spec/collectionspace/mapper/data_mapper_core_spec.rb index f7c8b562..2f060213 100644 --- a/spec/collectionspace/mapper/data_mapper_core_spec.rb +++ b/spec/collectionspace/mapper/data_mapper_core_spec.rb @@ -8,10 +8,12 @@ context 'core profile' do let(:client){ core_client } let(:cache){ core_cache } - let(:handler) { CollectionSpace::Mapper::DataHandler.new(record_mapper: mapper, - client: client, - cache: cache, - config: config) } + let(:handler) do + CollectionSpace::Mapper::DataHandler.new(record_mapper: mapper, + client: client, + cache: cache, + config: config) + end let(:datahash){ get_datahash(path: hashpath) } let(:response){ handler.process(datahash) } let(:mapped_doc){ remove_namespaces(response.doc) } @@ -25,11 +27,13 @@ # These tests are prone to failing if one of the records used in the test in core.dev is deleted # If a UUID is expected but you get blank, recreate the record in core.dev, rerun the test to # get the UUID for the new record, and replace the old UUID in both fixture XML files used. - let(:mapper) { get_json_record_mapper( - 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_nonhierarchicalrelationship.json' - ) } + let(:mapper) do + get_json_record_mapper( + 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_nonhierarchicalrelationship.json' + ) + end - context 'record 1' do + context 'when all IDs found' do let(:hashpath){ 'spec/fixtures/files/datahashes/core/nonHierarchicalRelationship1.json' } let(:mapped_doc1){ remove_namespaces(response[0].doc) } let(:mapped_doc2){ remove_namespaces(response[1].doc) } @@ -78,13 +82,64 @@ end end end + + context 'when ID not found' do + let(:hashpath){ 'spec/fixtures/files/datahashes/core/nonHierarchicalRelationship2.json' } + let(:mapped_doc1){ remove_namespaces(response[0].doc) } + let(:mapped_doc2){ remove_namespaces(response[1].doc) } + let(:mapped_xpaths1){ list_xpaths(mapped_doc1) } + let(:mapped_xpaths2){ list_xpaths(mapped_doc2) } + let(:fixture_doc1){ get_xml_fixture('core/nonHierarchicalRelationship2A.xml') } + let(:fixture_xpaths1){ test_xpaths(fixture_doc1, handler.mapper.mappings) } + let(:fixture_doc2){ get_xml_fixture('core/nonHierarchicalRelationship2B.xml') } + let(:fixture_xpaths2){ test_xpaths(fixture_doc2, handler.mapper.mappings) } + + context 'with original data' do + it 'sets response id field as expected' do + expect(response[0].identifier).to eq('2020.1.107 TEST (collectionobjects) -> LOC MISSING (movements)') + end + + it 'does not map unexpected fields' do + thisdiff = mapped_xpaths1 - fixture_xpaths1 + expect(thisdiff).to eq([]) + end + + it 'maps as expected' do + fixture_xpaths1.each do |xpath| + fixture_node = standardize_value(fixture_doc1.xpath(xpath).text) + mapped_node = standardize_value(mapped_doc1.xpath(xpath).text) + expect(mapped_node).to eq(fixture_node) + end + end + end + + context 'with flipped data' do + it 'sets response id field as expected' do + expect(response[1].identifier).to eq('LOC MISSING (movements) -> 2020.1.107 TEST (collectionobjects)') + end + + it 'does not map unexpected fields' do + thisdiff = mapped_xpaths2 - fixture_xpaths2 + expect(thisdiff).to eq([]) + end + + it 'maps as expected' do + fixture_xpaths2.each do |xpath| + fixture_node = standardize_value(fixture_doc2.xpath(xpath).text) + mapped_node = standardize_value(mapped_doc2.xpath(xpath).text) + expect(mapped_node).to eq(fixture_node) + end + end + end + end end context 'authority hierarchy record', services_call: true do - let(:mapper){ - get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_authorityhierarchy.json') } + let(:mapper) do + get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_authorityhierarchy.json') + end - context 'record 1' do + context 'with existing terms' do let(:hashpath){ 'spec/fixtures/files/datahashes/core/authorityHierarchy1.json' } let(:fixturepath){ 'core/authorityHierarchy1.xml' } @@ -104,28 +159,73 @@ end end end + + context 'with a missing term' do + let(:hashpath){ 'spec/fixtures/files/datahashes/core/authorityHierarchy2.json' } + let(:fixturepath){ 'core/authorityHierarchy2.xml' } + + it 'sets response id field as expected' do + expect(response.identifier).to eq('Cats > Tuxedo cats') + end + + it 'does not map unexpected fields' do + expect(diff).to eq([]) + end + + it 'maps as expected' do + fixture_xpaths.each do |xpath| + fixture_node = standardize_value(fixture_doc.xpath(xpath).text) + mapped_node = standardize_value(mapped_doc.xpath(xpath).text) + expect(mapped_node).to eq(fixture_node) + end + end + end end context 'object hierarchy record', services_call: true do let(:mapper) do get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_objecthierarchy.json') end - let(:hashpath) { 'spec/fixtures/files/datahashes/core/objectHierarchy1.json' } - let(:fixturepath) { 'core/objectHierarchy1.xml' } - it 'sets response id field as expected' do - expect(response.identifier).to eq('2020.1.105 > 2020.1.1055') - end - - it 'does not map unexpected fields' do - expect(diff).to eq([]) + context 'with existing records' do + let(:hashpath){ 'spec/fixtures/files/datahashes/core/objectHierarchy1.json' } + let(:fixturepath){ 'core/objectHierarchy1.xml' } + + it 'sets response id field as expected' do + expect(response.identifier).to eq('2020.1.105 > 2020.1.1055') + end + + it 'does not map unexpected fields' do + expect(diff).to eq([]) + end + + it 'maps as expected' do + fixture_xpaths.each do |xpath| + fixture_node = standardize_value(fixture_doc.xpath(xpath).text) + mapped_node = standardize_value(mapped_doc.xpath(xpath).text) + expect(mapped_node).to eq(fixture_node) + end + end end - it 'maps as expected' do - fixture_xpaths.each do |xpath| - fixture_node = standardize_value(fixture_doc.xpath(xpath).text) - mapped_node = standardize_value(mapped_doc.xpath(xpath).text) - expect(mapped_node).to eq(fixture_node) + context 'with missing record' do + let(:hashpath){ 'spec/fixtures/files/datahashes/core/objectHierarchy2.json' } + let(:fixturepath){ 'core/objectHierarchy2.xml' } + + it 'sets response id field as expected' do + expect(response.identifier).to eq('2020.1.105 > MISSING') + end + + it 'does not map unexpected fields' do + expect(diff).to eq([]) + end + + it 'maps as expected' do + fixture_xpaths.each do |xpath| + fixture_node = standardize_value(fixture_doc.xpath(xpath).text) + mapped_node = standardize_value(mapped_doc.xpath(xpath).text) + expect(mapped_node).to eq(fixture_node) + end end end end @@ -152,8 +252,9 @@ end context 'collectionobject record' do - let(:mapper){ - get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json') } + let(:mapper) do + get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json') + end context 'record 1' do let(:hashpath){ 'spec/fixtures/files/datahashes/core/collectionobject1.json' } @@ -209,8 +310,9 @@ end context 'conditioncheck record', services_call: true do - let(:mapper){ - get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_conditioncheck.json') } + let(:mapper) do + get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_conditioncheck.json') + end context 'record 1' do let(:hashpath){ 'spec/fixtures/files/datahashes/core/conditioncheck1.json' } @@ -231,8 +333,9 @@ end context 'conservation record', services_call: true do - let(:mapper){ - get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_conservation.json') } + let(:mapper) do + get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_conservation.json') + end context 'record 1' do let(:hashpath){ 'spec/fixtures/files/datahashes/core/conservation1.json' } @@ -277,7 +380,7 @@ let(:mapper){ get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_group.json') } context 'record 1' do - let(:hashpath){ 'spec/fixtures/files/datahashes/core/group1.json'} + let(:hashpath){ 'spec/fixtures/files/datahashes/core/group1.json' } let(:fixturepath){ 'core/group1.xml' } it 'does not map unexpected fields' do @@ -412,7 +515,7 @@ it 'maps as expected' do fixture_xpaths.each do |xpath| - # todo - why is this next clause here? + # TODO: - why is this next clause here? next if xpath.start_with?('/document/objectexit_common/exitDateGroup') fixture_node = standardize_value(fixture_doc.xpath(xpath).text) diff --git a/spec/collectionspace/mapper/data_mapper_spec.rb b/spec/collectionspace/mapper/data_mapper_spec.rb index 69c15ebe..1825fd07 100644 --- a/spec/collectionspace/mapper/data_mapper_spec.rb +++ b/spec/collectionspace/mapper/data_mapper_spec.rb @@ -26,8 +26,9 @@ data3 = JSON.parse('{"creditline":"Gift of Elizabeth, 1985","accessiondategroup":"1985","acquisitionmethod":"gift","acquisitionreferencenumber":"ACC208 (migrated accession)","acquisitionsourceperson":"Elizabeth","acquisitionsourceorganization":"","acquisitionauthorizer":"","acquisitionnote":"Acquisition source role(s): Donor"}') data = [data1, data2, data3] preppers = data.map{ |d| CollectionSpace::Mapper::DataPrepper.new(d, @handler) } - mappers = preppers.map{ |prepper| - CollectionSpace::Mapper::DataMapper.new(prepper.prep.response, @handler, prepper.xphash) } + mappers = preppers.map do |prepper| + CollectionSpace::Mapper::DataMapper.new(prepper.prep.response, @handler, prepper.xphash) + end docs = mappers.map{ |mapper| remove_namespaces(mapper.response.doc) } docxpaths = docs.map{ |doc| list_xpaths(doc) } @@ -219,7 +220,7 @@ default_values: { 'publishTo' => 'DPLA;Omeka', 'collection' => 'library-collection' - }, + } } @recmapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json') diff --git a/spec/collectionspace/mapper/data_prepper_spec.rb b/spec/collectionspace/mapper/data_prepper_spec.rb index 619a0b9b..0d9d6cea 100644 --- a/spec/collectionspace/mapper/data_prepper_spec.rb +++ b/spec/collectionspace/mapper/data_prepper_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::DataPrepper do - let(:delimiter) { ';' } - let(:client) { anthro_client } - let(:cache) { anthro_cache } - let(:mapperpath) { 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json' } - let(:mapper) { get_json_record_mapper(mapperpath) } + let(:delimiter){ ';' } + let(:client){ anthro_client } + let(:cache){ anthro_cache } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json' } + let(:mapper){ get_json_record_mapper(mapperpath) } let(:config) do { - delimiter: delimiter, + delimiter: delimiter } end let(:handler) do @@ -19,8 +19,8 @@ cache: cache, config: config) end - let(:prepper) { CollectionSpace::Mapper::DataPrepper.new(datahash, handler) } - let(:datahash) { { 'objectNumber' => '123' } } + let(:prepper){ CollectionSpace::Mapper::DataPrepper.new(datahash, handler) } + let(:datahash){ {'objectNumber' => '123'} } describe '#merge_default_values' do let(:datahash) do @@ -43,7 +43,7 @@ { delimiter: ';', default_values: { - 'publishTo' => 'DPLA;Omeka', + 'publishTo' => 'DPLA;Omeka' } } end @@ -69,13 +69,13 @@ expect(res).to eq(ex) end end - + context 'and :force_defaults = true' do let(:config) do { delimiter: ';', default_values: { - 'publishTo' => 'DPLA;Omeka', + 'publishTo' => 'DPLA;Omeka' }, force_defaults: true } @@ -92,10 +92,10 @@ describe '#process_xpaths' do context 'when authority record' do - let(:client) { core_client } - let(:cache) { core_cache } - let(:mapperpath) { 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_place-local.json' } - let(:datahash) { {'termdisplayname'=>'Silk Hope' } } + let(:client){ core_client } + let(:cache){ core_cache } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_place-local.json' } + let(:datahash){ {'termdisplayname' => 'Silk Hope'} } it 'keeps mapping for shortIdentifier in xphash' do result = prepper.prep.xphash['places_common'][:mappings].select do |mapping| @@ -109,7 +109,7 @@ describe '#handle_term_fields' do let(:datahash) do { - 'objectnumber'=>'123', + 'objectnumber' => '123', 'title' => 'A "Man";A Woman', 'titleLanguage' => 'English;English', 'titleTranslation' => 'Un Homme^^Hombre; Une Femme^^Fraulein', @@ -125,7 +125,7 @@ "urn:cspace:anthro.collectionspace.org:vocabularies:name(languages):item:name(deu)'German'"]] expect(res).to eq(expected) end - + it 'adds expected term Hashes to response.terms' do chk = prepper.prep.response.terms.select{ |t| t[:field] == 'titletranslationlanguage' } expect(chk.length).to eq(4) @@ -135,9 +135,9 @@ describe '#transform_date_fields' do let(:datahash) do { - 'objectnumber'=>'123', + 'objectnumber' => '123', 'annotationdate' => '12/19/2019;12/10/2019', - 'identdategroup' => '2019-09-30;4/5/2020', + 'identdategroup' => '2019-09-30;4/5/2020' } end context 'when field is a structured date' do @@ -159,7 +159,7 @@ describe '#combine_data_values' do let(:datahash) do { - 'objectnumber'=>'123', + 'objectnumber' => '123', 'fieldCollectorPerson' => 'Ann Analyst;Gabriel Solares', 'fieldCollectorOrganization' => 'Organization 1', 'objectProductionPeopleArchculture' => 'Blackfoot', @@ -191,9 +191,9 @@ end context 'and one or more combined field values is blank' do - let(:client) { core_client } - let(:cache) { core_cache } - let(:mapperpath) { 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_conservation.json' } + let(:client){ core_client } + let(:cache){ core_cache } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_conservation.json' } let(:datahash) do { 'conservationNumber' => 'CT2020.7', @@ -201,25 +201,25 @@ 'statusDate' => '' } end - let(:xpath) { 'conservation_common/conservationStatusGroupList/conservationStatusGroup' } + let(:xpath){ 'conservation_common/conservationStatusGroupList/conservationStatusGroup' } it 'removes empty fields from combined data response' do result = prepper.prep.response.combined_data[xpath].keys expect(result).to_not include('statusDate') end - + it 'removes empty fields from fieldmapping list passed on for mapping' do result = prepper.prep.xphash[xpath][:mappings] expect(result.length).to eq(1) end end end - + context 'when multi-authority field is part of repeating field subgroup' do - let(:client) { core_client } - let(:cache) { core_cache } - let(:mapperpath) { 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_media.json' } - let(:xpath) { 'media_common/measuredPartGroupList/measuredPartGroup/dimensionSubGroupList/dimensionSubGroup' } + let(:client){ core_client } + let(:cache){ core_cache } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_media.json' } + let(:xpath){ 'media_common/measuredPartGroupList/measuredPartGroup/dimensionSubGroupList/dimensionSubGroup' } context 'when there is more than one group' do let(:datahash) do @@ -237,8 +237,8 @@ 'valueDate' => '2020-09-23^^2020-09-28^^2020-09-25^^2020-09-30;2020-07-21^^^2020-07-21' } end - - # todo: why does this call services api? + + # TODO: why does this call services api? it 'combines values properly', services_call: true do result = prepper.prep.response.combined_data[xpath]['measuredBy'] expected = [ @@ -246,16 +246,17 @@ "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Gomongo1599463746195)'Gomongo'", "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Comodore1599463826401)'Comodore'", "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Cuckoo1599463786824)'Cuckoo'", - ''], + '' + ], [ "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Gomongo1599463746195)'Gomongo'", - "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Cuckoo1599463786824)'Cuckoo'", + "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Cuckoo1599463786824)'Cuckoo'" ] ] expect(result).to eq(expected) end end - + context 'when there is only one group' do let(:datahash) do { @@ -272,7 +273,7 @@ 'valueDate' => '2020-09-23^^2020-09-28^^2020-09-25^^2020-09-30' } end - + it 'combines values properly' do result = prepper.prep.response.combined_data[xpath]['measuredBy'] expected = [ @@ -280,7 +281,8 @@ "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Gomongo1599463746195)'Gomongo'", "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Comodore1599463826401)'Comodore'", "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Cuckoo1599463786824)'Cuckoo'", - ''], + '' + ] ] expect(result).to eq(expected) end @@ -289,7 +291,7 @@ end describe '#prep' do - let(:res) { prepper.prep } + let(:res){ prepper.prep } it 'returns self' do expect(res).to be_a(CollectionSpace::Mapper::DataPrepper) end @@ -317,9 +319,9 @@ end describe 'leading/trailing space stripping' do - let(:datahash) { { 'objectNumber' => '123 ' } } - let(:result) { prepper.prep.response.transformed_data['objectnumber'] } - + let(:datahash){ {'objectNumber' => '123 '} } + let(:result){ prepper.prep.response.transformed_data['objectnumber'] } + context 'with strip_id_values = true (the default)' do it 'strips leading/trailing spaces from id field(s)' do expect(result).to eq(['123']) @@ -332,7 +334,7 @@ strip_id_values: false } end - + it 'does not strip leading/trailing spaces from id field(s)' do expect(result).to eq(['123 ']) end diff --git a/spec/collectionspace/mapper/data_quality_checker_spec.rb b/spec/collectionspace/mapper/data_quality_checker_spec.rb index 5b62779d..403f43ac 100644 --- a/spec/collectionspace/mapper/data_quality_checker_spec.rb +++ b/spec/collectionspace/mapper/data_quality_checker_spec.rb @@ -7,39 +7,43 @@ let(:mapping){ CollectionSpace::Mapper::ColumnMapping.new(maphash, recordmapper) } context 'when source_type = optionlist' do - let(:maphash) { { - fieldname: 'collection', - datacolumn: 'collection', - transforms: {}, - source_type: 'optionlist', - opt_list_values: [ - 'library-collection', - 'permanent-collection', - 'study-collection', - 'teaching-collection' - ] - } } - it 'returns expected warnings' do - data = [ - 'Permanent Collection', # not a valid option, should return warning - '%NULLVALUE%', # indicates placeholder blank value, should be skipped - 'permanent-collection', # valid option - '' # non-placeholder blank value, should be skipped + let(:maphash) do + { + fieldname: 'collection', + datacolumn: 'collection', + transforms: {}, + source_type: 'optionlist', + opt_list_values: %w[ + library-collection + permanent-collection + study-collection + teaching-collection ] - res = CollectionSpace::Mapper::DataQualityChecker.new(mapping, data).warnings - expect(res.size).to eq(1) - end + } + end + it 'returns expected warnings' do + data = [ + 'Permanent Collection', # not a valid option, should return warning + '%NULLVALUE%', # indicates placeholder blank value, should be skipped + 'permanent-collection', # valid option + '' # non-placeholder blank value, should be skipped + ] + res = CollectionSpace::Mapper::DataQualityChecker.new(mapping, data).warnings + expect(res.size).to eq(1) end + end context 'when datacolumn contains `refname`' do context 'and source_type = vocabulary' do - let(:maphash) { { - fieldname: 'nagprainventoryname', - datacolumn: 'nagprainventorynamerefname', - transforms: {}, - source_type: 'vocabulary', - opt_list_values: [] - } } + let(:maphash) do + { + fieldname: 'nagprainventoryname', + datacolumn: 'nagprainventorynamerefname', + transforms: {}, + source_type: 'vocabulary', + opt_list_values: [] + } + end context 'and value is not well-formed refname' do it 'returns warning' do data = ["urn:pahma.cspace.berkeley.edu:vocabularies:name(nagpraPahmaInventoryNames):item:name(nagpraPahmaInventoryNames01)'AK-Alaska'"] @@ -57,13 +61,15 @@ end context 'and source_type = authority' do - let(:maphash) { { - fieldname: 'nagpradetermculture', - datacolumn: 'nagpradetermculturerefname', - transforms: {}, - source_type: 'authority', - opt_list_values: [] - } } + let(:maphash) do + { + fieldname: 'nagpradetermculture', + datacolumn: 'nagpradetermculturerefname', + transforms: {}, + source_type: 'authority', + opt_list_values: [] + } + end context 'and value is not well-formed refname' do it 'returns warning' do data = ["urn:cspace:pahma.cspace.berkeley.edu:orgauthorities:name(organization):item:name(Chumash1607458832492)'Chumash"] diff --git a/spec/collectionspace/mapper/data_splitter_spec.rb b/spec/collectionspace/mapper/data_splitter_spec.rb index 0ff7d64d..e9829753 100644 --- a/spec/collectionspace/mapper/data_splitter_spec.rb +++ b/spec/collectionspace/mapper/data_splitter_spec.rb @@ -49,33 +49,33 @@ RSpec.describe CollectionSpace::Mapper::SubgroupSplitter do before(:all) do - @config = CS::Mapper::Config.new(config: {delimiter: ';', subgroup_delimiter: '^^'}) - end + @config = CS::Mapper::Config.new(config: {delimiter: ';', subgroup_delimiter: '^^'}) + end describe '#result' do - context 'when "a^^b;c^^d"' do - it 'returns [["a", "b"], ["c", "d"]]' do - s = CollectionSpace::Mapper::SubgroupSplitter.new('a^^b;c^^d', @config) - expect(s.result).to eq([%w[a b], %w[c d]]) - end - end - context 'when "a;c"' do - it 'returns [["a"], ["c"]]' do - s = CollectionSpace::Mapper::SubgroupSplitter.new('a;c', @config) - expect(s.result).to eq([%w[a], %w[c]]) - end - end - context 'when "a;c^^d"' do - it 'returns [["a"], ["c", "d"]]' do - s = CollectionSpace::Mapper::SubgroupSplitter.new('a;c^^d', @config) - expect(s.result).to eq([%w[a], %w[c d]]) - end - end - context 'when "a^^;c^^d"' do - it 'returns [["a", ""], ["c", "d"]]' do - s = CollectionSpace::Mapper::SubgroupSplitter.new('a^^;c^^d', @config) - expect(s.result).to eq([['a', ''], %w[c d]]) - end - end - end + context 'when "a^^b;c^^d"' do + it 'returns [["a", "b"], ["c", "d"]]' do + s = CollectionSpace::Mapper::SubgroupSplitter.new('a^^b;c^^d', @config) + expect(s.result).to eq([%w[a b], %w[c d]]) + end + end + context 'when "a;c"' do + it 'returns [["a"], ["c"]]' do + s = CollectionSpace::Mapper::SubgroupSplitter.new('a;c', @config) + expect(s.result).to eq([%w[a], %w[c]]) + end + end + context 'when "a;c^^d"' do + it 'returns [["a"], ["c", "d"]]' do + s = CollectionSpace::Mapper::SubgroupSplitter.new('a;c^^d', @config) + expect(s.result).to eq([%w[a], %w[c d]]) + end + end + context 'when "a^^;c^^d"' do + it 'returns [["a", ""], ["c", "d"]]' do + s = CollectionSpace::Mapper::SubgroupSplitter.new('a^^;c^^d', @config) + expect(s.result).to eq([['a', ''], %w[c d]]) + end + end + end end diff --git a/spec/collectionspace/mapper/data_validator_spec.rb b/spec/collectionspace/mapper/data_validator_spec.rb index 9f1b96f1..49bd4755 100644 --- a/spec/collectionspace/mapper/data_validator_spec.rb +++ b/spec/collectionspace/mapper/data_validator_spec.rb @@ -94,14 +94,17 @@ before(:all) do @anthro_object_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json') @anthro_dv = CollectionSpace::Mapper::DataValidator.new( -CollectionSpace::Mapper::RecordMapper.new(mapper: @anthro_object_mapper, termcache: anthro_cache), anthro_cache) + CollectionSpace::Mapper::RecordMapper.new(mapper: @anthro_object_mapper, termcache: anthro_cache), anthro_cache + ) @botgarden_loanout_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/botgarden/botgarden_2-0-1_loanout.json') @botgarden_dv = CollectionSpace::Mapper::DataValidator.new( -CollectionSpace::Mapper::RecordMapper.new(mapper: @botgarden_loanout_mapper, - termcache: botgarden_cache), botgarden_cache) + CollectionSpace::Mapper::RecordMapper.new(mapper: @botgarden_loanout_mapper, + termcache: botgarden_cache), botgarden_cache + ) @core_authhier_mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_authorityhierarchy.json') @core_authhier_dv = CollectionSpace::Mapper::DataValidator.new( -CollectionSpace::Mapper::RecordMapper.new(mapper: @core_authhier_mapper, termcache: core_cache), core_cache) + CollectionSpace::Mapper::RecordMapper.new(mapper: @core_authhier_mapper, termcache: core_cache), core_cache + ) end describe '#validate' do @@ -114,7 +117,8 @@ before(:all) do @mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_movement.json') @validator = CollectionSpace::Mapper::DataValidator.new( -CollectionSpace::Mapper::RecordMapper.new(mapper: @mapper, termcache: core_cache), core_cache) + CollectionSpace::Mapper::RecordMapper.new(mapper: @mapper, termcache: core_cache), core_cache + ) end it 'validates' do data = {'movementReferenceNumber' => '1', 'currentLocationLocationLocal' => 'Loc'} diff --git a/spec/collectionspace/mapper/find_replace_operation_spec.rb b/spec/collectionspace/mapper/find_replace_operation_spec.rb index bc0c4579..c0f0995b 100644 --- a/spec/collectionspace/mapper/find_replace_operation_spec.rb +++ b/spec/collectionspace/mapper/find_replace_operation_spec.rb @@ -9,7 +9,7 @@ let(:creator){ described_class.create(opspec) } context 'given a plain operation' do - let(:opspec){ {find: ' ', replace:'-', type: 'plain'} } + let(:opspec){ {find: ' ', replace: '-', type: 'plain'} } it 'returns a FindReplaceOperation' do expect(creator).to be_a(CS::Mapper::FindReplaceOperation) end @@ -24,7 +24,7 @@ end describe '#perform' do - let(:opspec){ {find: ' ', replace:'-', type: 'plain'} } + let(:opspec){ {find: ' ', replace: '-', type: 'plain'} } let(:result){ operation.perform(value) } context 'given blank value' do let(:value){ '' } @@ -41,4 +41,3 @@ end end end - diff --git a/spec/collectionspace/mapper/find_replace_transformer_spec.rb b/spec/collectionspace/mapper/find_replace_transformer_spec.rb index 9b015b73..0bef2818 100644 --- a/spec/collectionspace/mapper/find_replace_transformer_spec.rb +++ b/spec/collectionspace/mapper/find_replace_transformer_spec.rb @@ -3,10 +3,12 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::FindReplaceTransformer do - let(:transform) { [ - {find: ' ', replace:'-', type: 'plain'}, - {find: '(\d)-A', replace: '\1 A', type: 'regex'} - ] } + let(:transform) do + [ + {find: ' ', replace: '-', type: 'plain'}, + {find: '(\d)-A', replace: '\1 A', type: 'regex'} + ] + end let(:transformer){ described_class.new(transform: transform) } describe '#precedence' do @@ -33,4 +35,3 @@ end end end - diff --git a/spec/collectionspace/mapper/group_column_value_spec.rb b/spec/collectionspace/mapper/group_column_value_spec.rb index a6833fc0..54888525 100644 --- a/spec/collectionspace/mapper/group_column_value_spec.rb +++ b/spec/collectionspace/mapper/group_column_value_spec.rb @@ -5,21 +5,24 @@ RSpec.describe CollectionSpace::Mapper::GroupColumnValue do let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), - batchconfig: config, - termcache: core_cache) } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + batchconfig: config, + termcache: core_cache) + end let(:mapping){ recmapper.mappings.lookup(colname) } - let(:colval) { described_class.new(column: colname, - value: colvalue, - recmapper: recmapper, - mapping: mapping) } + let(:colval) do + described_class.new(column: colname, + value: colvalue, + recmapper: recmapper, + mapping: mapping) + end describe '#split' do let(:colname){ 'title' } let(:colvalue){ 'blah| blah' } it 'returns value as stripped element(s) in Array' do - expect(colval.split).to eq(['blah', 'blah']) + expect(colval.split).to eq(%w[blah blah]) end end end - diff --git a/spec/collectionspace/mapper/group_multival_column_value_spec.rb b/spec/collectionspace/mapper/group_multival_column_value_spec.rb index cfcb807a..93b41894 100644 --- a/spec/collectionspace/mapper/group_multival_column_value_spec.rb +++ b/spec/collectionspace/mapper/group_multival_column_value_spec.rb @@ -5,23 +5,26 @@ RSpec.describe CollectionSpace::Mapper::GroupMultivalColumnValue do let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/bonsai/bonsai_4-1-1_conservation.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), - batchconfig: config, - termcache: bonsai_cache) } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + batchconfig: config, + termcache: bonsai_cache) + end let(:mapping){ recmapper.mappings.lookup(colname) } - let(:colval) { described_class.new(column: colname, - value: colvalue, - recmapper: recmapper, - mapping: mapping) } + let(:colval) do + described_class.new(column: colname, + value: colvalue, + recmapper: recmapper, + mapping: mapping) + end describe '#split' do let(:colname){ 'fertilizerToBeUsed' } let(:colvalue){ 'a|b^^c' } it 'returns value(s) as Hash where group occurrences are the keys' do expected = {1 => ['a'], - 2 => ['b', 'c']} + 2 => %w[b c]} expect(colval.split).to eq(expected) end end end - diff --git a/spec/collectionspace/mapper/identifiers/short_identifier_spec.rb b/spec/collectionspace/mapper/identifiers/short_identifier_spec.rb index b9a3aab0..97b2d980 100644 --- a/spec/collectionspace/mapper/identifiers/short_identifier_spec.rb +++ b/spec/collectionspace/mapper/identifiers/short_identifier_spec.rb @@ -16,4 +16,3 @@ end end end - diff --git a/spec/collectionspace/mapper/multival_column_value_spec.rb b/spec/collectionspace/mapper/multival_column_value_spec.rb index 215d7377..5eb6e631 100644 --- a/spec/collectionspace/mapper/multival_column_value_spec.rb +++ b/spec/collectionspace/mapper/multival_column_value_spec.rb @@ -5,21 +5,24 @@ RSpec.describe CollectionSpace::Mapper::MultivalColumnValue do let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), - batchconfig: config, - termcache: core_cache) } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + batchconfig: config, + termcache: core_cache) + end let(:mapping){ recmapper.mappings.lookup(colname) } - let(:colval) { described_class.new(column: colname, - value: colvalue, - recmapper: recmapper, - mapping: mapping) } + let(:colval) do + described_class.new(column: colname, + value: colvalue, + recmapper: recmapper, + mapping: mapping) + end describe '#split' do let(:colname){ 'collection' } let(:colvalue){ 'blah| blah' } it 'returns value as stripped element(s) in Array' do - expect(colval.split).to eq(['blah', 'blah']) + expect(colval.split).to eq(%w[blah blah]) end end end - diff --git a/spec/collectionspace/mapper/record_mapper_config_spec.rb b/spec/collectionspace/mapper/record_mapper_config_spec.rb index 5011d1cf..7fc4ad63 100644 --- a/spec/collectionspace/mapper/record_mapper_config_spec.rb +++ b/spec/collectionspace/mapper/record_mapper_config_spec.rb @@ -3,15 +3,17 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::RecordMapperConfig do - let(:hash) { {'ns_uri' => { - 'collectionobjects_common' => 'http://collectionspace.org/services/collectionobject', - 'collectionobjects_anthro' => 'http://collectionspace.org/services/collectionobject/domain/anthro', - 'collectionobjects_annotation' => 'http://collectionspace.org/services/collectionobject/domain/annotation', - 'collectionobjects_culturalcare' => 'http://collectionspace.org/services/collectionobject/domain/collectionobject', - 'collectionobjects_nagpra' => 'http://collectionspace.org/services/collectionobject/domain/nagpra', - 'collectionobjects_naturalhistory_extension' => 'http://collectionspace.org/services/collectionobject/domain/naturalhistory_extension', - 'somethingelse_common' => 'http://collectionspace.org/services/collectionobject/domain/nagpra' - }} } + let(:hash) do + {'ns_uri' => { + 'collectionobjects_common' => 'http://collectionspace.org/services/collectionobject', + 'collectionobjects_anthro' => 'http://collectionspace.org/services/collectionobject/domain/anthro', + 'collectionobjects_annotation' => 'http://collectionspace.org/services/collectionobject/domain/annotation', + 'collectionobjects_culturalcare' => 'http://collectionspace.org/services/collectionobject/domain/collectionobject', + 'collectionobjects_nagpra' => 'http://collectionspace.org/services/collectionobject/domain/nagpra', + 'collectionobjects_naturalhistory_extension' => 'http://collectionspace.org/services/collectionobject/domain/naturalhistory_extension', + 'somethingelse_common' => 'http://collectionspace.org/services/collectionobject/domain/nagpra' + }} + end let(:config){ described_class.new(hash) } describe '#namespaces' do it 'returns Array of namespace names' do diff --git a/spec/collectionspace/mapper/regex_find_replace_operation_spec.rb b/spec/collectionspace/mapper/regex_find_replace_operation_spec.rb index faca1d79..ce395e76 100644 --- a/spec/collectionspace/mapper/regex_find_replace_operation_spec.rb +++ b/spec/collectionspace/mapper/regex_find_replace_operation_spec.rb @@ -6,7 +6,7 @@ let(:operation){ described_class.new(opspec) } describe '#perform' do - let(:opspec){ {find: '(az|oo) ', replace:'\1-', type: 'regexp'} } + let(:opspec){ {find: '(az|oo) ', replace: '\1-', type: 'regexp'} } let(:result){ operation.perform(value) } context 'given blank value' do let(:value){ '' } @@ -38,4 +38,3 @@ end end end - diff --git a/spec/collectionspace/mapper/row_data_spec.rb b/spec/collectionspace/mapper/row_data_spec.rb index ffb8f521..8e931f0b 100644 --- a/spec/collectionspace/mapper/row_data_spec.rb +++ b/spec/collectionspace/mapper/row_data_spec.rb @@ -3,13 +3,15 @@ require 'spec_helper' RSpec.describe CollectionSpace::Mapper::RowData do - let(:recmapper){ core_object_mapper} - let(:data_hash) { { - 'objectNumber' => '123', - 'comment' => 'blah', - 'title' => 'The title', - 'titleTranslation' => 'La title' - } } + let(:recmapper){ core_object_mapper } + let(:data_hash) do + { + 'objectNumber' => '123', + 'comment' => 'blah', + 'title' => 'The title', + 'titleTranslation' => 'La title' + } + end let(:row){ CollectionSpace::Mapper::RowData.new(data_hash, recmapper) } @@ -19,7 +21,7 @@ expect(row.columns).to be_a(Array) end it 'of ColumnValues' do - expect(row.columns.any?{ |col| !col.kind_of?(CS::Mapper::ColumnValue)}).to be false + expect(row.columns.any?{ |col| !col.is_a?(CS::Mapper::ColumnValue) }).to be false end it '2 elements long' do expect(row.columns.length).to eq(4) diff --git a/spec/collectionspace/mapper/subgroup_column_value_spec.rb b/spec/collectionspace/mapper/subgroup_column_value_spec.rb index 6da9b59e..d0efb81e 100644 --- a/spec/collectionspace/mapper/subgroup_column_value_spec.rb +++ b/spec/collectionspace/mapper/subgroup_column_value_spec.rb @@ -5,23 +5,26 @@ RSpec.describe CollectionSpace::Mapper::SubgroupColumnValue do let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } let(:config){ {delimiter: '|', subgroup_delimiter: '^^'} } - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), - batchconfig: config, - termcache: core_cache) } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper(mapperpath), + batchconfig: config, + termcache: core_cache) + end let(:mapping){ recmapper.mappings.lookup(colname) } - let(:colval) { described_class.new(column: colname, - value: colvalue, - recmapper: recmapper, - mapping: mapping) } + let(:colval) do + described_class.new(column: colname, + value: colvalue, + recmapper: recmapper, + mapping: mapping) + end describe '#split' do let(:colname){ 'titleTranslation' } let(:colvalue){ 'a|b^^c' } it 'returns value(s) as Hash where group occurrences are the keys' do expected = {1 => ['a'], - 2 => ['b', 'c']} + 2 => %w[b c]} expect(colval.split).to eq(expected) end end end - diff --git a/spec/collectionspace/mapper/term_handler_spec.rb b/spec/collectionspace/mapper/term_handler_spec.rb index b71ce449..94ef01a1 100644 --- a/spec/collectionspace/mapper/term_handler_spec.rb +++ b/spec/collectionspace/mapper/term_handler_spec.rb @@ -6,17 +6,21 @@ let(:client){ core_client } let(:termcache){ core_cache } let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' } - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), - csclient: client, - termcache: termcache) } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), + csclient: client, + termcache: termcache) + end let(:colmapping){ recmapper.mappings.lookup(colname) } - let(:th) { CS::Mapper::TermHandler.new(mapping: colmapping, - data: data, - client: client, - cache: termcache, - mapper: recmapper) } - # before(:all) do -# @config = @handler.mapper.batchconfig + let(:th) do + CS::Mapper::TermHandler.new(mapping: colmapping, + data: data, + client: client, + cache: termcache, + mapper: recmapper) + end + # before(:all) do + # @config = @handler.mapper.batchconfig # @ref_mapping = CollectionSpace::Mapper::ColumnMapping.new({ # :fieldname=>"reference", # :transforms=>{:authority=>["citationauthorities", "citation"]}, @@ -53,48 +57,48 @@ # end describe '#result' do - context 'titletranslationlanguage (vocabulary, field subgroup)' do - let(:colname){ 'titleTranslationLanguage' } - let(:data){ [['%NULLVALUE%', 'Swahili'], ['Klingon', 'Spanish'], [CS::Mapper::THE_BOMB]] } + context 'titletranslationlanguage (vocabulary, field subgroup)' do + let(:colname){ 'titleTranslationLanguage' } + let(:data){ [['%NULLVALUE%', 'Swahili'], %w[Klingon Spanish], [CS::Mapper::THE_BOMB]] } - it 'result is the transformed value for mapping' do - expected = [['', - "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(swa)'Swahili'"], - ["urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(Klingon)'Klingon'", - "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'"], - [CS::Mapper::THE_BOMB]] - expect(th.result).to eq(expected) - end - it 'all values are refnames, blanks, or the bomb' do - chk = th.result.flatten.select{ |v| v.start_with?('urn:') || v.empty? || v = CS::Mapper::THE_BOMB } - expect(chk.length).to eq(5) - end + it 'result is the transformed value for mapping' do + expected = [['', + "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(swa)'Swahili'"], + ["urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(Klingon)'Klingon'", + "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'"], + [CS::Mapper::THE_BOMB]] + expect(th.result).to eq(expected) end + it 'all values are refnames, blanks, or the bomb' do + chk = th.result.flatten.select{ |v| v.start_with?('urn:') || v.empty? || v = CS::Mapper::THE_BOMB } + expect(chk.length).to eq(5) + end + end - context 'reference (authority, field group)' do - let(:colname){ 'referenceLocal' } - let(:data){ ['Reference 1', 'Reference 2', '%NULLVALUE%'] } + context 'reference (authority, field group)' do + let(:colname){ 'referenceLocal' } + let(:data){ ['Reference 1', 'Reference 2', '%NULLVALUE%'] } - it 'result is the transformed value for mapping' do - expected = [ - "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Reference11143445083)'Reference 1'", - "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Reference22573957271)'Reference 2'", - '' - ] - expect(th.result).to eq(expected) - end - it 'all values are refnames' do - chk = th.result.flatten.select{ |v| v.start_with?('urn:') } - expect(chk.length).to eq(2) - end + it 'result is the transformed value for mapping' do + expected = [ + "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Reference11143445083)'Reference 1'", + "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Reference22573957271)'Reference 2'", + '' + ] + expect(th.result).to eq(expected) + end + it 'all values are refnames' do + chk = th.result.flatten.select{ |v| v.start_with?('urn:') } + expect(chk.length).to eq(2) end end + end describe '#terms' do let(:terms){ th.terms } context 'titletranslationlanguage (vocabulary, field subgroup)' do let(:colname){ 'titleTranslationLanguage' } - let(:data){ [['%NULLVALUE%', 'Swahili'], ['Sanza', 'Spanish'], [CS::Mapper::THE_BOMB]] } + let(:data){ [['%NULLVALUE%', 'Swahili'], %w[Sanza Spanish], [CS::Mapper::THE_BOMB]] } context 'when new term (Sanza) is initially encountered' do it 'returns terms as expected' do @@ -107,9 +111,15 @@ end context 'when new term is subsequently encountered' do - it 'the term is treated as found' do + it 'the term is still treated as not found' do + first_handler = CS::Mapper::TermHandler.new(mapping: colmapping, + data: data, + client: client, + cache: termcache, + mapper: recmapper) + chk = terms.select{ |h| h[:found] } - expect(chk.length).to eq(3) + expect(chk.length).to eq(2) end end end @@ -123,17 +133,10 @@ found = th.terms.select{ |h| h[:found] } not_found = th.terms.select{ |h| !h[:found] } expect(terms.length).to eq(3) - expect(found.length).to eq(1) + expect(found.length).to eq(0) expect(not_found.first[:refname].display_name).to eq('Reference 3') end end - - context 'when new term is subsequently encountered' do - it 'the term is treated as found' do - chk = th.terms.select{ |h| h[:found] } - expect(chk.length).to eq(3) - end - end end end end diff --git a/spec/collectionspace/mapper/term_searchable_spec.rb b/spec/collectionspace/mapper/term_searchable_spec.rb index 65495985..3401708b 100644 --- a/spec/collectionspace/mapper/term_searchable_spec.rb +++ b/spec/collectionspace/mapper/term_searchable_spec.rb @@ -5,25 +5,23 @@ class TermClass attr_reader :cache, :client attr_accessor :type, :subtype, :errors + include CS::Mapper::TermSearchable - def initialize(cache, client) + def initialize(cache, client, type, subtype) @cache = cache @client = client - @type = 'conceptauthorities' - @subtype = 'concept' + @type = type + @subtype = subtype @errors = [] end - end RSpec.describe CollectionSpace::Mapper::TermSearchable do - before(:context) do - @cache = core_cache - populate_core(@cache) - end - - let(:term){ TermClass.new(@cache, core_client) } + let(:cache){ core_cache } + let(:termtype){ 'conceptauthorities' } + let(:termsubtype){ 'concept' } + let(:term){ TermClass.new(cache, core_client, termtype, termsubtype) } describe '#in_cache?' do let(:result){ term.in_cache?(val) } @@ -40,6 +38,31 @@ def initialize(cache, client) expect(result).to be true end end + + context 'when captitalized form is in cache' do + let(:val){ 'test' } + it 'returns true' do + expect(result).to be true + end + end + end + + describe '#cached_as_unknown?' do + let(:result){ term.cached_as_unknown?(val) } + let(:val){ 'blahblahblah' } + + context 'when not cached as unknown value' do + it 'returns false' do + expect(result).to be false + end + end + + context 'when cached as unknown value' do + it 'returns true' do + cache.put('unknownvalue', "#{termtype}/#{termsubtype}", val, nil) + expect(result).to be true + end + end end describe '#cached_term' do @@ -58,15 +81,45 @@ def initialize(cache, client) expect(result).to eq(expected) end end + + context 'when capitalized form is in cache' do + let(:val){ 'test' } + it 'returns refname urn' do + expected = "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(Test1599650854716)'Test'" + expect(result).to eq(expected) + end + end + end + + describe '#searched_term' do + let(:termtype){ 'vocabularies' } + let(:termsubtype){ 'publishto' } + let(:result){ term.searched_term(val) } + + context 'when val exists in instance' do + let(:val){ 'All' } + it 'returns refname urn' do + expected = "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(all)'All'" + expect(result).to eq(expected) + end + end + + context 'when case-swapped val exists in instance' do + let(:val){ 'all' } + it 'returns refname urn' do + expected = "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(all)'All'" + expect(result).to eq(expected) + end + end end - # also covers extract_refname_csid and lookup_obj_csid + # also covers lookup_obj_csid describe '#obj_csid' do - let(:result){ term.obj_csid(objnum, type) } let(:type){ 'collectionobjects' } + let(:result){ term.obj_csid(objnum, type) } context 'when in cache' do let(:objnum){ 'Hierarchy Test 001' } - + it 'returns csid' do expect(result).to eq('16161bff-b01a-4b55-95aa') end @@ -84,9 +137,9 @@ def initialize(cache, client) let(:result){ term.term_csid(val) } context 'when in cache' do let(:val){ 'Sample Concept 1' } - - it 'returns csid', :skip => 'does not cause mapping to fail, so we live with technical incorrectness for now' do - expect(result).to eq('c119ed04-d99d-4ea2-bbda') + it 'returns csid' do + # it 'returns csid', :skip => 'does not cause mapping to fail, so we live with technical incorrectness for now' do + expect(result).to eq('1111-2222-3333-4444') end end diff --git a/spec/collectionspace/mapper/tools/record_status_service_spec.rb b/spec/collectionspace/mapper/tools/record_status_service_spec.rb index 26866eb5..dfc1eeb8 100644 --- a/spec/collectionspace/mapper/tools/record_status_service_spec.rb +++ b/spec/collectionspace/mapper/tools/record_status_service_spec.rb @@ -7,21 +7,26 @@ let(:service){ CollectionSpace::Mapper::Tools::RecordStatusService.new(client, mapper) } context 'when mapper service_path not handled by collectionspace-client' do - let(:mapper) { CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper( - 'spec/fixtures/files/mappers/core_6-1-0_aardvark.json' - ), termcache: core_cache) } + let(:mapper) do + CS::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + 'spec/fixtures/files/mappers/core_6-1-0_aardvark.json' + ), termcache: core_cache) + end it 'raises NoClientServiceError' do - expect{ - CS::Mapper::Tools::RecordStatusService.new(client, mapper) }.to raise_error(CS::Mapper::NoClientServiceError) + expect do + CS::Mapper::Tools::RecordStatusService.new(client, mapper) + end.to raise_error(CS::Mapper::NoClientServiceError) end end describe '#lookup' do context 'when mapper is for an authority' do - let(:mapper) { CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( - 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_person-local.json' - ), termcache: core_cache) } + let(:mapper) do + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_person-local.json' + ), termcache: core_cache) + end context 'and one result is found' do let(:report){ service.lookup('John Doe') } @@ -54,7 +59,9 @@ # you may need to re-create them if they have been removed context 'with default config' do it 'raises error because we cannot know what to do with imported record' do - expect{ service.lookup('Inkpot Guineafowl') }.to raise_error(CollectionSpace::Mapper::MultipleCsRecordsFoundError) + expect do + service.lookup('Inkpot Guineafowl') + end.to raise_error(CollectionSpace::Mapper::MultipleCsRecordsFoundError) end end @@ -66,10 +73,10 @@ let(:mapper) do CollectionSpace::Mapper::RecordMapper.new( mapper: json, - batchconfig: { multiple_recs_found: 'use_first' } + batchconfig: {multiple_recs_found: 'use_first'} ) end - let(:result) { service.lookup('Inkpot Guineafowl').keys.any?(:multiple_recs_found) } + let(:result){ service.lookup('Inkpot Guineafowl').keys.any?(:multiple_recs_found) } it 'returns result with count of records found' do expect(result).to be true end @@ -78,9 +85,11 @@ end context 'when mapper is for an object' do - let(:mapper) { CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( - 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' - ), termcache: core_cache) } + let(:mapper) do + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_collectionobject.json' + ), termcache: core_cache) + end it 'works the same' do res = service.lookup('2000.1') @@ -89,9 +98,11 @@ end context 'when mapper is for a procedure' do - let(:mapper) { CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( - 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_acquisition.json' - ), termcache: core_cache) } + let(:mapper) do + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_acquisition.json' + ), termcache: core_cache) + end it 'works the same' do res = service.lookup('2000.001') @@ -100,9 +111,11 @@ end context 'when mapper is for a relationship' do - let(:mapper) { CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( - 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_objecthierarchy.json' - )) } + let(:mapper) do + CollectionSpace::Mapper::RecordMapper.new(mapper: get_json_record_mapper( + 'spec/fixtures/files/mappers/release_6_1/core/core_6-1-0_objecthierarchy.json' + )) + end it 'works the same' do res = service.lookup({sub: '56c04f5f-32b9-4f1d-8a4b', obj: '6f0ce7b3-0130-444d-8633'}) diff --git a/spec/collectionspace/mapper/tools/refname_spec.rb b/spec/collectionspace/mapper/tools/refname_spec.rb index 30c9e378..5e4ce16e 100644 --- a/spec/collectionspace/mapper/tools/refname_spec.rb +++ b/spec/collectionspace/mapper/tools/refname_spec.rb @@ -79,8 +79,9 @@ args = { urn: 'urn:cspace:core.collectionspace.org:weird' } - expect{ - CollectionSpace::Mapper::Tools::RefName.new(args) }.to raise_error(CollectionSpace::Mapper::Tools::UnparseableUrnError) + expect do + CollectionSpace::Mapper::Tools::RefName.new(args) + end.to raise_error(CollectionSpace::Mapper::Tools::UnparseableUrnError) end end end @@ -91,9 +92,9 @@ urn: "urn:cspace:anthro.collectionspace.org:personauthorities:name(person):item:name(MaryPoole1796320156)'Mary Poole'", cache: @cache } - expect{ - CollectionSpace::Mapper::Tools::RefName.new(args) }.to raise_error(CollectionSpace::Mapper::Tools::RefNameArgumentError) + expect do + CollectionSpace::Mapper::Tools::RefName.new(args) + end.to raise_error(CollectionSpace::Mapper::Tools::RefNameArgumentError) end end end - diff --git a/spec/collectionspace/mapper/tools/symbolizable_spec.rb b/spec/collectionspace/mapper/tools/symbolizable_spec.rb index 96c1d734..47b5154d 100644 --- a/spec/collectionspace/mapper/tools/symbolizable_spec.rb +++ b/spec/collectionspace/mapper/tools/symbolizable_spec.rb @@ -3,13 +3,13 @@ require 'spec_helper' RSpec.describe CS::Mapper::Tools::Symbolizable do - let(:config) { JSON.parse('{ + let(:config) do + JSON.parse('{ "delimiter": ";", "subgroup_delimiter": "^^", "response_mode": "verbose", "force_defaults": false, "check_record_status": true, - "check_terms": true, "date_format": "month day year", "two_digit_year_handling": "convert to four digit", "transforms": { @@ -29,26 +29,25 @@ "collection": "library-collection" } }') - } + end let(:symconfig){ CS::Mapper::Tools::Symbolizable.symbolize(config) } describe '#symbolize' do it 'turns hash keys into symbols' do expected = %i[delimiter subgroup_delimiter response_mode force_defaults check_record_status - check_terms date_format two_digit_year_handling transforms default_values] + date_format two_digit_year_handling transforms default_values] expect(symconfig.keys).to eq(expected) end end describe '#symbolize_transforms' do let(:transforms){ symconfig[:transforms] } - let(:expected) { {'collection' => {special: ['downcase_value'], - replacements: [{find: ' ', replace: '-', type: 'plain'}] - }} - } + let(:expected) do + {'collection' => {special: ['downcase_value'], + replacements: [{find: ' ', replace: '-', type: 'plain'}]}} + end it 'transforms as expected' do expect(CS::Mapper::Tools::Symbolizable.symbolize_transforms(transforms)).to eq(expected) end end end - diff --git a/spec/collectionspace/mapper/transformer_spec.rb b/spec/collectionspace/mapper/transformer_spec.rb index aeadd034..37fc25a8 100644 --- a/spec/collectionspace/mapper/transformer_spec.rb +++ b/spec/collectionspace/mapper/transformer_spec.rb @@ -5,19 +5,23 @@ RSpec.describe CollectionSpace::Mapper::Transformer do let(:client){ anthro_client } let(:cache){ anthro_cache } - let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject_transforms.json'} - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), - csclient: client, - termcache: cache) } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject_transforms.json' } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), + csclient: client, + termcache: cache) + end describe '.create' do - let(:creator) { described_class.create(recmapper: recmapper, - type: type, - transform: transform) } + let(:creator) do + described_class.create(recmapper: recmapper, + type: type, + transform: transform) + end context 'given an authority transform' do let(:type){ :authority } - let(:transform){ ['personauthorities', 'person'] } + let(:transform){ %w[personauthorities person] } it 'returns an AuthorityTransformer' do expect(creator).to be_a(CS::Mapper::AuthorityTransformer) @@ -34,7 +38,7 @@ context 'given special transforms' do let(:type){ :special } - let(:transform){ ['downcase_value', 'boolean', 'behrensmeyer_translate'] } + let(:transform){ %w[downcase_value boolean behrensmeyer_translate] } it 'returns array of expected transformers' do expected = [CS::Mapper::DowncaseTransformer, CS::Mapper::BooleanTransformer, CS::Mapper::BehrensmeyerTransformer] diff --git a/spec/collectionspace/mapper/transformers_spec.rb b/spec/collectionspace/mapper/transformers_spec.rb index 229dec1d..c89ecc43 100644 --- a/spec/collectionspace/mapper/transformers_spec.rb +++ b/spec/collectionspace/mapper/transformers_spec.rb @@ -5,14 +5,18 @@ RSpec.describe CollectionSpace::Mapper::Transformers do let(:client){ anthro_client } let(:cache){ anthro_cache } - let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject_transforms.json'} - let(:recmapper) { CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), - csclient: client, - termcache: cache) } + let(:mapperpath){ 'spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject_transforms.json' } + let(:recmapper) do + CS::Mapper::RecordMapper.new(mapper: File.read(mapperpath), + csclient: client, + termcache: cache) + end let(:mapping){ recmapper.mappings.lookup(colname) } - let(:xforms) { described_class.new(colmapping: mapping, - transforms: mapping.transforms, - recmapper: recmapper) } + let(:xforms) do + described_class.new(colmapping: mapping, + transforms: mapping.transforms, + recmapper: recmapper) + end describe '#queue' do context 'when measuredByPerson column' do diff --git a/spec/collectionspace/mapper/value_transformer_spec.rb b/spec/collectionspace/mapper/value_transformer_spec.rb index 9c85d7a5..ae00bd6f 100644 --- a/spec/collectionspace/mapper/value_transformer_spec.rb +++ b/spec/collectionspace/mapper/value_transformer_spec.rb @@ -4,15 +4,15 @@ RSpec.describe CollectionSpace::Mapper::ValueTransformer do before(:all) do - client = anthro_client - cache = anthro_cache - mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json') - handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: mapper, - client: client, - cache: cache, - config: {}) - @prepper = CollectionSpace::Mapper::DataPrepper.new({}, handler) - end + client = anthro_client + cache = anthro_cache + mapper = get_json_record_mapper('spec/fixtures/files/mappers/release_6_1/anthro/anthro_4-1-2_collectionobject.json') + handler = CollectionSpace::Mapper::DataHandler.new(record_mapper: mapper, + client: client, + cache: cache, + config: {}) + @prepper = CollectionSpace::Mapper::DataPrepper.new({}, handler) + end context 'when vocabulary' do context 'and vocabulary is behrensmeyer number' do @@ -32,8 +32,7 @@ transforms = {vocabulary: 'agerange', special: %w[downcase_value], replacements: [ {find: ' - ', replace: '-', type: :plain} - ] - } + ]} res = CollectionSpace::Mapper::ValueTransformer.new(value, transforms, @prepper).result ex = 'adolescent 26-75%' expect(res).to eq(ex) @@ -57,6 +56,3 @@ end end end - - - diff --git a/spec/collectionspace/mapper_spec.rb b/spec/collectionspace/mapper_spec.rb index c5a3e091..e2d5ab31 100644 --- a/spec/collectionspace/mapper_spec.rb +++ b/spec/collectionspace/mapper_spec.rb @@ -11,13 +11,13 @@ context 'when passed a CollectionSpace::Mapper::Response' do it 'returns that Response' do response = CollectionSpace::Mapper::Response.new({'objectNumber' => '123'}) - expect(CollectionSpace::Mapper::setup_data(response)).to eq(response) + expect(CollectionSpace::Mapper.setup_data(response)).to eq(response) end end context 'when passed a Hash' do before(:all) do @data = {'objectNumber' => '123'} - @response = CollectionSpace::Mapper::setup_data(@data) + @response = CollectionSpace::Mapper.setup_data(@data) end it 'returns a CollectionSpace::Mapper::Response with expected orig_data' do expect(@response).to be_a(CollectionSpace::Mapper::Response) @@ -26,10 +26,11 @@ end context 'when passed other class of object' do it 'returns a CollectionSpace::Mapper::Response' do - data = ['objectNumber', '123'] - expect{ - CollectionSpace::Mapper::setup_data(data) }.to raise_error(CollectionSpace::Mapper::Errors::UnprocessableDataError, - 'Cannot process a Array. Need a Hash or Mapper::Response') + data = %w[objectNumber 123] + expect do + CollectionSpace::Mapper.setup_data(data) + end.to raise_error(CollectionSpace::Mapper::Errors::UnprocessableDataError, + 'Cannot process a Array. Need a Hash or Mapper::Response') end end end diff --git a/spec/core_helpers.rb b/spec/core_helpers.rb index 9998db94..f9379a39 100644 --- a/spec/core_helpers.rb +++ b/spec/core_helpers.rb @@ -39,189 +39,372 @@ def core_object_mapper def populate_core(cache) terms = [ - ['citationauthorities', 'citation', 'Arthur', "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Arthur62605812848)'Arthur'"], - ['citationauthorities', 'citation', 'Harding', "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Harding2510592089)'Harding'"], - ['citationauthorities', 'citation', 'Wanting', "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Wanting1599560009399)'Wanting'"], - ['citationauthorities', 'citation', 'makasi', "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(makasi1599645537547)'makasi'"], - ['citationauthorities', 'worldcat', 'Chelse', "urn:cspace:core.collectionspace.org:citationauthorities:name(worldcat):item:name(Chelse1599645525740)'Chelse'"], - ['citationauthorities', 'worldcat', 'Patiently', "urn:cspace:core.collectionspace.org:citationauthorities:name(worldcat):item:name(Patiently1599559993332)'Patiently'"], - ['collectionobjects', '', 'Hierarchy Test 001', "urn:cspace:core.collectionspace.org:collectionobjects:id(16161bff-b01a-4b55-95aa)'Hierarchy Test 001'"], - ['conceptauthorities', 'concept', 'Test', "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(Test1599650854716)'Test'"], - ['conceptauthorities', 'concept', 'Sample Concept 1', "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(SampleConcept11581354228875)'Sample Concept 1'"], - ['conceptauthorities', 'concept', 'Uno', "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(Uno1599645111177)'Uno'"], - ['conceptauthorities', 'occasion', 'Computer', "urn:cspace:core.collectionspace.org:conceptauthorities:name(occasion):item:name(Computer1599734104251)'Computer'"], - ['locationauthorities', 'indeterminate', '~Indeterminate Location~', "urn:cspace:indeterminate:locationauthorities:name(indeterminate):item:name(indeterminate)'~Indeterminate Location~'"], - ['locationauthorities', 'location', 'Abardares', "urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(Abardares1599557570049)'Abardares'"], - ['locationauthorities', 'location', 'Kalif', "urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(Kalif1599734233745)'Kalif'"], - ['locationauthorities', 'location', 'Khago', "urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(Khago1599559772718)'Khago'"], - ['locationauthorities', 'location', 'Stay', "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Stay1599559824865)'Stay'"], - ['locationauthorities', 'offsite_sla', 'Lavington', "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Lavington1599144699983)'Lavington'"], - ['locationauthorities', 'offsite_sla', 'Ngong', "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Ngong1599557586466)'Ngong'"], - ['locationauthorities', 'offsite_sla', 'Stay', "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Stay)'Stay'"], - ['orgauthorities', 'organization', '2021', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(20211599147173971)'2021'"], - ['orgauthorities', 'organization', 'Astroworld', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Astroworld1599650794829)'Astroworld'"], - ['orgauthorities', 'organization', 'Broker', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Broker1599221487572)'Broker'"], - ['orgauthorities', 'organization', 'But Ohh', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(ButOhh1599665031368)'But Ohh'"], - ['orgauthorities', 'organization', 'Cuckoo', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Cuckoo1599463786824)'Cuckoo'"], - ['orgauthorities', 'organization', 'Ibiza', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Ibiza1599650806827)'Ibiza'"], - ['orgauthorities', 'organization', 'Joseph Hills', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(JosephHills1599463935463)'Joseph Hills'"], - ['orgauthorities', 'organization', 'Kremling', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Kremling1599464161204)'Kremling'"], - ['orgauthorities', 'organization', 'MMG', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(MMG1599569514486)'MMG'"], - ['orgauthorities', 'organization', 'Martin', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Martin1599559712783)'Martin'"], - ['orgauthorities', 'organization', 'Ninja', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Ninja1599147339325)'Ninja'"], - ['orgauthorities', 'organization', 'Oval', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Oval1599650891221)'Oval'"], - ['orgauthorities', 'organization', 'Podoa', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Podoa1599645346399)'Podoa'"], - ['orgauthorities', 'organization', 'Rock Nation', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(RockNation1599569481908)'Rock Nation'"], - ['orgauthorities', 'organization', 'Sidarec', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Sidarec1599210955079)'Sidarec'"], - ['orgauthorities', 'organization', 'TIm Herod', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(TImHerod1599144655199)'TIm Herod'"], - ['orgauthorities', 'organization', 'Tasia', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Tasia1599734050597)'Tasia'"], - ['orgauthorities', 'organization', 'Tesla', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Tesla1599144565539)'Tesla'"], - ['orgauthorities', 'organization', 'Walai', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Walai1599645181370)'Walai'"], - ['orgauthorities', 'organization', 'breakup', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(breakup1599559909048)'breakup'"], - ['orgauthorities', 'organization', 'fggf', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(fggf1599552009173)'fggf'"], - ['orgauthorities', 'organization', 'pandemic', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(pandemic1599645036126)'pandemic'"], - ['orgauthorities', 'organization', 'pop', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(pop1599664789385)'pop'"], - ['orgauthorities', 'organization', 'pupu', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(pupu1599645415676)'pupu'"], - ['orgauthorities', 'organization', 'tent', "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(tent1599664807586)'tent'"], - ['orgauthorities', 'ulan_oa', 'Again', "urn:cspace:core.collectionspace.org:orgauthorities:name(ulan_oa):item:name(Again1599559881266)'Again'"], - ['orgauthorities', 'ulan_oa', 'Signal', "urn:cspace:core.collectionspace.org:orgauthorities:name(ulan_oa):item:name(Signal1599559737158)'Signal'"], - ['orgauthorities', 'ulan_oa', 'Very fats', "urn:cspace:core.collectionspace.org:orgauthorities:name(ulan_oa):item:name(Veryfats1599645188567)'Very fats'"], - ['personauthorities', 'person', 'Broooks', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Broooks1599221558583)'Broooks'"], - ['personauthorities', 'person', '2020', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(20201599147149106)'2020'"], - ['personauthorities', 'person', '254Glock', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(254Glock1599569494651)'254Glock'"], - ['personauthorities', 'person', 'Abel', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Abel1599464025893)'Abel'"], - ['personauthorities', 'person', 'Alexa', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Alexa1599557607978)'Alexa'"], - ['personauthorities', 'person', 'Andrew Watts', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(AndrewWatts1599144553996)'Andrew Watts'"], - ['personauthorities', 'person', 'Busy', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Busy1599559723432)'Busy'"], - ['personauthorities', 'person', 'Cardi', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Cardi1599569468209)'Cardi'"], - ['personauthorities', 'person', 'Clemo', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Clemo1599221473000)'Clemo'"], - ['personauthorities', 'person', 'Clon', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Clon1599569543362)'Clon'"], - ['personauthorities', 'person', 'Comodore', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Comodore1599463826401)'Comodore'"], - ['personauthorities', 'person', 'Comrade', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Comrade1599664745661)'Comrade'"], - ['personauthorities', 'person', 'Cooper Phil', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(CooperPhil1599144599479)'Cooper Phil'"], - ['personauthorities', 'person', 'Disturb', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Disturb1599665062738)'Disturb'"], - ['personauthorities', 'person', 'Dudu', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Dudu1599645410044)'Dudu'"], - ['personauthorities', 'person', 'Erick', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Erick1599734121151)'Erick'"], - ['personauthorities', 'person', 'First Layer', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(FirstLayer1599463905818)'First Layer'"], - ['personauthorities', 'person', 'Glock', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Glock1599580905730)'Glock'"], - ['personauthorities', 'person', 'Gomongo', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Gomongo1599463746195)'Gomongo'"], - ['personauthorities', 'person', 'Grace', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Grace1599569599918)'Grace'"], - ['personauthorities', 'person', 'Henry', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Henry1599210937770)'Henry'"], - ['personauthorities', 'person', 'Home Alone', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(HomeAlone1599144524188)'Home Alone'"], - ['personauthorities', 'person', 'James', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(James1599210943727)'James'"], - ['personauthorities', 'person', 'Jamo', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Jamo1599221465693)'Jamo'"], - ['personauthorities', 'person', 'Joel', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Joel1599557736045)'Joel'"], - ['personauthorities', 'person', 'John Allen', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(JohnAllen1599144390263)'John Allen'"], - ['personauthorities', 'person', 'John Kay', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(JohnKay1599210868122)'John Kay'"], - ['personauthorities', 'person', 'Kali', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kali1599221504661)'Kali'"], - ['personauthorities', 'person', 'Karanja', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Karanja1599211015378)'Karanja'"], - ['personauthorities', 'person', 'Kev', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kev1599058769862)'Kev'"], - ['personauthorities', 'person', 'Kimani', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kimani1599210926973)'Kimani'"], - ['personauthorities', 'person', 'Kimonda', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kimonda1599211004900)'Kimonda'"], - ['personauthorities', 'person', 'King Kosa', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(KingKosa1599569726990)'King Kosa'"], - ['personauthorities', 'person', 'Kinuthia', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kinuthia1599734017515)'Kinuthia'"], - ['personauthorities', 'person', 'Lebron', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Lebron1599557725925)'Lebron'"], - ['personauthorities', 'person', 'Lima', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Lima1599645323459)'Lima'"], - ['personauthorities', 'person', 'Loan', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Loan1599210896616)'Loan'"], - ['personauthorities', 'person', 'Mark Smith', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(MarkSmith)'Mark Smith'"], - ['personauthorities', 'person', 'Meghan', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Meghan1599569567326)'Meghan'"], - ['personauthorities', 'person', 'Nyauma', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Nyauma1599210983879)'Nyauma'"], - ['personauthorities', 'person', 'Scribe', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Scribe1599645240974)'Scribe'"], - ['personauthorities', 'person', 'Shen Yeng', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(ShenYeng1599569685887)'Shen Yeng'"], - ['personauthorities', 'person', 'Soi', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Soi1599734190999)'Soi'"], - ['personauthorities', 'person', 'Switch', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Switch1599645085995)'Switch'"], - ['personauthorities', 'person', 'Tim Joes', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(TimJoes1599144424859)'Tim Joes'"], - ['personauthorities', 'person', 'Trepoz', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Trepoz1599221497512)'Trepoz'"], - ['personauthorities', 'person', 'Trevor', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Trevor1599144536281)'Trevor'"], - ['personauthorities', 'person', 'Troy', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Troy1599144360617)'Troy'"], - ['personauthorities', 'person', 'afa', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(afa1599645004939)'afa'"], - ['personauthorities', 'person', 'cxcx', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(cxcx1599551790384)'cxcx'"], - ['personauthorities', 'person', 'dfdd', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(dfdd1599551799173)'dfdd'"], - ['personauthorities', 'person', 'dssd', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(dssd1599552004115)'dssd'"], - ['personauthorities', 'person', 'fgfgf', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(fgfgf1599551987166)'fgfgf'"], - ['personauthorities', 'person', 'giri', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(giri1599645613143)'giri'"], - ['personauthorities', 'person', 'high grade', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(highgrade1599645597889)'high grade'"], - ['personauthorities', 'person', 'malik', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(malik1599664876144)'malik'"], - ['personauthorities', 'person', 'marcus', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(marcus1599650918612)'marcus'"], - ['personauthorities', 'person', 'marley', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(marley1599650874712)'marley'"], - ['personauthorities', 'person', 'rights', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(rights1599650868011)'rights'"], - ['personauthorities', 'person', 'rudelyt', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(rudelyt1599664917218)'rudelyt'"], - ['personauthorities', 'person', 'sasa', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(sasa1599551852678)'sasa'"], - ['personauthorities', 'person', 'tint', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(tint1599664800144)'tint'"], - ['personauthorities', 'person', 'tonight', "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(tonight1599664781376)'tonight'"], - ['personauthorities', 'ulan_pa', 'Chrus', "urn:cspace:core.collectionspace.org:personauthorities:name(ulan_pa):item:name(Chrus1599559702930)'Chrus'"], - ['personauthorities', 'ulan_pa', 'We go', "urn:cspace:core.collectionspace.org:personauthorities:name(ulan_pa):item:name(Wego1599559866517)'We go'"], - ['personauthorities', 'ulan_pa', 'panda nayo', "urn:cspace:core.collectionspace.org:personauthorities:name(ulan_pa):item:name(pandanayo1599645094507)'panda nayo'"], - ['placeauthorities', 'place', 'Chillspot', "urn:cspace:core.collectionspace.org:placeauthorities:name(place):item:name(Chillspot1599145441945)'Chillspot'"], - ['placeauthorities', 'tgn_place', 'mzingga', "urn:cspace:core.collectionspace.org:placeauthorities:name(tgn_place):item:name(mzingga1599645587502)'mzingga'"], - ['vocabularies', 'agequalifier', 'older than', "urn:cspace:core.collectionspace.org:vocabularies:name(agequalifier):item:name(olderthan)'older than'"], - ['vocabularies', 'collectionmethod', 'donation', "urn:cspace:core.collectionspace.org:vocabularies:name(collectionmethod):item:name(donation)'donation'"], - ['vocabularies', 'collectionmethod', 'excavation', "urn:cspace:core.collectionspace.org:vocabularies:name(collectionmethod):item:name(excavation)'excavation'"], - ['vocabularies', 'conditioncheckmethod', 'Observed', "urn:cspace:core.collectionspace.org:vocabularies:name(conditioncheckmethod):item:name(observed)'Observed'"], - ['vocabularies', 'conditioncheckreason', 'Damaged in transit', "urn:cspace:core.collectionspace.org:vocabularies:name(conditioncheckreason):item:name(damagedintransit)'Damaged in transit'"], - ['vocabularies', 'conditionfitness', 'Reasonable', "urn:cspace:core.collectionspace.org:vocabularies:name(conditionfitness):item:name(reasonable)'Reasonable'"], - ['vocabularies', 'conservationstatus', 'Analysis complete', "urn:cspace:core.collectionspace.org:vocabularies:name(conservationstatus):item:name(analysiscomplete)'Analysis complete'"], - ['vocabularies', 'conservationstatus', 'Treatment approved', "urn:cspace:core.collectionspace.org:vocabularies:name(conservationstatus):item:name(treatmentapproved)'Treatment approved'"], - ['vocabularies', 'conservationstatus', 'Treatment in progress', "urn:cspace:core.collectionspace.org:vocabularies:name(conservationstatus):item:name(treatmentinprogress)'Treatment in progress'"], - ['vocabularies', 'currency', 'Canadian Dollar', "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(CAD)'Canadian Dollar'"], - ['vocabularies', 'currency', 'Danish Krone', "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(DKK)'Danish Krone'"], - ['vocabularies', 'currency', 'Euro', "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(EUR)'Euro'"], - ['vocabularies', 'currency', 'Pound Sterling', "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(GBP)'Pound Sterling'"], - ['vocabularies', 'currency', 'Swedish Krona', "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(SEK)'Swedish Krona'"], - ['vocabularies', 'currency', 'Swiss Franc', "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(CHF)'Swiss Franc'"], - ['vocabularies', 'datecertainty', 'Circa', "urn:cspace:core.collectionspace.org:vocabularies:name(datecertainty):item:name(circa)'Circa'"], - ['vocabularies', 'dateera', 'BCE', "urn:cspace:core.collectionspace.org:vocabularies:name(dateera):item:name(bce)'BCE'"], - ['vocabularies', 'dateera', 'CE', "urn:cspace:core.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'"], - ['vocabularies', 'datequalifier', 'Day(s)', "urn:cspace:core.collectionspace.org:vocabularies:name(datequalifier):item:name(days)'Day(s)'"], - ['vocabularies', 'datequalifier', 'Year(s)', "urn:cspace:core.collectionspace.org:vocabularies:name(datequalifier):item:name(years)'Year(s)'"], - ['vocabularies', 'deaccessionapprovalgroup', 'board of trustees', "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(board_of_trustees)'board of trustees'"], - ['vocabularies', 'deaccessionapprovalgroup', 'collection committee', "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(collection_committee)'collection committee'"], - ['vocabularies', 'deaccessionapprovalgroup', 'executive committee', "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(executive_committee)'executive committee'"], - ['vocabularies', 'deaccessionapprovalstatus', 'approved', "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(approved)'approved'"], - ['vocabularies', 'deaccessionapprovalstatus', 'not approved', "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(not_approved)'not approved'"], - ['vocabularies', 'deaccessionapprovalstatus', 'not required', "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(not_required)'not required'"], - ['vocabularies', 'disposalmethod', 'destruction', "urn:cspace:core.collectionspace.org:vocabularies:name(disposalmethod):item:name(destruction)'destruction'"], - ['vocabularies', 'entrymethod', 'Found on doorstep', "urn:cspace:core.collectionspace.org:vocabularies:name(entrymethod):item:name(foundondoorstep)'Found on doorstep'"], - ['vocabularies', 'entrymethod', 'Post', "urn:cspace:core.collectionspace.org:vocabularies:name(entrymethod):item:name(post)'Post'"], - ['vocabularies', 'examinationphase', 'before treatment', "urn:cspace:core.collectionspace.org:vocabularies:name(examinationphase):item:name(beforetreatment)'before treatment'"], - ['vocabularies', 'examinationphase', 'during treatment', "urn:cspace:core.collectionspace.org:vocabularies:name(examinationphase):item:name(duringtreatment)'during treatment'"], - ['vocabularies', 'exhibitionpersonrole', 'Educator', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionpersonrole):item:name(educator)'Educator'"], - ['vocabularies', 'exhibitionpersonrole', 'Public programs coordinator', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionpersonrole):item:name(publicprogramscoordinator)'Public programs coordinator'"], - ['vocabularies', 'exhibitionreferencetype', 'News article', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionreferencetype):item:name(newsarticle)'News article'"], - ['vocabularies', 'exhibitionreferencetype', 'Press release', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionreferencetype):item:name(pressrelease)'Press release'"], - ['vocabularies', 'exhibitionstatus', 'Preliminary object list created', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionstatus):item:name(preliminaryobjectlistcreated)'Preliminary object list created'"], - ['vocabularies', 'exhibitiontype', 'Temporary', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitiontype):item:name(temporary)'Temporary'"], - ['vocabularies', 'inventorystatus', 'accession status unclear', "urn:cspace:core.collectionspace.org:vocabularies:name(inventorystatus):item:name(accessionstatusunclear)'accession status unclear'"], - ['vocabularies', 'inventorystatus', 'destroyed', "urn:cspace:core.collectionspace.org:vocabularies:name(inventorystatus):item:name(destroyed)'destroyed'"], - ['vocabularies', 'inventorystatus', 'unknown', "urn:cspace:core.collectionspace.org:vocabularies:name(inventorystatus):item:name(unknown)'unknown'"], - ['vocabularies', 'languages', 'Ancient Greek', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(grc)'Ancient Greek'"], - ['vocabularies', 'languages', 'Armenian', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(hye)'Armenian'"], - ['vocabularies', 'languages', 'English', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(eng)'English'"], - ['vocabularies', 'languages', 'French', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(fra)'French'"], - ['vocabularies', 'languages', 'Malaysian', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(mal)'Malaysian'"], - ['vocabularies', 'languages', 'Spanish', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'"], - ['vocabularies', 'languages', 'Swahili', "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(swa)'Swahili'"], - ['vocabularies', 'loanoutstatus', 'Authorized', "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(authorized)'Authorized'"], - ['vocabularies', 'loanoutstatus', 'Photography requested', "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(photographyrequested)'Photography requested'"], - ['vocabularies', 'loanoutstatus', 'Refused', "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(refused)'Refused'"], - ['vocabularies', 'loanoutstatus', 'Returned', "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(returned)'Returned'"], - ['vocabularies', 'newsarticle', 'News article', "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionreferencetype):item:name(newsarticle)'News article'"], - ['vocabularies', 'otherpartyrole', 'Preparator', "urn:cspace:core.collectionspace.org:vocabularies:name(otherpartyrole):item:name(preparator)'Preparator'"], - ['vocabularies', 'otherpartyrole', 'Technician', "urn:cspace:core.collectionspace.org:vocabularies:name(otherpartyrole):item:name(technician)'Technician'"], - ['vocabularies', 'publishto', 'CollectionSpace Public Browser', "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(cspacepub)'CollectionSpace Public Browser'"], - ['vocabularies', 'publishto', 'Culture Object', "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(cultureobject)'Culture Object'"], - ['vocabularies', 'publishto', 'None', "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(none)'None'"], - ['vocabularies', 'publishto', 'Omeka', "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(omeka)'Omeka'"], - ['vocabularies', 'treatmentpurpose', 'Exhibition', "urn:cspace:core.collectionspace.org:vocabularies:name(treatmentpurpose):item:name(exhibition)'Exhibition'"], - ['vocabularies', 'uocauthorizationstatuses', 'Approved', "urn:cspace:core.collectionspace.org:vocabularies:name(uocauthorizationstatuses):item:name(approved)'Approved'"], - ['vocabularies', 'uoccollectiontypes', 'archeology', "urn:cspace:core.collectionspace.org:vocabularies:name(uoccollectiontypes):item:name(uocarcheology)'archeology'"], - ['vocabularies', 'uocmaterialtypes', 'bulb', "urn:cspace:core.collectionspace.org:vocabularies:name(uocmaterialtypes):item:name(bulb)'bulb'"], - ['vocabularies', 'uocmethods', 'class', "urn:cspace:core.collectionspace.org:vocabularies:name(uocmethods):item:name(class)'class'"], - ['vocabularies', 'uocstaffroles', 'greeter', "urn:cspace:core.collectionspace.org:vocabularies:name(uocstaffroles):item:name(greeter)'greeter'"], - ['vocabularies', 'uocsubcollections', 'Asia', "urn:cspace:core.collectionspace.org:vocabularies:name(uocsubcollections):item:name(uocsubcollection02)'Asia'"], - ['vocabularies', 'uocuserroles', 'faculty', "urn:cspace:core.collectionspace.org:vocabularies:name(uocuserroles):item:name(faculty)'faculty'"], - ['vocabularies', 'uocusertypes', 'lecturer', "urn:cspace:core.collectionspace.org:vocabularies:name(uocusertypes):item:name(lecturer)'lecturer'"], - ['workauthorities', 'work', 'Makeup', "urn:cspace:core.collectionspace.org:workauthorities:name(work):item:name(Makeup1608768998350)'Makeup'"], + ['citationauthorities', 'citation', 'Arthur', + {refname: "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Arthur62605812848)'Arthur'", csid: '1111-2222-3333-4444'}], + ['citationauthorities', 'citation', 'Harding', + {refname: "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Harding2510592089)'Harding'", csid: '1111-2222-3333-4444'}], + ['citationauthorities', 'citation', 'Wanting', + {refname: "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(Wanting1599560009399)'Wanting'", csid: '1111-2222-3333-4444'}], + ['citationauthorities', 'citation', 'makasi', + {refname: "urn:cspace:core.collectionspace.org:citationauthorities:name(citation):item:name(makasi1599645537547)'makasi'", csid: '1111-2222-3333-4444'}], + ['citationauthorities', 'worldcat', 'Chelse', + {refname: "urn:cspace:core.collectionspace.org:citationauthorities:name(worldcat):item:name(Chelse1599645525740)'Chelse'", csid: '1111-2222-3333-4444'}], + ['citationauthorities', 'worldcat', 'Patiently', + {refname: "urn:cspace:core.collectionspace.org:citationauthorities:name(worldcat):item:name(Patiently1599559993332)'Patiently'", csid: '1111-2222-3333-4444'}], + ['collectionobjects', '', 'Hierarchy Test 001', + {refname: "urn:cspace:core.collectionspace.org:collectionobjects:id(16161bff-b01a-4b55-95aa)'Hierarchy Test 001'", csid: '16161bff-b01a-4b55-95aa'}], + ['conceptauthorities', 'concept', 'Test', + {refname: "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(Test1599650854716)'Test'", csid: '1111-2222-3333-4444'}], + ['conceptauthorities', 'concept', 'Sample Concept 1', + {refname: "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(SampleConcept11581354228875)'Sample Concept 1'", csid: '1111-2222-3333-4444'}], + ['conceptauthorities', 'concept', 'Uno', + {refname: "urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(Uno1599645111177)'Uno'", csid: '1111-2222-3333-4444'}], + ['conceptauthorities', 'occasion', 'Computer', + {refname: "urn:cspace:core.collectionspace.org:conceptauthorities:name(occasion):item:name(Computer1599734104251)'Computer'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'indeterminate', '~Indeterminate Location~', + {refname: "urn:cspace:indeterminate:locationauthorities:name(indeterminate):item:name(indeterminate)'~Indeterminate Location~'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'location', 'Abardares', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(Abardares1599557570049)'Abardares'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'location', 'Kalif', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(Kalif1599734233745)'Kalif'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'location', 'Khago', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(location):item:name(Khago1599559772718)'Khago'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'location', 'Stay', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Stay1599559824865)'Stay'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'offsite_sla', 'Lavington', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Lavington1599144699983)'Lavington'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'offsite_sla', 'Ngong', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Ngong1599557586466)'Ngong'", csid: '1111-2222-3333-4444'}], + ['locationauthorities', 'offsite_sla', 'Stay', + {refname: "urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Stay)'Stay'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', '2021', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(20211599147173971)'2021'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Astroworld', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Astroworld1599650794829)'Astroworld'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Broker', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Broker1599221487572)'Broker'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'But Ohh', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(ButOhh1599665031368)'But Ohh'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Cuckoo', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Cuckoo1599463786824)'Cuckoo'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Ibiza', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Ibiza1599650806827)'Ibiza'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Joseph Hills', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(JosephHills1599463935463)'Joseph Hills'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Kremling', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Kremling1599464161204)'Kremling'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'MMG', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(MMG1599569514486)'MMG'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Martin', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Martin1599559712783)'Martin'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Ninja', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Ninja1599147339325)'Ninja'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Oval', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Oval1599650891221)'Oval'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Podoa', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Podoa1599645346399)'Podoa'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Rock Nation', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(RockNation1599569481908)'Rock Nation'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Sidarec', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Sidarec1599210955079)'Sidarec'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'TIm Herod', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(TImHerod1599144655199)'TIm Herod'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Tasia', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Tasia1599734050597)'Tasia'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Tesla', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Tesla1599144565539)'Tesla'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'Walai', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(Walai1599645181370)'Walai'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'breakup', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(breakup1599559909048)'breakup'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'fggf', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(fggf1599552009173)'fggf'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'pandemic', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(pandemic1599645036126)'pandemic'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'pop', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(pop1599664789385)'pop'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'pupu', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(pupu1599645415676)'pupu'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'organization', 'tent', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(organization):item:name(tent1599664807586)'tent'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'ulan_oa', 'Again', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(ulan_oa):item:name(Again1599559881266)'Again'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'ulan_oa', 'Signal', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(ulan_oa):item:name(Signal1599559737158)'Signal'", csid: '1111-2222-3333-4444'}], + ['orgauthorities', 'ulan_oa', 'Very fats', + {refname: "urn:cspace:core.collectionspace.org:orgauthorities:name(ulan_oa):item:name(Veryfats1599645188567)'Very fats'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Broooks', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Broooks1599221558583)'Broooks'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', '2020', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(20201599147149106)'2020'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', '254Glock', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(254Glock1599569494651)'254Glock'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Abel', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Abel1599464025893)'Abel'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Alexa', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Alexa1599557607978)'Alexa'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Andrew Watts', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(AndrewWatts1599144553996)'Andrew Watts'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Busy', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Busy1599559723432)'Busy'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Cardi', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Cardi1599569468209)'Cardi'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Clemo', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Clemo1599221473000)'Clemo'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Clon', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Clon1599569543362)'Clon'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Comodore', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Comodore1599463826401)'Comodore'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Comrade', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Comrade1599664745661)'Comrade'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Cooper Phil', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(CooperPhil1599144599479)'Cooper Phil'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Disturb', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Disturb1599665062738)'Disturb'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Dudu', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Dudu1599645410044)'Dudu'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Erick', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Erick1599734121151)'Erick'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'First Layer', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(FirstLayer1599463905818)'First Layer'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Glock', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Glock1599580905730)'Glock'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Gomongo', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Gomongo1599463746195)'Gomongo'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Grace', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Grace1599569599918)'Grace'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Henry', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Henry1599210937770)'Henry'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Home Alone', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(HomeAlone1599144524188)'Home Alone'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'James', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(James1599210943727)'James'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Jamo', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Jamo1599221465693)'Jamo'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Joel', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Joel1599557736045)'Joel'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'John Allen', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(JohnAllen1599144390263)'John Allen'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'John Kay', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(JohnKay1599210868122)'John Kay'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Kali', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kali1599221504661)'Kali'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Karanja', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Karanja1599211015378)'Karanja'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Kev', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kev1599058769862)'Kev'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Kimani', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kimani1599210926973)'Kimani'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Kimonda', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kimonda1599211004900)'Kimonda'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'King Kosa', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(KingKosa1599569726990)'King Kosa'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Kinuthia', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Kinuthia1599734017515)'Kinuthia'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Lebron', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Lebron1599557725925)'Lebron'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Lima', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Lima1599645323459)'Lima'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Loan', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Loan1599210896616)'Loan'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Mark Smith', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(MarkSmith)'Mark Smith'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Meghan', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Meghan1599569567326)'Meghan'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Nyauma', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Nyauma1599210983879)'Nyauma'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Scribe', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Scribe1599645240974)'Scribe'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Shen Yeng', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(ShenYeng1599569685887)'Shen Yeng'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Soi', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Soi1599734190999)'Soi'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Switch', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Switch1599645085995)'Switch'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Tim Joes', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(TimJoes1599144424859)'Tim Joes'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Trepoz', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Trepoz1599221497512)'Trepoz'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Trevor', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Trevor1599144536281)'Trevor'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'Troy', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(Troy1599144360617)'Troy'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'afa', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(afa1599645004939)'afa'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'cxcx', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(cxcx1599551790384)'cxcx'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'dfdd', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(dfdd1599551799173)'dfdd'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'dssd', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(dssd1599552004115)'dssd'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'fgfgf', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(fgfgf1599551987166)'fgfgf'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'giri', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(giri1599645613143)'giri'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'high grade', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(highgrade1599645597889)'high grade'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'malik', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(malik1599664876144)'malik'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'marcus', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(marcus1599650918612)'marcus'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'marley', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(marley1599650874712)'marley'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'rights', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(rights1599650868011)'rights'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'rudelyt', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(rudelyt1599664917218)'rudelyt'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'sasa', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(sasa1599551852678)'sasa'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'tint', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(tint1599664800144)'tint'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'person', 'tonight', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(person):item:name(tonight1599664781376)'tonight'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'ulan_pa', 'Chrus', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(ulan_pa):item:name(Chrus1599559702930)'Chrus'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'ulan_pa', 'We go', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(ulan_pa):item:name(Wego1599559866517)'We go'", csid: '1111-2222-3333-4444'}], + ['personauthorities', 'ulan_pa', 'panda nayo', + {refname: "urn:cspace:core.collectionspace.org:personauthorities:name(ulan_pa):item:name(pandanayo1599645094507)'panda nayo'", csid: '1111-2222-3333-4444'}], + ['placeauthorities', 'place', 'Chillspot', + {refname: "urn:cspace:core.collectionspace.org:placeauthorities:name(place):item:name(Chillspot1599145441945)'Chillspot'", csid: '1111-2222-3333-4444'}], + ['placeauthorities', 'tgn_place', 'mzingga', + {refname: "urn:cspace:core.collectionspace.org:placeauthorities:name(tgn_place):item:name(mzingga1599645587502)'mzingga'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'agequalifier', 'older than', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(agequalifier):item:name(olderthan)'older than'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'collectionmethod', 'donation', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(collectionmethod):item:name(donation)'donation'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'collectionmethod', 'excavation', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(collectionmethod):item:name(excavation)'excavation'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'conditioncheckmethod', 'Observed', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(conditioncheckmethod):item:name(observed)'Observed'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'conditioncheckreason', 'Damaged in transit', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(conditioncheckreason):item:name(damagedintransit)'Damaged in transit'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'conditionfitness', 'Reasonable', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(conditionfitness):item:name(reasonable)'Reasonable'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'conservationstatus', 'Analysis complete', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(conservationstatus):item:name(analysiscomplete)'Analysis complete'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'conservationstatus', 'Treatment approved', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(conservationstatus):item:name(treatmentapproved)'Treatment approved'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'conservationstatus', 'Treatment in progress', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(conservationstatus):item:name(treatmentinprogress)'Treatment in progress'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'currency', 'Canadian Dollar', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(CAD)'Canadian Dollar'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'currency', 'Danish Krone', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(DKK)'Danish Krone'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'currency', 'Euro', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(EUR)'Euro'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'currency', 'Pound Sterling', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(GBP)'Pound Sterling'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'currency', 'Swedish Krona', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(SEK)'Swedish Krona'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'currency', 'Swiss Franc', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(currency):item:name(CHF)'Swiss Franc'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'datecertainty', 'Circa', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(datecertainty):item:name(circa)'Circa'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'dateera', 'BCE', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(dateera):item:name(bce)'BCE'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'dateera', 'CE', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(dateera):item:name(ce)'CE'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'datequalifier', 'Day(s)', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(datequalifier):item:name(days)'Day(s)'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'datequalifier', 'Year(s)', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(datequalifier):item:name(years)'Year(s)'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'deaccessionapprovalgroup', 'board of trustees', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(board_of_trustees)'board of trustees'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'deaccessionapprovalgroup', 'collection committee', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(collection_committee)'collection committee'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'deaccessionapprovalgroup', 'executive committee', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalgroup):item:name(executive_committee)'executive committee'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'deaccessionapprovalstatus', 'approved', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(approved)'approved'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'deaccessionapprovalstatus', 'not approved', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(not_approved)'not approved'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'deaccessionapprovalstatus', 'not required', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(deaccessionapprovalstatus):item:name(not_required)'not required'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'disposalmethod', 'destruction', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(disposalmethod):item:name(destruction)'destruction'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'entrymethod', 'Found on doorstep', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(entrymethod):item:name(foundondoorstep)'Found on doorstep'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'entrymethod', 'Post', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(entrymethod):item:name(post)'Post'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'examinationphase', 'before treatment', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(examinationphase):item:name(beforetreatment)'before treatment'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'examinationphase', 'during treatment', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(examinationphase):item:name(duringtreatment)'during treatment'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'exhibitionpersonrole', 'Educator', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionpersonrole):item:name(educator)'Educator'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'exhibitionpersonrole', 'Public programs coordinator', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionpersonrole):item:name(publicprogramscoordinator)'Public programs coordinator'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'exhibitionreferencetype', 'News article', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionreferencetype):item:name(newsarticle)'News article'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'exhibitionreferencetype', 'Press release', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionreferencetype):item:name(pressrelease)'Press release'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'exhibitionstatus', 'Preliminary object list created', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionstatus):item:name(preliminaryobjectlistcreated)'Preliminary object list created'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'exhibitiontype', 'Temporary', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitiontype):item:name(temporary)'Temporary'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'inventorystatus', 'accession status unclear', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(inventorystatus):item:name(accessionstatusunclear)'accession status unclear'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'inventorystatus', 'destroyed', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(inventorystatus):item:name(destroyed)'destroyed'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'inventorystatus', 'unknown', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(inventorystatus):item:name(unknown)'unknown'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'Ancient Greek', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(grc)'Ancient Greek'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'Armenian', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(hye)'Armenian'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'English', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(eng)'English'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'French', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(fra)'French'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'Malaysian', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(mal)'Malaysian'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'Spanish', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(spa)'Spanish'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'languages', 'Swahili', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(languages):item:name(swa)'Swahili'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'loanoutstatus', 'Authorized', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(authorized)'Authorized'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'loanoutstatus', 'Photography requested', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(photographyrequested)'Photography requested'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'loanoutstatus', 'Refused', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(refused)'Refused'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'loanoutstatus', 'Returned', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(loanoutstatus):item:name(returned)'Returned'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'newsarticle', 'News article', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(exhibitionreferencetype):item:name(newsarticle)'News article'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'otherpartyrole', 'Preparator', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(otherpartyrole):item:name(preparator)'Preparator'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'otherpartyrole', 'Technician', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(otherpartyrole):item:name(technician)'Technician'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'publishto', 'CollectionSpace Public Browser', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(cspacepub)'CollectionSpace Public Browser'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'publishto', 'Culture Object', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(cultureobject)'Culture Object'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'publishto', 'None', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(none)'None'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'publishto', 'Omeka', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(publishto):item:name(omeka)'Omeka'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'treatmentpurpose', 'Exhibition', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(treatmentpurpose):item:name(exhibition)'Exhibition'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocauthorizationstatuses', 'Approved', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocauthorizationstatuses):item:name(approved)'Approved'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uoccollectiontypes', 'archeology', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uoccollectiontypes):item:name(uocarcheology)'archeology'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocmaterialtypes', 'bulb', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocmaterialtypes):item:name(bulb)'bulb'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocmethods', 'class', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocmethods):item:name(class)'class'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocstaffroles', 'greeter', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocstaffroles):item:name(greeter)'greeter'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocsubcollections', 'Asia', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocsubcollections):item:name(uocsubcollection02)'Asia'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocuserroles', 'faculty', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocuserroles):item:name(faculty)'faculty'", csid: '1111-2222-3333-4444'}], + ['vocabularies', 'uocusertypes', 'lecturer', + {refname: "urn:cspace:core.collectionspace.org:vocabularies:name(uocusertypes):item:name(lecturer)'lecturer'", csid: '1111-2222-3333-4444'}], + ['workauthorities', 'work', 'Makeup', + {refname: "urn:cspace:core.collectionspace.org:workauthorities:name(work):item:name(Makeup1608768998350)'Makeup'", csid: '1111-2222-3333-4444'}] ] populate(cache, terms) end diff --git a/spec/fcart_helpers.rb b/spec/fcart_helpers.rb index 13debc5b..90ec898d 100644 --- a/spec/fcart_helpers.rb +++ b/spec/fcart_helpers.rb @@ -22,8 +22,8 @@ def fcart_cache def populate_fcart(cache) terms = [ ['personauthorities', 'person', 'Elizabeth', - "urn:cspace:fcart.collectionspace.org:personauthorities:name(person):item:name(Elizabeth123)'Elizabeth'"] ] + {refname: "urn:cspace:fcart.collectionspace.org:personauthorities:name(person):item:name(Elizabeth123)'Elizabeth'", csid: '1111-2222-3333-4444'}] + ] populate(cache, terms) end - end diff --git a/spec/fixtures/files/datahashes/core/authorityHierarchy2.json b/spec/fixtures/files/datahashes/core/authorityHierarchy2.json new file mode 100644 index 00000000..be6d9d51 --- /dev/null +++ b/spec/fixtures/files/datahashes/core/authorityHierarchy2.json @@ -0,0 +1,6 @@ +{ + "term_type": "conceptauthorities", + "term_subtype": "concept", + "narrower_term": "Tuxedo cats", + "broader_term": "Cats" +} diff --git a/spec/fixtures/files/datahashes/core/nonHierarchicalRelationship2.json b/spec/fixtures/files/datahashes/core/nonHierarchicalRelationship2.json new file mode 100644 index 00000000..ff697bdc --- /dev/null +++ b/spec/fixtures/files/datahashes/core/nonHierarchicalRelationship2.json @@ -0,0 +1,6 @@ +{ + "item1_type": "collectionobjects", + "item1_id": "2020.1.107 TEST", + "item2_type": "movements", + "item2_id": "LOC MISSING" +} diff --git a/spec/fixtures/files/datahashes/core/objectHierarchy2.json b/spec/fixtures/files/datahashes/core/objectHierarchy2.json new file mode 100644 index 00000000..1bcd55d8 --- /dev/null +++ b/spec/fixtures/files/datahashes/core/objectHierarchy2.json @@ -0,0 +1,5 @@ +{ + "narrower_object_number": "MISSING", + "relationship_type": "separable-part", + "broader_object_number": "2020.1.105" +} diff --git a/spec/fixtures/files/xml/core/authorityHierarchy2.xml b/spec/fixtures/files/xml/core/authorityHierarchy2.xml new file mode 100644 index 00000000..54d286fd --- /dev/null +++ b/spec/fixtures/files/xml/core/authorityHierarchy2.xml @@ -0,0 +1,8 @@ + + + + + hasBroader + fba204d0-004b-49a3-8676 + + diff --git a/spec/fixtures/files/xml/core/nonHierarchicalRelationship2A.xml b/spec/fixtures/files/xml/core/nonHierarchicalRelationship2A.xml new file mode 100644 index 00000000..ba6b97e4 --- /dev/null +++ b/spec/fixtures/files/xml/core/nonHierarchicalRelationship2A.xml @@ -0,0 +1,8 @@ + + + + 22706401-8328-4778-86fa + affects + + + diff --git a/spec/fixtures/files/xml/core/nonHierarchicalRelationship2B.xml b/spec/fixtures/files/xml/core/nonHierarchicalRelationship2B.xml new file mode 100644 index 00000000..cf6b5036 --- /dev/null +++ b/spec/fixtures/files/xml/core/nonHierarchicalRelationship2B.xml @@ -0,0 +1,8 @@ + + + + + affects + 22706401-8328-4778-86fa + + diff --git a/spec/fixtures/files/xml/core/objectHierarchy2.xml b/spec/fixtures/files/xml/core/objectHierarchy2.xml new file mode 100644 index 00000000..2d0a870e --- /dev/null +++ b/spec/fixtures/files/xml/core/objectHierarchy2.xml @@ -0,0 +1,11 @@ + + + + + collectionobjects + hasBroader + separable-part + e37949e9-6402-4ad2-b899 + collectionobjects + + diff --git a/spec/helpers.rb b/spec/helpers.rb index 01764788..968ae08e 100644 --- a/spec/helpers.rb +++ b/spec/helpers.rb @@ -66,9 +66,7 @@ def get_xml_fixture(filename, remove_blanks = true) rejectfields = %w[computedCurrentLocation].sort doc.traverse do |node| # Drop empty nodes - if remove_blanks - node.remove unless node.text.match?(/\S/m) - end + node.remove if remove_blanks && !node.text.match?(/\S/m) # Drop sections of the document we don't write with the mapper node.remove if node.name == 'collectionspace_core' || node.name == 'account_permission' # Drop fields created by CS application @@ -107,22 +105,20 @@ def mapper_defined_paths(xpaths, mappings) end def remove_xpath_occurrence_indicators(path) - path.match(/^(.*)\//)[1].gsub(/\[\d+\]/, '') + path.match(%r{^(.*)/})[1].gsub(/\[\d+\]/, '') end def list_xpaths(doc) xpaths = get_xpaths(doc) - xpaths = field_value_xpaths(xpaths) - xpaths + field_value_xpaths(xpaths) end def standardize_value(string) if string.start_with?('urn:cspace') - val = string.sub(/(item:name\([a-zA-Z]+)\d+(\)')/, '\1\2') + string.sub(/(item:name\([a-zA-Z]+)\d+(\)')/, '\1\2') else - val = string + string end - val end def populate(cache, terms) @@ -131,5 +127,4 @@ def populate(cache, terms) end cache end - end diff --git a/spec/lhmc_helpers.rb b/spec/lhmc_helpers.rb index 176b5a7a..4163ffaf 100644 --- a/spec/lhmc_helpers.rb +++ b/spec/lhmc_helpers.rb @@ -22,9 +22,9 @@ def lhmc_cache def populate_lhmc(cache) terms = [ ['personauthorities', 'person', 'Ann Analyst', - "urn:cspace:lhmc.collectionspace.org:personauthorities:name(person):item:name(AnnAnalyst1594848799340)'Ann Analyst'"], + {refname: "urn:cspace:lhmc.collectionspace.org:personauthorities:name(person):item:name(AnnAnalyst1594848799340)'Ann Analyst'", csid: '1111-2222-3333-4444'}], ['vocabularies', 'agerange', 'adolescent 26-75%', - "urn:cspace:lhmc.collectionspace.org:vocabularies:name(agerange):item:name(adolescent_26_75)'adolescent 26-75%'"], + {refname: "urn:cspace:lhmc.collectionspace.org:vocabularies:name(agerange):item:name(adolescent_26_75)'adolescent 26-75%'", csid: '1111-2222-3333-4444'}] ] populate(cache, terms) end diff --git a/utils/benchmarking/profile.rb b/utils/benchmarking/profile.rb index c6864da2..26d12602 100644 --- a/utils/benchmarking/profile.rb +++ b/utils/benchmarking/profile.rb @@ -23,9 +23,7 @@ def mapping_workflow v_result = handler.validate(datahash) - if v_result.valid? - result = handler.process(datahash) - end + result = handler.process(datahash) if v_result.valid? result end diff --git a/utils/csv-to-datahashes.rb b/utils/csv-to-datahashes.rb index 90b1496e..2648ea9f 100644 --- a/utils/csv-to-datahashes.rb +++ b/utils/csv-to-datahashes.rb @@ -15,11 +15,11 @@ end options = {} -OptionParser.new{ |opts| +OptionParser.new do |opts| opts.banner = 'Usage: ruby csv-to-datahashes.rb -i PATH_TO_CSV' opts.on('-i', '--input PATH_TO_CSV', - 'Path to CSV file. One JSON file will be created per row in the same directory.'){ |i| + 'Path to CSV file. One JSON file will be created per row in the same directory.') do |i| options[:input] = i unless File.file?(i) puts "File #{i} does not exist" @@ -29,17 +29,17 @@ puts "File #{i} does not have '.csv' suffix" exit end - } - opts.on('-h', '--help', 'Prints this help'){ + end + opts.on('-h', '--help', 'Prints this help') do puts opts exit - } -}.parse! + end +end.parse! datahashes = [] -filename_stub = options[:input].sub(/^.*\//, '').sub('.csv', '') -dir = options[:input]['/'] ? options[:input].sub(/\/[^\/]+$/, '/') : '' +filename_stub = options[:input].sub(%r{^.*/}, '').sub('.csv', '') +dir = options[:input]['/'] ? options[:input].sub(%r{/[^/]+$}, '/') : '' CSV.foreach(options[:input], headers: true) do |row| datahashes << row.to_h diff --git a/utils/datahash_to_csv.rb b/utils/datahash_to_csv.rb index 70186775..04e780cd 100644 --- a/utils/datahash_to_csv.rb +++ b/utils/datahash_to_csv.rb @@ -16,10 +16,10 @@ end options = {} -OptionParser.new{ |opts| +OptionParser.new do |opts| opts.banner = 'Usage: ruby datahash-to-csv.rb -i PATH_TO_JSON' - opts.on('-i', '--input PATH_TO_JSON', 'Path to JSON datahash file.'){ |i| + opts.on('-i', '--input PATH_TO_JSON', 'Path to JSON datahash file.') do |i| options[:input] = i unless File.file?(i) puts "File #{i} does not exist" @@ -29,15 +29,15 @@ puts "File #{i} does not have '.json' suffix" exit end - } - opts.on('-h', '--help', 'Prints this help'){ + end + opts.on('-h', '--help', 'Prints this help') do puts opts exit - } -}.parse! + end +end.parse! -dir = options[:input]['/'] ? options[:input].sub(/\/[^\/]+$/, '/') : '' -filename_stub = options[:input].sub(/^.*\//, '').sub('.json', '') +dir = options[:input]['/'] ? options[:input].sub(%r{/[^/]+$}, '/') : '' +filename_stub = options[:input].sub(%r{^.*/}, '').sub('.json', '') csv_file = "#{dir}#{filename_stub}.csv" data = JSON.parse(File.read(options[:input]))