Revision 34819
Added by Alessia Bardi over 9 years ago
modules/cnr-openaire-exporter/trunk/src/test/java/eu/dnetlib/openaire/exporter/EPrintsTest.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
public class EPrintsTest { |
15 | 15 |
|
16 |
private String inputXML = "<projects><project><FIELD name=\"funder\">funderID</FIELD><FIELD name=\"grant_agreement_number\">GRANTID1</FIELD><FIELD name=\"title\">Project title 1</FIELD><FIELD name=\"acronym\">ACRO1</FIELD></project><project><FIELD name=\"grant_agreement_number\">GRANTID2</FIELD><FIELD name=\"title\">Project title 2</FIELD><FIELD name=\"funder\">funderID2</FIELD><FIELD name=\"acronym\">ACRO 2</FIELD></project></projects>"; |
|
16 |
private String inputXML = "<projects><project><FIELD name=\"jurisdiction\">JUR</FIELD><FIELD name=\"funder\">funderID</FIELD><FIELD name=\"grant_agreement_number\">GRANTID1</FIELD><FIELD name=\"title\">Project title 1</FIELD><FIELD name=\"acronym\">ACRO1</FIELD></project><project><FIELD name=\"grant_agreement_number\">GRANTID2</FIELD><FIELD name=\"title\">Project title 2</FIELD><FIELD name=\"funder\">funderID2</FIELD><FIELD name=\"acronym\">ACRO 2</FIELD></project></projects>";
|
|
17 | 17 |
private Resource wtProject = new ClassPathResource("eu/dnetlib/openaire/exporter/WT-project.xml"); |
18 | 18 |
private Resource fctProject = new ClassPathResource("eu/dnetlib/openaire/exporter/FCT-project.xml"); |
19 | 19 |
private Resource fp7Project = new ClassPathResource("eu/dnetlib/openaire/exporter/FP7-project.xml"); |
modules/cnr-openaire-exporter/trunk/src/test/java/eu/dnetlib/openaire/exporter/ProjectsControllerTest.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
private ProjectsController controller; |
11 | 11 |
private ProjectQueryParams params; |
12 |
private String expectedFP7Query = "select 'EC' as funder, p.acronym as acronym, " + "p.title as title, " |
|
12 |
private String expectedFP7Query = "select 'EC' as funder, 'EU' as jurisdiction, p.acronym as acronym, " + "p.title as title, "
|
|
13 | 13 |
+ "regexp_replace(p.id, '^corda_______::' , '') as grant_agreement_number, " + "p.startdate as start_date, " + "p.enddate as end_date, " |
14 | 14 |
+ "f1.name as subdivision, " + "f2.name as specificprogramme, " + "f3.name as fundingprogramme " + "from projects p " |
15 | 15 |
+ "left outer join project_funding pf on (p.id = pf.project) " + "left outer join funding_funding ff1 on (pf.funding = ff1.funding1) " |
... | ... | |
22 | 22 |
+ "left outer join funding_funding ff1 on (pf.funding = ff1.funding1) " |
23 | 23 |
+ "left outer join fundings f1 on (f1.id = ff1.funding1) " |
24 | 24 |
+ "left outer join fundings f2 on (f2.id = ff1.funding2) " + "where f2.id = 'wt::WT' "; |
25 |
private String expectedFCTQuery = "select p.acronym as acronym, p.title as title, regexp_replace(p.id, '^fct_________::' , '') as grant_agreement_number, " |
|
25 |
private String expectedFCTQuery = "select 'PT' as jurisdiction, p.acronym as acronym, p.title as title, regexp_replace(p.id, '^fct_________::' , '') as grant_agreement_number, "
|
|
26 | 26 |
+ "p.startdate as start_date, p.enddate as end_date, f1.name as fundingprogramme, f2.name as funder " |
27 | 27 |
+ "from projects p left outer join project_funding pf on (p.id = pf.project) " |
28 | 28 |
+ "left outer join funding_funding ff1 on (pf.funding = ff1.funding1) " |
modules/cnr-openaire-exporter/trunk/src/test/resources/eu/dnetlib/openaire/exporter/FCT-project.xml | ||
---|---|---|
7 | 7 |
<FIELD name="fundingprogramme">POCI</FIELD> |
8 | 8 |
<FIELD name="acronym">POCTI/EME/32639/2000</FIELD> |
9 | 9 |
<FIELD name="start_date">2000-11-01</FIELD> |
10 |
<FIELD name="jurisdiction">PT</FIELD> |
|
10 | 11 |
</ROW> |
11 | 12 |
|
modules/cnr-openaire-exporter/trunk/src/test/resources/eu/dnetlib/openaire/exporter/FP7-project.xml | ||
---|---|---|
9 | 9 |
<FIELD name="acronym">SENDBEAMS</FIELD> |
10 | 10 |
<FIELD name="specificprogramme">SP3</FIELD> |
11 | 11 |
<FIELD name="start_date">2010-08-01</FIELD> |
12 |
<FIELD name="jurisdiction">EU</FIELD> |
|
12 | 13 |
</ROW> |
modules/cnr-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/ProjectsController.java | ||
---|---|---|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
@RequestMapping(value = "/openaire/export/project2tsv.do") |
106 |
void processEprints(final HttpServletRequest request, final HttpServletResponse response, |
|
106 |
void processEprints(final HttpServletRequest request, |
|
107 |
final HttpServletResponse response, |
|
107 | 108 |
@RequestParam(value = "funding", required = true) final String funding) throws Exception { |
108 | 109 |
|
109 | 110 |
final String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
... | ... | |
120 | 121 |
st.setAttribute("fundingprefix", "corda_______::H2020::"); |
121 | 122 |
} else if (funding.equalsIgnoreCase("fp7")) { |
122 | 123 |
st.setAttribute("fundingprefix", "corda_______::FP7::"); |
123 |
} else { |
|
124 |
throw new Exception("Invalid funding " + funding + " (valid are: fp7, h2020, wt, fct)"); |
|
125 |
} |
|
124 |
} else throw new Exception("Invalid funding " + funding + " (valid are: fp7, h2020, wt, fct)"); |
|
126 | 125 |
|
127 | 126 |
emitAsTsv(response.getOutputStream(), st.toString()); |
128 | 127 |
} |
... | ... | |
158 | 157 |
* @return the query string |
159 | 158 |
*/ |
160 | 159 |
protected String obtainFP7Query(final ProjectQueryParams params) { |
161 |
String query = "select 'EC' as funder, p.acronym as acronym, " + "p.title as title, " |
|
160 |
String query = "select 'EC' as funder, 'EU' as jurisdiction, p.acronym as acronym, " + "p.title as title, "
|
|
162 | 161 |
+ "regexp_replace(p.id, '^corda_______::' , '') as grant_agreement_number, " + "p.startdate as start_date, " + "p.enddate as end_date, " |
163 | 162 |
+ "f1.name as subdivision, " + "f2.name as specificprogramme, " + "f3.name as fundingprogramme " + "from projects p " |
164 | 163 |
+ "left outer join project_funding pf on (p.id = pf.project) " + "left outer join funding_funding ff1 on (pf.funding = ff1.funding1) " |
... | ... | |
205 | 204 |
* @param params |
206 | 205 |
*/ |
207 | 206 |
protected String obtainFCTQuery(final ProjectQueryParams params) { |
208 |
String query = "select p.acronym as acronym, p.title as title, regexp_replace(p.id, '^fct_________::' , '') as grant_agreement_number, " |
|
207 |
String query = "select 'PT' as jurisdiction, p.acronym as acronym, p.title as title, regexp_replace(p.id, '^fct_________::' , '') as grant_agreement_number, "
|
|
209 | 208 |
+ "p.startdate as start_date, p.enddate as end_date, f1.name as fundingprogramme, f2.name as funder " |
210 | 209 |
+ "from projects p left outer join project_funding pf on (p.id = pf.project) " |
211 |
+ "left outer join funding_funding ff1 on (pf.funding = ff1.funding1) " + "left outer join fundings f1 on (f1.id = ff1.funding1) " |
|
210 |
+ "left outer join funding_funding ff1 on (pf.funding = ff1.funding1) " |
|
211 |
+ "left outer join fundings f1 on (f1.id = ff1.funding1) " |
|
212 | 212 |
+ "left outer join fundings f2 on (f2.id = ff1.funding2) where f2.id = 'fct_________::FCT' "; |
213 | 213 |
|
214 | 214 |
if (StringUtils.isNotBlank(params.getSpecificProgramme())) { |
modules/cnr-openaire-exporter/trunk/src/main/resources/eu/dnetlib/openaire/exporter/xslt/projects_dspace.xslt | ||
---|---|---|
5 | 5 |
<xsl:output omit-xml-declaration="yes" standalone="omit" indent="yes"/> |
6 | 6 |
|
7 | 7 |
<xsl:template match="/"> |
8 |
<xsl:variable name="jurisdiction" select="//FIELD[@name='jurisdiction']"/> |
|
8 | 9 |
<xsl:variable name="id" select="//FIELD[@name='grant_agreement_number']" /> |
9 | 10 |
<xsl:variable name="title" select="//FIELD[@name='title']" /> |
10 | 11 |
<xsl:variable name="acronym" select="//FIELD[@name='acronym']" /> |
... | ... | |
13 | 14 |
<xsl:variable name="idnamespace"> |
14 | 15 |
<!-- info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID /[Jurisdiction]/[ProjectName]/[ProjectAcronym] --> |
15 | 16 |
<xsl:choose> |
16 |
<xsl:when test="$funder = 'EC'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/' )" /></xsl:when>
|
|
17 |
<xsl:when test="$funder = 'WT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/')" /></xsl:when> |
|
18 |
<xsl:when test="$funder = 'FCT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/' )" /></xsl:when> |
|
17 |
<xsl:when test="$funder = 'EC'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/', $id, '/', $jurisdiction)" /></xsl:when>
|
|
18 |
<xsl:when test="$funder = 'WT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $id)" /></xsl:when>
|
|
19 |
<xsl:when test="$funder = 'FCT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/' , $id, '/', $jurisdiction)" /></xsl:when>
|
|
19 | 20 |
<xsl:otherwise>info:eu-repo/grantAgreement/</xsl:otherwise> |
20 | 21 |
</xsl:choose> |
21 | 22 |
</xsl:variable> |
22 | 23 |
<pair> |
23 | 24 |
<displayed-value><xsl:value-of select="concat($id, ' - ', $acronym, ' - ', $title)" /></displayed-value> |
24 |
<stored-value><xsl:value-of select="concat($idnamespace, $id)" /></stored-value>
|
|
25 |
<stored-value><xsl:value-of select="$idnamespace" /></stored-value>
|
|
25 | 26 |
</pair> |
26 | 27 |
</xsl:template> |
27 | 28 |
|
modules/cnr-openaire-exporter/trunk/src/main/resources/eu/dnetlib/openaire/exporter/xslt/projects_eprints.xslt | ||
---|---|---|
6 | 6 |
<xsl:output omit-xml-declaration="yes" standalone="omit" indent="no"/> |
7 | 7 |
|
8 | 8 |
<xsl:template match="/"> |
9 |
<xsl:variable name="jurisdiction" select="//FIELD[@name='jurisdiction']"/> |
|
9 | 10 |
<xsl:variable name="id" select="//FIELD[@name='grant_agreement_number']" /> |
10 | 11 |
<xsl:variable name="title" select="//FIELD[@name='title']" /> |
11 | 12 |
<xsl:variable name="acronym" select="//FIELD[@name='acronym']" /> |
... | ... | |
14 | 15 |
<xsl:variable name="idnamespace"> |
15 | 16 |
<!-- info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID /[Jurisdiction]/[ProjectName]/[ProjectAcronym] --> |
16 | 17 |
<xsl:choose> |
17 |
<xsl:when test="$funder = 'EC'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/' )" /></xsl:when> |
|
18 |
<xsl:when test="$funder = 'WT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/')" /></xsl:when> |
|
19 |
<xsl:when test="$funder = 'FCT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/' )" /></xsl:when> |
|
18 |
<xsl:when test="$funder = 'EC'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/', $id, '/', $jurisdiction )" /></xsl:when>
|
|
19 |
<xsl:when test="$funder = 'WT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $id)" /></xsl:when>
|
|
20 |
<xsl:when test="$funder = 'FCT'"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/' , $id, '/', $jurisdiction)" /></xsl:when>
|
|
20 | 21 |
<xsl:otherwise>info:eu-repo/grantAgreement/</xsl:otherwise> |
21 | 22 |
</xsl:choose> |
22 | 23 |
</xsl:variable> |
... | ... | |
28 | 29 |
<xsl:otherwise>info:eu-repo/grantAgreement/</xsl:otherwise> |
29 | 30 |
</xsl:choose> |
30 | 31 |
</xsl:variable> |
31 |
<xsl:value-of select="concat($acronym, ' - ', $title, '	')" /><li style='border-right: solid 50px #30FF30' ><xsl:value-of select="concat($id, ' - ', $acronym, ' - ', $title)" /><ul><li id="{$listLabel}"><xsl:value-of select="concat($idnamespace, $id)" /></li></ul></li><xsl:text>
|
|
32 |
<xsl:value-of select="concat($acronym, ' - ', $title, '	')" /><li style='border-right: solid 50px #30FF30' ><xsl:value-of select="concat($id, ' - ', $acronym, ' - ', $title)" /><ul><li id="{$listLabel}"><xsl:value-of select="$idnamespace" /></li></ul></li><xsl:text>
|
|
32 | 33 |
</xsl:text> |
33 | 34 |
</xsl:template> |
34 | 35 |
|
Also available in: Unified diff
handling urisdiction (see #1037)