Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2596 In legacy datasets, our brand new ORCID validation may c… #2605

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions scripts/database/delete_unfixable_orcids.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-- !!!!!!! run fix_fixable_orcids.sql before this script,
-- !!!!!!! otherwse fixable ORCIDs will be lost
lbownik marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need also a check that the field is of type authorIdentifierScheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

from datasetfield_controlledvocabularyvalue
where
controlledvocabularyvalues_id in (select controlledvocabularyvalue.id
from controlledvocabularyvalue join datasetfieldtype ON controlledvocabularyvalue.datasetfieldtype_id = datasetfieldtype.id
where controlledvocabularyvalue.strvalue = 'ORCID' and datasetfieldtype.name = 'authorIdentifierScheme')))
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 $$;;
41 changes: 41 additions & 0 deletions scripts/database/fix_fixable_orcids.sql
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');
Loading