-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use find_by_source_identifier instead of find_by_bulkrax_identifier #907
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6075930
i903 - move bulkrax identifier custom queries into bulkrax
ShanaLMoore 78e677b
make find_by_source_identifier dynamic
ShanaLMoore ff02e13
remove files: they live in Hyku for now
ShanaLMoore 29f2264
🧹 Place custom queries back in Bulkrax
kirkkwang 9ad140f
🧹 remove misleading comment
ShanaLMoore 5fc4962
🧹 Entry is a required argument when initializing ObjectFactory
ShanaLMoore 6d09235
revert changes to pass Entry arg
ShanaLMoore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
35 changes: 35 additions & 0 deletions
35
app/services/hyrax/custom_queries/find_by_source_identifier.rb
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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyrax | ||
module CustomQueries | ||
## | ||
# @see https://github.com/samvera/valkyrie/wiki/Queries#custom-queries | ||
class FindBySourceIdentifier | ||
def self.queries | ||
[:find_by_source_identifier] | ||
end | ||
|
||
def initialize(query_service:) | ||
@query_service = query_service | ||
end | ||
|
||
attr_reader :query_service | ||
delegate :resource_factory, to: :query_service | ||
delegate :orm_class, to: :resource_factory | ||
|
||
## | ||
# @param identifier String | ||
def find_by_source_identifier(work_identifier:, source_identifier_value:) | ||
sql_query = sql_by_source_identifier | ||
query_service.run_query(sql_query, work_identifier, source_identifier_value).first | ||
end | ||
|
||
def sql_by_source_identifier | ||
<<-SQL | ||
SELECT * FROM orm_resources | ||
WHERE metadata -> ? ->> 0 = ?; | ||
SQL | ||
end | ||
end | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
app/services/wings/custom_queries/find_by_source_identifier.rb
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,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Wings | ||
module CustomQueries | ||
class FindBySourceIdentifier | ||
# Custom query override specific to Wings | ||
|
||
def self.queries | ||
[:find_by_source_identifier] | ||
end | ||
|
||
attr_reader :query_service | ||
delegate :resource_factory, to: :query_service | ||
|
||
def initialize(query_service:) | ||
@query_service = query_service | ||
end | ||
|
||
def find_by_source_identifier(identifier:, use_valkyrie: true) | ||
af_object = ActiveFedora::Base.where("bulkrax_identifier_sim:#{identifier}").first | ||
|
||
return af_object unless use_valkyrie | ||
|
||
resource_factory.to_resource(object: af_object) | ||
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
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
Oops, something went wrong.
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 was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worries this is a breaking change for upgraded non valkyrie users.
Should I make it optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disregard, I don't need it. Object factory is already passing work_identifier: parser.work_identifier.