Revision 45369
Added by Alessia Bardi over 7 years ago
modules/cnr-openaire-exporter/trunk/src/test/java/eu/dnetlib/openaire/exporter/ProjectsControllerTest.java | ||
---|---|---|
35 | 35 |
params.setFundingPath(null); |
36 | 36 |
String res = controller.obtainQuery(params); |
37 | 37 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
38 |
st.setAttribute("fundingprefix", "ec__________::EC::FP7::");
|
|
38 |
st.setAttribute("fundingprefix", "ec__________::EC::FP7"); |
|
39 | 39 |
System.out.println(res); |
40 | 40 |
System.out.println(st); |
41 | 41 |
assertEquals(st.toString(), res); |
... | ... | |
80 | 80 |
params.setFundingPath(null); |
81 | 81 |
String res = controller.obtainQuery(params); |
82 | 82 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
83 |
st.setAttribute("fundingprefix", "wt__________::WT::");
|
|
83 |
st.setAttribute("fundingprefix", "wt__________::WT"); |
|
84 | 84 |
System.out.println(res); |
85 | 85 |
assertEquals(st.toString(), res); |
86 | 86 |
} |
... | ... | |
91 | 91 |
params.setFundingPath(null); |
92 | 92 |
String res = controller.obtainQuery(params); |
93 | 93 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
94 |
st.setAttribute("fundingprefix", "fct_________::FCT::");
|
|
94 |
st.setAttribute("fundingprefix", "fct_________::FCT"); |
|
95 | 95 |
System.out.println(res); |
96 |
assertEquals(st.toString() + "", res);
|
|
96 |
assertEquals(st.toString(), res); |
|
97 | 97 |
} |
98 | 98 |
|
99 | 99 |
@Test |
... | ... | |
104 | 104 |
String res = controller.obtainQuery(params); |
105 | 105 |
System.out.println(res); |
106 | 106 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
107 |
st.setAttribute("fundingprefix", "wt__________::WT::");
|
|
107 |
st.setAttribute("fundingprefix", "wt__________::WT"); |
|
108 | 108 |
String q = st.toString() + " AND startdate >= '2015-05-04'"; |
109 | 109 |
assertEquals(q, res); |
110 | 110 |
} |
111 | 111 |
|
112 |
@Test |
|
113 |
public void testObtainSNSFQuery() throws IllegalArgumentException, IOException { |
|
114 |
params.setFundingProgramme("SNSF"); |
|
115 |
params.setFundingPath(null); |
|
116 |
String res = controller.obtainQuery(params); |
|
117 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
118 |
st.setAttribute("fundingprefix", "snsf________::SNSF"); |
|
119 |
System.out.println(res); |
|
120 |
assertEquals(st.toString(), res); |
|
121 |
} |
|
122 |
|
|
112 | 123 |
} |
modules/cnr-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/ProjectsController.java | ||
---|---|---|
64 | 64 |
private ProjectQueryParamsFactory projectQueryParamsFactory; |
65 | 65 |
|
66 | 66 |
public enum Funding { |
67 |
FP7, WT, FCT, H2020, NHMRC, ARC, SFI, MZOS, HRZZ, NWO, MESTD, FWF |
|
67 |
FP7, WT, FCT, H2020, NHMRC, ARC, SFI, MZOS, HRZZ, NWO, MESTD, FWF, SNSF
|
|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
@RequestMapping(value = "/openaire/export/**/project/dspace.do") |
... | ... | |
244 | 244 |
private String getFundingPrefix(final Funding funding, final String suffix) throws IllegalArgumentException { |
245 | 245 |
switch (funding) { |
246 | 246 |
case FCT: |
247 |
if (StringUtils.isBlank(suffix)) return "fct_________::FCT::";
|
|
247 |
if (StringUtils.isBlank(suffix)) return "fct_________::FCT"; |
|
248 | 248 |
else return "fct_________::FCT::" + suffix; |
249 | 249 |
case WT: |
250 |
if (StringUtils.isBlank(suffix)) return "wt__________::WT::";
|
|
250 |
if (StringUtils.isBlank(suffix)) return "wt__________::WT"; |
|
251 | 251 |
else return "wt__________::WT::" + suffix; |
252 | 252 |
case FP7: |
253 |
if (StringUtils.isBlank(suffix)) return "ec__________::EC::FP7::";
|
|
253 |
if (StringUtils.isBlank(suffix)) return "ec__________::EC::FP7"; |
|
254 | 254 |
else return "ec__________::EC::FP7::" + suffix; |
255 | 255 |
case H2020: |
256 | 256 |
if (StringUtils.isBlank(suffix)) return "ec__________::EC::H2020"; |
257 | 257 |
else return "ec__________::EC::H2020" + suffix; |
258 | 258 |
case NHMRC: |
259 |
if (StringUtils.isBlank(suffix)) return "nhmrc_______::NHMRC::";
|
|
259 |
if (StringUtils.isBlank(suffix)) return "nhmrc_______::NHMRC"; |
|
260 | 260 |
else return "nhmrc_______::NHMRC::" + suffix; |
261 | 261 |
case ARC: |
262 |
if (StringUtils.isBlank(suffix)) return "arc_________::ARC::";
|
|
262 |
if (StringUtils.isBlank(suffix)) return "arc_________::ARC"; |
|
263 | 263 |
else return "arc_________::ARC::" + suffix; |
264 | 264 |
case SFI: |
265 |
if (StringUtils.isBlank(suffix)) return "sfi_________::SFI::";
|
|
265 |
if (StringUtils.isBlank(suffix)) return "sfi_________::SFI"; |
|
266 | 266 |
else return "sfi_________::SFI::" + suffix; |
267 | 267 |
case MZOS: |
268 | 268 |
if (StringUtils.isBlank(suffix)) return "irb_hr______::MZOS"; |
... | ... | |
279 | 279 |
case FWF: |
280 | 280 |
if (StringUtils.isBlank(suffix)) return "fwf_________::FWF"; |
281 | 281 |
else return "fwf_________::FWF::" + suffix; |
282 |
case SNSF: |
|
283 |
if (StringUtils.isBlank(suffix)) return "snsf________::SNSF"; |
|
284 |
else return "snsf________::SNSF::" + suffix; |
|
282 | 285 |
default: |
283 | 286 |
throw new IllegalArgumentException("Invalid funding " + funding + " (valid are: " + Arrays.asList(Funding.values()) + ") "); |
284 | 287 |
} |
Also available in: Unified diff
Support for SNSF - Swiss National Science Foundation