Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access the default split pattern from the parser instead of the config #984

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/matchers/bulkrax/application_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def result(_parser, content)

def process_split
if self.split.is_a?(TrueClass)
@result = @result.split(Bulkrax.multi_value_element_split_on)
@result = @result.split(ApplicationParser.multi_value_element_split_on)
elsif self.split
@result = @result.split(Regexp.new(self.split))
@result = @result.map(&:strip).select(&:present?)
Expand Down
4 changes: 2 additions & 2 deletions app/models/bulkrax/csv_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def add_ingested_metadata
def add_file
self.parsed_metadata['file'] ||= []
if record['file']&.is_a?(String)
self.parsed_metadata['file'] = record['file'].split(Bulkrax.multi_value_element_split_on)
self.parsed_metadata['file'] = record['file'].split(parser.multi_value_element_split_on)
elsif record['file'].is_a?(Array)
self.parsed_metadata['file'] = record['file']
end
Expand Down Expand Up @@ -350,7 +350,7 @@ def collection_identifiers
return [] unless parent_field_mapping.present? && record[parent_field_mapping].present?

identifiers = []
split_references = record[parent_field_mapping].split(Bulkrax.multi_value_element_split_on)
split_references = record[parent_field_mapping].split(parser.multi_value_element_split_on)
split_references.each do |c_reference|
matching_collection_entries = importerexporter.entries.select do |e|
(e.raw_metadata&.[](source_identifier) == c_reference) &&
Expand Down
4 changes: 4 additions & 0 deletions app/parsers/bulkrax/application_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def self.import_supported?
true
end

def self.multi_value_element_split_on
Bulkrax.multi_value_element_split_on
end

def initialize(importerexporter)
@importerexporter = importerexporter
@headers = []
Expand Down
4 changes: 2 additions & 2 deletions app/parsers/bulkrax/csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def file_paths
file_mapping = Bulkrax.field_mappings.dig(self.class.to_s, 'file', :from)&.first&.to_sym || :file
next if r[file_mapping].blank?

r[file_mapping].split(Bulkrax.multi_value_element_split_on).map do |f|
r[file_mapping].split(multi_value_element_split_on).map do |f|
file = File.join(path_to_files, f.tr(' ', '_'))
if File.exist?(file) # rubocop:disable Style/GuardClause
file
Expand Down Expand Up @@ -366,7 +366,7 @@ def unique_collection_identifier(collection_hash)
entry_uid ||= if Bulkrax.fill_in_blank_source_identifiers.present?
Bulkrax.fill_in_blank_source_identifiers.call(self, records.find_index(collection_hash))
else
collection_hash[:title].split(Bulkrax.multi_value_element_split_on).first
collection_hash[:title].split(multi_value_element_split_on).first
end

entry_uid
Expand Down
Loading