Revision 43081
Added by Alessia Bardi over 8 years ago
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" ?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
<relativePath /> |
|
8 |
</parent> |
|
9 |
<modelVersion>4.0.0</modelVersion> |
|
10 |
<groupId>eu.dnetlib</groupId> |
|
11 |
<artifactId>cnr-openaire-exporter</artifactId> |
|
12 |
<packaging>jar</packaging> |
|
13 |
<version>5.1.8</version> |
|
14 |
<scm> |
|
15 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8</developerConnection> |
|
16 |
</scm> |
|
17 |
<dependencies> |
|
18 |
<dependency> |
|
19 |
<groupId>eu.dnetlib</groupId> |
|
20 |
<artifactId>cnr-service-common</artifactId> |
|
21 |
<version>[2.1.2,3.0.0)</version> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>eu.dnetlib</groupId> |
|
25 |
<artifactId>cnr-resultset-client</artifactId> |
|
26 |
<version>[2.0.0,3.0.0)</version> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>eu.dnetlib</groupId> |
|
30 |
<artifactId>cnr-enabling-database-api</artifactId> |
|
31 |
<version>[2.0.0,3.0.0)</version> |
|
32 |
</dependency> |
|
33 |
<dependency> |
|
34 |
<groupId>javax.servlet</groupId> |
|
35 |
<artifactId>javax.servlet-api</artifactId> |
|
36 |
<version>${javax.servlet.version}</version> |
|
37 |
<scope>provided</scope> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>junit</groupId> |
|
41 |
<artifactId>junit</artifactId> |
|
42 |
<version>${junit.version}</version> |
|
43 |
<scope>test</scope> |
|
44 |
</dependency> |
|
45 |
</dependencies> |
|
46 |
</project> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/java/eu/dnetlib/openaire/exporter/ProjectQueryParamsTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import org.junit.Before; |
|
4 |
import org.junit.Test; |
|
5 |
|
|
6 |
import static org.junit.Assert.assertEquals; |
|
7 |
|
|
8 |
public class ProjectQueryParamsTest { |
|
9 |
|
|
10 |
private ProjectQueryParams queryParams; |
|
11 |
|
|
12 |
@Before |
|
13 |
public void setUp() throws Exception { |
|
14 |
queryParams = new ProjectQueryParams(); |
|
15 |
|
|
16 |
} |
|
17 |
|
|
18 |
@Test |
|
19 |
public void testVerifyParamWhiteSpace() { |
|
20 |
queryParams.verifyParam("Discovery Projects"); |
|
21 |
} |
|
22 |
|
|
23 |
@Test |
|
24 |
public void testVerifyParamPercentage() { |
|
25 |
queryParams.verifyParam("Discovery%20Projects"); |
|
26 |
} |
|
27 |
|
|
28 |
@Test |
|
29 |
public void testVerifyDateParam(){ |
|
30 |
String correctDate = "2012-03-04"; |
|
31 |
assertEquals(correctDate, queryParams.verifyDateParam(correctDate)); |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
@Test(expected=java.lang.IllegalArgumentException.class) |
|
36 |
public void testVerifyDateParamException(){ |
|
37 |
String wrongDate = "12-12-12"; |
|
38 |
queryParams.verifyDateParam(wrongDate); |
|
39 |
|
|
40 |
} |
|
41 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/java/eu/dnetlib/openaire/exporter/ProjectsControllerTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.antlr.stringtemplate.StringTemplate; |
|
6 |
import org.apache.commons.io.IOUtils; |
|
7 |
import org.junit.Before; |
|
8 |
import org.junit.Test; |
|
9 |
import org.springframework.core.io.ClassPathResource; |
|
10 |
import org.springframework.core.io.Resource; |
|
11 |
|
|
12 |
import static org.junit.Assert.assertEquals; |
|
13 |
|
|
14 |
public class ProjectsControllerTest { |
|
15 |
|
|
16 |
private String queryTemplate = "/eu/dnetlib/openaire/exporter/sql/projects_fundings.sql.st"; |
|
17 |
private Resource expectedQueryTemplate = new ClassPathResource("/eu/dnetlib/openaire/exporter/sql/expected_projects_fundings.sql.st"); |
|
18 |
|
|
19 |
private ProjectsController controller; |
|
20 |
private ProjectQueryParams params; |
|
21 |
|
|
22 |
@Before |
|
23 |
public void setup() { |
|
24 |
controller = new ProjectsController(); |
|
25 |
Resource template = new ClassPathResource(queryTemplate); |
|
26 |
|
|
27 |
controller.setProjectsFundingQueryTemplate(template); |
|
28 |
params = new ProjectQueryParams(); |
|
29 |
} |
|
30 |
|
|
31 |
@Test |
|
32 |
public void testObtainFP7Query() throws IllegalArgumentException, IOException { |
|
33 |
params.setFundingProgramme("FP7"); |
|
34 |
params.setFundingPath(null); |
|
35 |
String res = controller.obtainQuery(params); |
|
36 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
37 |
st.setAttribute("fundingprefix", "ec__________::EC::FP7::"); |
|
38 |
System.out.println(res); |
|
39 |
System.out.println(st); |
|
40 |
assertEquals(st.toString(), res); |
|
41 |
} |
|
42 |
|
|
43 |
@Test |
|
44 |
public void testObtainFP7QuerySP1() throws IllegalArgumentException, IOException { |
|
45 |
params.setFundingProgramme("FP7"); |
|
46 |
params.setFundingPath("SP1"); |
|
47 |
String res = controller.obtainQuery(params); |
|
48 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
49 |
st.setAttribute("fundingprefix", "ec__________::EC::FP7::SP1"); |
|
50 |
System.out.println(res); |
|
51 |
assertEquals(st.toString(), res); |
|
52 |
} |
|
53 |
|
|
54 |
@Test |
|
55 |
public void testObtainFP7QueryHealth() throws IllegalArgumentException, IOException { |
|
56 |
params.setFundingProgramme("FP7"); |
|
57 |
params.setFundingPath("SP1::HEALTH"); |
|
58 |
String res = controller.obtainQuery(params); |
|
59 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
60 |
st.setAttribute("fundingprefix", "ec__________::EC::FP7::SP1::HEALTH"); |
|
61 |
System.out.println(res); |
|
62 |
assertEquals(st.toString(), res); |
|
63 |
} |
|
64 |
|
|
65 |
@Test |
|
66 |
public void testObtainFP7QueryHealth2() throws IllegalArgumentException, IOException { |
|
67 |
params.setFundingProgramme("FP7"); |
|
68 |
params.setFundingPath("%::HEALTH"); |
|
69 |
String res = controller.obtainQuery(params); |
|
70 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
71 |
st.setAttribute("fundingprefix", "ec__________::EC::FP7::%::HEALTH"); |
|
72 |
System.out.println(res); |
|
73 |
assertEquals(st.toString(), res); |
|
74 |
} |
|
75 |
|
|
76 |
@Test |
|
77 |
public void testObtainWellcomeTrustQuery() throws IllegalArgumentException, IOException { |
|
78 |
params.setFundingProgramme("WT"); |
|
79 |
params.setFundingPath(null); |
|
80 |
String res = controller.obtainQuery(params); |
|
81 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
82 |
st.setAttribute("fundingprefix", "wt__________::WT::"); |
|
83 |
System.out.println(res); |
|
84 |
assertEquals(st.toString(), res); |
|
85 |
} |
|
86 |
|
|
87 |
@Test |
|
88 |
public void testObtainFCTQuery() throws IllegalArgumentException, IOException { |
|
89 |
params.setFundingProgramme("FCT"); |
|
90 |
params.setFundingPath(null); |
|
91 |
String res = controller.obtainQuery(params); |
|
92 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
93 |
st.setAttribute("fundingprefix", "fct_________::FCT::"); |
|
94 |
System.out.println(res); |
|
95 |
assertEquals(st.toString() + "", res); |
|
96 |
} |
|
97 |
|
|
98 |
@Test |
|
99 |
public void testQueryWithDateParams() throws IllegalArgumentException, IOException { |
|
100 |
params.setFundingProgramme("WT"); |
|
101 |
params.setFundingPath(null); |
|
102 |
params.setStartFrom("2015-05-04"); |
|
103 |
String res = controller.obtainQuery(params); |
|
104 |
System.out.println(res); |
|
105 |
final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream())); |
|
106 |
st.setAttribute("fundingprefix", "wt__________::WT::"); |
|
107 |
String q = st.toString() + " AND p.startdate >= '2015-05-04'"; |
|
108 |
assertEquals(q, res); |
|
109 |
} |
|
110 |
|
|
111 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/java/eu/dnetlib/openaire/exporter/DSpaceTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
5 |
|
|
6 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
7 |
import org.apache.commons.io.IOUtils; |
|
8 |
import org.junit.Before; |
|
9 |
import org.junit.Test; |
|
10 |
import org.springframework.core.io.ClassPathResource; |
|
11 |
import org.springframework.core.io.Resource; |
|
12 |
|
|
13 |
public class DSpaceTest { |
|
14 |
|
|
15 |
private Resource wtProject = new ClassPathResource("eu/dnetlib/openaire/exporter/WT-project.xml"); |
|
16 |
private Resource fctProject = new ClassPathResource("eu/dnetlib/openaire/exporter/FCT-project.xml"); |
|
17 |
private Resource fp7Project = new ClassPathResource("eu/dnetlib/openaire/exporter/FP7-project.xml"); |
|
18 |
private Resource sfiProject = new ClassPathResource("eu/dnetlib/openaire/exporter/SFI-project.xml"); |
|
19 |
private Resource msesProject = new ClassPathResource("eu/dnetlib/openaire/exporter/MSES-project.xml"); |
|
20 |
|
|
21 |
private Resource dspaceXslt; |
|
22 |
|
|
23 |
@Before |
|
24 |
public void setUp() throws Exception { |
|
25 |
dspaceXslt = new ClassPathResource("xslt/projects_dspace.xslt", getClass()); |
|
26 |
} |
|
27 |
|
|
28 |
@Test |
|
29 |
public void testWTdspace() throws IOException { |
|
30 |
ApplyXslt applyXslt = new ApplyXslt(dspaceXslt); |
|
31 |
StringWriter w = new StringWriter(); |
|
32 |
IOUtils.copy(wtProject.getInputStream(), w); |
|
33 |
String result = applyXslt.evaluate(w.toString()); |
|
34 |
System.out.println("<?xml version='1.0' encoding='UTF-8'?>\n\n" + "<form-value-pairs>\n" |
|
35 |
+ " <value-pairs value-pairs-name='WTprojects' dc-term='relation'>\n"); |
|
36 |
System.out.println(result); |
|
37 |
System.out.println(" </value-pairs>\n" + "</form-value-pairs>\n"); |
|
38 |
} |
|
39 |
|
|
40 |
@Test |
|
41 |
public void testFCTdspace() throws IOException { |
|
42 |
doTest(fctProject); |
|
43 |
} |
|
44 |
|
|
45 |
@Test |
|
46 |
public void testFP7dspace() throws IOException { |
|
47 |
doTest(fp7Project); |
|
48 |
} |
|
49 |
|
|
50 |
@Test |
|
51 |
public void testSFIdspace() throws IOException { |
|
52 |
doTest(sfiProject); |
|
53 |
} |
|
54 |
|
|
55 |
@Test |
|
56 |
public void testMSESdspace() throws IOException { |
|
57 |
doTest(msesProject); |
|
58 |
} |
|
59 |
|
|
60 |
private void doTest(Resource resource) throws IOException { |
|
61 |
ApplyXslt applyXslt = new ApplyXslt(dspaceXslt); |
|
62 |
StringWriter w = new StringWriter(); |
|
63 |
IOUtils.copy(resource.getInputStream(), w); |
|
64 |
String result = applyXslt.evaluate(w.toString()); |
|
65 |
System.out.println(result); |
|
66 |
} |
|
67 |
|
|
68 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/java/eu/dnetlib/openaire/exporter/EPrintsTest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringWriter; |
|
5 |
|
|
6 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
7 |
import org.apache.commons.io.IOUtils; |
|
8 |
import org.junit.Before; |
|
9 |
import org.junit.Test; |
|
10 |
import org.springframework.core.io.ClassPathResource; |
|
11 |
import org.springframework.core.io.Resource; |
|
12 |
|
|
13 |
public class EPrintsTest { |
|
14 |
|
|
15 |
private Resource wtProject = new ClassPathResource("eu/dnetlib/openaire/exporter/WT-project.xml"); |
|
16 |
private Resource fctProject = new ClassPathResource("eu/dnetlib/openaire/exporter/FCT-project.xml"); |
|
17 |
private Resource fp7Project = new ClassPathResource("eu/dnetlib/openaire/exporter/FP7-project.xml"); |
|
18 |
private Resource sfiProject = new ClassPathResource("eu/dnetlib/openaire/exporter/SFI-project.xml"); |
|
19 |
private Resource msesProject = new ClassPathResource("eu/dnetlib/openaire/exporter/MSES-project.xml"); |
|
20 |
|
|
21 |
private Resource ePrintsXslt; |
|
22 |
|
|
23 |
@Before |
|
24 |
public void setUp() throws Exception { |
|
25 |
ePrintsXslt = new ClassPathResource("xslt/projects_eprints.xslt", getClass()); |
|
26 |
} |
|
27 |
|
|
28 |
@Test |
|
29 |
public void testWTePrints() throws IOException { |
|
30 |
doTest(wtProject); |
|
31 |
} |
|
32 |
|
|
33 |
@Test |
|
34 |
public void testFCTePrints() throws IOException { |
|
35 |
doTest(fctProject); |
|
36 |
} |
|
37 |
|
|
38 |
@Test |
|
39 |
public void testFP7ePrints() throws IOException { |
|
40 |
doTest(fp7Project); |
|
41 |
} |
|
42 |
|
|
43 |
@Test |
|
44 |
public void testSFIePrints() throws IOException { |
|
45 |
doTest(sfiProject); |
|
46 |
} |
|
47 |
|
|
48 |
@Test |
|
49 |
public void testMSESePrints() throws IOException { |
|
50 |
doTest(msesProject); |
|
51 |
} |
|
52 |
|
|
53 |
private void assertTab(final String str) { |
|
54 |
System.out.println(str); |
|
55 |
String[] splitOnTab = str.split("\t"); |
|
56 |
org.junit.Assert.assertTrue(splitOnTab.length > 1); |
|
57 |
System.out.println(splitOnTab[0]); |
|
58 |
System.out.println("According to the Java split function, now there is a tab, followed by:"); |
|
59 |
System.out.println(splitOnTab[1]); |
|
60 |
} |
|
61 |
|
|
62 |
private void doTest(Resource resource) throws IOException { |
|
63 |
ApplyXslt applyXslt = new ApplyXslt(ePrintsXslt); |
|
64 |
StringWriter w = new StringWriter(); |
|
65 |
IOUtils.copy(resource.getInputStream(), w); |
|
66 |
String res = applyXslt.evaluate(w.toString()); |
|
67 |
assertTab(res); |
|
68 |
} |
|
69 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/resources/eu/dnetlib/openaire/exporter/MSES-project.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ROW> |
|
3 |
<FIELD name="funder">MSES</FIELD> |
|
4 |
<FIELD name="end_date">2009-12-31</FIELD> |
|
5 |
<FIELD name="grant_agreement_number">001-0000000-3177</FIELD> |
|
6 |
<FIELD name="title">Residence time of bacteria Escherichia coli in seawater and marine organisms</FIELD> |
|
7 |
<FIELD name="acronym" isNull="true"/> |
|
8 |
<FIELD name="fundingpathid">irb_hr______::MSES::fundingStream</FIELD> |
|
9 |
<FIELD name="jurisdiction">HR</FIELD> |
|
10 |
<FIELD name="start_date">2007-01-01</FIELD> |
|
11 |
</ROW> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/resources/eu/dnetlib/openaire/exporter/SFI-project.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ROW> |
|
3 |
<FIELD name="funder">SFI</FIELD> |
|
4 |
<FIELD name="end_date">2016-08-31</FIELD> |
|
5 |
<FIELD name="grant_agreement_number">14/ADV/RC3022</FIELD> |
|
6 |
<FIELD name="title">Dr. Vesna Jaksic</FIELD> |
|
7 |
<FIELD name="acronym" isNull="true"/> |
|
8 |
<FIELD name="fundingpathid">sfi_________::SFI::Advance Award Programme</FIELD> |
|
9 |
<FIELD name="jurisdiction" isNull="true"/> |
|
10 |
<FIELD name="start_date">2014-09-01</FIELD> |
|
11 |
</ROW> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/resources/eu/dnetlib/openaire/exporter/FCT-project.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ROW> |
|
3 |
<FIELD name="funder">FCT</FIELD> |
|
4 |
<FIELD name="jurisdiction">PT</FIELD> |
|
5 |
<FIELD name="end_date">2003-10-31</FIELD> |
|
6 |
<FIELD name="grant_agreement_number">32639</FIELD> |
|
7 |
<FIELD name="title">Social Classes and «lifestyles» in the city of Oporto</FIELD> |
|
8 |
<FIELD name="fundingpathid">fct_________::FCT::Orçamento de Funcionamento/POSC</FIELD> |
|
9 |
<FIELD name="acronym">PTDC/FIL-FIL/109889/2009</FIELD> |
|
10 |
<FIELD name="start_date">2000-11-01</FIELD> |
|
11 |
<FIELD name="description">description of the funding path</FIELD> |
|
12 |
</ROW> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/resources/eu/dnetlib/openaire/exporter/FP7-project.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ROW> |
|
3 |
<FIELD name="funder">EC</FIELD> |
|
4 |
<FIELD name="jurisdiction">EU</FIELD> |
|
5 |
<FIELD name="end_date">2012-07-31</FIELD> |
|
6 |
<FIELD name="grant_agreement_number">255646</FIELD> |
|
7 |
<FIELD name="title">Semiconductor lasers for generation of non-diffracting (Bessel) beams.</FIELD> |
|
8 |
<FIELD name="fundingpathid">ec__________::EC::FP7::SP3::PEOPLE</FIELD> |
|
9 |
<FIELD name="acronym">SENDBEAMS</FIELD> |
|
10 |
<FIELD name="start_date">2010-08-01</FIELD> |
|
11 |
<FIELD name="description">description of the funding path</FIELD> |
|
12 |
</ROW> |
|
13 |
|
|
14 |
|
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/resources/eu/dnetlib/openaire/exporter/WT-project.xml | ||
---|---|---|
1 |
<ROW> |
|
2 |
<FIELD name="funder">WT</FIELD> |
|
3 |
<FIELD name="end_date">2013-07-29</FIELD> |
|
4 |
<FIELD name="grant_agreement_number">098241</FIELD> |
|
5 |
<FIELD name="title">EYEDIO DIGI - DEVELOPMENT OF AN INNOVATIVE, AFFORDABLE, EASY TO USE, HANDHELD RETINAL IMAGING PRODUCT FOR THE DIAGNOSIS OF DIABETIC RETINOPATHY.</FIELD> |
|
6 |
<FIELD name="acronym"></FIELD> |
|
7 |
<FIELD name="fundingpathid">wt__________::WT::Immunology and Infectious Disease</FIELD> |
|
8 |
<FIELD name="start_date">2012-01-30</FIELD> |
|
9 |
<FIELD name="jurisdiction"/> |
|
10 |
<FIELD name="description">description of the funding path</FIELD> |
|
11 |
</ROW> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/test/resources/eu/dnetlib/openaire/exporter/sql/expected_projects_fundings.sql.st | ||
---|---|---|
1 |
SELECT |
|
2 |
org.legalshortname as funder, |
|
3 |
fp.jurisdiction as jurisdiction, |
|
4 |
p.acronym as acronym, |
|
5 |
p.title as title, |
|
6 |
p.code as grant_agreement_number, |
|
7 |
p.startdate as start_date, |
|
8 |
p.enddate as end_date, |
|
9 |
fp.id as fundingpathid |
|
10 |
FROM projects p |
|
11 |
left outer join project_fundingpath pfp on (p.id = pfp.project) |
|
12 |
left outer join fundingpaths fp on (pfp.funding=fp.id) |
|
13 |
left outer join organizations org on (org.id = fp.funder) |
|
14 |
WHERE fp.id like '$fundingprefix$%' |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/java/eu/dnetlib/openaire/exporter/ProjectQueryParams.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import java.util.regex.Pattern; |
|
4 |
|
|
5 |
import org.apache.commons.logging.Log; |
|
6 |
import org.apache.commons.logging.LogFactory; |
|
7 |
|
|
8 |
public class ProjectQueryParams { |
|
9 |
|
|
10 |
private String fundingProgramme = null; |
|
11 |
/** Whatever is following the fundingProgramme **/ |
|
12 |
private String fundingPath = null; |
|
13 |
|
|
14 |
private String startFrom = null; |
|
15 |
private String startUntil = null; |
|
16 |
private String endFrom = null; |
|
17 |
private String endUntil = null; |
|
18 |
|
|
19 |
private static final Log log = LogFactory.getLog(ProjectQueryParams.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
20 |
|
|
21 |
public String getFundingProgramme() { |
|
22 |
return fundingProgramme; |
|
23 |
} |
|
24 |
|
|
25 |
public void setFundingProgramme(final String fundingProgramme) { |
|
26 |
this.fundingProgramme = verifyParam(fundingProgramme); |
|
27 |
} |
|
28 |
|
|
29 |
public String getFundingPath() { |
|
30 |
return fundingPath; |
|
31 |
} |
|
32 |
|
|
33 |
public void setFundingPath(final String fundingPath) { |
|
34 |
this.fundingPath = verifyParam(fundingPath); |
|
35 |
} |
|
36 |
|
|
37 |
public String getStartFrom() { |
|
38 |
return startFrom; |
|
39 |
} |
|
40 |
|
|
41 |
public void setStartFrom(final String startFrom) { |
|
42 |
this.startFrom = verifyDateParam(startFrom); |
|
43 |
} |
|
44 |
|
|
45 |
public String getStartUntil() { |
|
46 |
return startUntil; |
|
47 |
} |
|
48 |
|
|
49 |
public void setStartUntil(final String startUntil) { |
|
50 |
this.startUntil = verifyDateParam(startUntil); |
|
51 |
} |
|
52 |
|
|
53 |
public String getEndFrom() { |
|
54 |
return endFrom; |
|
55 |
} |
|
56 |
|
|
57 |
public void setEndFrom(final String endFrom) { |
|
58 |
this.endFrom = verifyDateParam(endFrom); |
|
59 |
} |
|
60 |
|
|
61 |
public String getEndUntil() { |
|
62 |
return endUntil; |
|
63 |
} |
|
64 |
|
|
65 |
public void setEndUntil(final String endUntil) { |
|
66 |
this.endUntil = verifyDateParam(endUntil); |
|
67 |
} |
|
68 |
|
|
69 |
protected String verifyParam(final String p) { |
|
70 |
Pattern pattern = Pattern.compile("(\\w*(::|%| )*)*"); |
|
71 |
log.debug("TESTING SQL PARAM: " + p); |
|
72 |
if ((p != null) && !pattern.matcher(p).matches()) throw new IllegalArgumentException("Parameter contains an invalid character"); |
|
73 |
log.debug("TEST OK"); |
|
74 |
return p; |
|
75 |
} |
|
76 |
|
|
77 |
protected String verifyDateParam(final String date){ |
|
78 |
Pattern pattern = Pattern.compile("\\d\\d\\d\\d-\\d\\d-\\d\\d"); |
|
79 |
log.debug("TESTING SQL DATE PARAM: " + date); |
|
80 |
if ((date != null) && !pattern.matcher(date).matches()) throw new IllegalArgumentException("Parameter date contains an invalid character. Accepted pattern is "+pattern.toString()); |
|
81 |
log.debug("TEST OK"); |
|
82 |
return date; |
|
83 |
|
|
84 |
} |
|
85 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/java/eu/dnetlib/openaire/exporter/ProjectsController.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.OutputStream; |
|
5 |
import java.io.StringReader; |
|
6 |
import java.text.SimpleDateFormat; |
|
7 |
import java.util.Arrays; |
|
8 |
import java.util.Date; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
import javax.servlet.ServletOutputStream; |
|
12 |
import javax.servlet.ServletResponse; |
|
13 |
import javax.servlet.http.HttpServletRequest; |
|
14 |
import javax.servlet.http.HttpServletResponse; |
|
15 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
16 |
|
|
17 |
import com.google.common.base.Joiner; |
|
18 |
import com.google.common.base.Splitter; |
|
19 |
import com.google.common.collect.Lists; |
|
20 |
import com.google.common.collect.Maps; |
|
21 |
import eu.dnetlib.enabling.database.rmi.DatabaseException; |
|
22 |
import eu.dnetlib.enabling.database.rmi.DatabaseService; |
|
23 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
24 |
import eu.dnetlib.enabling.resultset.client.IterableResultSetClient; |
|
25 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
26 |
import eu.dnetlib.miscutils.collections.MappedCollection; |
|
27 |
import eu.dnetlib.miscutils.functional.xml.ApplyXslt; |
|
28 |
import org.antlr.stringtemplate.StringTemplate; |
|
29 |
import org.apache.commons.io.IOUtils; |
|
30 |
import org.apache.commons.lang.StringUtils; |
|
31 |
import org.apache.commons.logging.Log; |
|
32 |
import org.apache.commons.logging.LogFactory; |
|
33 |
import org.dom4j.Document; |
|
34 |
import org.dom4j.io.SAXReader; |
|
35 |
import org.springframework.beans.factory.annotation.Autowired; |
|
36 |
import org.springframework.beans.factory.annotation.Value; |
|
37 |
import org.springframework.core.io.Resource; |
|
38 |
import org.springframework.stereotype.Controller; |
|
39 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
40 |
import org.springframework.web.bind.annotation.RequestParam; |
|
41 |
|
|
42 |
@Controller |
|
43 |
public class ProjectsController { |
|
44 |
|
|
45 |
private static final Log log = LogFactory.getLog(ProjectsController.class); // NOPMD by marko on 11/24/08 5:02 PM |
|
46 |
@javax.annotation.Resource |
|
47 |
private UniqueServiceLocator serviceLocator; |
|
48 |
|
|
49 |
@Value("${dnet.openaire.db.name}") |
|
50 |
private String dbName; |
|
51 |
@Value("${openaire.exporter.dspace.xslt}") |
|
52 |
private Resource dspaceXslt; |
|
53 |
@Value("${openaire.exporter.eprints.xslt}") |
|
54 |
private Resource eprintsXslt; |
|
55 |
@Value("${openaire.exporter.projectsfundings.sql.template}") |
|
56 |
private Resource projectsFundingQueryTemplate; |
|
57 |
@Value("${openaire.exporter.projects2tsv.sql.template}") |
|
58 |
private Resource projects2tsvQueryTemplate; |
|
59 |
@Value("${openaire.exporter.projects2tsv.fields}") |
|
60 |
private String tsvFields; |
|
61 |
|
|
62 |
@Autowired |
|
63 |
private ResultSetClientFactory resultSetClientFactory; |
|
64 |
@Autowired |
|
65 |
private ProjectQueryParamsFactory projectQueryParamsFactory; |
|
66 |
|
|
67 |
@RequestMapping(value = "/openaire/export/**/project/dspace.do") |
|
68 |
void processDspace(final HttpServletRequest request, |
|
69 |
final ServletResponse response, |
|
70 |
@RequestParam(value = "startFrom", required = false) final String startFrom, |
|
71 |
@RequestParam(value = "startUntil", required = false) final String startUntil, |
|
72 |
@RequestParam(value = "endFrom", required = false) final String endFrom, |
|
73 |
@RequestParam(value = "endUntil", required = false) final String endUntil) throws Exception { |
|
74 |
|
|
75 |
response.setContentType("text/xml"); |
|
76 |
|
|
77 |
ProjectQueryParams params = projectQueryParamsFactory.generateParams(request, startFrom, startUntil, endFrom, endUntil); |
|
78 |
|
|
79 |
ServletOutputStream out = response.getOutputStream(); |
|
80 |
|
|
81 |
String head = "<?xml version='1.0' encoding='UTF-8'?>\n\n" + "<form-value-pairs>\n" + " <value-pairs value-pairs-name='" + params.getFundingProgramme() |
|
82 |
+ "projects' dc-term='relation'>\n"; |
|
83 |
|
|
84 |
String tail = " </value-pairs>\n" + "</form-value-pairs>\n"; |
|
85 |
|
|
86 |
IOUtils.copy(new StringReader(head), out); |
|
87 |
emit(out, dspaceXslt, obtainQuery(params)); |
|
88 |
IOUtils.copy(new StringReader(tail), out); |
|
89 |
} |
|
90 |
|
|
91 |
@RequestMapping(value = "/openaire/export/**/project/eprints.do") |
|
92 |
void processEprints(final HttpServletRequest request, |
|
93 |
final ServletResponse response, |
|
94 |
@RequestParam(value = "startFrom", required = false) final String startFrom, |
|
95 |
@RequestParam(value = "startUntil", required = false) final String startUntil, |
|
96 |
@RequestParam(value = "endFrom", required = false) final String endFrom, |
|
97 |
@RequestParam(value = "endUntil", required = false) final String endUntil) throws Exception { |
|
98 |
|
|
99 |
response.setContentType("text/html"); |
|
100 |
emit(response.getOutputStream(), eprintsXslt, obtainQuery(projectQueryParamsFactory.generateParams(request, startFrom, startUntil, endFrom, endUntil))); |
|
101 |
} |
|
102 |
|
|
103 |
@RequestMapping(value = "/openaire/export/project2tsv.do") |
|
104 |
void processTsv(final HttpServletRequest request, final HttpServletResponse response, |
|
105 |
@RequestParam(value = "funding", required = true) final String funding, |
|
106 |
@RequestParam(value = "article293", required = false) final Boolean article293) throws Exception { |
|
107 |
|
|
108 |
final String date = new SimpleDateFormat("yyyyMMdd").format(new Date()); |
|
109 |
response.setContentType("text/tab-separated-values"); |
|
110 |
response.setHeader("Content-Disposition", "attachment; filename=\"projects_" + funding + "_" + date + ".tsv\""); |
|
111 |
|
|
112 |
final StringTemplate st = new StringTemplate(IOUtils.toString(projects2tsvQueryTemplate.getInputStream())); |
|
113 |
Funding requestedFunding = Funding.valueOf(funding.toUpperCase()); |
|
114 |
String fundingPrefix = getFundingPrefix(requestedFunding, null); |
|
115 |
log.debug("Setting fundingprefix to " + fundingPrefix); |
|
116 |
st.setAttribute("fundingprefix", fundingPrefix); |
|
117 |
st.setAttribute("filters", expandFilters(article293)); |
|
118 |
emitAsTsv(response.getOutputStream(), st.toString()); |
|
119 |
} |
|
120 |
|
|
121 |
private Map<String, String> expandFilters(final Boolean article293) { |
|
122 |
final Map<String, String> res = Maps.newHashMap(); |
|
123 |
|
|
124 |
if (article293 != null) { |
|
125 |
res.put("pr.ec_article29_3", String.valueOf(article293)); |
|
126 |
} |
|
127 |
|
|
128 |
return res; |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* Creates the query on the fundingProgramme specified in the given parameters. |
|
133 |
* |
|
134 |
* @param params |
|
135 |
* request parameters |
|
136 |
* @return the query string |
|
137 |
* @throws IllegalArgumentException |
|
138 |
* if the funding program is not recognized |
|
139 |
* @throws IOException |
|
140 |
* if there are problem loading the query temlate |
|
141 |
* @throws IllegalArgumentException |
|
142 |
* if the funding program is not recognized |
|
143 |
*/ |
|
144 |
protected String obtainQuery(final ProjectQueryParams params) throws IllegalArgumentException, IOException { |
|
145 |
String funding = params.getFundingProgramme(); |
|
146 |
String suffix = params.getFundingPath(); |
|
147 |
String fundingPrefix = getFundingPrefix(Funding.valueOf(funding.toUpperCase()), suffix); |
|
148 |
final StringTemplate st = new StringTemplate(IOUtils.toString(projectsFundingQueryTemplate.getInputStream())); |
|
149 |
st.setAttribute("fundingprefix", fundingPrefix); |
|
150 |
String theQuery = setDateParameters(st.toString(), params); |
|
151 |
log.debug("Generated query: " + theQuery); |
|
152 |
return theQuery; |
|
153 |
} |
|
154 |
|
|
155 |
private String getFundingPrefix(final Funding funding, final String suffix) throws IllegalArgumentException { |
|
156 |
switch (funding) { |
|
157 |
case FCT: |
|
158 |
if (StringUtils.isBlank(suffix)) return "fct_________::FCT::"; |
|
159 |
else return "fct_________::FCT::" + suffix; |
|
160 |
case WT: |
|
161 |
if (StringUtils.isBlank(suffix)) return "wt__________::WT::"; |
|
162 |
else return "wt__________::WT::" + suffix; |
|
163 |
case FP7: |
|
164 |
if (StringUtils.isBlank(suffix)) return "ec__________::EC::FP7::"; |
|
165 |
else return "ec__________::EC::FP7::" + suffix; |
|
166 |
case H2020: |
|
167 |
if (StringUtils.isBlank(suffix)) return "ec__________::EC::H2020"; |
|
168 |
else return "ec__________::EC::H2020" + suffix; |
|
169 |
case NHMRC: |
|
170 |
if (StringUtils.isBlank(suffix)) return "nhmrc_______::NHMRC::"; |
|
171 |
else return "nhmrc_______::NHMRC::" + suffix; |
|
172 |
case ARC: |
|
173 |
if (StringUtils.isBlank(suffix)) return "arc_________::ARC::"; |
|
174 |
else return "arc_________::ARC::" + suffix; |
|
175 |
case SFI: |
|
176 |
if (StringUtils.isBlank(suffix)) return "sfi_________::SFI::"; |
|
177 |
else return "sfi_________::SFI::" + suffix; |
|
178 |
case MSES: |
|
179 |
if (StringUtils.isBlank(suffix)) return "irb_hr______::MSES"; |
|
180 |
else return "irb_hr______::MSES::" + suffix; |
|
181 |
case CSF: |
|
182 |
if (StringUtils.isBlank(suffix)) return "irb_hr______::CSF"; |
|
183 |
else return "irb_hr______::CSF::" + suffix; |
|
184 |
case NWO: |
|
185 |
if (StringUtils.isBlank(suffix)) return "nwo_________::NWO"; |
|
186 |
else return "nwo_________::NWO::" + suffix; |
|
187 |
default: |
|
188 |
throw new IllegalArgumentException("Invalid funding " + funding + " (valid are: " + Arrays.asList(Funding.values()) + ") "); |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
192 |
void emit(final OutputStream out, final Resource xslt, final String query) throws IOException { |
|
193 |
W3CEndpointReference epr = null; |
|
194 |
try { |
|
195 |
epr = serviceLocator.getService(DatabaseService.class).searchSQL(dbName, query); |
|
196 |
|
|
197 |
IterableResultSetClient iter = resultSetClientFactory.getClient(epr); |
|
198 |
|
|
199 |
for (String s : new MappedCollection<String, String>(iter, new ApplyXslt(xslt))) { |
|
200 |
out.write(s.getBytes()); |
|
201 |
} |
|
202 |
} catch (DatabaseException e) { |
|
203 |
throw new IOException(e); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
void emitAsTsv(final OutputStream out, final String query) throws Exception { |
|
208 |
W3CEndpointReference epr = serviceLocator.getService(DatabaseService.class).searchSQL(dbName, query); |
|
209 |
|
|
210 |
final List<String> fields = Lists.newArrayList(Splitter.on(",").omitEmptyStrings().trimResults().split(tsvFields)); |
|
211 |
writeCSVLine(out, fields); |
|
212 |
|
|
213 |
final SAXReader reader = new SAXReader(); |
|
214 |
for (String s : resultSetClientFactory.getClient(epr)) { |
|
215 |
final Document doc = reader.read(new StringReader(s)); |
|
216 |
final List<String> list = Lists.newArrayList(); |
|
217 |
for (String f : fields) { |
|
218 |
list.add(doc.valueOf("//FIELD[@name='" + f + "']").replaceAll("\\n|\\t", " ").replaceAll("\\s+", " ").trim()); |
|
219 |
} |
|
220 |
writeCSVLine(out, list); |
|
221 |
} |
|
222 |
out.flush(); |
|
223 |
} |
|
224 |
|
|
225 |
private void writeCSVLine(final OutputStream out, final List<String> list) throws Exception { |
|
226 |
out.write(Joiner.on('\t').useForNull("").join(list).getBytes()); |
|
227 |
out.write('\n'); |
|
228 |
} |
|
229 |
|
|
230 |
private String setDateParameters(final String query, final ProjectQueryParams params) { |
|
231 |
String queryWithDates = query; |
|
232 |
if (params.getStartFrom() != null) { |
|
233 |
queryWithDates += " AND p.startdate >= '" + params.getStartFrom() + "'"; |
|
234 |
} |
|
235 |
if (params.getStartUntil() != null) { |
|
236 |
queryWithDates += " AND p.startdate <= '" + params.getStartUntil() + "'"; |
|
237 |
} |
|
238 |
if (params.getEndFrom() != null) { |
|
239 |
queryWithDates += " AND p.enddate >= '" + params.getEndFrom() + "'"; |
|
240 |
} |
|
241 |
if (params.getEndUntil() != null) { |
|
242 |
queryWithDates += " AND p.enddate <= '" + params.getEndUntil() + "'"; |
|
243 |
} |
|
244 |
return queryWithDates; |
|
245 |
} |
|
246 |
|
|
247 |
public String getDbName() { |
|
248 |
return dbName; |
|
249 |
} |
|
250 |
|
|
251 |
public void setDbName(final String dbName) { |
|
252 |
this.dbName = dbName; |
|
253 |
} |
|
254 |
|
|
255 |
public Resource getDspaceXslt() { |
|
256 |
return dspaceXslt; |
|
257 |
} |
|
258 |
|
|
259 |
public void setDspaceXslt(final Resource dspaceXslt) { |
|
260 |
this.dspaceXslt = dspaceXslt; |
|
261 |
} |
|
262 |
|
|
263 |
public Resource getEprintsXslt() { |
|
264 |
return eprintsXslt; |
|
265 |
} |
|
266 |
|
|
267 |
public void setEprintsXslt(final Resource eprintsXslt) { |
|
268 |
this.eprintsXslt = eprintsXslt; |
|
269 |
} |
|
270 |
|
|
271 |
public ProjectQueryParamsFactory getProjectQueryParamsFactory() { |
|
272 |
return projectQueryParamsFactory; |
|
273 |
} |
|
274 |
|
|
275 |
public void setProjectQueryParamsFactory(final ProjectQueryParamsFactory projectQueryParamsFactory) { |
|
276 |
this.projectQueryParamsFactory = projectQueryParamsFactory; |
|
277 |
} |
|
278 |
|
|
279 |
public Resource getProjectsFundingQueryTemplate() { |
|
280 |
return projectsFundingQueryTemplate; |
|
281 |
} |
|
282 |
|
|
283 |
public void setProjectsFundingQueryTemplate(final Resource projectsFundingQueryTemplate) { |
|
284 |
this.projectsFundingQueryTemplate = projectsFundingQueryTemplate; |
|
285 |
} |
|
286 |
|
|
287 |
public Resource getProjects2tsvQueryTemplate() { |
|
288 |
return projects2tsvQueryTemplate; |
|
289 |
} |
|
290 |
|
|
291 |
public void setProjects2tsvQueryTemplate(final Resource projects2tsvQueryTemplate) { |
|
292 |
this.projects2tsvQueryTemplate = projects2tsvQueryTemplate; |
|
293 |
} |
|
294 |
|
|
295 |
private enum Funding { |
|
296 |
FP7, WT, FCT, H2020, NHMRC, ARC, SFI, MSES, CSF, NWO |
|
297 |
} |
|
298 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/java/eu/dnetlib/openaire/exporter/ProjectQueryParamsFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.exporter; |
|
2 |
|
|
3 |
import javax.servlet.http.HttpServletRequest; |
|
4 |
|
|
5 |
public class ProjectQueryParamsFactory { |
|
6 |
|
|
7 |
private static final String BASE_PATH = "/openaire/export/"; |
|
8 |
private static final String NO_FILTER = "ALL"; |
|
9 |
|
|
10 |
public ProjectQueryParams generateParams(final HttpServletRequest request, |
|
11 |
final String startFrom, |
|
12 |
final String startUntil, |
|
13 |
final String endFrom, |
|
14 |
final String endUntil) { |
|
15 |
ProjectQueryParams params = new ProjectQueryParams(); |
|
16 |
|
|
17 |
String[] arr = request.getPathInfo().replace(BASE_PATH, "").split("\\/"); |
|
18 |
if (arr.length != 5) throw new IllegalArgumentException("Invalid url"); |
|
19 |
|
|
20 |
params.setFundingProgramme(arr[0]); |
|
21 |
String stream = NO_FILTER.equals(arr[1]) ? null : arr[1]; |
|
22 |
String substream = NO_FILTER.equals(arr[2]) ? null : arr[2]; |
|
23 |
if (substream == null) { |
|
24 |
params.setFundingPath(stream); |
|
25 |
} else { |
|
26 |
if (stream == null) { |
|
27 |
stream = "%"; |
|
28 |
} |
|
29 |
params.setFundingPath(stream + "::" + substream); |
|
30 |
} |
|
31 |
// params.setSpecificProgramme(NO_FILTER.equals(arr[1]) ? null : arr[1]); |
|
32 |
// params.setSubdivision(NO_FILTER.equals(arr[2]) ? null : arr[2]); |
|
33 |
// NB: arr[3] should be 'projects' |
|
34 |
// NB: arr[4] should be '[file].do' |
|
35 |
params.setStartFrom(startFrom); |
|
36 |
params.setStartUntil(startUntil); |
|
37 |
params.setEndFrom(endFrom); |
|
38 |
params.setEndUntil(endUntil); |
|
39 |
|
|
40 |
return params; |
|
41 |
} |
|
42 |
} |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/resources/eu/dnetlib/openaire/exporter/xslt/projects_eprints.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="xsl xsi"> |
|
4 |
|
|
5 |
<!-- DO NOT REINDENT THIS FILE: IT IS IMPORTANT THAT EACH PROJECT IS ON ONE SINGLE LINE --> |
|
6 |
<xsl:output omit-xml-declaration="yes" standalone="omit" indent="no"/> |
|
7 |
|
|
8 |
<xsl:template match="/"> |
|
9 |
<xsl:variable name="jurisdiction" select="//FIELD[@name='jurisdiction']"/> |
|
10 |
<xsl:variable name="unescapedId" select="//FIELD[@name='grant_agreement_number']"/> |
|
11 |
<xsl:variable name="id" select="replace($unescapedId, '/', '%2F')"/> |
|
12 |
<xsl:variable name="title" select="//FIELD[@name='title']" /> |
|
13 |
<xsl:variable name="acronym" select="//FIELD[@name='acronym']" /> |
|
14 |
<xsl:variable name="funder" select="//FIELD[@name='funder']" /> |
|
15 |
<xsl:variable name="fundingProgramme"> |
|
16 |
<xsl:value-of select="replace(tokenize(//FIELD[@name='fundingpathid'],'::')[3], '/', '%2F')"/> |
|
17 |
</xsl:variable> |
|
18 |
<xsl:variable name="idnamespace"> |
|
19 |
<!-- info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID /[Jurisdiction]/[ProjectName]/[ProjectAcronym] --> |
|
20 |
<xsl:choose> |
|
21 |
<xsl:when test="$jurisdiction != ''"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/', $id, '/', $jurisdiction )" /></xsl:when> |
|
22 |
<xsl:otherwise><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $id)" /></xsl:otherwise> |
|
23 |
</xsl:choose> |
|
24 |
</xsl:variable> |
|
25 |
<xsl:variable name="listLabel"> |
|
26 |
<xsl:choose> |
|
27 |
<xsl:when test="$fundingProgramme = 'FP7'">for:value:component:_fp7_project_id</xsl:when> |
|
28 |
<xsl:when test="$fundingProgramme = 'H2020'">for:value:component:_h2020_project_id</xsl:when> |
|
29 |
<xsl:when test="$funder = 'WT'">for:value:component:_wt_project_id</xsl:when> |
|
30 |
<xsl:when test="$funder = 'FCT'">for:value:component:_fct_project_id</xsl:when> |
|
31 |
<xsl:when test="$funder = 'NHMRC'">for:value:component:_nhmrc_project_id</xsl:when> |
|
32 |
<xsl:when test="$funder = 'ARC'">for:value:component:_arc_project_id</xsl:when> |
|
33 |
<xsl:when test="$funder = 'SFI'">for:value:component:_sfi_project_id</xsl:when> |
|
34 |
<xsl:when test="$funder = 'MSES'">for:value:component:_mses_project_id</xsl:when> |
|
35 |
<xsl:when test="$funder = 'CSF'">for:value:component:_csf_project_id</xsl:when> |
|
36 |
<xsl:when test="$funder = 'NWO'">for:value:component:_nwo_project_id</xsl:when> |
|
37 |
<xsl:otherwise>info:eu-repo/grantAgreement/</xsl:otherwise> |
|
38 |
</xsl:choose> |
|
39 |
</xsl:variable> |
|
40 |
<xsl:value-of select="concat($acronym, ' - ', $title, '	')" /><li style='border-right: solid 50px #30FF30' ><xsl:value-of select="concat($unescapedId, ' - ', $acronym, ' - ', $title)" /><ul><li id="{$listLabel}"><xsl:value-of select="$idnamespace" /></li></ul></li><xsl:text> |
|
41 |
</xsl:text> |
|
42 |
</xsl:template> |
|
43 |
|
|
44 |
</xsl:stylesheet> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/resources/eu/dnetlib/openaire/exporter/xslt/projects_dspace.xslt | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
3 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="xsl xsi"> |
|
4 |
|
|
5 |
<xsl:output omit-xml-declaration="yes" standalone="omit" indent="yes"/> |
|
6 |
|
|
7 |
<xsl:template match="/"> |
|
8 |
<xsl:variable name="jurisdiction" select="//FIELD[@name='jurisdiction']"/> |
|
9 |
<xsl:variable name="unescapedId" select="//FIELD[@name='grant_agreement_number']"/> |
|
10 |
<xsl:variable name="id" select="replace($unescapedId, '/', '%2F')"/> |
|
11 |
<xsl:variable name="title" select="//FIELD[@name='title']" /> |
|
12 |
<xsl:variable name="acronym" select="//FIELD[@name='acronym']" /> |
|
13 |
<xsl:variable name="funder" select="//FIELD[@name='funder']" /> |
|
14 |
<xsl:variable name="fundingProgramme"> |
|
15 |
<xsl:value-of select="replace(tokenize(//FIELD[@name='fundingpathid'],'::')[3], '/', '%2F')"/> |
|
16 |
</xsl:variable> |
|
17 |
|
|
18 |
<xsl:variable name="idnamespace"> |
|
19 |
<!-- info:eu-repo/grantAgreement/Funder/FundingProgram/ProjectID /[Jurisdiction]/[ProjectName]/[ProjectAcronym] --> |
|
20 |
<xsl:choose> |
|
21 |
<xsl:when test="$jurisdiction != ''"><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $fundingProgramme, '/', $id, '/', $jurisdiction)" /></xsl:when> |
|
22 |
<xsl:otherwise><xsl:value-of select="concat('info:eu-repo/grantAgreement/', $funder, '/', $id)" /></xsl:otherwise> |
|
23 |
</xsl:choose> |
|
24 |
</xsl:variable> |
|
25 |
<pair> |
|
26 |
<displayed-value> |
|
27 |
<xsl:value-of select="concat($unescapedId, ' - ', $acronym, ' - ', $title)"/> |
|
28 |
</displayed-value> |
|
29 |
<stored-value><xsl:value-of select="$idnamespace" /></stored-value> |
|
30 |
</pair> |
|
31 |
</xsl:template> |
|
32 |
|
|
33 |
</xsl:stylesheet> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/resources/eu/dnetlib/openaire/exporter/sql/projects_tsv.sql.st | ||
---|---|---|
1 |
select |
|
2 |
pr.code AS "Grant Agreement Number", |
|
3 |
pr.acronym AS "Project Acronym", |
|
4 |
pr.title AS "Project Title", |
|
5 |
pr.call_identifier AS "Call ID", |
|
6 |
pr.startdate AS "Start Date", |
|
7 |
pr.enddate AS "End Date", |
|
8 |
pr.ec_sc39 AS "ec_sc39", |
|
9 |
pr.oa_mandate_for_publications AS "oa_mandate_for_publications", |
|
10 |
pr.ec_article29_3 AS "ec_article29_3", |
|
11 |
f.description AS "Discipline", |
|
12 |
org.legalname AS "Organization", |
|
13 |
org.countryclass AS "Country", |
|
14 |
CASE WHEN po.participantnumber = 1 THEN 'coordinator' ELSE '' END AS "Role", |
|
15 |
pe.firstname AS "Person Name", |
|
16 |
pe.secondnames AS "Person Second Names", |
|
17 |
pe.email AS "Person Email" |
|
18 |
from projects pr |
|
19 |
left outer join project_organization po on (pr.id = po.project) |
|
20 |
left outer join persons pe on (po.contactperson=pe.id) |
|
21 |
left outer join organizations org on (po.resporganization = org.id) |
|
22 |
left outer join project_fundingpath pf on (pr.id = pf.project) |
|
23 |
left outer join fundingpaths f on (pf.funding = f.id) |
|
24 |
where f.id like '$fundingprefix$%'$filters.keys:{k| AND $k$=$filters.(k)$}$ |
|
25 |
order by pr.acronym |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/resources/eu/dnetlib/openaire/exporter/sql/projects_fundings.sql.st | ||
---|---|---|
1 |
SELECT |
|
2 |
org.legalshortname as funder, |
|
3 |
fp.jurisdiction as jurisdiction, |
|
4 |
p.acronym as acronym, |
|
5 |
p.title as title, |
|
6 |
p.code as grant_agreement_number, |
|
7 |
p.startdate as start_date, |
|
8 |
p.enddate as end_date, |
|
9 |
fp.id as fundingpathid |
|
10 |
FROM projects p |
|
11 |
left outer join project_fundingpath pfp on (p.id = pfp.project) |
|
12 |
left outer join fundingpaths fp on (pfp.funding=fp.id) |
|
13 |
left outer join organizations org on (org.id = fp.funder) |
|
14 |
WHERE fp.id like '$fundingprefix$%' |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/resources/eu/dnetlib/openaire/exporter/applicationContext-openaire-exporter.properties | ||
---|---|---|
1 |
openaire.exporter.dspace.xslt=classpath:/eu/dnetlib/openaire/exporter/xslt/projects_dspace.xslt |
|
2 |
openaire.exporter.eprints.xslt=classpath:/eu/dnetlib/openaire/exporter/xslt/projects_eprints.xslt |
|
3 |
openaire.exporter.projects2tsv.sql.template=classpath:/eu/dnetlib/openaire/exporter/sql/projects_tsv.sql.st |
|
4 |
openaire.exporter.projects2tsv.fields = Grant Agreement Number, Project Acronym, Project Title, Call ID, Start Date, End Date, ec_sc39, oa_mandate_for_publications, ec_article29_3, Discipline, Organization, Country, Role, Person Name, Person Second Names, Person Email |
|
5 |
openaire.exporter.projectsfundings.sql.template=classpath:/eu/dnetlib/openaire/exporter/sql/projects_fundings.sql.st |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/src/main/resources/eu/dnetlib/openaire/exporter/webContext-openaire-exporter.xml | ||
---|---|---|
1 |
<beans xmlns="http://www.springframework.org/schema/beans" |
|
2 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" |
|
3 |
xmlns:context="http://www.springframework.org/schema/context" |
|
4 |
xmlns:util="http://www.springframework.org/schema/util" |
|
5 |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
|
6 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd |
|
7 |
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> |
|
8 |
|
|
9 |
<bean id="projectQueryParamsFactory" class="eu.dnetlib.openaire.exporter.ProjectQueryParamsFactory" /> |
|
10 |
|
|
11 |
</beans> |
modules/cnr-openaire-exporter/tags/cnr-openaire-exporter-5.1.8/deploy.info | ||
---|---|---|
1 |
{"type_source": "SVN", |
|
2 |
"goal": "package -U source:jar", |
|
3 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-openaire-exporter/trunk/", |
|
4 |
"deploy_repository": "dnet4-snapshots", |
|
5 |
"version": "4", |
|
6 |
"mail": "alessia.bardi@isti.cnr.it", |
|
7 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-openaire-exporter"} |
Also available in: Unified diff
[maven-release-plugin] copy for tag cnr-openaire-exporter-5.1.8