-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #2596 In legacy datasets, our brand new ORCID validation may c…
…reate confusing errors when trying to save a draft after file edit (upload or changes in metadata or licenses)
- Loading branch information
lbownik
committed
Dec 5, 2024
1 parent
40f4024
commit 7a09048
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
-- !!!!!!! run fix_fixable_orcids.sql before this script, | ||
-- !!!!!!! otherwse fixable ORCIDs will be lost | ||
DO $$ | ||
DECLARE | ||
ids numeric[]; | ||
BEGIN | ||
-- find indetifiers of all dataset fields with supposed ORCID values | ||
-- that don't match ORCIS format | ||
SELECT ARRAY(select id | ||
from datasetfield | ||
where | ||
datasetfieldtype_id in (select id | ||
from datasetfieldtype | ||
where | ||
name = 'authorIdentifier') | ||
and | ||
datasetfieldparent_id in | ||
(select datasetfieldparent_id | ||
from datasetfield | ||
where | ||
id in (select datasetfield_id | ||
from datasetfield_controlledvocabularyvalue | ||
where | ||
controlledvocabularyvalues_id in (select id | ||
from controlledvocabularyvalue | ||
where | ||
strvalue = 'ORCID'))) | ||
and fieldvalue !~ '^(\d{4}-){3}\d{3}[\dX]$' | ||
and fieldvalue is not null) | ||
INTO ids; | ||
|
||
-- clear all unfixable orcid values | ||
update datasetfield | ||
set | ||
fieldvalue = null | ||
where | ||
id = any(ids); | ||
|
||
-- clear indetified schema selections for deleted ORCIDs | ||
delete | ||
from datasetfield_controlledvocabularyvalue | ||
where datasetfield_id in (select id from datasetfield | ||
where | ||
datasetfieldparent_id in (select datasetfieldparent_id | ||
from datasetfield | ||
where | ||
id = any(ids)) | ||
and | ||
datasetfieldtype_id in (select id | ||
from datasetfieldtype | ||
where | ||
name = 'authorIdentifierScheme')); | ||
END $$; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- fixes ORCID values | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'ORCID: ') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'ORCID: %'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'ORCID ') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'ORCID 0%'; | ||
|
||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'http://orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'http://orcid.org/%'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'https://orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'https://orcid.org/%'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'https://orcid.org/ ') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'https://orcid.org/ %'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'hhttps://orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'hhttps://orcid.org/%'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'Warsaw, Poland https://orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'Warsaw, Poland https://orcid.org/%'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'ORCID logo https://orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'ORCID logo https://orcid.org/%'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'orcid logo https://orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'orcid logo https://orcid.org/%'; | ||
update datasetfield set fieldvalue = LTRIM(fieldvalue, 'orcid.org/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like 'orcid.org/%'; | ||
|
||
update datasetfield set fieldvalue = RTRIM(fieldvalue, 'Zbiór') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like '%Zbiór'; | ||
|
||
update datasetfield set fieldvalue = ('0' || fieldvalue) | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like '000-%'; | ||
|
||
update datasetfield set fieldvalue = LTRIM(fieldvalue, '/') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like '/0000-%'; | ||
|
||
update datasetfield set fieldvalue = RTRIM(fieldvalue, '.') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like '%.'; | ||
|
||
update datasetfield set fieldvalue = RTRIM(fieldvalue, ',') | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier') and fieldvalue like '%,'; | ||
|
||
|
||
update datasetfield set fieldvalue = TRIM(fieldvalue) | ||
where datasetfieldtype_id in (select id from datasetfieldtype where name = 'authorIdentifier'); |