[Backport] Provide patterns and infrastructure for assigning remote identifiers (DOI, Handle, etc.) #4465
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are three patterns provided: dispatcher, registrar, and builder
Dispatcher - assigns registered identifer to a given object
Registrar - handles communication with external identifier service
Builder - constructs identifier to submit to external identifier service
Registrar implementations just need to implement the
registrar!
method. They can be tested with the provided shared spec and then
registered with Hyrax by the identifier_registrars configuration (which
is generated commented out in the hyrax initializer).
identifier_registrars should be a Hash with Symbol keys and Class values.
A custom builder implementation can be injected into your registrar by
overriding the registrar's initialize method setting the custom builder
as the default value for the builder keyword argument.
def initialize(builder: MyCustomBuilder.new)
super(builder: builder)
end
With this infrastructure in place, a new remote identifier can be
assigned to a work by calling the dispatcher with the work object.
Assuming a :datacite registrar has been registered in Hyrax's
configuration then this would look like:
Hyrax::Identifier::Dispatcher.for(:datacite).assign_for!(object: work)
This will set the remote identifier in the work's identifier attribute
and save the work. To avoid saving the object use
assign_for
instead.If a different attribute is desired the pass the attribute as a symbol
in the :attribute keyword argument to
assign_for!
.This work is ported from mahonia (which had parts ported from epigaea).
Both of those implementations were done by @no-reply.
Backport of #4458
@samvera/hyrax-code-reviewers