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

fix oai after application_parser rework #932

Merged
merged 4 commits into from
Mar 8, 2024
Merged
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
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 @@ -242,16 +242,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
Loading