diff --git a/Gemfile.lock b/Gemfile.lock index 60fe4bcea..9a0d56670 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -440,7 +440,7 @@ GEM loofah (2.25.2) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.9.0) + mail (2.9.1) logger mini_mime (>= 0.1.1) net-imap diff --git a/app/jobs/enrichment_batch_process_job.rb b/app/jobs/enrichment_batch_process_job.rb index 7c9faeb5d..df1311776 100644 --- a/app/jobs/enrichment_batch_process_job.rb +++ b/app/jobs/enrichment_batch_process_job.rb @@ -47,8 +47,6 @@ def perform(lines, filename, source_id) filename: filename, doi: uid, source_id: source_id, - contributors: parsed_line["contributors"], - resources: parsed_line["resources"], field: parsed_line["field"], action: parsed_line["action"], original_value: parsed_line["originalValue"], diff --git a/app/models/enrichment.rb b/app/models/enrichment.rb index 79a555996..9b4e5e19e 100644 --- a/app/models/enrichment.rb +++ b/app/models/enrichment.rb @@ -48,8 +48,7 @@ def validate_json_schema def to_enrichment_hash { "doi" => doi, - "contributors" => contributors, - "resources" => resources, + "sourceId" => source_id, "field" => field, "action" => action, "originalValue" => original_value, diff --git a/app/models/schemas/enrichment/enrichment.json b/app/models/schemas/enrichment/enrichment.json index ea2382201..b4bd0b875 100644 --- a/app/models/schemas/enrichment/enrichment.json +++ b/app/models/schemas/enrichment/enrichment.json @@ -7,76 +7,6 @@ "type": "string", "description": "The target DOI of the enrichment record." }, - "contributors": { - "type": "array", - "minItems": 1, - "description": "The source entities of the enrichment represented as an array of contributors", - "items": { - "type": "object", - "additionalProperties": false, - "required": ["name", "contributorType"], - "properties": { - "name": { - "type": "string" - }, - "nameType": { - "$ref": "#/definitions/nameType" - }, - "givenName": { - "type": ["string", "null"] - }, - "familyName": { - "type": ["string", "null"] - }, - "lang": { - "type": ["string", "null"] - }, - "affiliation": { - "$ref": "#/definitions/affiliations" - }, - "nameIdentifiers": { - "$ref": "#/definitions/nameIdentifiers" - }, - "contributorType": { - "$ref": "#/definitions/contributorTypes" - } - } - } - }, - "resources": { - "type": "array", - "minItems": 1, - "description": "The processes that produced the enrichment represented as an array of relatedIdentifiers", - "items": { - "type": "object", - "additionalProperties": false, - "required": [ - "relatedIdentifier", - "relationType", - "relatedIdentifierType" - ], - "properties": { - "relatedIdentifier": { - "type": "string" - }, - "relationType": { - "$ref": "#/definitions/relationTypes" - }, - "relatedIdentifierType": { - "$ref": "#/definitions/relatedIdentifierTypes" - }, - "relatedMetadataScheme": { - "type": "string" - }, - "schemeUri": { - "type": "string" - }, - "resourceTypeGeneral": { - "$ref": "#/definitions/resourceTypeGeneral" - } - } - } - }, "field": { "type": "string", "description": "The top-level field to enrich.", @@ -140,9 +70,13 @@ "type": "array" } ] + }, + "sourceId": { + "type": "string", + "description": "The source id (DOI) of the enrichment record." } }, - "required": ["doi", "contributors", "resources", "action", "field"], + "required": ["doi", "action", "field", "sourceId"], "allOf": [ { "if": { @@ -168,192 +102,5 @@ "required": ["enrichedValue"] } } - ], - "definitions": { - "nameType": { - "anyOf": [ - { - "type": "string", - "enum": ["Organizational", "Personal"] - }, - { - "type": "null" - } - ] - }, - "affiliations": { - "type": "array", - "items": { - "type": "object", - "required": ["name"], - "additionalProperties": false, - "properties": { - "affiliationIdentifier": { - "type": ["string", "null"] - }, - "affiliationIdentifierScheme": { - "type": ["string", "null"] - }, - "name": { - "type": "string" - }, - "schemeUri": { - "type": ["string", "null"] - } - } - } - }, - "nameIdentifiers": { - "type": "array", - "items": { - "type": "object", - "required": ["nameIdentifier", "nameIdentifierScheme"], - "additionalProperties": false, - "properties": { - "schemeUri": { - "type": ["string", "null"] - }, - "nameIdentifier": { - "type": "string" - }, - "nameIdentifierScheme": { - "type": "string" - } - } - } - }, - "relationTypes": { - "type": "string", - "enum": [ - "IsCitedBy", - "Cites", - "IsSupplementTo", - "IsSupplementedBy", - "IsContinuedBy", - "Continues", - "IsDescribedBy", - "Describes", - "HasMetadata", - "IsMetadataFor", - "HasVersion", - "IsVersionOf", - "IsNewVersionOf", - "IsPreviousVersionOf", - "IsPartOf", - "HasPart", - "IsPublishedIn", - "IsReferencedBy", - "References", - "IsDocumentedBy", - "Documents", - "IsCompiledBy", - "Compiles", - "IsVariantFormOf", - "IsOriginalFormOf", - "IsIdenticalTo", - "IsReviewedBy", - "Reviews", - "IsDerivedFrom", - "IsSourceOf", - "IsRequiredBy", - "Requires", - "IsObsoletedBy", - "Obsoletes", - "IsCollectedBy", - "Collects", - "IsTranslationOf", - "HasTranslation" - ] - }, - "relatedIdentifierTypes": { - "type": "string", - "enum": [ - "ARK", - "arXiv", - "bibcode", - "CSTR", - "DOI", - "EAN13", - "EISSN", - "Handle", - "IGSN", - "ISBN", - "ISSN", - "ISTC", - "LISSN", - "LSID", - "PMID", - "PURL", - "RRID", - "UPC", - "URL", - "URN", - "w3id" - ] - }, - "resourceTypeGeneral": { - "type": "string", - "enum": [ - "Audiovisual", - "Award", - "Book", - "BookChapter", - "Collection", - "ComputationalNotebook", - "ConferencePaper", - "ConferenceProceeding", - "DataPaper", - "Dataset", - "Dissertation", - "Event", - "Image", - "InteractiveResource", - "Instrument", - "Journal", - "JournalArticle", - "Model", - "OutputManagementPlan", - "PeerReview", - "PhysicalObject", - "Preprint", - "Project", - "Report", - "Service", - "Software", - "Sound", - "Standard", - "StudyRegistration", - "Text", - "Workflow", - "Other" - ] - }, - "contributorTypes": { - "type": "string", - "enum": [ - "ContactPerson", - "DataCollector", - "DataCurator", - "DataManager", - "Distributor", - "Editor", - "HostingInstitution", - "Producer", - "ProjectLeader", - "ProjectManager", - "ProjectMember", - "RegistrationAgency", - "RegistrationAuthority", - "RelatedPerson", - "Researcher", - "ResearchGroup", - "RightsHolder", - "Sponsor", - "Supervisor", - "Translator", - "WorkPackageLeader", - "Other" - ] - } - } + ] } diff --git a/app/serializers/enrichment_serializer.rb b/app/serializers/enrichment_serializer.rb index 1b1092858..8026dbe91 100644 --- a/app/serializers/enrichment_serializer.rb +++ b/app/serializers/enrichment_serializer.rb @@ -8,8 +8,7 @@ class EnrichmentSerializer set_id :uuid attributes :doi, - :contributors, - :resources, + :source_id, :field, :action, :original_value, diff --git a/db/migrate/20260804153743_remove_contributors_from_enrichments.rb b/db/migrate/20260804153743_remove_contributors_from_enrichments.rb new file mode 100644 index 000000000..a49793728 --- /dev/null +++ b/db/migrate/20260804153743_remove_contributors_from_enrichments.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveContributorsFromEnrichments < ActiveRecord::Migration[7.2] + disable_departure! + + def change + remove_column :enrichments, :contributors, :json, null: false + end +end diff --git a/db/migrate/20260804154200_remove_resources_from_enrichments.rb b/db/migrate/20260804154200_remove_resources_from_enrichments.rb new file mode 100644 index 000000000..5f6e3ba85 --- /dev/null +++ b/db/migrate/20260804154200_remove_resources_from_enrichments.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class RemoveResourcesFromEnrichments < ActiveRecord::Migration[7.2] + disable_departure! + + def change + remove_column :enrichments, :resources, :json, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 537a39f75..97bbf234b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_06_17_100000) do +ActiveRecord::Schema[8.1].define(version: 2026_08_04_154200) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.bigint "blob_id", null: false t.datetime "created_at", null: false @@ -255,14 +255,12 @@ create_table "enrichments", charset: "utf8mb3", force: :cascade do |t| t.string "action", null: false - t.json "contributors", null: false t.datetime "created_at", null: false t.string "doi", null: false t.json "enriched_value" t.string "field", null: false t.string "filename" t.json "original_value" - t.json "resources", null: false t.string "source_id", null: false t.datetime "updated_at", null: false t.string "uuid", limit: 36, null: false diff --git a/spec/factories/enrichment.rb b/spec/factories/enrichment.rb index 1ff7c52d0..0e2f6e2ae 100644 --- a/spec/factories/enrichment.rb +++ b/spec/factories/enrichment.rb @@ -6,7 +6,7 @@ field { "creators" } action { "updateChild" } - source_id { "datacite.comet" } + source_id { "10.0000/fake.test.doi.2026.001" } original_value do { @@ -34,14 +34,6 @@ } end - contributors do - [{ "name" => "DataCite COMET", "contributorType" => "DataCurator" }] - end - - resources do - [{ "relatedIdentifier" => "https://ror.org/04wxnsj81", "relationType" => "IsDerivedFrom", "relatedIdentifierType" => "URL" }] - end - transient do doi { nil } end diff --git a/spec/requests/datacite_dois/datacite_dois_spec.rb b/spec/requests/datacite_dois/datacite_dois_spec.rb index 3dbf8801a..2d45937f4 100755 --- a/spec/requests/datacite_dois/datacite_dois_spec.rb +++ b/spec/requests/datacite_dois/datacite_dois_spec.rb @@ -2374,41 +2374,11 @@ def refresh_enriched_doi_index end end let!(:enrichment_for_doi_with_invalid_url) { create(:enrichment, doi: doi_with_invalid_url.doi) } - let(:doi_with_contributor) do - create(:doi, client: client, aasm_state: "findable", contributors: [{ - "name" => "Arslan, M.", - "givenName" => "M.", - "familyName" => "Arslan", - "contributorType" => "ContactPerson", - "affiliation" => [], - }]) - end - let!(:enrichment_with_invalid_contributor) { create(:enrichment, - doi: doi_with_contributor.doi, - field: "contributors", - original_value: doi_with_contributor.contributors.first, - enriched_value: { - "name" => "Arslan, M.", - "givenName" => "M.", - "familyName" => "Arslan", - "contributorType" => "Funder", - "affiliation" => [ - { - "name": "UNSW Sydney, neilcmalan@gmail.com", - "schemeUri": "https://ror.org", - "affiliationIdentifier": "https://ror.org/03r8z3t63", - "affiliationIdentifierScheme": "ROR" - } - ], - "nameIdentifiers" => [], - }) } before do IndexJobDoiRegistration.perform_now(doi) IndexJobDoiRegistration.perform_now(doi_with_invalid_url) - IndexJobDoiRegistration.perform_now(doi_with_contributor) EnrichedDoiIndexJob.perform_now(doi_with_invalid_url.doi) - EnrichedDoiIndexJob.perform_now(doi_with_contributor.doi) import_doi_index refresh_enriched_doi_index end @@ -2525,38 +2495,5 @@ def refresh_enriched_doi_index expect(json.dig("data", 0, "relationships", "enrichments", "data").count).to eq(1) end end - - context "when an enrichment record has an invalid contributor" do - it "returns the original value at /dois" do - get "/dois?query=doi:#{doi_with_contributor.doi}", nil, headers - expect(last_response.status).to eq(200) - expect(json.dig("data").size).to eq(1) - expect(json.dig("data", 0, "attributes", "doi")).to eq(doi_with_contributor.doi.downcase) - expect(json.dig("data", 0, "attributes", "contributors")).to eq([{ - "name" => "Arslan, M.", - "givenName" => "M.", - "familyName" => "Arslan", - "contributorType" => "ContactPerson", - "affiliation" => [], - "nameIdentifiers" => [], - }]) - end - - it "returns the original value at /dois?enriched=true" do - get "/dois?query=doi:#{doi_with_contributor.doi}&enriched=true", nil, headers - expect(last_response.status).to eq(200) - expect(json.dig("data").size).to eq(1) - expect(json.dig("data", 0, "attributes", "doi")).to eq(doi_with_contributor.doi.downcase) - expect(json.dig("data", 0, "attributes", "contributors")).to eq([{ - "name" => "Arslan, M.", - "givenName" => "M.", - "familyName" => "Arslan", - "contributorType" => "ContactPerson", - "affiliation" => [], - "nameIdentifiers" => [], - }]) - expect(json.dig("data", 0, "relationships", "enrichments", "data").count).to eq(0) - end - end end end