Skip to content

Commit

Permalink
Merge pull request #877 from datacite/doi-enrichment
Browse files Browse the repository at this point in the history
Doi enrichment - Add subjects to repositories/clients
  • Loading branch information
jrhoads authored Jan 11, 2023
2 parents 033485f + 0c9558f commit 221d82a
Show file tree
Hide file tree
Showing 15 changed files with 256 additions and 124 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "aasm", "~> 5.0", ">= 5.0.1"
gem "active_model_serializers", "~> 0.10.0"
gem "activerecord_json_validator", "~> 1.3"
gem "apollo-federation", "1.1.3"
gem "audited", "~> 4.8"
gem "aws-sdk-s3", require: false
Expand Down
92 changes: 56 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ GEM
activerecord (6.1.7)
activemodel (= 6.1.7)
activesupport (= 6.1.7)
activerecord_json_validator (1.3.0)
activerecord (>= 4.2.0, < 7)
json-schema (~> 2.8)
activestorage (6.1.7)
actionpack (= 6.1.7)
activejob (= 6.1.7)
Expand All @@ -78,20 +81,20 @@ GEM
audited (4.10.0)
activerecord (>= 4.2, < 6.2)
aws-eventstream (1.2.0)
aws-partitions (1.653.0)
aws-sdk-core (3.166.0)
aws-partitions (1.690.0)
aws-sdk-core (3.168.4)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.59.0)
aws-sdk-kms (1.61.0)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.117.1)
aws-sdk-s3 (1.117.2)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sdk-sqs (1.52.0)
aws-sdk-sqs (1.52.1)
aws-sdk-core (~> 3, >= 3.165.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.5.2)
Expand Down Expand Up @@ -134,7 +137,7 @@ GEM
rdf-rdfxml (~> 3.1)
rdf-turtle (~> 3.1)
thor (>= 0.19)
bootsnap (1.13.0)
bootsnap (1.15.0)
msgpack (~> 1.2)
builder (3.2.4)
bullet (6.1.5)
Expand Down Expand Up @@ -175,7 +178,7 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
crawler_detect (1.2.1)
crawler_detect (1.2.2)
qonfig (~> 0.24)
csl (1.6.0)
namae (~> 1.0)
Expand All @@ -191,6 +194,7 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.3)
ddtrace (0.32.0)
msgpack
debug_inspector (1.1.0)
Expand Down Expand Up @@ -228,7 +232,7 @@ GEM
multi_json
equivalent-xml (0.6.0)
nokogiri (>= 1.4.3)
erubi (1.11.0)
erubi (1.12.0)
excon (0.71.1)
facets (3.1.0)
factory_bot (4.11.1)
Expand All @@ -238,7 +242,7 @@ GEM
railties (>= 3.0.0)
faker (1.9.6)
i18n (>= 0.7)
faraday (0.17.5)
faraday (0.17.6)
multipart-post (>= 1.2, < 3)
faraday-encoding (0.0.5)
faraday
Expand All @@ -256,7 +260,7 @@ GEM
flipper (~> 0.17.2)
gender_detector (0.1.2)
unicode_utils (>= 1.3.0)
git (1.12.0)
git (1.13.0)
addressable (~> 2.8)
rchardet (~> 1.8)
globalid (1.0.0)
Expand Down Expand Up @@ -287,11 +291,11 @@ GEM
i18n (1.12.0)
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
iso-639 (0.3.5)
iso-639 (0.3.6)
iso8601 (0.9.1)
jmespath (1.6.1)
json (2.6.2)
json-canonicalization (0.3.0)
jmespath (1.6.2)
json (2.6.3)
json-canonicalization (0.3.1)
json-ld (3.2.3)
htmlentities (~> 4.3)
json-canonicalization (~> 0.3)
Expand All @@ -302,11 +306,13 @@ GEM
json-ld-preloaded (3.2.2)
json-ld (~> 3.2)
rdf (~> 3.2)
json-schema (2.8.1)
addressable (>= 2.4)
jsonapi-renderer (0.2.2)
jsonlint (0.3.0)
oj (~> 3)
optimist (~> 3)
jwt (2.5.0)
jwt (2.6.0)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
Expand All @@ -331,7 +337,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
logger (1.5.1)
logger (1.5.3)
lograge (0.11.2)
actionpack (>= 4)
activesupport (>= 4)
Expand All @@ -345,9 +351,12 @@ GEM
nokogiri (>= 1.5.9)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.7.1)
mail (2.8.0)
mini_mime (>= 0.1.1)
mailgun-ruby (1.2.5)
net-imap
net-pop
net-smtp
mailgun-ruby (1.2.6)
rest-client (>= 2.0.2)
marcel (1.0.2)
maremma (4.9.8)
Expand All @@ -369,9 +378,9 @@ GEM
mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_magick (4.11.0)
mini_magick (4.12.0)
mini_mime (1.1.2)
minitest (5.16.3)
minitest (5.17.0)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
msgpack (1.6.0)
Expand All @@ -381,6 +390,15 @@ GEM
namae (1.1.1)
net-http-persistent (4.0.1)
connection_pool (~> 2.2)
net-imap (0.3.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-protocol
netrc (0.11.0)
nio4r (2.5.8)
nokogiri (1.13.10-arm64-darwin)
Expand All @@ -389,13 +407,13 @@ GEM
racc (~> 1.4)
nokogiri (1.13.10-x86_64-linux)
racc (~> 1.4)
oj (3.13.21)
oj (3.13.23)
oj_mimic_json (1.0.1)
optimist (3.0.1)
parallel (1.22.1)
parallel_tests (3.13.0)
parallel
parser (3.1.2.1)
parser (3.2.0.0)
ast (~> 2.4.1)
postrank-uri (1.0.24)
addressable (>= 2.4.0)
Expand All @@ -411,8 +429,8 @@ GEM
docopt (~> 0.5)
sysrandom
qonfig (0.28.0)
racc (1.6.1)
rack (2.2.4)
racc (1.6.2)
rack (2.2.5)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (1.1.1)
Expand Down Expand Up @@ -477,7 +495,7 @@ GEM
rdf-xsd (3.2.1)
rdf (~> 3.2)
rexml (~> 3.2)
regexp_parser (2.6.0)
regexp_parser (2.6.1)
request_store (1.5.1)
rack (>= 1.4)
rest-client (2.1.0)
Expand Down Expand Up @@ -514,28 +532,28 @@ GEM
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.4)
rubocop (1.37.1)
rubocop (1.43.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
rubocop-ast (>= 1.24.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.23.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
rubocop-performance (1.15.0)
rubocop-performance (1.15.2)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.17.2)
rubocop-rails (2.17.4)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.14.2)
rubocop-rspec (2.16.0)
rubocop (~> 1.33)
ruby-progressbar (1.11.0)
ruby_dep (1.5.0)
Expand All @@ -560,7 +578,7 @@ GEM
slack-notifier (2.4.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
sparql (3.2.4)
sparql (3.2.5)
builder (~> 3.2)
ebnf (~> 2.2, >= 2.3.1)
logger (~> 1.5)
Expand Down Expand Up @@ -600,6 +618,7 @@ GEM
test-prof (0.10.2)
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.1)
turnout (2.5.0)
i18n (>= 0.7, < 2)
rack (>= 1.3, < 3)
Expand All @@ -610,7 +629,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (2.3.0)
unicode-display_width (2.4.2)
unicode-types (1.8.0)
unicode_utils (1.4.0)
uniform_notifier (1.16.0)
Expand All @@ -626,7 +645,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.2)
zeitwerk (2.6.6)

PLATFORMS
universal-darwin-21
Expand All @@ -635,6 +654,7 @@ PLATFORMS
DEPENDENCIES
aasm (~> 5.0, >= 5.0.1)
active_model_serializers (~> 0.10.0)
activerecord_json_validator (~> 1.3)
apollo-federation (= 1.1.3)
audited (~> 4.8)
aws-sdk-s3
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ def safe_params
"salesforceId",
"fromSalesforce",
"analyticsDashboardUrl",
:subjects,
{ subjects: %i[subject subjectScheme schemeUri valueUri lang classificationCode] },
],
keys: {
"systemEmail" => :system_email,
Expand All @@ -383,6 +385,9 @@ def safe_params
"repositoryType" => :repository_type,
"serviceContact" => :service_contact,
"analyticsDashboardUrl" => :analytics_dashboard_url,
"subjectScheme" => :subject_scheme,
"valueUri" => :value_uri,
"classificationCode" => :classification_code,
},
)
end
Expand Down
15 changes: 15 additions & 0 deletions app/models/client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

class Client < ApplicationRecord
SUBJECTS_JSON_SCHEMA = "#{Rails.root}/app/models/schemas/client/subjects.json"
audited except: %i[
system_email
service_contact
Expand Down Expand Up @@ -51,6 +52,12 @@ class Client < ApplicationRecord
attr_accessor :password_input, :target_id
attr_reader :from_salesforce

validates :subjects, if: :subjects?,
json: {
message: ->(errors) { errors },
schema: SUBJECTS_JSON_SCHEMA
}

validates_presence_of :symbol, :name, :system_email
validates_uniqueness_of :symbol,
message: "This Client ID has already been taken"
Expand Down Expand Up @@ -188,6 +195,14 @@ class Client < ApplicationRecord
indexes :deleted_at, type: :date
indexes :analytics_dashboard_url, type: :text
indexes :cumulative_years, type: :integer, index: "false"
indexes :subjects, type: :object, properties: {
subjectScheme: { type: :keyword },
subject: { type: :keyword },
schemeUri: { type: :keyword },
valueUri: { type: :keyword },
lang: { type: :keyword },
classificationCode: { type: :keyword },
}

# include parent objects
indexes :provider,
Expand Down
39 changes: 39 additions & 0 deletions app/models/schemas/client/subjects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array",
"minItems": 0,
"items": {
"type": "object",
"properties": {
"classification_code": { "type": "string" },
"classificationCode": { "type": "string" },
"scheme_uri": { "type": "string" },
"schemeUri": { "type": "string" },
"value_uri": { "type": "string" },
"valueUri": { "type": "string" },
"lang": { "type": "string" },
"subject": { "type": "string" },
"subject_scheme": { "type": "string" },
"subjectScheme": { "type": "string" }
},
"oneOf": [
{
"required": [
"classification_code",
"scheme_uri",
"subject",
"subject_scheme"
]
},
{
"required": [
"classificationCode",
"schemeUri",
"subject",
"subjectScheme"
]
}
],
"additionalProperties": false
}
}
Loading

0 comments on commit 221d82a

Please sign in to comment.