Skip to content

Commit

Permalink
fix oai after application_parser rework (#932)
Browse files Browse the repository at this point in the history
* fix oai after application_parser rework

* fix importer/exporter pagination

* 💄 endless and ever appeasing of the coppers

* Add a more robust handling of values

---------

Co-authored-by: Jeremy Friesen <[email protected]>
  • Loading branch information
orangewolf and jeremyf authored Mar 8, 2024
1 parent e3d02b7 commit ac34c18
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/concerns/bulkrax/datatables_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def format_importers(importers)
{
data: result,
recordsTotal: Bulkrax::Importer.count,
recordsFiltered: importers.size
recordsFiltered: Bulkrax::Importer.count
}
end

Expand All @@ -120,7 +120,7 @@ def format_exporters(exporters)
{
data: result,
recordsTotal: Bulkrax::Exporter.count,
recordsFiltered: exporters.size
recordsFiltered: Bulkrax::Exporter.count
}
end

Expand Down
20 changes: 17 additions & 3 deletions app/parsers/bulkrax/application_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,30 @@ def calculate_type_delay(type)
return 0
end

def record_raw_metadata(record)
record.to_h
end

def record_deleted?(record)
return false unless record.key?(:delete)
ActiveModel::Type::Boolean.new.cast(record[:delete])
end

def record_remove_and_rerun?(record)
return false unless record.key?(:remove_and_rerun)
ActiveModel::Type::Boolean.new.cast(record[:remove_and_rerun])
end

def create_entry_and_job(current_record, type, identifier = nil)
identifier ||= current_record[source_identifier]
new_entry = find_or_create_entry(send("#{type}_entry_class"),
identifier,
'Bulkrax::Importer',
current_record.to_h)
record_raw_metadata(current_record))
new_entry.status_info('Pending', importer.current_run)
if current_record[:delete].present?
if record_deleted?(current_record)
"Bulkrax::Delete#{type.camelize}Job".constantize.send(perform_method, new_entry, current_run)
elsif current_record[:remove_and_rerun].present? || remove_and_rerun
elsif record_remove_and_rerun?(current_record) || remove_and_rerun
delay = calculate_type_delay(type)
"Bulkrax::DeleteAndImport#{type.camelize}Job".constantize.set(wait: delay).send(perform_method, new_entry, current_run)
else
Expand Down
18 changes: 18 additions & 0 deletions app/parsers/bulkrax/oai_dc_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ def create_works
set_status_info(e)
end

def create_file_sets; end

def create_relationships
ScheduleRelationshipsJob.set(wait: 5.minutes).perform_later(importer_id: importerexporter.id)
end

def record_raw_metadata(_record)
nil
end

def record_deleted?(_record)
false
end

def record_remove_and_rerun?(_record)
false
end

# oai records so not let us set the source identifier easily
def record_has_source_identifier(record, index)
identifier = record.send(source_identifier)
Expand Down

0 comments on commit ac34c18

Please sign in to comment.