All of the methods in this class are transitional and should be removed when the transition process is complete. Having these in use will make identifying dregs and cleaning them up easier. A search for any of these methods will identify parts of the code that are still in transition or haven't really begun to transition.
When one method A has been changed to Valkyrie and method A calls method B passing a model object and
method B has not been converted to Valkyrie and is expecting to receive an ActiveFedora object, the
.to_active_fedora
method allows you to pass the received object not knowing its class and receive back
an ActiveFedora object.
Example
FileActor's perform_ingest_file_through_valkyrie works only with Valkyrie Resources. It calls CharacterizeJob.perform_later
and receives file_set as a parameter. In order to allow FileActor to pass a Valkyrie Resource to CharacterizeJob without having
to expand the scope of the current changes to include CharacterizeJob, CharacterizeJob has a small update added to call
.to_active_fedora
as the first call to be sure that it can proceed with an ActiveFedora object.
In file_actor.rb
CharacterizeJob.perform_later(file_set, id, pathhint || io.path) # where file_set is a Valkyrie Resource
In chacterize_job.rb
def perform(file_set, file_id, filepath = nil) # where file_set is either Valkyrie Resource OR ActiveFedora object
file_set = ValkyrieTransitionHelper.to_active_fedora(object: file_set)
...
end
When methods in a class are being converted to accept valkyrie resources and passing valkyrie resources to other methods, some methods may end up receiving an object with a valkyrie resource sometimes and an active fedora object other times.
To be sure that all objects are of the same type, or to be sure all objects are resources, this method can be called. It can receive either an active fedora object or a valkyrie resource and always returns a valkyrie resource.
Some classes that need to continue to work whether passed a valkyrie resource or an active fedora object. To avoid doing the temporary switching logic in the class being transitioned, it can call ValkyrieTransitionHelper.save
which will call the appropriate code to do the save in either approach.
This is used extensively in tests. This method will do a reload for a valkyrie resource or an active fedora object. You don't have to know whick you have before calling it.
Both these methods are used extensively when switching between working with ActiveFedora objects and Valkyrie objects. It is unlikely that these will be needed once the transition is complete. Both are used internally to the ValkyrieTransitionHelper class and are made public for use in other classes that are doing switching those classes.
Abstracts out what it means to be a valkyrie object making the code easier to read.
Abstracts out what it means to be an active fedora object making the code easier to read.
When a class is partially valkyrized, some methods may be at a point where they are passing a valkyrie resource whether or not the use_valkyrie flag is true. This can be checked by this method which returns true if use_valkyrie is true or if any of the objects being checked are valkyrie resources. This is often followed by a call to ValkyrieTransitionHelper.to_resource for each object used in the calling method to be sure that all objects are Valkyrie Resources.
The need for this occured while making changes to file_set_actor which effects a file_set and a work.