From b3382816c96d99dba2e141b375aeb453bd487cf6 Mon Sep 17 00:00:00 2001 From: amontenegro Date: Thu, 5 Dec 2024 12:52:25 -0600 Subject: [PATCH] Fix the code so the app can start with an empty identifer_type table --- docker-entrypoint-initdb.d/4-orcid-schema.sql | 52 +++++++++++++++++++ .../core/manager/IdentifierTypeManager.java | 4 +- .../v3/identifiers/PIDResolverService.java | 37 +++++++------ 3 files changed, 74 insertions(+), 19 deletions(-) diff --git a/docker-entrypoint-initdb.d/4-orcid-schema.sql b/docker-entrypoint-initdb.d/4-orcid-schema.sql index 113028002b6..670d56907a6 100644 --- a/docker-entrypoint-initdb.d/4-orcid-schema.sql +++ b/docker-entrypoint-initdb.d/4-orcid-schema.sql @@ -957,6 +957,58 @@ CREATE TABLE public.identifier_type ( case_sensitive boolean DEFAULT false NOT NULL ); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (1, 'OTHER_ID', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (2, 'ASIN_TLD', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (3, 'EID', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (4, 'CBA', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (5, 'CIT', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (6, 'CTX', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (7, 'HIR', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (8, 'PAT', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (9, 'SOURCE_WORK_ID', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (10, 'URN', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (11, 'WOSUID', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (12, 'ASIN', NULL, 'http://www.amazon.com/dp/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (13, 'JFM', NULL, 'http://zbmath.org/?format=complete&q=an%3A', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (14, 'JSTOR', NULL, 'http://www.jstor.org/stable/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (15, 'LCCN', NULL, 'http://lccn.loc.gov/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (16, 'MR', NULL, 'http://www.ams.org/mathscinet-getitem?mr=', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (17, 'OCLC', NULL, 'http://www.worldcat.org/oclc/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (18, 'SSRN', NULL, 'http://papers.ssrn.com/abstract_id=', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (19, 'ZBL', NULL, 'http://zbmath.org/?format=complete&q=', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (20, 'LENSID', NULL, 'https://www.lens.org/', false, NULL, '2016-11-09 15:58:48.048155+00', '2016-11-09 15:58:48.048155+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (21, 'PDB', NULL, 'http://identifiers.org/pdb/', false, NULL, '2016-10-13 21:08:32.999427+00', '2016-10-13 21:08:32.999427+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (22, 'CIENCIAIUL', NULL, 'https://ciencia.iscte-iul.pt/id/', false, NULL, '2017-01-27 18:19:06.455101+00', '2017-01-27 18:19:06.455101+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (23, 'DOI', NULL, 'https://doi.org/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (24, 'KUID', NULL, 'https://koreamed.org/article/', false, NULL, '2016-11-03 16:47:12.334209+00', '2016-11-03 16:47:12.334209+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (25, 'AUTHENTICUSID', NULL, 'https://www.authenticus.pt/', false, NULL, '2017-10-10 16:54:48.278545+00', '2017-10-10 16:54:48.278545+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (26, 'BIBCODE', NULL, 'http://adsabs.harvard.edu/abs/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (27, 'ARK', NULL, NULL, false, NULL, '2018-01-31 22:36:09.661795+00', '2018-01-31 22:36:09.661795+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (28, 'ARXIV', NULL, 'https://arxiv.org/abs/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (29, 'RRID', NULL, 'https://identifiers.org/rrid/', false, NULL, '2017-05-18 20:59:37.276411+00', '2017-05-18 20:59:37.276411+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (30, 'RFC', NULL, 'https://tools.ietf.org/html/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (31, 'DNB', NULL, 'https://d-nb.info/', false, NULL, '2018-06-21 16:27:54.505109+00', '2018-06-21 16:27:54.505109+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (32, 'URI', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (33, 'ISSN', NULL, 'https://portal.issn.org/resource/ISSN/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (34, 'HANDLE', NULL, 'http://hdl.handle.net/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (35, 'HAL', NULL, 'https://hal.archives-ouvertes.fr/view/resolver/', false, NULL, '2020-10-28 23:27:05.258004+00', '2020-10-28 23:27:05.258004+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (36, 'OSTI', NULL, 'https://www.osti.gov/biblio/', false, NULL, '2016-05-20 11:17:37.775534+00', '2021-02-23 17:22:47.289413+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (37, 'PPR', NULL, 'https://europepmc.org/article/PPR/', false, NULL, '2021-03-13 17:48:30.572269+00', '2021-03-13 17:48:30.572269+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (38, 'GRANT_NUMBER', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775534+00', '2021-04-20 14:41:36.898489+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (39, 'PROPOSAL_ID', NULL, NULL, false, NULL, '2019-01-15 20:43:10.21477+00', '2021-04-20 14:41:36.910654+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (40, 'ETHOS', NULL, 'http://ethos.bl.uk/OrderDetails.do?uin=', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (41, 'OL', NULL, 'http://openlibrary.org/b/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (42, 'EMPIAR', NULL, 'https://www.ebi.ac.uk/empiar/', false, NULL, '2021-08-25 01:33:13.522236+00', '2021-08-25 01:33:13.522236+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (43, 'AGR', NULL, NULL, false, NULL, '2016-05-20 11:17:37.775+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (44, 'ISMN', NULL, NULL, false, NULL, '2021-11-18 23:04:00.197881+00', '2021-11-18 23:04:00.197881+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (45, 'EMDB', NULL, 'https://www.ebi.ac.uk/emdb/', false, NULL, '2021-11-22 22:30:13.66811+00', '2021-11-22 22:30:13.66811+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (46, 'PMID', NULL, 'https://pubmed.ncbi.nlm.nih.gov/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (47, 'PMC', NULL, 'https://europepmc.org/article/pmc/', false, NULL, '2016-05-20 11:17:37.775534+00', '2016-05-20 11:17:37.775534+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (48, 'CSTR', NULL, 'https://www.cstr.cn/', false, NULL, '2022-06-07 18:54:40.806959+00', '2022-06-07 18:54:40.806959+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (49, 'ISBN', '', 'https://www.worldcat.org/isbn/', false, NULL, '2016-05-25 11:17:37.775+00', '2016-05-25 11:17:37.775+00', 'work', false); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (50, 'K10PLUS', NULL, 'https://opac.k10plus.de/DB=2.299/PPNSET?PPN=', false, NULL, '2022-09-01 08:43:11.796091+00', '2022-09-01 08:43:11.796091+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (51, 'CGN', NULL, 'https://id.culturegraph.org/', false, NULL, '2022-09-20 01:50:54.126735+00', '2022-09-20 01:50:54.126735+00', 'work', true); +INSERT INTO public.identifier_type (id, id_name, id_validation_regex, id_resolution_prefix, id_deprecated, client_source_id, date_created, last_modified, primary_use, case_sensitive) VALUES (52, 'RAiD', NULL, 'https://raid.org/', false, NULL, '2024-06-20 16:59:23.95768+00', '2024-06-20 16:59:23.95768+00', 'work', false); ALTER TABLE public.identifier_type OWNER TO orcid; diff --git a/orcid-core/src/main/java/org/orcid/core/manager/IdentifierTypeManager.java b/orcid-core/src/main/java/org/orcid/core/manager/IdentifierTypeManager.java index b8379934a99..6f816c5ca95 100644 --- a/orcid-core/src/main/java/org/orcid/core/manager/IdentifierTypeManager.java +++ b/orcid-core/src/main/java/org/orcid/core/manager/IdentifierTypeManager.java @@ -16,7 +16,7 @@ public interface IdentifierTypeManager { Map fetchIdentifierTypesByAPITypeName(Locale loc); - List queryByPrefix(String query, Locale loc); + List queryByPrefix(String query, Locale loc); - List fetchDefaultIdentifierTypes(Locale loc); + List fetchDefaultIdentifierTypes(Locale loc); } diff --git a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/PIDResolverService.java b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/PIDResolverService.java index c4cb2cd32c4..2dd73c21389 100644 --- a/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/PIDResolverService.java +++ b/orcid-core/src/main/java/org/orcid/core/utils/v3/identifiers/PIDResolverService.java @@ -48,31 +48,34 @@ public void init() { } // populate lookup maps for link checking - for (LinkResolver n : linkResolvers) { - List supported = n.canHandle(); - if (supported.equals(LinkResolver.CAN_HANDLE_EVERYTHING)) { - for (String type : linkResolverMap.keySet()) - linkResolverMap.get(type).add(n); - } else { - for (String type : supported) { - linkResolverMap.get(type).add(n); + if(!linkResolverMap.isEmpty()) { + for (LinkResolver n : linkResolvers) { + List supported = n.canHandle(); + if (supported.equals(LinkResolver.CAN_HANDLE_EVERYTHING)) { + for (String type : linkResolverMap.keySet()) + linkResolverMap.get(type).add(n); + } else { + for (String type : supported) { + linkResolverMap.get(type).add(n); + } } } } // populate lookup maps for metadata resolution - for (MetadataResolver n : metaResolvers) { - List supported = n.canHandle(); - if (supported.equals(MetadataResolver.CAN_HANDLE_EVERYTHING)) { - for (String type : metaResolverMap.keySet()) - metaResolverMap.get(type).add(n); - } else { - for (String type : supported) { - metaResolverMap.get(type).add(n); + if(!metaResolverMap.isEmpty()) { + for (MetadataResolver n : metaResolvers) { + List supported = n.canHandle(); + if (supported.equals(MetadataResolver.CAN_HANDLE_EVERYTHING)) { + for (String type : metaResolverMap.keySet()) + metaResolverMap.get(type).add(n); + } else { + for (String type : supported) { + metaResolverMap.get(type).add(n); + } } } } - } /**