-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
At present we have not incorporated using the `Bulkrax.persistence_adapter` into the application. It is instead put forward for discussion and review. Why introduce the adapter strategy? Because there are several instances of Bulkrax that are installed along various points of Hyrax versions as well as non-Hyrax versions; which means that there are some cases where we'll be using ActiveFedora and some where we'll be moving towards Valkyrie. The goal of the adapter is two fold: - Clarify and define the data interface between Bulkrax and the Main App - Allow for ease of maintaining Bulkrax releative to varying versions of Hyrax and Hyku; thus allowing folks to upgrade to new features of Bulkrax without mandating an upgrade of their entire persistence strategy. Related to: - scientist-softserv/hykuup_knapsack#35
- Loading branch information
Showing
6 changed files
with
119 additions
and
0 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 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,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bulkrax | ||
## | ||
# The target data layer where we write and read our imported {Bulkrax::Entry} objects. | ||
module PersistenceLayer | ||
# We're inheriting from an ActiveRecord exception as that is something we know will be here; and | ||
# something that the main_app will be expect to be able to handle. | ||
class ObjectNotFoundError < ActiveRecord::RecordNotFound | ||
end | ||
|
||
# We're inheriting from an ActiveRecord exception as that is something we know will be here; and | ||
# something that the main_app will be expect to be able to handle. | ||
class RecordInvalid < ActiveRecord::RecordInvalid | ||
end | ||
|
||
class AbstractAdapter | ||
# @see ActiveFedora::Base.find | ||
def self.find(id) | ||
raise NotImplementedError, "#{self}.#{__method__}" | ||
end | ||
|
||
def self.solr_name(field_name) | ||
raise NotImplementedError, "#{self}.#{__method__}" | ||
end | ||
|
||
# @yield when Rails application is running in test environment. | ||
def self.clean! | ||
return true unless Rails.env.test? | ||
yield | ||
end | ||
|
||
def self.query(q, **kwargs) | ||
raise NotImplementedError, "#{self}.#{__method__}" | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bulkrax | ||
module PersistenceLayer | ||
class ActiveFedoraAdapter < AbstractAdapter | ||
def self.find(id) | ||
ActiveFedora::Base.find(id) | ||
rescue ActiveFedora::ObjectNotFoundError => e | ||
raise PersistenceLayer::RecordNotFound, e.message | ||
end | ||
|
||
def self.query(q, **kwargs) | ||
ActiveFedora::SolrService.query(q, **kwargs) | ||
end | ||
|
||
def self.clean! | ||
super do | ||
ActiveFedora::Cleaner.clean! | ||
end | ||
end | ||
|
||
def self.solr_name(field_name) | ||
ActiveFedora.index_field_mapper.solr_name(field_name) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bulkrax | ||
module PersistenceLayer | ||
class ValkyrieAdapter < AbstractAdapter | ||
end | ||
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