fix researchers reference fetcher

This commit is contained in:
Efstratios Giannopoulos 2024-04-17 13:01:43 +03:00
parent 0757713e63
commit ec7e2a6ea3
2 changed files with 2 additions and 7 deletions

View File

@ -192,12 +192,7 @@ public class ReferenceServiceImpl implements ReferenceService {
}
List<Reference> models = this.fetchReferenceFromDb(lookup);
for (Reference externalReference : externalModels){
if (models.stream().noneMatch(x-> x.getReference() != null && x.getSource() != null && x.getReference().equals(externalReference.getReference()) && x.getSource().equals(externalReference.getSource()))) models.add(externalReference);
}
if (!this.conventionService.isNullOrEmpty(like)) { models = models.stream().filter(x -> x.getLabel().toLowerCase(Locale.ROOT).toLowerCase().contains(like.toLowerCase(Locale.ROOT))).collect(Collectors.toList()); }
models.addAll(externalModels);
models = models.stream().sorted(Comparator.comparing(Reference::getLabel, Comparator.nullsFirst(Comparator.naturalOrder()))).collect(Collectors.toList());
if (lookup.getPage() != null && !lookup.getPage().isEmpty()){

View File

@ -24,7 +24,7 @@ BEGIN
INSERT INTO public."ReferenceType" VALUES ('3d372db5-a456-45e6-a845-e41e1a8311f8', 'projects', 'projects', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><sources><static><key>project</key><label>project</label><ordinal>1</ordinal><type>1</type><items><item><options><option><code>reference_id</code><value>cite_project</value></option><option><code>label</code><value>Cite Project</value></option><option><code>description</code><value>Cite Project</value></option></options></item></items></static></sources></definition>', 1, '2023-11-17 08:55:05.190807', '2023-11-17 08:56:23.012619', NULL);
INSERT INTO public."ReferenceType" VALUES ('51225b6a-86a6-48ac-9192-f15096dbcb8a', 'publications', 'publications', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><fields><field code="pid" label="pid" description="pid" dataType="Text"/><field code="pidTypeField" label="pidTypeField" description="pidTypeField" dataType="Text"/></fields><sources><api><key>openaire</key><label>OpenAIRE Publications</label><ordinal>1</ordinal><referenceTypeDependencyIds/><type>0</type><authentication><authUrlMethod>0</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json;charset=UTF-8</contentType><filterType>remote</filterType><firstPage>0</firstPage><requestHttpMethod>0</requestHttpMethod><paginationPath>$[''meta''][''pagination''][''page'',''pages'',''count'']</paginationPath><queries><query><cases><case><value>{like}</value></case></cases><defaultValue>*</defaultValue><name>like</name></query></queries><requestBody></requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>originalId</responsePath></field><field><code>label</code><responsePath>title</responsePath></field><field><code>description</code><responsePath>title</responsePath></field><field><code>pid</code><responsePath>[''pid''][''content'']</responsePath></field><field><code>pidTypeField</code><responsePath>[''pid''][''classid'']</responsePath></field></fieldsMapping><resultsArrayPath>$[''results''][*][''result''][''metadata''][''oaf:entity''][''oaf:result'']</resultsArrayPath></results><url>https://services.openaire.eu/search/v2/api/resources?query=oaftype exact result and {like}&amp;page={page}&amp;size={pageSize}&amp;format=json</url></api></sources></definition>', 1, '2023-11-16 13:07:20.591433', '2024-02-19 08:23:49.91191', NULL);
INSERT INTO public."ReferenceType" VALUES ('538928bb-c7c6-452e-b66d-08e539f5f082', 'funders', 'funders', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><sources><api><key>openaire</key><label>OpenAIRE</label><ordinal>1</ordinal><referenceTypeDependencyIds/><type>0</type><authentication><authUrlMethod>1</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json; charset=utf-8</contentType><filterType>local</filterType><firstPage>0</firstPage><requestHttpMethod>0</requestHttpMethod><paginationPath>$[*]</paginationPath><requestBody></requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>id</responsePath></field><field><code>label</code><responsePath>name</responsePath></field><field><code>description</code><responsePath>name</responsePath></field></fieldsMapping><resultsArrayPath>$[''refineResults''][''relfunder''][*]</resultsArrayPath></results><url>https://services.openaire.eu/search/v2/api/publications?&amp;refine=true&amp;fields=relfunder&amp;page={page}&amp;size=0&amp;format=json</url></api></sources></definition>', 1, '2023-11-16 11:22:57.942097', '2024-02-16 09:16:19.195353', NULL);
INSERT INTO public."ReferenceType" VALUES ('5a2112e7-ea99-4cfe-98a1-68665e26726e', 'researchers', 'researchers', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><fields><field code="firstName" label="Researchers First Name" description="Researchers First Name" dataType="Text"/><field code="lastName" label="Researchers Last Name" description="Researchers Last Name" dataType="Text"/></fields><sources><api><key>orcid</key><label>ORCID</label><ordinal>1</ordinal><referenceTypeDependencyIds/><type>0</type><authentication><authUrlMethod>0</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json; charset=UTF-8</contentType><filterType>remote</filterType><firstPage>0</firstPage><requestHttpMethod>0</requestHttpMethod><paginationPath>$[''num-found'']</paginationPath><queries><query><cases><case><value>{like}</value></case></cases><defaultValue>*</defaultValue><name>like</name></query></queries><requestBody></requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>orcid-id</responsePath></field><field><code>label</code><responsePath>institution-name</responsePath></field><field><code>description</code><responsePath>institution-name</responsePath></field><field><code>fistName</code><responsePath>family-names</responsePath></field><field><code>lastName</code><responsePath>given-names</responsePath></field></fieldsMapping><resultsArrayPath>$[''expanded-result''][*]</resultsArrayPath></results><url>https://pub.orcid.org/v3.0/expanded-search/?q={like}&amp;start={page}&amp;rows={pageSize}</url></api></sources></definition>', 1, '2023-11-16 18:21:43.272982', '2024-02-16 14:43:03.12758', NULL);
INSERT INTO public."ReferenceType" VALUES ('5a2112e7-ea99-4cfe-98a1-68665e26726e', 'researchers', 'researchers', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><fields><field code="firstName" label="Researchers First Name" description="Researchers First Name" dataType="Text"/><field code="lastName" label="Researchers Last Name" description="Researchers Last Name" dataType="Text"/></fields><sources><api><key>orcid</key><label>ORCID</label><ordinal>1</ordinal><type>0</type><authentication><authUrlMethod>0</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json; charset=UTF-8</contentType><filterType>remote</filterType><firstPage>0</firstPage><requestHttpMethod>0</requestHttpMethod><paginationPath>$[''num-found'']</paginationPath><queries><query><cases><case><likePattern>^[A-Za-z0-9]+ [A-Za-z0-9]+$</likePattern><separator> </separator><value>((given-names:{like1}+AND+family-name:{like2})+OR+(given-names:{like2}+AND+family-name:{like1}))</value></case><case><likePattern>\d{4}-\d{4}-\d{4}-\d{4}</likePattern><value>orcid:{like}</value></case><case><likePattern>.+</likePattern><value>given-names:{like}+OR+family-name:{like}</value></case></cases><defaultValue>*</defaultValue><name>like</name></query></queries><requestBody></requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>orcid-id</responsePath></field><field><code>label</code><responsePath>@{{given-names}} @{{family-names}} (@{{orcid-id}})</responsePath></field><field><code>description</code><responsePath>institution-name</responsePath></field><field><code>fistName</code><responsePath>given-names</responsePath></field><field><code>lastName</code><responsePath>family-names</responsePath></field></fieldsMapping><resultsArrayPath>$[''expanded-result''][*]</resultsArrayPath></results><url>https://pub.orcid.org/v3.0/expanded-search/?q={like}&amp;start={page}&amp;rows={pageSize}</url></api></sources></definition>', 1, '2023-11-16 18:21:43.272982', '2024-04-17 09:44:53.656849', NULL);
INSERT INTO public."ReferenceType" VALUES ('5b9c284f-f041-4995-96cc-fad7ad13289c', 'grants', 'grants', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><sources><api><key>openaire</key><label>OpenAIRE</label><ordinal>1</ordinal><referenceTypeDependencyIds><referenceTypeDependencyIds>538928bb-c7c6-452e-b66d-08e539f5f082</referenceTypeDependencyIds></referenceTypeDependencyIds><type>0</type><authentication><authUrlMethod>0</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json; charset=utf-8</contentType><filterType>remote</filterType><firstPage>0</firstPage><requestHttpMethod>0</requestHttpMethod><paginationPath>$[''meta''][''pagination''][''page'',''pages'',''count'']</paginationPath><queries><query><cases><case><referenceTypeSourceKey>538928bb-c7c6-452e-b66d-08e539f5f082</referenceTypeSourceKey><defaultValue>openaire</defaultValue><value>{like}</value></case></cases><defaultValue>*</defaultValue><name>like</name></query></queries><requestBody></requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>originalId</responsePath></field><field><code>label</code><responsePath>title</responsePath></field><field><code>description</code><responsePath>title</responsePath></field></fieldsMapping><resultsArrayPath>$[''results''][*][''result''][''metadata''][''oaf:entity''][''oaf:project'']</resultsArrayPath></results><url>https://services.openaire.eu/search/v2/api/resources?query=((oaftype exact project) and ((projectcode_nt exact "{like}")or({like})))&amp;page={page}&amp;size={pageSize}&amp;format=json</url></api></sources></definition>', 1, '2023-11-16 16:41:53.106646', '2024-02-19 12:33:49.420526', NULL);
INSERT INTO public."ReferenceType" VALUES ('7eeffb98-58fb-4921-82ec-e27f32f8e738', 'organisations', 'organisations', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><fields><field code="pid" label="Pid Organisations" description="Pid Organisations" dataType="Text"/><field code="pidTypeField" label="PidType Organisations" description="PidType Organisations" dataType="Text"/></fields><sources><api><key>openaire</key><label>OpenAIRE</label><ordinal>1</ordinal><referenceTypeDependencyIds/><type>0</type><authentication><authUrlMethod>0</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json; charset=utf-8</contentType><filterType>remote</filterType><firstPage>0</firstPage><requestHttpMethod>0</requestHttpMethod><paginationPath>$[''meta''][''pagination''][''page'',''pages'',''count'']</paginationPath><queries><query><cases><case><value>{like}</value></case></cases><name>like</name></query></queries><requestBody></requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>originalId</responsePath></field><field><code>label</code><responsePath>legalname</responsePath></field><field><code>description</code><responsePath>legalname</responsePath></field><field><code>pid</code><responsePath>[''pid''][''content'']</responsePath></field><field><code>pidTypeField</code><responsePath>[''pid''][''classid'']</responsePath></field></fieldsMapping><resultsArrayPath>$[''results''][*][''result''][''metadata''][''oaf:entity''][''oaf:organization'']</resultsArrayPath></results><url>https://services.openaire.eu/search/v2/api/organizations/?q={like}&amp;page={page}&amp;size={pageSize}&amp;format=json</url></api></sources></definition>', 1, '2023-11-17 10:13:15.873808', '2024-02-16 15:35:47.874131', NULL);
INSERT INTO public."ReferenceType" VALUES ('8ec7556b-749d-4c4a-a4b9-43d064693795', 'journals', 'journals', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><definition><sources><api><key>openaire</key><label>OpenAIRE Journals</label><ordinal>1</ordinal><referenceTypeDependencyIds/><type>0</type><authentication><authUrlMethod>0</authUrlMethod><authUrlBody></authUrlBody><authTokenPath></authTokenPath><authUrl></authUrl><enabled>false</enabled><authType></authType></authentication><contentType>application/json</contentType><filterType>remote</filterType><firstPage>0</firstPage><requestHttpMethod>1</requestHttpMethod><paginationPath>$[''meta''][''pagination''][''page'',''pages'',''count'']</paginationPath><queries><query><cases><case><value>{like}</value></case></cases><name>like</name></query></queries><requestBody>{"officialname": "{like}", "typology":"journal"}</requestBody><results><fieldsMapping><field><code>reference_id</code><responsePath>id</responsePath></field><field><code>label</code><responsePath>officialname</responsePath></field><field><code>description</code><responsePath>officialname</responsePath></field></fieldsMapping><resultsArrayPath>$[''datasourceInfo''][*]</resultsArrayPath></results><url>https://services.openaire.eu/openaire/ds/searchdetails/{page}/{pageSize}?requestSortBy=id&amp;order=ASCENDING</url></api></sources></definition>', 1, '2023-11-16 17:40:12.811667', '2024-02-16 09:09:22.816978', NULL);