Repository navigation
Conversation
…OutputsController` - Updates `#new` and `#edit` to populate `@prefill_doi` (falling back to the existing DOI identifier on edit) and resolve metadata via `prefill_from_doi` when `params[:prefill_doi]` is supplied. - Adds `assign_doi_identifier` and `set_doi_identifier` to normalize, build/update, or mark cleared DOI identifiers for destruction prior to saving. - Wraps `#update` association clearing, DOI assignment, and `@research_output.update` in a `ResearchOutput.transaction` with `ActiveRecord::Rollback` so existing repositories and metadata standards are preserved if validation fails. - Re-renders `new` and `edit` in place with `flash.now[:alert]` and preserved `@prefill_doi` on validation errors. - Adds `prefill_from_doi` and `doi_error_message` private helpers to map DOI resolution statuses to localized user alerts.
- Implements `.api_base_url` and `.active?` configuration helpers. - Adds `.execute_api_get` to query the Crossref `/works/:doi` REST endpoint with polite `User-Agent` headers and 5-second open/read timeouts. - Adds `.parse_attributes` to extract title, sanitized abstract description, partial `issued.date-parts` release dates, mapped output type, and normalized DOI. - Adds `.map_crossref_type` to map Crossref work types to `ResearchOutput` enum values (`:dataset`, `:software`, `:text`, `:other`). - Adds `.log_and_notify_error` to log lookup failures and report them to Rollbar.
- Implements `.api_base_url` and `.active?` configuration helpers. - Adds `.execute_api_get` to query the DataCite `/dois/:doi` endpoint with JSON:API `Accept` headers and 5-second open/read timeouts. - Adds `.parse_attributes` to extract title, sanitized description (preferring `Abstract` with fallback to the first description), mapped `ResearchOutput` type, `Issued` release date, and normalized DOI. - Adds `.log_and_notify_error` to log lookup failures and report them to Rollbar.
…d normalization - Defines shared `MODERN_DOI_PATTERN` and `OLD_DOI_PATTERN` regex constants alongside `.normalize_doi` to strip `doi.org` and `dx.doi.org` prefixes and validate DOI syntax. - Implements `.fetch_metadata` with 5-minute top-level and per-provider `Rails.cache` caching, querying DataCite first and falling back to Crossref (`resolve_from_providers`, `execute_fetch`, `evaluate_statuses`). - Adds `.sanitize_and_normalize_description` to convert JATS XML markup (`<jats:p>`, `<jats:italic>`, `<jats:bold>`, `<jats:list>`, `<jats:list-item>`) into standard HTML, strip `<script>`/`<style>` nodes, and sanitize output against `ALLOWED_TAGS` and `ALLOWED_ATTRIBUTES`. - Adds `.active?` to check whether DataCite or Crossref integration is enabled.
- Add title sanitization
- Renders a `#doi_lookup_panel` card when `ExternalApis::DoiResolutionService.active?` is enabled. - Adds `#doi_lookup_input` (`name="prefill_doi"`) pre-populated with `@prefill_doi` so users can trigger a metadata lookup via `#btn_prefill_doi` or submit/clear the DOI directly with the form. - Sets `data-prefill-path` on `#btn_prefill_doi` to route lookups to `new_plan_research_output_path` or `edit_plan_research_output_path` based on record state, alongside a hidden `#doi_lookup_status` element for client-side feedback.
…put form - Resets `#btn_prefill_doi` disabled state and default label on `pageshow` when restored from the browser back-forward cache. - Adds a `#btn_toggle_doi_form` click handler to show/hide `#doi_lookup_panel` and focus `#doi_lookup_input` when opened. - Adds a `#btn_prefill_doi` click handler that strips `doi.org` and `dx.doi.org` URL prefixes, validates the DOI against `DOI_MODERN_PATTERN` and `DOI_OLD_PATTERN` constants, displays inline validation errors via `#doi_lookup_status`, and redirects to `data-prefill-path` with `?prefill_doi=<clean_doi>`.
momo3404
force-pushed
the
momo/feat/doi-research-outputs
branch
from
December 1, 2026 20:15
54ed724 to
84c46d6
Compare
aaronskiba
reviewed
Dec 1, 2026
momo3404
force-pushed
the
momo/feat/doi-research-outputs
branch
from
December 1, 2026 20:38
643ac4d to
18a7b70
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code in this PR was written and reviewed by @momo3404, @aaronskiba, @gjacob24, @alasdair-macleod through two previous PRs on the DMP Assistant sister repository: The first PR and the second one. This PR exists to merge that code into the Roadmap repository.
Changes proposed in this PR:
newandeditforms while validating and persisting DOI identifiers consistently across the UI and v2 API.app/services/external_apis/): AddsDoiResolutionService,DataciteService, andCrossrefServiceto normalize DOIs (stripping doi.org/dx.doi.org), resolve metadata with DataCite-to-Crossref failover and 5-minute caching, and sanitize JATS descriptions.app/models/identifier.rb): Addsvalid_doi_formatvalidation scoped to doi scheme identifiers usingDoiResolutionService.normalize_doi.app/controllers/research_outputs_controller.rb): Populates@prefill_doiand resolves metadata onnew/edit, assigns or marks cleared DOI identifiers for destruction before saving, and wraps update in a transaction withActiveRecord::Rollbackto preserve repositories and metadata standards on validation failure.app/views/research_outputs/_form.html.erb,app/javascript/src/researchOutputs/form.js): Adds the#doi_lookup_panelcard with client-side prefix normalization, format validation, and inline status feedback.