Revision 62848
Added by Alessia Bardi 11 months ago
modules/dnet-directindex-api/trunk/src/main/java/eu/dnetlib/openaire/directindex/objects/ResultEntryToOaf.java | ||
---|---|---|
31 | 31 |
private static final Map<String, String> cached_contexts = new HashMap<>(); |
32 | 32 |
|
33 | 33 |
private static final String ZENODO_ID="opendoar____::2659"; |
34 |
private static final String DOI_PREFIX = "doi_________"; |
|
34 | 35 |
|
35 | 36 |
private OpenAIRESubmitterUtils utils; |
36 | 37 |
|
... | ... | |
63 | 64 |
if (StringUtils.isBlank(entry.getOpenaireId())) { |
64 | 65 |
if(entry.getCollectedFromId().equals(ZENODO_ID)){ |
65 | 66 |
String doi = entry.getPids().stream().filter(e -> e.getType().equalsIgnoreCase("doi")).findFirst().get().getValue(); |
66 |
entry.setOpenaireId(calculateOpenaireId(doi, collectedFromEntry));
|
|
67 |
entry.setOpenaireId(calculateOpenaireId(DOI_PREFIX, doi));
|
|
67 | 68 |
} |
68 | 69 |
else entry.setOpenaireId(calculateOpenaireId(entry.getOriginalId(), collectedFromEntry)); |
69 | 70 |
} |
... | ... | |
154 | 155 |
} |
155 | 156 |
return cached_contexts; |
156 | 157 |
} |
158 |
private static String calculateOpenaireId(final String prefix, final String id) { |
|
159 |
return prefix + "::" + Hashing.md5(id); |
|
160 |
} |
|
157 | 161 |
|
158 | 162 |
private static String calculateOpenaireId(final String originalId, final DatasourceEntry collectedFromEntry) { |
159 | 163 |
return collectedFromEntry.getPrefix() + "::" + Hashing.md5(originalId); |
modules/dnet-directindex-api/trunk/src/test/java/eu/dnetlib/openaire/directindex/objects/ResultEntryToOafTest.java | ||
---|---|---|
61 | 61 |
doReturn(Lists.newArrayList("noLabel", "enermaps")).when(utils).translateZenodoCommunity("https://sandbox.zenodo.org/communities/oac-ni"); |
62 | 62 |
doReturn(Lists.newArrayList("noLabel", "enermaps")).when(utils).translateZenodoCommunity("https://zenodo.org/communities/oac-ni"); |
63 | 63 |
doReturn(new DatasourceEntry("test________::XXX", "XXX", "xxxx________")).when(utils).findDatasource(anyString()); |
64 |
doReturn(new DatasourceEntry("opendoar____::2659", "ZENODO", "doi_________")).when(utils).findDatasource("opendoar____::2659");
|
|
64 |
doReturn(new DatasourceEntry("opendoar____::2659", "ZENODO", "od______2659")).when(utils).findDatasource("opendoar____::2659");
|
|
65 | 65 |
|
66 | 66 |
toOaf = new ResultEntryToOaf(utils); |
67 | 67 |
|
... | ... | |
329 | 329 |
} |
330 | 330 |
|
331 | 331 |
@Test |
332 |
public void testAsIndexRecordFromZenodo_intelcomp() throws Exception { |
|
333 |
testAsIndexRecord_json("test_zenodo_dmp_intelcomp.json"); |
|
334 |
} |
|
335 |
|
|
336 |
@Test |
|
332 | 337 |
public void testEscapeUnicode() { |
333 | 338 |
final String unicodeTxt = |
334 | 339 |
"i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$"; |
335 | 340 |
System.out.println(StringEscapeUtils.escapeXml11(unicodeTxt)); |
336 | 341 |
} |
337 | 342 |
|
343 |
@Test |
|
344 |
public void testAsIndexRecordFromZenodo_doi() throws Exception { |
|
345 |
testAsIndexRecord_json("test_zenodo_doi.json"); |
|
346 |
} |
|
347 |
|
|
338 | 348 |
} |
modules/dnet-directindex-api/trunk/src/test/resources/eu/dnetlib/openaire/directindex/objects/test_zenodo_dmp_intelcomp.json | ||
---|---|---|
4 | 4 |
], |
5 | 5 |
"description": "<p>IntelComp sets out to build an innovative Cloud Platform that...", |
6 | 6 |
"publisher": "Zenodo", |
7 |
"contexts": [ |
|
8 |
"https://zenodo.org/communities/argos", |
|
9 |
"https://zenodo.org/communities/intelcomp" |
|
10 |
], |
|
11 | 7 |
"collectedFromId": "opendoar____::2659", |
12 | 8 |
"hostedById": "opendoar____::2659", |
13 | 9 |
"originalId": "oai:zenodo.org:5109933", |
Also available in: Unified diff
The prefix of Zenodo is not doi as previously assumed by the tests, hence version 4.0.0 did not introduce the fix I expected in the beta env. Now it should work