Skip to content

Commit

Permalink
Merge pull request #193 from collectionspace/remove-handler-servicety…
Browse files Browse the repository at this point in the history
…pe-dependency

Remove dependency on collectionspace-mapper DataHandler to get service_type
  • Loading branch information
mark-cooper authored Jan 2, 2024
2 parents 911de86 + 7400274 commit bbb62cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 3 additions & 1 deletion app/jobs/process_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def perform(process)

begin
handler = process.batch.handler
service_type = process.batch
.record_mapper['config']['service_type']
rcs = RecordCacheService.new(batch_id: process.batch.id)

rep = ReportService.new(name: "#{manager.filename_base}_processed",
Expand Down Expand Up @@ -77,7 +79,7 @@ def perform(process)
else
rus.add(row: row_num, row_occ: row_occ, rec_id: id)

if handler.service_type == 'relation'
if service_type == 'relation'
rep.append({ row: row_num,
row_occ: row_occ,
header: 'INFO: relationship id',
Expand Down
7 changes: 5 additions & 2 deletions app/models/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ def fingerprint
Digest::SHA2.hexdigest "#{id}-#{name}"
end

def record_mapper
@record_mapper ||= fetch_mapper
end

def handler
@rm ||= fetch_mapper
CollectionSpace::Mapper::DataHandler.new(
record_mapper: @rm,
record_mapper: record_mapper,
client: connection.client,
cache: connection.refcache,
csid_cache: connection.csidcache,
Expand Down
10 changes: 2 additions & 8 deletions app/services/record_transfer_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def initialize(transfer: transfer_step)
@transfer_step = transfer
@batch = transfer.batch
@client = @batch.connection.client
mapper = get_mapper
@service_type = transfer.batch.handler.service_type
mapper = @batch.record_mapper
@service_type = mapper['config']['service_type']
@type = mapper['config']['service_path']
@subtype = mapper['config']['authority_subtype']
@blob_checker = BlobCheckService.new(client: @client)
Expand Down Expand Up @@ -157,10 +157,4 @@ def blob_status(data)

@blob_checker.status(uri: data['uri'])
end

def get_mapper
Rails.cache.fetch(@batch.mapper.title, namespace: 'mapper', expires_in: 1.day) do
JSON.parse(@batch.mapper.config.download)
end
end
end

0 comments on commit bbb62cd

Please sign in to comment.