From 40e395a0f74fafbd4aa795d60c91a8159443f133 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 13 Dec 2022 17:25:09 -0500 Subject: [PATCH 01/30] Add subjects to client indexing. Include client.subjects in DB seed/factories --- app/models/client.rb | 1 + db/seeds/development/base.seeds.rb | 8 ++++++++ spec/factories/client.rb | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/app/models/client.rb b/app/models/client.rb index c0d12d1b9..253361d68 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -396,6 +396,7 @@ def as_indexed_json(options = {}) end, "analytics_dashboard_url" => analytics_dashboard_url, "analytics_tracking_id" => analytics_tracking_id, + "subjects" => Array.wrap(subjects), } end diff --git a/db/seeds/development/base.seeds.rb b/db/seeds/development/base.seeds.rb index 4a32778aa..226187224 100644 --- a/db/seeds/development/base.seeds.rb +++ b/db/seeds/development/base.seeds.rb @@ -29,6 +29,14 @@ symbol: ENV["MDS_USERNAME"], password_input: ENV["MDS_PASSWORD"], ) +if Prefix.where(uid: "10.14454").blank? + prefix = FactoryBot.create(:prefix, uid: "10.14454") + ### This creates both the client_prefix and the provider association + FactoryBot.create( + :client_prefix, + client_id: client.symbol, prefix_id: prefix.uid, + ) +end dois = FactoryBot.create_list(:doi, 10, client: client, state: "findable") FactoryBot.create_list(:event_for_datacite_related, 3, obj_id: dois.first.doi) FactoryBot.create_list(:event_for_datacite_usage, 2, obj_id: dois.first.doi) diff --git a/spec/factories/client.rb b/spec/factories/client.rb index 16b82fe80..5000972ff 100644 --- a/spec/factories/client.rb +++ b/spec/factories/client.rb @@ -18,6 +18,16 @@ role_name { "ROLE_DATACENTRE" } password_input { "12345" } is_active { true } + subjects do + [ + { + classificationCode: "1001", + schemeUri: "http://example.com/schemeUri", + subject: "Example Subject", + subjectScheme: "Example Subject Scheme (ESS)", + }, + ] + end initialize_with { Client.where(symbol: symbol).first_or_initialize } end From 628192a024e590cc065799b0d47b5cec41ff785d Mon Sep 17 00:00:00 2001 From: jrhoads Date: Thu, 15 Dec 2022 16:11:50 -0500 Subject: [PATCH 02/30] Add repository subjects to doi elasticsearch indexing --- app/models/doi.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/doi.rb b/app/models/doi.rb index e5c0cb729..8447a4748 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -408,6 +408,14 @@ class Doi < ApplicationRecord updated: { type: :date }, deleted_at: { type: :date }, cumulative_years: { type: :integer, index: "false" }, + subjects: { type: :object, include_in_parent: true, properties: { + subjectScheme: { type: :keyword }, + subject: { type: :keyword }, + schemeUri: { type: :keyword }, + valueUri: { type: :keyword }, + lang: { type: :keyword }, + classificationCode: { type: :keyword }, + } } } indexes :provider, type: :object, properties: { id: { type: :keyword }, From 38d12892d56be3a358d0d2eae549010b10a92a68 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 10 Jan 2023 11:18:31 -0500 Subject: [PATCH 03/30] Add repository subjects to doi endpoint for works --- app/graphql/schema.graphql | 189 +++++++++++++++++++++++++++++----- app/graphql/types/doi_item.rb | 21 +++- 2 files changed, 181 insertions(+), 29 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 29fb47266..bef374fc4 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -292,6 +292,11 @@ type Audiovisual implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -345,7 +350,7 @@ type Audiovisual implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -601,6 +606,11 @@ type Book implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -654,7 +664,7 @@ type Book implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -865,6 +875,11 @@ type BookChapter implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -918,7 +933,7 @@ type BookChapter implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -1259,6 +1274,11 @@ type Collection implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -1312,7 +1332,7 @@ type Collection implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -1567,6 +1587,11 @@ type ConferencePaper implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -1620,7 +1645,7 @@ type ConferencePaper implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -2168,6 +2193,11 @@ type DataManagementPlan implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -2221,7 +2251,7 @@ type DataManagementPlan implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -2477,6 +2507,11 @@ type DataPaper implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -2530,7 +2565,7 @@ type DataPaper implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -2785,6 +2820,11 @@ type Dataset implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -2859,7 +2899,7 @@ type Dataset implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -3212,6 +3252,11 @@ type Dissertation implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -3265,7 +3310,7 @@ type Dissertation implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -3524,6 +3569,11 @@ interface DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -3577,7 +3627,7 @@ interface DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -3838,6 +3888,11 @@ type Event implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -3891,7 +3946,7 @@ type Event implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -4131,6 +4186,11 @@ type EventData implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -4184,7 +4244,7 @@ type EventData implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -4720,6 +4780,11 @@ type Image implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -4773,7 +4838,7 @@ type Image implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -5027,6 +5092,11 @@ type Instrument implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -5080,7 +5150,7 @@ type Instrument implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -5334,6 +5404,11 @@ type InteractiveResource implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -5387,7 +5462,7 @@ type InteractiveResource implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -5647,6 +5722,11 @@ type JournalArticle implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -5700,7 +5780,7 @@ type JournalArticle implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -6251,6 +6331,11 @@ type Model implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -6304,7 +6389,7 @@ type Model implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -6731,6 +6816,11 @@ type Other implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -6784,7 +6874,7 @@ type Other implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -7064,6 +7154,11 @@ type PeerReview implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -7117,7 +7212,7 @@ type PeerReview implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -7509,6 +7604,11 @@ type PhysicalObject implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -7562,7 +7662,7 @@ type PhysicalObject implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -7870,6 +7970,11 @@ type Preprint implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -7923,7 +8028,7 @@ type Preprint implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -8178,6 +8283,11 @@ type Publication implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -8231,7 +8341,7 @@ type Publication implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -9131,6 +9241,11 @@ type Service implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -9184,7 +9299,7 @@ type Service implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -9440,6 +9555,11 @@ type Software implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -9493,7 +9613,7 @@ type Software implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -9779,6 +9899,11 @@ type Sound implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -9832,7 +9957,7 @@ type Sound implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -10298,6 +10423,11 @@ type Work implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -10351,7 +10481,7 @@ type Work implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -10612,6 +10742,11 @@ type Workflow implements DoiItem { """ repository: Repository + """ + OECD Fields of Science of the containing repository + """ + repositoryFieldsOfScience: [FieldOfScience!] + """ Any rights information for this resource """ @@ -10665,7 +10800,7 @@ type Workflow implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index b4134356e..708ce884b 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -66,6 +66,11 @@ module DoiItem field :fields_of_science, [FieldOfScienceType], null: true, description: "OECD Fields of Science of the resource" + + field :repository_fields_of_science, + [FieldOfScienceType], + null: true, description: "OECD Fields of Science of the containing repository" + field :dates, [DateType], null: true, description: "Different dates relevant to the work" @@ -382,6 +387,7 @@ module DoiItem argument :has_views, Int, required: false argument :has_downloads, Int, required: false argument :field_of_science, String, required: false + argument :repository_field_of_science, String, required: false argument :first, Int, required: false, default_value: 25 argument :after, String, required: false end @@ -418,8 +424,8 @@ def registration_agency { id: object.agency, name: REGISTRATION_AGENCIES[object.agency] }.compact end - def fields_of_science - Array.wrap(object.subjects).select do |s| + def _fos_filter(subjects) + Array.wrap(subjects).select do |s| s["subjectScheme"] == "Fields of Science and Technology (FOS)" end.map do |s| name = s["subject"].gsub("FOS: ", "") @@ -427,6 +433,17 @@ def fields_of_science end.uniq end + def repository_fields_of_science + if object.client.blank? + return [] + end + _fos_filter(object.client.subjects) + end + + def fields_of_science + _fos_filter(object.subjects) + end + def creators(**args) Array.wrap(object.creators)[0...args[:first]].map do |c| Hashie::Mash.new( From b5168c86f2d97a3cfd362e6f5993f30ea93eb9a8 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 10 Jan 2023 11:19:24 -0500 Subject: [PATCH 04/30] Update Elasticsearch indexing/mapping for repository subjects --- app/models/client.rb | 2 +- app/models/doi.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index 253361d68..4ce5f4a1e 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -198,7 +198,7 @@ class Client < ApplicationRecord indexes :analytics_dashboard_url, type: :text indexes :analytics_tracking_id, type: :text indexes :cumulative_years, type: :integer, index: "false" - indexes :subjects, type: :object, properties: { + indexes :subjects, type: :nested, include_in_parent: true, properties: { subjectScheme: { type: :keyword }, subject: { type: :keyword }, schemeUri: { type: :keyword }, diff --git a/app/models/doi.rb b/app/models/doi.rb index 8447a4748..ebd4add26 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -408,7 +408,7 @@ class Doi < ApplicationRecord updated: { type: :date }, deleted_at: { type: :date }, cumulative_years: { type: :integer, index: "false" }, - subjects: { type: :object, include_in_parent: true, properties: { + subjects: { type: :nested, include_in_parent: true, properties: { subjectScheme: { type: :keyword }, subject: { type: :keyword }, schemeUri: { type: :keyword }, From aa67fe09400c86a8066c9b5c78d73eb837a36b89 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 10 Jan 2023 11:20:31 -0500 Subject: [PATCH 05/30] Update seeds/factories for client/repositories that have subjects --- db/seeds/development/base.seeds.rb | 2 +- spec/factories/client.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/db/seeds/development/base.seeds.rb b/db/seeds/development/base.seeds.rb index 226187224..f9725fcfe 100644 --- a/db/seeds/development/base.seeds.rb +++ b/db/seeds/development/base.seeds.rb @@ -24,7 +24,7 @@ client = Client.where(symbol: "DATACITE.TEST").first || FactoryBot.create( - :client, + :client_with_fos, provider: provider, symbol: ENV["MDS_USERNAME"], password_input: ENV["MDS_PASSWORD"], diff --git a/spec/factories/client.rb b/spec/factories/client.rb index 5000972ff..b70726c0f 100644 --- a/spec/factories/client.rb +++ b/spec/factories/client.rb @@ -29,6 +29,19 @@ ] end + factory :client_with_fos do + subjects do + [ + { + classificationCode: "1001", + schemeUri: "http://example.com/schemeUri", + subject: "Example Subject", + subjectScheme: "Fields of Science and Technology (FOS)" + }, + ] + end + end + initialize_with { Client.where(symbol: symbol).first_or_initialize } end end From c851d67b5624de7f4b4906522ac9c423fdab12af Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 13 Jan 2023 20:41:40 -0500 Subject: [PATCH 06/30] Add subjects_combined field to elasticsearch and the doi_item type in graphql --- app/graphql/types/doi_item.rb | 8 ++++++++ app/models/doi.rb | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index 708ce884b..a607d4264 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -67,6 +67,10 @@ module DoiItem [FieldOfScienceType], null: true, description: "OECD Fields of Science of the resource" + field :fields_of_science_combined, + [FieldOfScienceType], + null: true, description: "OECD Fields of Science of the resource and containing repository" + field :repository_fields_of_science, [FieldOfScienceType], null: true, description: "OECD Fields of Science of the containing repository" @@ -440,6 +444,10 @@ def repository_fields_of_science _fos_filter(object.client.subjects) end + def fields_of_science_combined + _fos_filter(object.subjects_combined) + end + def fields_of_science _fos_filter(object.subjects) end diff --git a/app/models/doi.rb b/app/models/doi.rb index ebd4add26..e6fc1c6c9 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -332,6 +332,14 @@ class Doi < ApplicationRecord lang: { type: :keyword }, classificationCode: { type: :keyword }, } + indexes :subjects_combined, type: :object, properties: { + subjectScheme: { type: :keyword }, + subject: { type: :keyword }, + schemeUri: { type: :keyword }, + valueUri: { type: :keyword }, + lang: { type: :keyword }, + classificationCode: { type: :keyword }, + } indexes :container, type: :object, properties: { type: { type: :keyword }, identifier: { type: :keyword, normalizer: "keyword_lowercase" }, @@ -575,6 +583,7 @@ def as_indexed_json(_options = {}) "sizes" => Array.wrap(sizes), "language" => language, "subjects" => Array.wrap(subjects), + "subjects_combined" => subjects_combined, "xml" => xml, "is_active" => is_active, "landing_page" => landing_page, @@ -1709,6 +1718,12 @@ def client_id client.symbol.downcase if client.present? end + def subjects_combined + ret = Array.wrap(subjects) + ret += Array.wrap(client&.subjects) + ret.uniq + end + def client_id_and_name "#{client_id}:#{client.name}" if client.present? end From be51d14d1c0b0ddc6cad68b4fba1d92271ba8691 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 27 Jan 2023 11:36:45 -0500 Subject: [PATCH 07/30] Add subjects_combined as a nested object. Access/filter aggregation. Expose with Graphql. --- app/graphql/schema.graphql | 137 ++++++++++++++++++ .../types/work_connection_with_total_type.rb | 18 +++ app/models/doi.rb | 35 ++++- 3 files changed, 189 insertions(+), 1 deletion(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index bef374fc4..6fe4f306f 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -186,6 +186,11 @@ type Audiovisual implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -500,6 +505,11 @@ type Book implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -769,6 +779,11 @@ type BookChapter implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -1168,6 +1183,11 @@ type Collection implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -1481,6 +1501,11 @@ type ConferencePaper implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -2087,6 +2112,11 @@ type DataManagementPlan implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -2401,6 +2431,11 @@ type DataPaper implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -2714,6 +2749,11 @@ type Dataset implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -3146,6 +3186,11 @@ type Dissertation implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -3463,6 +3508,11 @@ interface DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -3782,6 +3832,11 @@ type Event implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -4080,6 +4135,11 @@ type EventData implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -4674,6 +4734,11 @@ type Image implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -4986,6 +5051,11 @@ type Instrument implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -5298,6 +5368,11 @@ type InteractiveResource implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -5616,6 +5691,11 @@ type JournalArticle implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -6225,6 +6305,11 @@ type Model implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -6710,6 +6795,11 @@ type Other implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -7048,6 +7138,11 @@ type PeerReview implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -7498,6 +7593,11 @@ type PhysicalObject implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -7864,6 +7964,11 @@ type Preprint implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -8177,6 +8282,11 @@ type Publication implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -9135,6 +9245,11 @@ type Service implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -9449,6 +9564,11 @@ type Software implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -9793,6 +9913,11 @@ type Sound implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -10317,6 +10442,11 @@ type Work implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ @@ -10521,6 +10651,7 @@ type WorkConnectionWithTotal { """ edges: [WorkEdge] fieldsOfScience: [Facet!] + fieldsOfScienceCombined: [Facet!] languages: [Facet!] licenses: [Facet!] @@ -10537,6 +10668,7 @@ type WorkConnectionWithTotal { published: [Facet!] registrationAgencies: [Facet!] repositories: [Facet!] + repositoryFieldsOfScience: [Facet!] resourceTypes: [Facet!] totalContentUrl: Int totalCount: Int! @@ -10636,6 +10768,11 @@ type Workflow implements DoiItem { """ fieldsOfScience: [FieldOfScience!] + """ + OECD Fields of Science of the resource and containing repository + """ + fieldsOfScienceCombined: [FieldOfScience!] + """ Technical format of the resource """ diff --git a/app/graphql/types/work_connection_with_total_type.rb b/app/graphql/types/work_connection_with_total_type.rb index b0c5b58d4..88101967a 100644 --- a/app/graphql/types/work_connection_with_total_type.rb +++ b/app/graphql/types/work_connection_with_total_type.rb @@ -17,6 +17,8 @@ class WorkConnectionWithTotalType < BaseConnection field :affiliations, [FacetType], null: true, cache: true field :authors, [FacetType], null: true, cache: true field :fields_of_science, [FacetType], null: true, cache: true + field :fields_of_science_combined, [FacetType], null: true, cache: true + field :repository_fields_of_science, [FacetType], null: true, cache: true field :licenses, [FacetType], null: true, cache: true field :languages, [FacetType], null: true, cache: true @@ -106,6 +108,22 @@ def fields_of_science end end + def fields_of_science_combined + if object.aggregations.subject_combined&.fos&.subject + facet_by_fos(object.aggregations.subject_combined.fos.subject.buckets) + else + [] + end + end + + def repository_fields_of_science + if object.aggregations.repository_fields_of_science + facet_by_fos(object.aggregations.repository_fields_of_science.subject.buckets) + else + [] + end + end + def languages if object.aggregations.languages facet_by_language(object.aggregations.languages.buckets) diff --git a/app/models/doi.rb b/app/models/doi.rb index e6fc1c6c9..48477673e 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -332,7 +332,7 @@ class Doi < ApplicationRecord lang: { type: :keyword }, classificationCode: { type: :keyword }, } - indexes :subjects_combined, type: :object, properties: { + indexes :subjects_combined, type: :nested, properties: { subjectScheme: { type: :keyword }, subject: { type: :keyword }, schemeUri: { type: :keyword }, @@ -665,6 +665,39 @@ def self.gql_query_aggregations(facet_count: 10) include: "FOS:.*" } }, }, }, + subject_combined: { + "nested": { + "path": "subjects_combined" + }, + "aggs": { + "fos": { + "filter": { + "term": { + "subjects_combined.subjectScheme": "Fields of Science and Technology (FOS)" + } + }, + "aggs": { + "subject": { + "terms": { + "field": "subjects_combined.subject", + "size": 10, + "min_doc_count": 1 + } + } + } + } + } + }, + repository_fields_of_science: { + filter: { term: { "client.subjects.subjectScheme": "Fields of Science and Technology (FOS)" } }, + aggs: { + subject: { terms: { + field: "client.subjects.subject", + size: facet_count, + min_doc_count: 1 + } }, + }, + }, licenses: { terms: { field: "rights_list.rightsIdentifier", size: facet_count, min_doc_count: 1 } }, languages: { terms: { field: "language", size: facet_count, min_doc_count: 1 } }, view_count: { sum: { field: "view_count" } }, From 1f54f76d3da8ea4d32a68fc951d3e9761b294179 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Wed, 1 Feb 2023 15:35:15 -0500 Subject: [PATCH 08/30] Update graphql doi_item and spec to include fieldOfScience fields --- app/graphql/types/doi_item.rb | 6 +++--- spec/graphql/types/doi_item_spec.rb | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index a607d4264..bb43f02ac 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -71,7 +71,7 @@ module DoiItem [FieldOfScienceType], null: true, description: "OECD Fields of Science of the resource and containing repository" - field :repository_fields_of_science, + field :fields_of_science_repository, [FieldOfScienceType], null: true, description: "OECD Fields of Science of the containing repository" @@ -391,7 +391,7 @@ module DoiItem argument :has_views, Int, required: false argument :has_downloads, Int, required: false argument :field_of_science, String, required: false - argument :repository_field_of_science, String, required: false + argument :field_of_science_repository, String, required: false argument :first, Int, required: false, default_value: 25 argument :after, String, required: false end @@ -437,7 +437,7 @@ def _fos_filter(subjects) end.uniq end - def repository_fields_of_science + def fields_of_science_repository if object.client.blank? return [] end diff --git a/spec/graphql/types/doi_item_spec.rb b/spec/graphql/types/doi_item_spec.rb index 2db00a772..e88ef3ff3 100644 --- a/spec/graphql/types/doi_item_spec.rb +++ b/spec/graphql/types/doi_item_spec.rb @@ -13,6 +13,9 @@ it { is_expected.to have_field(:publicationYear).of_type("Int") } it { is_expected.to have_field(:publisher).of_type("String") } it { is_expected.to have_field(:subjects).of_type("[Subject!]") } + it { is_expected.to have_field(:fieldsOfScience).of_type("[FieldOfScience!]") } + it { is_expected.to have_field(:fieldsOfScienceRepository).of_type("[FieldOfScience!]") } + it { is_expected.to have_field(:fieldsOfScienceCombined).of_type("[FieldOfScience!]") } it { is_expected.to have_field(:dates).of_type("[Date!]") } it { is_expected.to have_field(:registered).of_type("ISO8601DateTime") } it { is_expected.to have_field(:language).of_type("Language") } From 4b7740fa4569fc8c195022e132a95a654560ef5f Mon Sep 17 00:00:00 2001 From: jrhoads Date: Wed, 1 Feb 2023 15:37:04 -0500 Subject: [PATCH 09/30] Rename repository_fields_of_scienc to fields_of_science_repository --- app/graphql/types/work_connection_with_total_type.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/graphql/types/work_connection_with_total_type.rb b/app/graphql/types/work_connection_with_total_type.rb index 88101967a..e9d8acc49 100644 --- a/app/graphql/types/work_connection_with_total_type.rb +++ b/app/graphql/types/work_connection_with_total_type.rb @@ -18,7 +18,7 @@ class WorkConnectionWithTotalType < BaseConnection field :authors, [FacetType], null: true, cache: true field :fields_of_science, [FacetType], null: true, cache: true field :fields_of_science_combined, [FacetType], null: true, cache: true - field :repository_fields_of_science, [FacetType], null: true, cache: true + field :fields_of_science_repository, [FacetType], null: true, cache: true field :licenses, [FacetType], null: true, cache: true field :languages, [FacetType], null: true, cache: true @@ -116,7 +116,7 @@ def fields_of_science_combined end end - def repository_fields_of_science + def fields_of_science_repository if object.aggregations.repository_fields_of_science facet_by_fos(object.aggregations.repository_fields_of_science.subject.buckets) else From e9af35a1cdd69741daef9b8f097aff9eeceb326c Mon Sep 17 00:00:00 2001 From: jrhoads Date: Wed, 1 Feb 2023 15:37:56 -0500 Subject: [PATCH 10/30] Update schema --- app/graphql/schema.graphql | 324 ++++++++++++++++++------------------- 1 file changed, 162 insertions(+), 162 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 6fe4f306f..1b370168c 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -191,6 +191,11 @@ type Audiovisual implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -297,11 +302,6 @@ type Audiovisual implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -355,7 +355,7 @@ type Audiovisual implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -510,6 +510,11 @@ type Book implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -616,11 +621,6 @@ type Book implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -674,7 +674,7 @@ type Book implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -784,6 +784,11 @@ type BookChapter implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -890,11 +895,6 @@ type BookChapter implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -948,7 +948,7 @@ type BookChapter implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -1188,6 +1188,11 @@ type Collection implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -1294,11 +1299,6 @@ type Collection implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -1352,7 +1352,7 @@ type Collection implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -1506,6 +1506,11 @@ type ConferencePaper implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -1612,11 +1617,6 @@ type ConferencePaper implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -1670,7 +1670,7 @@ type ConferencePaper implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -2117,6 +2117,11 @@ type DataManagementPlan implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -2223,11 +2228,6 @@ type DataManagementPlan implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -2281,7 +2281,7 @@ type DataManagementPlan implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -2436,6 +2436,11 @@ type DataPaper implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -2542,11 +2547,6 @@ type DataPaper implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -2600,7 +2600,7 @@ type DataPaper implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -2754,6 +2754,11 @@ type Dataset implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -2860,11 +2865,6 @@ type Dataset implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -2939,7 +2939,7 @@ type Dataset implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -3191,6 +3191,11 @@ type Dissertation implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -3297,11 +3302,6 @@ type Dissertation implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -3355,7 +3355,7 @@ type Dissertation implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -3513,6 +3513,11 @@ interface DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -3619,11 +3624,6 @@ interface DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -3677,7 +3677,7 @@ interface DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -3837,6 +3837,11 @@ type Event implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -3943,11 +3948,6 @@ type Event implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -4001,7 +4001,7 @@ type Event implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -4140,6 +4140,11 @@ type EventData implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -4246,11 +4251,6 @@ type EventData implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -4304,7 +4304,7 @@ type EventData implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -4739,6 +4739,11 @@ type Image implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -4845,11 +4850,6 @@ type Image implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -4903,7 +4903,7 @@ type Image implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -5056,6 +5056,11 @@ type Instrument implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -5162,11 +5167,6 @@ type Instrument implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -5220,7 +5220,7 @@ type Instrument implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -5373,6 +5373,11 @@ type InteractiveResource implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -5479,11 +5484,6 @@ type InteractiveResource implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -5537,7 +5537,7 @@ type InteractiveResource implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -5696,6 +5696,11 @@ type JournalArticle implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -5802,11 +5807,6 @@ type JournalArticle implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -5860,7 +5860,7 @@ type JournalArticle implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -6310,6 +6310,11 @@ type Model implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -6416,11 +6421,6 @@ type Model implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -6474,7 +6474,7 @@ type Model implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -6800,6 +6800,11 @@ type Other implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -6906,11 +6911,6 @@ type Other implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -6964,7 +6964,7 @@ type Other implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -7143,6 +7143,11 @@ type PeerReview implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -7249,11 +7254,6 @@ type PeerReview implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -7307,7 +7307,7 @@ type PeerReview implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -7598,6 +7598,11 @@ type PhysicalObject implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -7704,11 +7709,6 @@ type PhysicalObject implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -7762,7 +7762,7 @@ type PhysicalObject implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -7969,6 +7969,11 @@ type Preprint implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -8075,11 +8080,6 @@ type Preprint implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -8133,7 +8133,7 @@ type Preprint implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -8287,6 +8287,11 @@ type Publication implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -8393,11 +8398,6 @@ type Publication implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -8451,7 +8451,7 @@ type Publication implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -9250,6 +9250,11 @@ type Service implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -9356,11 +9361,6 @@ type Service implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -9414,7 +9414,7 @@ type Service implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -9569,6 +9569,11 @@ type Software implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -9675,11 +9680,6 @@ type Software implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -9733,7 +9733,7 @@ type Software implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -9918,6 +9918,11 @@ type Sound implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -10024,11 +10029,6 @@ type Sound implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -10082,7 +10082,7 @@ type Sound implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -10447,6 +10447,11 @@ type Work implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -10553,11 +10558,6 @@ type Work implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -10611,7 +10611,7 @@ type Work implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of @@ -10773,6 +10773,11 @@ type Workflow implements DoiItem { """ fieldsOfScienceCombined: [FieldOfScience!] + """ + OECD Fields of Science of the containing repository + """ + fieldsOfScienceRepository: [FieldOfScience!] + """ Technical format of the resource """ @@ -10879,11 +10884,6 @@ type Workflow implements DoiItem { """ repository: Repository - """ - OECD Fields of Science of the containing repository - """ - repositoryFieldsOfScience: [FieldOfScience!] - """ Any rights information for this resource """ @@ -10937,7 +10937,7 @@ type Workflow implements DoiItem { """ The DOI is a version of this DOI. """ - versionOf(affiliationId: String, after: String, fieldOfScience: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryFieldOfScience: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal + versionOf(affiliationId: String, after: String, fieldOfScience: String, fieldOfScienceRepository: String, first: Int = 25, funderId: String, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, organizationId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal """ Total number of DOIs the resource is a version of From 5b182f6420f9c4c927efb1d966c2573b2a67ca7b Mon Sep 17 00:00:00 2001 From: jrhoads Date: Wed, 1 Feb 2023 15:38:42 -0500 Subject: [PATCH 11/30] Start adding tests for fieldOfScienc facets to the work_type_spec --- spec/graphql/types/work_type_spec.rb | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index 30e5b63f2..4adf614b6 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1201,4 +1201,61 @@ ) end end + + describe "query works with repository subjects" , elasticsearch: true do + let(:search_query) do + ' + fragment facetFields on Facet { + id + title + count + } + query{ + works(query:"*"){ + totalCount + fieldsOfScience { ...facetFields } + fieldsOfScienceRepository { ...facetFields } + fieldsOfScienceCombined{ ...facetFields } + } + } + ' + end + let(:client){create(:client_with_fos)} + let!(:works) do + create_list( + :doi, + 10, + aasm_state: "findable", + client: client + ) + end + + before :all do + SLEEP_TIME=2 + end + + before do + Doi.import + sleep SLEEP_TIME + @facet_response = LupoSchema.execute(search_query).as_json + end + + it "has all dois in the search results" do + response = @facet_response + expect(response.dig("data", "works", "totalCount")).to eq(10) + end + + it "returns Field of Science Facets" do + response = @facet_response + expect( + response.dig("data", "works", "fieldsOfScienceCombined") + ).to match_array([ + { + "id" => "example_subject", + "title" =>"Example Subject", + "count" =>10 + } + ]) + end + end end From 232a0c82967836314243dc97c9db0fdfb0b5361b Mon Sep 17 00:00:00 2001 From: jrhoads Date: Wed, 1 Feb 2023 16:31:52 -0500 Subject: [PATCH 12/30] Add remaining tests for fieldOfScience-related facets --- spec/graphql/types/work_type_spec.rb | 62 +++++++++++++++++++--------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index 4adf614b6..ad545598b 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1202,9 +1202,16 @@ end end - describe "query works with repository subjects" , elasticsearch: true do - let(:search_query) do - ' + describe "query works with repository subjects" do + + before :all do + SLEEP_TIME=2 + WORK_COUNT=10 + + DataciteDoi.import(force: true) + Client.import(force: true) + + search_query=' fragment facetFields on Facet { id title @@ -1219,33 +1226,48 @@ } } ' - end - let(:client){create(:client_with_fos)} - let!(:works) do - create_list( - :doi, - 10, - aasm_state: "findable", - client: client - ) - end - before :all do - SLEEP_TIME=2 - end - - before do + client = create(:client_with_fos) + create_list( :doi, WORK_COUNT, + aasm_state: "findable", + client: client + ) Doi.import sleep SLEEP_TIME @facet_response = LupoSchema.execute(search_query).as_json end + after :all do + Rails.logger.level = :fatal + Client.destroy_all + DataciteDoi.destroy_all + end + it "has all dois in the search results" do response = @facet_response - expect(response.dig("data", "works", "totalCount")).to eq(10) + expect(response.dig("data", "works", "totalCount")).to eq(WORK_COUNT) end it "returns Field of Science Facets" do + response = @facet_response + expect( + response.dig("data", "works", "fieldsOfScience") + ).to match_array([]) + end + + it "returns Field of Science Facets from the repository" do + response = @facet_response + expect( + response.dig("data", "works", "fieldsOfScienceRepository") + ).to match_array([ + { + "id" => "example_subject", + "title" =>"Example Subject", + "count" =>WORK_COUNT + } + ]) + end + it "returns combined Field of Science Facets" do response = @facet_response expect( response.dig("data", "works", "fieldsOfScienceCombined") @@ -1253,7 +1275,7 @@ { "id" => "example_subject", "title" =>"Example Subject", - "count" =>10 + "count" =>WORK_COUNT } ]) end From a1345f4060eb419c5e73af6e6b5b3bc05a04a941 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Wed, 1 Feb 2023 17:33:50 -0500 Subject: [PATCH 13/30] Appease Rubocop --- spec/graphql/types/work_type_spec.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index ad545598b..dff032db6 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1203,15 +1203,14 @@ end describe "query works with repository subjects" do - before :all do - SLEEP_TIME=2 - WORK_COUNT=10 + SLEEP_TIME = 2 + WORK_COUNT = 10 DataciteDoi.import(force: true) Client.import(force: true) - search_query=' + search_query = ' fragment facetFields on Facet { id title @@ -1228,7 +1227,7 @@ ' client = create(:client_with_fos) - create_list( :doi, WORK_COUNT, + create_list(:doi, WORK_COUNT, aasm_state: "findable", client: client ) @@ -1262,8 +1261,8 @@ ).to match_array([ { "id" => "example_subject", - "title" =>"Example Subject", - "count" =>WORK_COUNT + "title" => "Example Subject", + "count" => WORK_COUNT } ]) end @@ -1274,8 +1273,8 @@ ).to match_array([ { "id" => "example_subject", - "title" =>"Example Subject", - "count" =>WORK_COUNT + "title" => "Example Subject", + "count" => WORK_COUNT } ]) end From 48e8b219872a4af5ea253544290581219948df40 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Thu, 2 Feb 2023 14:47:24 -0500 Subject: [PATCH 14/30] Create prefix for work_type_spec and cleanup other models created. --- spec/graphql/types/work_type_spec.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index dff032db6..f8ce55742 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1209,6 +1209,10 @@ DataciteDoi.import(force: true) Client.import(force: true) + Prefix.import(force: true) + ClientPrefix.import(force: true) + ReferenceRepository.import(force: true) + Event.import(force: true) search_query = ' fragment facetFields on Facet { @@ -1226,6 +1230,7 @@ } ' + create(:prefix) client = create(:client_with_fos) create_list(:doi, WORK_COUNT, aasm_state: "findable", @@ -1234,12 +1239,17 @@ Doi.import sleep SLEEP_TIME @facet_response = LupoSchema.execute(search_query).as_json + Rails.logger.level = :fatal + DataciteDoi.destroy_all + ReferenceRepository.destroy_all + Client.destroy_all + Provider.destroy_all + Prefix.destroy_all + ClientPrefix.destroy_all + Event.destroy_all end after :all do - Rails.logger.level = :fatal - Client.destroy_all - DataciteDoi.destroy_all end it "has all dois in the search results" do From 39fc584d03dd8c2a253cca2ec8a86923d284ead1 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Mon, 6 Feb 2023 15:08:19 -0500 Subject: [PATCH 15/30] Pre-index field_of_science fields. Use in aggregates --- app/models/doi.rb | 90 ++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index 48477673e..48e1be05f 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -141,6 +141,8 @@ class Doi < ApplicationRecord before_save :set_defaults, :save_metadata before_create { self.created = Time.zone.now.utc.iso8601 } + FIELD_OF_SCIENCE_SCHEME = "Fields of Science and Technology (FOS)" + scope :q, ->(query) { where("dataset.doi = ?", query) } # use different index for testing @@ -332,14 +334,6 @@ class Doi < ApplicationRecord lang: { type: :keyword }, classificationCode: { type: :keyword }, } - indexes :subjects_combined, type: :nested, properties: { - subjectScheme: { type: :keyword }, - subject: { type: :keyword }, - schemeUri: { type: :keyword }, - valueUri: { type: :keyword }, - lang: { type: :keyword }, - classificationCode: { type: :keyword }, - } indexes :container, type: :object, properties: { type: { type: :keyword }, identifier: { type: :keyword, normalizer: "keyword_lowercase" }, @@ -528,6 +522,9 @@ class Doi < ApplicationRecord titleType: { type: :keyword }, lang: { type: :keyword }, } + indexes :fields_of_science, type: :keyword + indexes :fields_of_science_combined, type: :keyword + indexes :fields_of_science_repository, type: :keyword end end @@ -583,7 +580,9 @@ def as_indexed_json(_options = {}) "sizes" => Array.wrap(sizes), "language" => language, "subjects" => Array.wrap(subjects), - "subjects_combined" => subjects_combined, + "fields_of_science" => fields_of_science, + "fields_of_science_repository" => fields_of_science_repository, + "fields_of_science_combined" => fields_of_science_combined, "xml" => xml, "is_active" => is_active, "landing_page" => landing_page, @@ -659,44 +658,13 @@ def self.gql_query_aggregations(facet_count: 10) }, }, fields_of_science: { - filter: { term: { "subjects.subjectScheme": "Fields of Science and Technology (FOS)" } }, - aggs: { - subject: { terms: { field: "subjects.subject", size: facet_count, min_doc_count: 1, - include: "FOS:.*" } }, - }, + terms: { field: "fields_of_science", size: facet_count, min_doc_count: 1 } }, - subject_combined: { - "nested": { - "path": "subjects_combined" - }, - "aggs": { - "fos": { - "filter": { - "term": { - "subjects_combined.subjectScheme": "Fields of Science and Technology (FOS)" - } - }, - "aggs": { - "subject": { - "terms": { - "field": "subjects_combined.subject", - "size": 10, - "min_doc_count": 1 - } - } - } - } - } + fields_of_science_combined: { + terms: { field: "fields_of_science_combined", size: facet_count, min_doc_count: 1 } }, - repository_fields_of_science: { - filter: { term: { "client.subjects.subjectScheme": "Fields of Science and Technology (FOS)" } }, - aggs: { - subject: { terms: { - field: "client.subjects.subject", - size: facet_count, - min_doc_count: 1 - } }, - }, + fields_of_science_repository: { + terms: { field: "fields_of_science_repository", size: facet_count, min_doc_count: 1 } }, licenses: { terms: { field: "rights_list.rightsIdentifier", size: facet_count, min_doc_count: 1 } }, languages: { terms: { field: "language", size: facet_count, min_doc_count: 1 } }, @@ -751,11 +719,7 @@ def self.query_aggregations(disable_facets: false) }, }, fields_of_science: { - filter: { term: { "subjects.subjectScheme": "Fields of Science and Technology (FOS)" } }, - aggs: { - subject: { terms: { field: "subjects.subject", size: 10, min_doc_count: 1, - include: "FOS:.*" } }, - }, + terms: { field: "fields_of_science", size: 10, min_doc_count: 1 } }, licenses: { terms: { field: "rights_list.rightsIdentifier", size: 10, min_doc_count: 1 } }, languages: { terms: { field: "language", size: 10, min_doc_count: 1 } }, @@ -953,7 +917,7 @@ def self.gql_query(query, options = {}) filter << { terms: { "subjects.subject": options[:pid_entity].split(",").map(&:humanize) } } end if options[:field_of_science].present? - filter << { term: { "subjects.subjectScheme": "Fields of Science and Technology (FOS)" } } + filter << { term: { "subjects.subjectScheme": FIELD_OF_SCIENCE_SCHEME} } filter << { terms: { "subjects.subject": options[:field_of_science].split(",").map { |s| "FOS: " + s.humanize } } } end filter << { terms: { "rights_list.rightsIdentifier" => options[:license].split(",") } } if options[:license].present? @@ -1153,7 +1117,7 @@ def self.query(query, options = {}) filter << { terms: { "subjects.subject": options[:pid_entity].split(",").map(&:humanize) } } end if options[:field_of_science].present? - filter << { term: { "subjects.subjectScheme": "Fields of Science and Technology (FOS)" } } + filter << { term: { "subjects.subjectScheme": FIELD_OF_SCIENCE_SCHEME} } filter << { terms: { "subjects.subject": options[:field_of_science].split(",").map { |s| "FOS: " + s.humanize } } } end filter << { terms: { "rights_list.rightsIdentifier" => options[:license].split(",") } } if options[:license].present? @@ -1751,10 +1715,24 @@ def client_id client.symbol.downcase if client.present? end - def subjects_combined - ret = Array.wrap(subjects) - ret += Array.wrap(client&.subjects) - ret.uniq + def _fos_filter(subject_array) + Array.wrap(subject_array).select{ |sub| + sub.dig('subjectScheme') == FIELD_OF_SCIENCE_SCHEME + }.map do |fos| + fos["subject"].gsub("FOS: ", "") + end + end + + def fields_of_science + _fos_filter(subjects) + end + + def fields_of_science_repository + _fos_filter(client&.subjects) + end + + def fields_of_science_combined + fields_of_science | fields_of_science_repository end def client_id_and_name From 149b484d969b61d5d691cbce891f6a26322814e4 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Mon, 6 Feb 2023 15:10:26 -0500 Subject: [PATCH 16/30] Update REST and GQL endpoints to use new field_of_science aggregates --- app/controllers/datacite_dois_controller.rb | 2 +- app/graphql/types/work_connection_with_total_type.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/datacite_dois_controller.rb b/app/controllers/datacite_dois_controller.rb index 3d09dc1ce..6d0b6213b 100644 --- a/app/controllers/datacite_dois_controller.rb +++ b/app/controllers/datacite_dois_controller.rb @@ -228,7 +228,7 @@ def index # sources = total.positive? ? facet_by_key(response.aggregations.sources.buckets) : nil subjects = facet_by_key(response.aggregations.subjects.buckets) fields_of_science = facet_by_fos( - response.aggregations.fields_of_science.subject.buckets, + response.aggregations.fields_of_science.buckets, ) certificates = facet_by_key(response.aggregations.certificates.buckets) licenses = facet_by_license(response.aggregations.licenses.buckets) diff --git a/app/graphql/types/work_connection_with_total_type.rb b/app/graphql/types/work_connection_with_total_type.rb index e9d8acc49..31da87097 100644 --- a/app/graphql/types/work_connection_with_total_type.rb +++ b/app/graphql/types/work_connection_with_total_type.rb @@ -102,23 +102,23 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end end def fields_of_science_combined - if object.aggregations.subject_combined&.fos&.subject - facet_by_fos(object.aggregations.subject_combined.fos.subject.buckets) + if object.aggregations.fields_of_science_combined + facet_by_fos(object.aggregations.fields_of_science_combined.buckets) else [] end end def fields_of_science_repository - if object.aggregations.repository_fields_of_science - facet_by_fos(object.aggregations.repository_fields_of_science.subject.buckets) + if object.aggregations.fields_of_science_repository + facet_by_fos(object.aggregations.fields_of_science_repository.buckets) else [] end From 13a00e4e4af3ffccb1130f39311009da85cef6a1 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Mon, 6 Feb 2023 15:11:45 -0500 Subject: [PATCH 17/30] Use new field_of_science fields from doi model/index --- app/graphql/types/doi_item.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index bb43f02ac..bb599bf95 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -428,11 +428,8 @@ def registration_agency { id: object.agency, name: REGISTRATION_AGENCIES[object.agency] }.compact end - def _fos_filter(subjects) - Array.wrap(subjects).select do |s| - s["subjectScheme"] == "Fields of Science and Technology (FOS)" - end.map do |s| - name = s["subject"].gsub("FOS: ", "") + def _fos_to_facet(fos_list) + Array.wrap(fos_list).map do |name| { "id" => name.parameterize(separator: "_"), "name" => name } end.uniq end @@ -441,15 +438,15 @@ def fields_of_science_repository if object.client.blank? return [] end - _fos_filter(object.client.subjects) + _fos_to_facet(object.fields_of_science_repository) end def fields_of_science_combined - _fos_filter(object.subjects_combined) + _fos_to_facet(object.fields_of_science_combined) end def fields_of_science - _fos_filter(object.subjects) + _fos_to_facet(object.fields_of_science) end def creators(**args) From 594c0a5348bc2b06bd2b26de4df37f10c3a3f86d Mon Sep 17 00:00:00 2001 From: jrhoads Date: Mon, 6 Feb 2023 16:24:46 -0500 Subject: [PATCH 18/30] Add fieldsOfScience related fields to the graphql search parameters for dois --- app/graphql/schema.graphql | 4 +-- app/graphql/types/query_type.rb | 43 +++++++++++++++++++++++++++++++-- app/models/doi.rb | 18 +++++++++++--- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 1b370168c..048162db7 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -8615,7 +8615,7 @@ type Query { work(id: ID!): Work! workflow(id: ID!): Workflow! workflows(after: String, facetCount: Int = 10, fieldOfScience: String, first: Int = 25, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasMember: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, published: String, query: String, registrationAgency: String, repositoryId: String, userId: String): WorkflowConnectionWithTotal! - works(after: String, facetCount: Int = 10, fieldOfScience: String, first: Int = 25, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasMember: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceType: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal! + works(after: String, facetCount: Int = 10, fieldOfScience: String, fieldOfScienceCombined: String, fieldOfScienceRepository: String, first: Int = 25, hasAffiliation: Boolean, hasCitations: Int, hasDownloads: Int, hasFunder: Boolean, hasMember: Boolean, hasOrganization: Boolean, hasParts: Int, hasPerson: Boolean, hasVersions: Int, hasViews: Int, ids: [String!], language: String, license: String, memberId: String, published: String, query: String, registrationAgency: String, repositoryId: String, resourceType: String, resourceTypeId: String, userId: String): WorkConnectionWithTotal! } """ @@ -10652,6 +10652,7 @@ type WorkConnectionWithTotal { edges: [WorkEdge] fieldsOfScience: [Facet!] fieldsOfScienceCombined: [Facet!] + fieldsOfScienceRepository: [Facet!] languages: [Facet!] licenses: [Facet!] @@ -10668,7 +10669,6 @@ type WorkConnectionWithTotal { published: [Facet!] registrationAgencies: [Facet!] repositories: [Facet!] - repositoryFieldsOfScience: [Facet!] resourceTypes: [Facet!] totalContentUrl: Int totalCount: Int! diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 22f2d2d76..8e88ec927 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -271,13 +271,20 @@ def actor(id:) argument :has_views, Int, required: false argument :has_downloads, Int, required: false argument :field_of_science, String, required: false + argument :field_of_science_repository, String, required: false + argument :field_of_science_combined, String, required: false argument :facet_count, Int, required: false, default_value: 10 argument :first, Int, required: false, default_value: 25 argument :after, String, required: false end def works(**args) - ElasticsearchModelResponseConnection.new(response(args), context: context, first: args[:first], after: args[:after]) + ElasticsearchModelResponseConnection.new( + response(args), { + context: context, + first: args[:first], + after: args[:after] + }) end field :work, WorkType, null: false do @@ -1253,7 +1260,39 @@ def usage_report(id:) end def response(**args) - Doi.gql_query(args[:query], ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], resource_type_id: args[:resource_type_id], resource_type: args[:resource_type], published: args[:published], agency: args[:registration_agency], language: args[:language], license: args[:license], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_affiliation: args[:has_affiliation], has_member: args[:has_member], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], facet_count: args[:facet_count], pid_entity: args[:pid_entity], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] }) + Doi.gql_query( + args[:query], + ids: args[:ids], + user_id: args[:user_id], + client_id: args[:repository_id], + provider_id: args[:member_id], + resource_type_id: args[:resource_type_id], + resource_type: args[:resource_type], + published: args[:published], + agency: args[:registration_agency], + language: args[:language], + license: args[:license], + has_person: args[:has_person], + has_funder: args[:has_funder], + has_organization: args[:has_organization], + has_affiliation: args[:has_affiliation], + has_member: args[:has_member], + has_citations: args[:has_citations], + has_parts: args[:has_parts], + has_versions: args[:has_versions], + has_views: args[:has_views], + has_downloads: args[:has_downloads], + field_of_science: args[:field_of_science], + field_of_science_repository: args[:field_of_science_repository], + field_of_science_combined: args[:field_of_science_combined], + facet_count: args[:facet_count], + pid_entity: args[:pid_entity], + state: "findable", + page: { + cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], + size: args[:first] + } + ) end def set_doi(id) diff --git a/app/models/doi.rb b/app/models/doi.rb index 48e1be05f..a7ab31fa8 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -917,8 +917,13 @@ def self.gql_query(query, options = {}) filter << { terms: { "subjects.subject": options[:pid_entity].split(",").map(&:humanize) } } end if options[:field_of_science].present? - filter << { term: { "subjects.subjectScheme": FIELD_OF_SCIENCE_SCHEME} } - filter << { terms: { "subjects.subject": options[:field_of_science].split(",").map { |s| "FOS: " + s.humanize } } } + filter << { terms: { "fields_of_science": options[:field_of_science].split(",").map { |s| s.humanize } } } + end + if options[:field_of_science_repository].present? + filter << { terms: { "fields_of_science_repository": options[:field_of_science_repository].split(",").map { |s| s.humanize } } } + end + if options[:field_of_science_combined].present? + filter << { terms: { "fields_of_science_combined": options[:field_of_science_combined].split(",").map { |s| s.humanize } } } end filter << { terms: { "rights_list.rightsIdentifier" => options[:license].split(",") } } if options[:license].present? filter << { term: { source: options[:source] } } if options[:source].present? @@ -1117,8 +1122,13 @@ def self.query(query, options = {}) filter << { terms: { "subjects.subject": options[:pid_entity].split(",").map(&:humanize) } } end if options[:field_of_science].present? - filter << { term: { "subjects.subjectScheme": FIELD_OF_SCIENCE_SCHEME} } - filter << { terms: { "subjects.subject": options[:field_of_science].split(",").map { |s| "FOS: " + s.humanize } } } + filter << { terms: { "fields_of_science": options[:field_of_science].split(",").map { |s| s.humanize } } } + end + if options[:field_of_science_repository].present? + filter << { terms: { "fields_of_science_repository": options[:field_of_science_repository].split(",").map { |s| s.humanize } } } + end + if options[:field_of_science_combined].present? + filter << { terms: { "fields_of_science_combined": options[:field_of_science_combined].split(",").map { |s| s.humanize } } } end filter << { terms: { "rights_list.rightsIdentifier" => options[:license].split(",") } } if options[:license].present? filter << { term: { source: options[:source] } } if options[:source].present? From 16992709b67fbc1532055615f5717c354ee457cc Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 7 Feb 2023 11:02:42 -0500 Subject: [PATCH 19/30] Update each of the *_connection_with_total_type to use the new aggregate for fields_of_science --- .../types/audiovisual_connection_with_total_type.rb | 8 ++++++++ .../types/book_chapter_connection_with_total_type.rb | 2 +- app/graphql/types/book_connection_with_total_type.rb | 2 +- .../types/collection_connection_with_total_type.rb | 2 +- .../types/conference_paper_connection_with_total_type.rb | 2 +- .../data_management_plan_connection_with_total_type.rb | 2 +- .../types/data_paper_connection_with_total_type.rb | 8 ++++++++ app/graphql/types/dataset_connection_with_total_type.rb | 2 +- .../types/dissertation_connection_with_total_type.rb | 2 +- app/graphql/types/event_connection_with_total_type.rb | 2 +- .../types/instrument_connection_with_total_type.rb | 8 ++++++++ .../interactive_resource_connection_with_total_type.rb | 8 ++++++++ .../types/journal_article_connection_with_total_type.rb | 8 ++++++++ app/graphql/types/model_connection_with_total_type.rb | 2 +- app/graphql/types/other_connection_with_total_type.rb | 2 +- .../types/peer_review_connection_with_total_type.rb | 2 +- .../types/physical_object_connection_with_total_type.rb | 2 +- app/graphql/types/preprint_connection_with_total_type.rb | 2 +- .../types/publication_connection_with_total_type.rb | 2 +- app/graphql/types/service_connection_with_total_type.rb | 2 +- app/graphql/types/software_connection_with_total_type.rb | 2 +- app/graphql/types/sound_connection_with_total_type.rb | 2 +- app/graphql/types/workflow_connection_with_total_type.rb | 2 +- 23 files changed, 58 insertions(+), 18 deletions(-) diff --git a/app/graphql/types/audiovisual_connection_with_total_type.rb b/app/graphql/types/audiovisual_connection_with_total_type.rb index f8b3e4f04..778ff0019 100644 --- a/app/graphql/types/audiovisual_connection_with_total_type.rb +++ b/app/graphql/types/audiovisual_connection_with_total_type.rb @@ -75,4 +75,12 @@ def languages [] end end + + def fields_of_science + if object.aggregations.fields_of_science + facet_by_fos(object.aggregations.fields_of_science.buckets) + else + [] + end + end end diff --git a/app/graphql/types/book_chapter_connection_with_total_type.rb b/app/graphql/types/book_chapter_connection_with_total_type.rb index 33f549366..3510c0cd2 100644 --- a/app/graphql/types/book_chapter_connection_with_total_type.rb +++ b/app/graphql/types/book_chapter_connection_with_total_type.rb @@ -70,7 +70,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/book_connection_with_total_type.rb b/app/graphql/types/book_connection_with_total_type.rb index c0ffb7c90..9a0767ac6 100644 --- a/app/graphql/types/book_connection_with_total_type.rb +++ b/app/graphql/types/book_connection_with_total_type.rb @@ -62,7 +62,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/collection_connection_with_total_type.rb b/app/graphql/types/collection_connection_with_total_type.rb index 47a528e78..2d001a5ee 100644 --- a/app/graphql/types/collection_connection_with_total_type.rb +++ b/app/graphql/types/collection_connection_with_total_type.rb @@ -69,7 +69,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/conference_paper_connection_with_total_type.rb b/app/graphql/types/conference_paper_connection_with_total_type.rb index 9e1928b30..c3c5da6ed 100644 --- a/app/graphql/types/conference_paper_connection_with_total_type.rb +++ b/app/graphql/types/conference_paper_connection_with_total_type.rb @@ -70,7 +70,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/data_management_plan_connection_with_total_type.rb b/app/graphql/types/data_management_plan_connection_with_total_type.rb index 2a8c755d9..566c682cd 100644 --- a/app/graphql/types/data_management_plan_connection_with_total_type.rb +++ b/app/graphql/types/data_management_plan_connection_with_total_type.rb @@ -70,7 +70,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/data_paper_connection_with_total_type.rb b/app/graphql/types/data_paper_connection_with_total_type.rb index d100ca57b..31adc911f 100644 --- a/app/graphql/types/data_paper_connection_with_total_type.rb +++ b/app/graphql/types/data_paper_connection_with_total_type.rb @@ -42,4 +42,12 @@ def licenses def languages facet_by_language(object.aggregations.languages.buckets) end + + def fields_of_science + if object.aggregations.fields_of_science + facet_by_fos(object.aggregations.fields_of_science.buckets) + else + [] + end + end end diff --git a/app/graphql/types/dataset_connection_with_total_type.rb b/app/graphql/types/dataset_connection_with_total_type.rb index 6fc42ac1f..cb0159c83 100644 --- a/app/graphql/types/dataset_connection_with_total_type.rb +++ b/app/graphql/types/dataset_connection_with_total_type.rb @@ -77,7 +77,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/dissertation_connection_with_total_type.rb b/app/graphql/types/dissertation_connection_with_total_type.rb index 892ffe1e3..5fbd75945 100644 --- a/app/graphql/types/dissertation_connection_with_total_type.rb +++ b/app/graphql/types/dissertation_connection_with_total_type.rb @@ -70,7 +70,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/event_connection_with_total_type.rb b/app/graphql/types/event_connection_with_total_type.rb index 2e4ca6be0..b1d368693 100644 --- a/app/graphql/types/event_connection_with_total_type.rb +++ b/app/graphql/types/event_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/instrument_connection_with_total_type.rb b/app/graphql/types/instrument_connection_with_total_type.rb index 38af30287..7a368775c 100644 --- a/app/graphql/types/instrument_connection_with_total_type.rb +++ b/app/graphql/types/instrument_connection_with_total_type.rb @@ -65,4 +65,12 @@ def languages [] end end + + def fields_of_science + if object.aggregations.fields_of_science + facet_by_fos(object.aggregations.fields_of_science.buckets) + else + [] + end + end end diff --git a/app/graphql/types/interactive_resource_connection_with_total_type.rb b/app/graphql/types/interactive_resource_connection_with_total_type.rb index 592495b11..bc71ff328 100644 --- a/app/graphql/types/interactive_resource_connection_with_total_type.rb +++ b/app/graphql/types/interactive_resource_connection_with_total_type.rb @@ -66,4 +66,12 @@ def languages [] end end + + def fields_of_science + if object.aggregations.fields_of_science + facet_by_fos(object.aggregations.fields_of_science.buckets) + else + [] + end + end end diff --git a/app/graphql/types/journal_article_connection_with_total_type.rb b/app/graphql/types/journal_article_connection_with_total_type.rb index cef302b19..b627a973b 100644 --- a/app/graphql/types/journal_article_connection_with_total_type.rb +++ b/app/graphql/types/journal_article_connection_with_total_type.rb @@ -66,4 +66,12 @@ def languages [] end end + + def fields_of_science + if object.aggregations.fields_of_science + facet_by_fos(object.aggregations.fields_of_science.buckets) + else + [] + end + end end diff --git a/app/graphql/types/model_connection_with_total_type.rb b/app/graphql/types/model_connection_with_total_type.rb index 167d27322..ee3c59d48 100644 --- a/app/graphql/types/model_connection_with_total_type.rb +++ b/app/graphql/types/model_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/other_connection_with_total_type.rb b/app/graphql/types/other_connection_with_total_type.rb index f7dc416d3..203dc702d 100644 --- a/app/graphql/types/other_connection_with_total_type.rb +++ b/app/graphql/types/other_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/peer_review_connection_with_total_type.rb b/app/graphql/types/peer_review_connection_with_total_type.rb index 6bf2c777b..5f850de78 100644 --- a/app/graphql/types/peer_review_connection_with_total_type.rb +++ b/app/graphql/types/peer_review_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/physical_object_connection_with_total_type.rb b/app/graphql/types/physical_object_connection_with_total_type.rb index f13ec3a36..b5e886fed 100644 --- a/app/graphql/types/physical_object_connection_with_total_type.rb +++ b/app/graphql/types/physical_object_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/preprint_connection_with_total_type.rb b/app/graphql/types/preprint_connection_with_total_type.rb index 85c7b88f1..3e294d202 100644 --- a/app/graphql/types/preprint_connection_with_total_type.rb +++ b/app/graphql/types/preprint_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/publication_connection_with_total_type.rb b/app/graphql/types/publication_connection_with_total_type.rb index d1e0656f6..8eb476f2c 100644 --- a/app/graphql/types/publication_connection_with_total_type.rb +++ b/app/graphql/types/publication_connection_with_total_type.rb @@ -68,7 +68,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/service_connection_with_total_type.rb b/app/graphql/types/service_connection_with_total_type.rb index a9366626a..96a49f007 100644 --- a/app/graphql/types/service_connection_with_total_type.rb +++ b/app/graphql/types/service_connection_with_total_type.rb @@ -70,7 +70,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/software_connection_with_total_type.rb b/app/graphql/types/software_connection_with_total_type.rb index 31f93b0a3..850877a73 100644 --- a/app/graphql/types/software_connection_with_total_type.rb +++ b/app/graphql/types/software_connection_with_total_type.rb @@ -68,7 +68,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/sound_connection_with_total_type.rb b/app/graphql/types/sound_connection_with_total_type.rb index 9fbb9441c..2057c139d 100644 --- a/app/graphql/types/sound_connection_with_total_type.rb +++ b/app/graphql/types/sound_connection_with_total_type.rb @@ -61,7 +61,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end diff --git a/app/graphql/types/workflow_connection_with_total_type.rb b/app/graphql/types/workflow_connection_with_total_type.rb index d08db5ef9..2dec549d8 100644 --- a/app/graphql/types/workflow_connection_with_total_type.rb +++ b/app/graphql/types/workflow_connection_with_total_type.rb @@ -70,7 +70,7 @@ def licenses def fields_of_science if object.aggregations.fields_of_science - facet_by_fos(object.aggregations.fields_of_science.subject.buckets) + facet_by_fos(object.aggregations.fields_of_science.buckets) else [] end From f7d7bdb18997812296ecb621a7a787d1d6aa4fd5 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 7 Feb 2023 11:02:56 -0500 Subject: [PATCH 20/30] Appease rubocop --- app/models/doi.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/doi.rb b/app/models/doi.rb index a7ab31fa8..fec8c202d 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -1726,8 +1726,8 @@ def client_id end def _fos_filter(subject_array) - Array.wrap(subject_array).select{ |sub| - sub.dig('subjectScheme') == FIELD_OF_SCIENCE_SCHEME + Array.wrap(subject_array).select { |sub| + sub.dig("subjectScheme") == FIELD_OF_SCIENCE_SCHEME }.map do |fos| fos["subject"].gsub("FOS: ", "") end From c05fec8db6c6bfe96dc63ab3eab8c282953eedb9 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 7 Feb 2023 13:00:13 -0500 Subject: [PATCH 21/30] Clean up after spec --- spec/graphql/types/work_type_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index f8ce55742..74772ddbb 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1246,6 +1246,7 @@ Provider.destroy_all Prefix.destroy_all ClientPrefix.destroy_all + ProviderPrefix.destroy_all Event.destroy_all end From 93d7f84641b1f163231fc352085179b4d61b5ad7 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 15:50:28 -0500 Subject: [PATCH 22/30] Only allow subjects for disciplinary repositories --- app/models/client.rb | 27 +++++++++++++++++++++++++++ spec/factories/client.rb | 17 ++++------------- spec/models/client_spec.rb | 12 +++++++++++- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index 4ce5f4a1e..c8cb3e5af 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -52,6 +52,7 @@ class Client < ApplicationRecord attr_accessor :password_input, :target_id attr_reader :from_salesforce + validate :subjects_only_for_disciplinary_repos validates :subjects, if: :subjects?, json: { message: ->(errors) { errors }, @@ -96,12 +97,16 @@ class Client < ApplicationRecord has_many :activities, as: :auditable, dependent: :destroy before_validation :set_defaults + before_validation :convert_subject_hashes_to_camelcase before_create { self.created = Time.zone.now.utc.iso8601 } before_save { self.updated = Time.zone.now.utc.iso8601 } after_create :assign_prefix after_create_commit :create_reference_repository after_update_commit :update_reference_repository after_destroy_commit :destroy_reference_repository + after_commit on: %i[create update] do + ::Client.import_dois(self.symbol) + end # use different index for testing if Rails.env.test? @@ -911,6 +916,16 @@ def freeze_symbol errors.add(:symbol, "cannot be changed") if symbol_changed? end + def subjects_only_for_disciplinary_repos + if Array.wrap(subjects).any? && Array.wrap(repository_type).exclude?("disciplinary") + errors.add( + :subjects, + "Subjects are only allowed for disciplinary repositories. This repository_type is: #{repository_type}", + ) + end + + end + def check_id if symbol && symbol.split(".").first != provider.symbol errors.add( @@ -981,6 +996,18 @@ def set_defaults self.doi_quota_allowed = -1 unless doi_quota_allowed.to_i > 0 end + def convert_subject_hashes_to_camelcase + if self.subjects? + self.subjects = Array.wrap(self.subjects).map { |subject| + subject.transform_keys! do |key| + key.to_s.camelcase(:lower) + end + } + else + [] + end + end + def create_reference_repository ReferenceRepository.create_from_client(self) end diff --git a/spec/factories/client.rb b/spec/factories/client.rb index b70726c0f..a0a545f4a 100644 --- a/spec/factories/client.rb +++ b/spec/factories/client.rb @@ -18,25 +18,16 @@ role_name { "ROLE_DATACENTRE" } password_input { "12345" } is_active { true } - subjects do - [ - { - classificationCode: "1001", - schemeUri: "http://example.com/schemeUri", - subject: "Example Subject", - subjectScheme: "Example Subject Scheme (ESS)", - }, - ] - end factory :client_with_fos do subjects do [ { + subject: "Physical sciences", + valueUri: "", + schemeUri: "http://www.oecd.org/science/inno/38235147.pdf", + subjectScheme: "Fields of Science and Technology (FOS)", classificationCode: "1001", - schemeUri: "http://example.com/schemeUri", - subject: "Example Subject", - subjectScheme: "Fields of Science and Technology (FOS)" }, ] end diff --git a/spec/models/client_spec.rb b/spec/models/client_spec.rb index 4f26310ee..bfd1a49e3 100644 --- a/spec/models/client_spec.rb +++ b/spec/models/client_spec.rb @@ -15,7 +15,11 @@ end describe "subjects" do - let(:client) { build(:client, provider: provider) } + let(:client) { build(:client, + provider: provider, + repository_type: "disciplinary" + ) + } let(:valid_subjects) do { classificationCode: "6.1", @@ -25,6 +29,12 @@ } end + it "are invalid if the repository_type is not disciplinary" do + client.repository_type = nil + client.subjects = [valid_subjects] + expect(client).to_not be_valid + end + it "valid hash" do client.subjects = [valid_subjects] expect(client).to be_valid From 5a486bf10605fa03cc478d8293dfc5961cfdd40e Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 16:01:40 -0500 Subject: [PATCH 23/30] Remove relaxed json schema for subjects since key case is standardized --- app/models/schemas/client/subjects.json | 26 +++++-------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/app/models/schemas/client/subjects.json b/app/models/schemas/client/subjects.json index 7179c2243..8ece1f194 100644 --- a/app/models/schemas/client/subjects.json +++ b/app/models/schemas/client/subjects.json @@ -5,34 +5,18 @@ "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" - ] - } + "required": [ + "classificationCode", + "schemeUri", + "subject", + "subjectScheme" ], "additionalProperties": false } From 65afb36aa635cd448d1d8e393cc79235a464450d Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 16:31:31 -0500 Subject: [PATCH 24/30] Update client factory to include disciplinary repository and spec facets --- spec/graphql/types/work_type_spec.rb | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index 74772ddbb..95e253961 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1250,7 +1250,12 @@ Event.destroy_all end - after :all do + let (:fos_facet) do + { + "id" => "physical_sciences", + "title" => "Physical sciences", + "count" => WORK_COUNT + } end it "has all dois in the search results" do @@ -1269,25 +1274,14 @@ response = @facet_response expect( response.dig("data", "works", "fieldsOfScienceRepository") - ).to match_array([ - { - "id" => "example_subject", - "title" => "Example Subject", - "count" => WORK_COUNT - } - ]) + ).to match_array([ fos_facet ]) end + it "returns combined Field of Science Facets" do response = @facet_response expect( response.dig("data", "works", "fieldsOfScienceCombined") - ).to match_array([ - { - "id" => "example_subject", - "title" => "Example Subject", - "count" => WORK_COUNT - } - ]) + ).to match_array([ fos_facet ]) end end end From c3444354d6d99ffdf110aefaee59d2294e46acba Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 16:37:01 -0500 Subject: [PATCH 25/30] Really update the factory --- spec/factories/client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/factories/client.rb b/spec/factories/client.rb index a0a545f4a..c5a40efe6 100644 --- a/spec/factories/client.rb +++ b/spec/factories/client.rb @@ -20,6 +20,7 @@ is_active { true } factory :client_with_fos do + repository_type { "disciplinary" } subjects do [ { From aa17060222e92be8f928ab4a7d67dc96343255c3 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 16:37:43 -0500 Subject: [PATCH 26/30] Update the elasticsearch mapping for subjects in clinet and dois --- app/models/client.rb | 2 +- app/models/doi.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index c8cb3e5af..75600f0cf 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -203,7 +203,7 @@ class Client < ApplicationRecord indexes :analytics_dashboard_url, type: :text indexes :analytics_tracking_id, type: :text indexes :cumulative_years, type: :integer, index: "false" - indexes :subjects, type: :nested, include_in_parent: true, properties: { + indexes :subjects, type: :object, properties: { subjectScheme: { type: :keyword }, subject: { type: :keyword }, schemeUri: { type: :keyword }, diff --git a/app/models/doi.rb b/app/models/doi.rb index fec8c202d..1b6e3a3a2 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -410,7 +410,7 @@ class Doi < ApplicationRecord updated: { type: :date }, deleted_at: { type: :date }, cumulative_years: { type: :integer, index: "false" }, - subjects: { type: :nested, include_in_parent: true, properties: { + subjects: { type: :object, properties: { subjectScheme: { type: :keyword }, subject: { type: :keyword }, schemeUri: { type: :keyword }, From 070e6e80978aacd9bc45a3f103040e7e27d3435f Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 16:39:25 -0500 Subject: [PATCH 27/30] Appease rubocop --- app/models/client.rb | 1 - spec/graphql/types/work_type_spec.rb | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index 75600f0cf..83b5692cf 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -923,7 +923,6 @@ def subjects_only_for_disciplinary_repos "Subjects are only allowed for disciplinary repositories. This repository_type is: #{repository_type}", ) end - end def check_id diff --git a/spec/graphql/types/work_type_spec.rb b/spec/graphql/types/work_type_spec.rb index 95e253961..6f5473628 100644 --- a/spec/graphql/types/work_type_spec.rb +++ b/spec/graphql/types/work_type_spec.rb @@ -1251,11 +1251,11 @@ end let (:fos_facet) do - { - "id" => "physical_sciences", - "title" => "Physical sciences", - "count" => WORK_COUNT - } + { + "id" => "physical_sciences", + "title" => "Physical sciences", + "count" => WORK_COUNT + } end it "has all dois in the search results" do From d02f6384366d319e9d4bc6c92fb09fb14648d8cf Mon Sep 17 00:00:00 2001 From: jrhoads Date: Fri, 10 Feb 2023 17:02:13 -0500 Subject: [PATCH 28/30] Add repositoryType=discliplinary to the REST spec for subjects --- spec/requests/repositories_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb index 3f2512696..374841395 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -413,6 +413,7 @@ "type" => "repositories", "attributes" => { "subjects" => subjects, + "repositoryType" => "disciplinary", }, }, } From 38c3c6126402617a7d202ae55c43011ef9d29232 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 14 Feb 2023 13:30:15 -0500 Subject: [PATCH 29/30] Ensure subjects and fieldOfScience fields are unique --- app/models/client.rb | 2 +- app/models/doi.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/client.rb b/app/models/client.rb index 83b5692cf..b8f31c86d 100644 --- a/app/models/client.rb +++ b/app/models/client.rb @@ -510,7 +510,7 @@ def re3data=(value) end def subjects=(value) - write_attribute(:subjects, Array.wrap(value)) + write_attribute(:subjects, Array.wrap(value).uniq) end def opendoar=(value) diff --git a/app/models/doi.rb b/app/models/doi.rb index 1b6e3a3a2..c8c986cf6 100644 --- a/app/models/doi.rb +++ b/app/models/doi.rb @@ -1734,11 +1734,11 @@ def _fos_filter(subject_array) end def fields_of_science - _fos_filter(subjects) + _fos_filter(subjects).uniq end def fields_of_science_repository - _fos_filter(client&.subjects) + _fos_filter(client&.subjects).uniq end def fields_of_science_combined From 7b60d407854883e48b740e52bcd60961fc580b19 Mon Sep 17 00:00:00 2001 From: jrhoads Date: Tue, 14 Feb 2023 13:31:58 -0500 Subject: [PATCH 30/30] Add rake task to back-fill disciplinary clients/repositories that have re3data subjects. --- lib/tasks/enrich.rake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/tasks/enrich.rake diff --git a/lib/tasks/enrich.rake b/lib/tasks/enrich.rake new file mode 100644 index 000000000..91ec75f4e --- /dev/null +++ b/lib/tasks/enrich.rake @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +namespace :enrich do + desc "Enrich Clients with Subjects from re3data and converted to Field Of Science subjectScheme" + task client_subjects: :environment do + def enrich_client(client) + re3data = DataCatalog.find_by_id(client.re3data_id).fetch(:data, []).first + if re3data + subs = re3data.subjects + dfg_ids = subs.select { |subject| + subject.scheme == "DFG" + }.map { |subject| + subject.text.split.first + } + fos_subjects = Bolognese::Utils.dfg_ids_to_fos(dfg_ids) + client.subjects = fos_subjects.uniq + client.save + end + end + + puts "Searching for disciplinary repositories with re3data_ids without subjects" + search_results = Client.search("re3data_id:* AND -subjects:* AND repository_type:disciplinary") + puts "Found #{search_results.records.count} repostitories. Enriching now..." + search_results.records.map do |c| + enrich_client(c) + end + puts "Enrichment complete" + end +end