hyrax icon indicating copy to clipboard operation
hyrax copied to clipboard

WINGS - update uses of ::Collection.find(id) with Valkyrie equivalent

Open elrayle opened this issue 4 years ago • 0 comments

Descriptive summary

Use of ::Collection.find(id) only returns ActiveFedora::Base collections. There needs to be an equivalent to find a Valkyrie::Resource collection (i.e. `Hyrax::PcdmCollection).

ActiveFedora code

collection = ::Collection.find(id)

Replacement code

Code to get a Valkyrie collection...

val_collection = Hyrax.query_service.find(id: id)
val_collection = nil unless resource.collection?

Better yet would be to write a custom_query find_collection_by(id: id) at app/services/custom_queries/navigators/find_generic_type.rb that uses this code making the replacement code...

Hyrax.custom_query_service.find_collection_by(id: id)

Then we can also have custom queries find_work_by(id: id) and find_fileset_by(id: id).

If ActiveFedora::Base object is required, convert resource using...

af_collection = Wings::ActiveFedoraConverter.convert(resource: val_collection)

Example usage

app/actors/hyrax/actors/collections_membership_actor.rb #add and #remove

Find by searching for ::Collection.find

elrayle avatar Jul 15 '21 12:07 elrayle