-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connects to sul-dlss/sdr-client#261
- Loading branch information
Showing
16 changed files
with
145 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
# Deposits a Collection into SDR API. | ||
class DepositCollectionJob < BaseDepositJob | ||
class DepositCollectionJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(collection_version) | ||
deposit(request_dro: CocinaGenerator::CollectionGenerator.generate_model(collection_version:), | ||
version_description: collection_version.version_description.presence) | ||
rescue StandardError => e | ||
Honeybadger.notify(e) | ||
end | ||
|
||
private | ||
|
||
def deposit(request_dro:, version_description:) | ||
login_result = login | ||
|
||
raise login_result.failure unless login_result.success? | ||
collection_model = CocinaGenerator::CollectionGenerator.generate_model(collection_version:) | ||
version_description = collection_version.version_description.presence | ||
|
||
create_or_update(request_dro, version_description) | ||
end | ||
|
||
def create_or_update(request_dro, version_description) | ||
case request_dro | ||
case collection_model | ||
when Cocina::Models::RequestCollection | ||
SdrClient::Deposit::CreateResource.run(accession: true, | ||
metadata: request_dro, | ||
logger: Rails.logger, | ||
connection:) | ||
# TODO: Consider removing `basepath` as a required arg in sdr-client since it's useless without files | ||
SdrClient::RedesignedClient.deposit_model( | ||
model: collection_model, | ||
accession: true, | ||
basepath: '.' | ||
) | ||
when Cocina::Models::Collection | ||
SdrClient::Deposit::UpdateResource.run(metadata: request_dro, | ||
logger: Rails.logger, | ||
connection:, | ||
version_description:) | ||
SdrClient::RedesignedClient.update_model(model: collection_model, | ||
version_description:) | ||
end | ||
end | ||
|
||
def connection | ||
@connection ||= SdrClient::Connection.new(url: Settings.sdr_api.url) | ||
rescue StandardError => e | ||
Honeybadger.notify(e) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
# Register a DRUID in the SDR API. | ||
class ReserveJob < BaseDepositJob | ||
class ReserveJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(work_version) | ||
login_result = login | ||
raise login_result.failure unless login_result.success? | ||
|
||
request_dro = CocinaGenerator::DROGenerator.generate_model(work_version:) | ||
SdrClient::Deposit::CreateResource.run(accession: false, | ||
metadata: request_dro, | ||
logger: Rails.logger, | ||
connection:) | ||
end | ||
|
||
def connection | ||
@connection ||= SdrClient::Connection.new(url: Settings.sdr_api.url) | ||
# TODO: Consider removing `basepath` as a required arg in sdr-client since it's useless without files | ||
SdrClient::RedesignedClient.deposit_model( | ||
model: request_dro, | ||
accession: false, | ||
basepath: '.' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'sdr_client' | ||
require 'sdr_client/redesigned_client' # TODO: Remove this when the redesigned client is promoted | ||
|
||
# Configure SDR client | ||
SdrClient::RedesignedClient.configure( | ||
url: Settings.sdr_api.url, | ||
email: Settings.sdr_api.email, | ||
password: Settings.sdr_api.password, | ||
logger: Rails.logger | ||
) |
Oops, something went wrong.