-
Notifications
You must be signed in to change notification settings - Fork 5
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
LIBHYDRA-564. Add VocabService to fetch vocab options from web #394
Merged
peichman-umd
merged 10 commits into
umd-lib:develop
from
dsteelma-umd:feature/LIBHYDRA-564
Apr 4, 2024
Merged
LIBHYDRA-564. Add VocabService to fetch vocab options from web #394
peichman-umd
merged 10 commits into
umd-lib:develop
from
dsteelma-umd:feature/LIBHYDRA-564
Apr 4, 2024
Conversation
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
Based on a discussion on April 3, 2024, in the "archelon" WebEx channel, Peter Eichman indicated that the "access" field for all content models should have a "terms" entry matching that of the "Item" model, i.e.: ``` terms: ['Public', 'Campus'] ``` https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Added the "webmock" gem (as recommended by the "http" gem documentation) to the "test" dependencies, to support mocking the HTTP requests to the vocabulary server in tests. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Replaced custom mocks that intercept HTTP requests in existing tests with the "webmock" equivalent. In "retrieve_controller_test.rb", some tests no longer needed to be mocked because the code return before actually reaching the network call. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Moved the "app/services/plastron_services/http/send_json_request.rb" file to "app/services/send_json_request.rb" as it is a generic class that is not specific to Plastron, and is useful for other services. Updated "Plastron::HTTP::SendActivityStreamMessage" class to reflect the change. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Added a "follow_redirects" constructor argument, which defaults to "false". When set to "true", the request will follow redirects, which is necessary when communicating with the vocabulary server, as the vocabulary URIs typically use an "http" scheme. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Added logging to record JSON parsing errors to the log. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Added the "VocabService" class which contains a "vocab_options_hash" method to query a vocabulary server for a list of terms, and returns an "options" hash for terms indexed by their Local URI suitable for display in a ControlledURI drop-down list. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
dsteelma-umd
force-pushed
the
feature/LIBHYDRA-564
branch
from
April 4, 2024 13:27
10f47e2
to
264aa7d
Compare
dsteelma-umd
force-pushed
the
feature/LIBHYDRA-564
branch
from
April 4, 2024 13:28
264aa7d
to
5e131e0
Compare
When a vocabulary only has one term, there is no "@graph" element in the JSON returned from the vocabulary server. Once a second term is added, the "@graph" element is added, and populated with the terms. For example, a "collection" vocabulary with only one term looks like: ``` { "@context": { "owl": "http://www.w3.org/2002/07/owl#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "dc": "http://purl.org/dc/elements/1.1/" }, "@id": "http://vocab.lib.umd.edu/collection#0001-GDOC", "dc:identifier": "0001-GDOC", "rdfs:label": "United States Government Posters" } ``` while a "collection" vocabulary with two terms looks like: ``` { "@context": { "owl": "http://www.w3.org/2002/07/owl#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "dc": "http://purl.org/dc/elements/1.1/" }, "@graph": [ { "@id": "http://vocab.lib.umd.edu/collection#0211-UA", "rdfs:label": "Diamondback Photos", "dc:identifier": "0211-UA", "owl:sameAs": { "@id": "http://vocab.lib.umd.edu/collection#0211-UA" } }, { "@id": "http://vocab.lib.umd.edu/collection#0001-GDOC", "rdfs:label": "United States Government Posters", "dc:identifier": "0001-GDOC" } ] } ``` While we don't expect to have "one term" vocabularies very often, they may occur when a new vocabulary is being rolled out, so it was decided to handle that case. These changes modify the "parse_options" method in "app/services/vocab_service.rb" to handle both "one term" and multi-term vocabularies. Added a test to verify the "one term" vocabulary. https://umd-dit.atlassian.net/browse/LIBHYDRA-564
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Added the "VocabService" class which contains a "vocab_options_hash"
method to query a vocabulary server for a list of terms, and returns
an "options" hash for terms indexed by their Local URI suitable for
display in a ControlledURI drop-down list.
Added the "webmock" gem (as recommended by the "http" gem documentation)
to the "test" dependencies, to support mocking the HTTP requests to the
vocabulary server in tests.
Moved the "app/services/plastron_services/http/send_json_request.rb"
file to "app/services/send_json_request.rb" as it is a generic class
that is not specific to Plastron, and is useful for other services.
Added a "follow_redirects" constructor argument, which defaults to
"false". When set to "true", the request will follow redirects, which
is necessary when communicating with the vocabulary server, as the
vocabulary URIs typically use an "http" scheme.
Added logging to JsonRestResult class to record JSON parsing errors to the log.
Added documentation on content model definitions
https://umd-dit.atlassian.net/browse/LIBHYDRA-564