Revision 59954
Added by Alessia Bardi over 3 years ago
OpenAIRESubmitterUtils.java | ||
---|---|---|
36 | 36 |
final String jurisdiction = arr.length > 5 ? arr[5] : ""; |
37 | 37 |
final String funderId = calculateFunderId(arr[2], arr[3]); |
38 | 38 |
info.put("id", calculateProjectId(arr[2], arr[3], arr[4])); |
39 |
info.put("funderShortName", arr[2]);
|
|
39 |
info.put("funderShortName", fixFunderShortName(arr[2]));
|
|
40 | 40 |
info.put("fundingName", arr[3]); |
41 |
info.put("code", arr[4]);
|
|
41 |
info.put("code", unescape(arr[4]));
|
|
42 | 42 |
info.put("jurisdiction", jurisdiction); |
43 | 43 |
info.put("title", title); |
44 | 44 |
info.put("acronym", acronym); |
45 | 45 |
info.put("funderId", funderId); |
46 | 46 |
info.put("funderName", calculateFunderName(arr[2])); |
47 |
info.put("fundingId", funderId + "::" + arr[3]); |
|
47 |
if(StringUtils.isNotBlank(arr[3])) info.put("fundingId", funderId + "::" + arr[3]);
|
|
48 | 48 |
} |
49 | 49 |
return info; |
50 | 50 |
} |
51 | 51 |
|
52 |
//TODO: remove me when Zenodo ingests the good UKRI projects |
|
53 |
protected String fixFunderShortName(final String funderShortName){ |
|
54 |
switch(funderShortName){ |
|
55 |
case "RCUK": |
|
56 |
return "UKRI"; |
|
57 |
default: |
|
58 |
return funderShortName; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
52 | 62 |
protected String calculateFunderPrefix(final String funderShortName, final String funding){ |
53 | 63 |
switch(funderShortName.toLowerCase()){ |
54 | 64 |
case "conicyt": |
... | ... | |
71 | 81 |
case "tubitak": |
72 | 82 |
return "tubitakf____::"; |
73 | 83 |
case "rcuk": |
74 |
return "ukri________"; |
|
84 |
return "ukri________::";
|
|
75 | 85 |
default: |
76 | 86 |
String prefix = funderShortName.toLowerCase(); |
77 | 87 |
//ensure we have 12 chars |
... | ... | |
81 | 91 |
} |
82 | 92 |
|
83 | 93 |
protected String calculateProjectId(final String funderShortName, final String funding, final String code) { |
84 |
final String suffix = Hashing.md5(code); |
|
94 |
final String suffix = Hashing.md5(unescape(code)); |
|
95 |
//final String suffix = Hashing.md5(code); |
|
85 | 96 |
final String funderPrefix = calculateFunderPrefix(funderShortName, funding); |
86 | 97 |
return funderPrefix + suffix; |
87 | 98 |
} |
88 | 99 |
|
100 |
private String unescape(String code) { |
|
101 |
return StringUtils.replaceChars(code, "%2F", "/"); |
|
102 |
} |
|
103 |
|
|
89 | 104 |
protected String calculateFunderId(final String funderShortName, final String funding) { |
90 | 105 |
switch (funderShortName.toLowerCase()) { |
91 | 106 |
case "ec": |
92 | 107 |
return "ec__________::EC"; |
93 | 108 |
default: |
94 |
String prefix = calculateFunderPrefix(funderShortName, funding); |
|
95 |
return prefix + funderShortName.toUpperCase(); |
|
109 |
String fixedFunderShortName = fixFunderShortName(funderShortName); |
|
110 |
String prefix = calculateFunderPrefix(fixedFunderShortName, funding); |
|
111 |
return prefix + fixedFunderShortName.toUpperCase(); |
|
96 | 112 |
} |
97 | 113 |
} |
98 | 114 |
|
Also available in: Unified diff
Fixed direct indexing to projects with no funding streams and with escaped '/' in the grant code. Fixed UKRI acronym/names