Skip to content

Commit

Permalink
♻️ Favor Bulkrax's persistence layer
Browse files Browse the repository at this point in the history
Instead of direct calls to a deprecated service favor a persistence
layer call; one that defines an interface.

Note this means we need to implement the methods in the Valkyrie
adapter; but those should be trivial.
  • Loading branch information
jeremyf committed Jan 31, 2024
1 parent 91583af commit bf1762c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions app/parsers/bulkrax/parser_export_record_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ def extra_filters
end

def works
@works ||= ActiveFedora::SolrService.query(works_query, **works_query_kwargs)
@works ||= Bulkrax.persistence_adapter.query(works_query, **works_query_kwargs)
end

def collections
@collections ||= if collections_query
ActiveFedora::SolrService.query(collections_query, **collections_query_kwargs)
Bulkrax.persistence_adapter.query(collections_query, **collections_query_kwargs)
else
[]
end
Expand All @@ -175,7 +175,7 @@ def file_sets
@file_sets ||= ParserExportRecordSet.in_batches(candidate_file_set_ids) do |batch_of_ids|
fsq = "has_model_ssim:#{Bulkrax.file_model_class} AND id:(\"" + batch_of_ids.join('" OR "') + "\")"
fsq += extra_filters if extra_filters.present?
ActiveFedora::SolrService.query(
Bulkrax.persistence_adapter.query(
fsq,
{ fl: "id", method: :post, rows: batch_of_ids.size }
)
Expand Down Expand Up @@ -247,7 +247,7 @@ def complete_entry_identifiers

def works
@works ||= ParserExportRecordSet.in_batches(complete_entry_identifiers) do |ids|
ActiveFedora::SolrService.query(
Bulkrax.persistence_adapter.query(
extra_filters.to_s,
**query_kwargs.merge(
fq: [
Expand All @@ -262,7 +262,7 @@ def works

def collections
@collections ||= ParserExportRecordSet.in_batches(complete_entry_identifiers) do |ids|
ActiveFedora::SolrService.query(
Bulkrax.persistence_adapter.query(
"has_model_ssim:Collection #{extra_filters}",
**query_kwargs.merge(
fq: [
Expand All @@ -281,7 +281,7 @@ def collections
# @see Bulkrax::ParserExportRecordSet::Base#file_sets
def file_sets
@file_sets ||= ParserExportRecordSet.in_batches(complete_entry_identifiers) do |ids|
ActiveFedora::SolrService.query(
Bulkrax.persistence_adapter.query(
extra_filters,
query_kwargs.merge(
fq: [
Expand Down
2 changes: 1 addition & 1 deletion spec/parsers/bulkrax/bagit_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ module Bulkrax
let(:fileset_entry_2) { FactoryBot.create(:bulkrax_csv_entry_file_set, importerexporter: exporter) }

before do
allow(ActiveFedora::SolrService).to receive(:query).and_return(work_ids_solr)
allow(Bulkrax.persistence_adapter).to receive(:query).and_return(work_ids_solr)
allow(exporter.entries).to receive(:where).and_return([work_entry_1, work_entry_2, fileset_entry_1, fileset_entry_2])
end

Expand Down
2 changes: 1 addition & 1 deletion spec/parsers/bulkrax/csv_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ module Bulkrax
end

before do
allow(ActiveFedora::SolrService).to receive(:query).and_return(SolrDocument.new(id: work_id))
allow(Bulkrax.persistence_adapter).to receive(:query).and_return(SolrDocument.new(id: work_id))
allow(exporter.entries).to receive(:where).and_return([entry])
allow(parser).to receive(:headers).and_return(entry.parsed_metadata.keys)
end
Expand Down

0 comments on commit bf1762c

Please sign in to comment.