Revision 50119
Added by Alessia Bardi over 6 years ago
OpenAIRESubmitterUtils.java | ||
---|---|---|
16 | 16 |
*/ |
17 | 17 |
public class OpenAIRESubmitterUtils { |
18 | 18 |
|
19 |
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(OpenAIRESubmitterUtils.class); |
|
20 |
|
|
19 | 21 |
public Map<String, String> calculateProjectInfo(final String link) { |
20 | 22 |
final Map<String, String> info = new HashMap<String, String>(); |
21 | 23 |
final String[] arr = link.split("/"); |
... | ... | |
25 | 27 |
final String acronym = arr.length > 7 ? arr[7] : ""; |
26 | 28 |
final String title = arr.length > 6 ? StringUtils.isNotBlank(arr[6]) ? arr[6] : acronym : ""; |
27 | 29 |
final String jurisdiction = arr.length > 5 ? arr[5] : ""; |
28 |
final String funderId = calculateFunderId(arr[2]); |
|
30 |
final String funderId = calculateFunderId(arr[2], arr[3]);
|
|
29 | 31 |
info.put("id", calculateProjectId(arr[2], arr[3], arr[4])); |
30 | 32 |
info.put("funderShortName", arr[2]); |
31 | 33 |
info.put("fundingName", arr[3]); |
... | ... | |
40 | 42 |
return info; |
41 | 43 |
} |
42 | 44 |
|
43 |
private String calculateProjectId(final String funderShortName, final String funding, final String code) { |
|
44 |
final String suffix = Hashing.md5(code); |
|
45 |
|
|
46 |
if (funderShortName.equalsIgnoreCase("ec")) { |
|
45 |
protected String calculateFunderPrefix(final String funderShortName, final String funding){ |
|
46 |
switch(funderShortName.toLowerCase()){ |
|
47 |
case "conicyt": |
|
48 |
return "conicytf____::"; |
|
49 |
case "ec": |
|
47 | 50 |
if (funding.equalsIgnoreCase("fp7")) { |
48 |
return "corda_______::" + suffix;
|
|
51 |
return "corda_______::"; |
|
49 | 52 |
} else { |
50 |
return "corda__h2020::" + suffix;
|
|
53 |
return "corda__h2020::"; |
|
51 | 54 |
} |
52 |
} else if (funderShortName.equalsIgnoreCase("arc")) { |
|
53 |
return "arc_________::" + suffix; |
|
54 |
} else if (funderShortName.equalsIgnoreCase("fct")) { |
|
55 |
return "fct_________::" + suffix; |
|
56 |
} else if (funderShortName.equalsIgnoreCase("nhmrc")) { |
|
57 |
return "nhmrc_______::" + suffix; |
|
58 |
} else if (funderShortName.equalsIgnoreCase("wt")) { |
|
59 |
return "wt__________::" + suffix; |
|
60 |
} else { |
|
61 |
return ""; |
|
55 |
case "hrzz": |
|
56 |
case "mzos": |
|
57 |
return "irb_hr______::"; |
|
58 |
case "tara": |
|
59 |
return "taraexp_____::"; |
|
60 |
case "tubitak": |
|
61 |
return "tubitakf____::"; |
|
62 |
default: |
|
63 |
String prefix = funderShortName.toLowerCase(); |
|
64 |
//ensure we have 12 chars |
|
65 |
while(prefix.length() < 12) prefix += "_"; |
|
66 |
return prefix +"::"; |
|
62 | 67 |
} |
63 | 68 |
} |
64 | 69 |
|
65 |
private String calculateFunderId(final String funderShortName) { |
|
66 |
if (funderShortName.equalsIgnoreCase("ec")) { |
|
70 |
protected String calculateProjectId(final String funderShortName, final String funding, final String code) { |
|
71 |
final String suffix = Hashing.md5(code); |
|
72 |
final String funderPrefix = calculateFunderPrefix(funderShortName, funding); |
|
73 |
return funderPrefix + suffix; |
|
74 |
} |
|
75 |
|
|
76 |
protected String calculateFunderId(final String funderShortName, final String funding) { |
|
77 |
switch (funderShortName.toLowerCase()) { |
|
78 |
case "ec": |
|
67 | 79 |
return "ec__________::EC"; |
68 |
} else if (funderShortName.equalsIgnoreCase("arc")) { |
|
69 |
return "arc_________::ARC"; |
|
70 |
} else if (funderShortName.equalsIgnoreCase("fct")) { |
|
71 |
return "fct_________::FCT"; |
|
72 |
} else if (funderShortName.equalsIgnoreCase("nhmrc")) { |
|
73 |
return "nhmrc_______::NHMRC"; |
|
74 |
} else if (funderShortName.equalsIgnoreCase("wt")) { |
|
75 |
return "wt__________::WT"; |
|
76 |
} else { |
|
77 |
return ""; |
|
80 |
default: |
|
81 |
String prefix = calculateFunderPrefix(funderShortName, funding); |
|
82 |
return prefix + funderShortName.toUpperCase(); |
|
78 | 83 |
} |
79 | 84 |
} |
80 | 85 |
|
81 |
private String calculateFunderName(final String funderShortName) { |
|
82 |
if (funderShortName.equalsIgnoreCase("ec")) { |
|
86 |
|
|
87 |
protected String calculateFunderName(final String funderShortName) { |
|
88 |
|
|
89 |
switch (funderShortName.toLowerCase()) { |
|
90 |
case "aff": |
|
91 |
return "Suomen Akatemia"; |
|
92 |
case "arc": |
|
93 |
return "Australian Research Council (ARC)"; |
|
94 |
case "conicyt": |
|
95 |
return "Comisión Nacional de Investigación Científica y Tecnológica"; |
|
96 |
case "ec": |
|
83 | 97 |
return "European Commission"; |
84 |
} else if (funderShortName.equalsIgnoreCase("arc")) { |
|
85 |
return "Australian Research Council (ARC)"; |
|
86 |
} else if (funderShortName.equalsIgnoreCase("fct")) { |
|
98 |
case "fct": |
|
87 | 99 |
return "Fundação para a Ciência e a Tecnologia, I.P."; |
88 |
} else if (funderShortName.equalsIgnoreCase("nhmrc")) { |
|
100 |
case "fwf": |
|
101 |
return "Austrian Science Fund (FWF)"; |
|
102 |
case "hrzz": |
|
103 |
return "Croatian Science Foundation (CSF)"; |
|
104 |
case "mestd": |
|
105 |
return "Ministry of Education, Science and Technological Development of Republic of Serbia"; |
|
106 |
case "mzos": |
|
107 |
return "Ministry of Science, Education and Sports of the Republic of Croatia (MSES)"; |
|
108 |
case "nhmrc": |
|
89 | 109 |
return "National Health and Medical Research Council (NHMRC)"; |
90 |
} else if (funderShortName.equalsIgnoreCase("wt")) { |
|
110 |
case "nih": |
|
111 |
return "National Institutes of Health"; |
|
112 |
case "nsf": |
|
113 |
return "National Science Foundation"; |
|
114 |
case "nwo": |
|
115 |
return "Netherlands Organisation for Scientific Research (NWO)"; |
|
116 |
case "rcuk": |
|
117 |
return "Research Council UK"; |
|
118 |
case "sfi": |
|
119 |
return "Science Foundation Ireland"; |
|
120 |
case "sgov": |
|
121 |
return "Gobierno de España"; |
|
122 |
case "snsf": |
|
123 |
return "Swiss National Science Foundation"; |
|
124 |
case "tara": |
|
125 |
return "Tara Expeditions Foundation"; |
|
126 |
case "tubitak": |
|
127 |
return "Türkiye Bilimsel ve Teknolojik Araştırma Kurumu"; |
|
128 |
case "wt": |
|
91 | 129 |
return "Wellcome Trust"; |
92 |
} else { |
|
130 |
default: |
|
131 |
log.error("Funder short name '"+funderShortName+"' not managed"); |
|
93 | 132 |
return ""; |
94 | 133 |
} |
95 | 134 |
} |
Also available in: Unified diff
Adding an almost geenric approach to obtain funder prefixes and ids. For names, however, we are still hard-coding them