Project

General

Profile

« Previous | Next » 

Revision 49615

[maven-release-plugin] copy for tag dnet-openaire-exporter-1.0.10

View differences:

modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/dnet-openaire-exporter.iml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
  <component name="FacetManager">
4
    <facet type="Spring" name="Spring">
5
      <configuration />
6
    </facet>
7
  </component>
8
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
9
    <output url="file://$MODULE_DIR$/target/classes" />
10
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
11
    <content url="file://$MODULE_DIR$">
12
      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
13
      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
14
      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
15
      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
16
      <excludeFolder url="file://$MODULE_DIR$/target" />
17
    </content>
18
    <orderEntry type="inheritedJdk" />
19
    <orderEntry type="sourceFolder" forTests="false" />
20
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-pace-core:2.5.1" level="project" />
21
    <orderEntry type="library" name="Maven: org.apache.solr:solr-solrj:5.5.4" level="project" />
22
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-rmi-api:2.6.2-SNAPSHOT" level="project" />
23
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-core:3.1.5" level="project" />
24
    <orderEntry type="library" name="Maven: org.apache.ws.xmlschema:xmlschema-core:2.2.1" level="project" />
25
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-jaxws:3.1.5" level="project" />
26
    <orderEntry type="library" name="Maven: xml-resolver:xml-resolver:1.2" level="project" />
27
    <orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
28
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-soap:3.1.5" level="project" />
29
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-wsdl:3.1.5" level="project" />
30
    <orderEntry type="library" name="Maven: wsdl4j:wsdl4j:1.6.3" level="project" />
31
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-databinding-jaxb:3.1.5" level="project" />
32
    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.11" level="project" />
33
    <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.2.11" level="project" />
34
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-bindings-xml:3.1.5" level="project" />
35
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-frontend-simple:3.1.5" level="project" />
36
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-addr:3.1.5" level="project" />
37
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-ws-policy:3.1.5" level="project" />
38
    <orderEntry type="library" name="Maven: org.apache.neethi:neethi:3.0.3" level="project" />
39
    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
40
    <orderEntry type="library" name="Maven: org.apache.cxf:cxf-rt-transports-http:3.1.5" level="project" />
41
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-service-common:2.1.7-SNAPSHOT" level="project" />
42
    <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.2.2" level="project" />
43
    <orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.1" level="project" />
44
    <orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.7.RELEASE" level="project" />
45
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.7.RELEASE" level="project" />
46
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-misc-utils:1.0.5-SNAPSHOT" level="project" />
47
    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
48
    <orderEntry type="library" name="Maven: jaxen:jaxen:1.1.6" level="project" />
49
    <orderEntry type="library" name="Maven: saxonica:saxon:9.1.0.8" level="project" />
50
    <orderEntry type="library" name="Maven: saxonica:saxon-dom:9.1.0.8" level="project" />
51
    <orderEntry type="library" name="Maven: jgrapht:jgrapht:0.7.2" level="project" />
52
    <orderEntry type="library" name="Maven: net.sf.ehcache:ehcache:2.10.3" level="project" />
53
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-service-utils:1.0.3-SNAPSHOT" level="project" />
54
    <orderEntry type="library" name="Maven: apache:oro:2.0.8" level="project" />
55
    <orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.7.RELEASE" level="project" />
56
    <orderEntry type="library" name="Maven: eu.dnetlib:cnr-spring-utils:1.0.2-SNAPSHOT" level="project" />
57
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.7.RELEASE" level="project" />
58
    <orderEntry type="library" name="Maven: jparsec:jparsec:2.0" level="project" />
59
    <orderEntry type="library" name="Maven: runcc:runcc:0.7" level="project" />
60
    <orderEntry type="module" module-name="dnet-openaireplus-mapping-utils" />
61
    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
62
    <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
63
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-openaire-data-protos:3.8.10" level="project" />
64
    <orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.4.1" level="project" />
65
    <orderEntry type="module" module-name="dnet-pace-core" />
66
    <orderEntry type="library" name="Maven: edu.cmu:secondstring:1.0.0" level="project" />
67
    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
68
    <orderEntry type="library" name="Maven: eu.dnetlib:dnet-index-solr-common:1.3.1" level="project" />
69
    <orderEntry type="library" name="Maven: com.googlecode.protobuf-java-format:protobuf-java-format:1.2" level="project" />
70
    <orderEntry type="library" name="Maven: org.apache.solr:solr-solrj:6.6.0" level="project" />
71
    <orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.4.1" level="project" />
72
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.3" level="project" />
73
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.6" level="project" />
74
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.3" level="project" />
75
    <orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.4.10" level="project" />
76
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" />
77
    <orderEntry type="library" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.4.1" level="project" />
78
    <orderEntry type="library" name="Maven: org.noggit:noggit:0.6" level="project" />
79
    <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.24" level="project" />
80
    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.24" level="project" />
81
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.2.RELEASE" level="project" />
82
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.2.RELEASE" level="project" />
83
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.2.RELEASE" level="project" />
84
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.5.2.RELEASE" level="project" />
85
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.2.RELEASE" level="project" />
86
    <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.11" level="project" />
87
    <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.11" level="project" />
88
    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.24" level="project" />
89
    <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.24" level="project" />
90
    <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
91
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.5.2.RELEASE" level="project" />
92
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.11" level="project" />
93
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.11" level="project" />
94
    <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.11" level="project" />
95
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.3.4.Final" level="project" />
96
    <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
97
    <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
98
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.7" level="project" />
99
    <orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.7.RELEASE" level="project" />
100
    <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.7.RELEASE" level="project" />
101
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.7.RELEASE" level="project" />
102
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:1.5.2.RELEASE" level="project" />
103
    <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jdbc:8.5.11" level="project" />
104
    <orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.11" level="project" />
105
    <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:4.3.7.RELEASE" level="project" />
106
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:1.5.2.RELEASE" level="project" />
107
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:1.5.2.RELEASE" level="project" />
108
    <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.9" level="project" />
109
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.0.12.Final" level="project" />
110
    <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
111
    <orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
112
    <orderEntry type="library" name="Maven: org.jboss:jandex:2.0.0.Final" level="project" />
113
    <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" />
114
    <orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:5.0.12.Final" level="project" />
115
    <orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.2" level="project" />
116
    <orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:1.11.1.RELEASE" level="project" />
117
    <orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.13.1.RELEASE" level="project" />
118
    <orderEntry type="library" name="Maven: org.springframework:spring-orm:4.3.7.RELEASE" level="project" />
119
    <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.3.7.RELEASE" level="project" />
120
    <orderEntry type="library" name="Maven: org.postgresql:postgresql:42.0.0" level="project" />
121
    <orderEntry type="library" name="Maven: org.apache.commons:commons-dbcp2:2.1" level="project" />
122
    <orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
123
    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
124
    <orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
125
    <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
126
    <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
127
    <orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
128
    <orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
129
    <orderEntry type="library" name="Maven: net.sf.supercsv:super-csv:2.4.0" level="project" />
130
    <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
131
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-joda:2.6.6" level="project" />
132
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
133
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.7" level="project" />
134
    <orderEntry type="library" name="Maven: joda-time:joda-time:2.8.2" level="project" />
135
    <orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.4.2" level="project" />
136
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.7.0" level="project" />
137
    <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.13" level="project" />
138
    <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.13" level="project" />
139
    <orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.7.0" level="project" />
140
    <orderEntry type="library" name="Maven: io.springfox:springfox-core:2.7.0" level="project" />
141
    <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.6.14" level="project" />
142
    <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.7.0" level="project" />
143
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.7.0" level="project" />
144
    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.7.0" level="project" />
145
    <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" />
146
    <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.3" level="project" />
147
    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
148
    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
149
    <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.1.0.Final" level="project" />
150
    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.7.0" level="project" />
151
    <orderEntry type="library" name="Maven: io.prometheus:simpleclient_spring_boot:0.0.25" level="project" />
152
    <orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.0.25" level="project" />
153
    <orderEntry type="library" name="Maven: io.prometheus:simpleclient_common:0.0.25" level="project" />
154
    <orderEntry type="library" name="Maven: io.prometheus:simpleclient_spring_web:0.0.25" level="project" />
155
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:1.5.2.RELEASE" level="project" />
156
    <orderEntry type="library" name="Maven: io.prometheus:simpleclient_hotspot:0.0.25" level="project" />
157
    <orderEntry type="library" name="Maven: io.prometheus:simpleclient_servlet:0.0.25" level="project" />
158
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.2.RELEASE" level="project" />
159
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.2.RELEASE" level="project" />
160
    <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.2.RELEASE" level="project" />
161
    <orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.2.0" level="project" />
162
    <orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.2.1" level="project" />
163
    <orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.1" level="project" />
164
    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
165
    <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:2.6.0" level="project" />
166
    <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:1.10.19" level="project" />
167
    <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.1" level="project" />
168
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
169
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
170
    <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
171
    <orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
172
    <orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.7.RELEASE" level="project" />
173
    <orderEntry type="library" name="Maven: org.springframework:spring-test:4.3.7.RELEASE" level="project" />
174
  </component>
175
</module>
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/deploy.info
1
{"type_source": "SVN", "goal": "package -U source:jar", 
2
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-openaire-exporter/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it",
3
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-openaire-exporter"}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/test/java/eu/dnetlib/openaire/exporter/model/project/ProjectDetailsTest.java
1
package eu.dnetlib.openaire.exporter.model.project;
2

  
3
import java.io.IOException;
4

  
5
import org.junit.Test;
6

  
7
/**
8
 * Created by claudio on 05/07/2017.
9
 */
10
public class ProjectDetailsTest {
11

  
12
	@Test
13
	public void testCSV() throws IOException {
14

  
15
		final ProjectDetails p = ProjectDetails.fromCSV(
16
				"arc_________::ANZCCART,,ANZCCART,{},\"[\"\"\\u003cfundingtree\\u003e\\n      \\u003cfunder\\u003e\\n         \\u003cid\\u003earc_________::ARC\\u003c/id\\u003e\\n         \\u003cshortname\\u003eARC\\u003c/shortname\\u003e\\n         \\u003cname\\u003eAustralian Research Council (ARC)\\u003c/name\\u003e\\n         \\u003cjurisdiction\\u003eAU\\u003c/jurisdiction\\u003e\\n      \\u003c/funder\\u003e\\n      \\u003cfunding_level_0\\u003e\\n         \\u003cid\\u003earc_________::ARC::Special Research initiative (Australian and New Zealand Council for the Care of Animals in Research and Teaching)\\u003c/id\\u003e\\n         \\u003cname\\u003eSpecial Research initiative (Australian and New Zealand Council for the Care of Animals in Research and Teaching)\\u003c/name\\u003e\\n         \\u003cdescription\\u003eSpecial Research initiative (Australian and New Zealand Council for the Care of Animals in Research and Teaching)\\u003c/description\\u003e\\n         \\u003cparent/\\u003e\\n         \\u003cclass\\u003earc:fundingStream\\u003c/class\\u003e\\n      \\u003c/funding_level_0\\u003e\\n   \\u003c/fundingtree\\u003e\"\"]\"");
17

  
18
		System.out.println(p.asJson());
19

  
20
		System.out.println(p.asCSV());
21

  
22

  
23
	}
24

  
25
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/test/java/eu/dnetlib/openaire/exporter/project/ProjectQueryParamsTest.java
1
package eu.dnetlib.openaire.exporter.project;
2

  
3
import eu.dnetlib.openaire.exporter.project.ProjectQueryParams;
4
import org.junit.Before;
5
import org.junit.Test;
6

  
7
import static org.junit.Assert.assertEquals;
8

  
9
public class ProjectQueryParamsTest {
10

  
11
	private ProjectQueryParams queryParams;
12

  
13
	@Before
14
	public void setUp() throws Exception {
15
		queryParams = new ProjectQueryParams();
16

  
17
	}
18

  
19
	@Test
20
	public void testVerifyParamWhiteSpace() {
21
		queryParams.verifyParam("Discovery Projects");
22
	}
23

  
24
	@Test
25
	public void testVerifyParamPercentage() {
26
		queryParams.verifyParam("Discovery%20Projects");
27
	}
28

  
29
	@Test
30
	public void testVerifyDateParam(){
31
		String correctDate = "2012-03-04";
32
		assertEquals(correctDate, queryParams.verifyDateParam(correctDate));
33

  
34
	}
35

  
36
	@Test(expected=IllegalArgumentException.class)
37
	public void testVerifyDateParamException(){
38
		String wrongDate = "12-12-12";
39
		queryParams.verifyDateParam(wrongDate);
40

  
41
	}
42
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/test/java/eu/dnetlib/openaire/exporter/project/ProjectsControllerTest.java
1
package eu.dnetlib.openaire.exporter.project;
2

  
3
import java.io.IOException;
4

  
5
import org.antlr.stringtemplate.StringTemplate;
6
import org.apache.commons.io.IOUtils;
7
import org.apache.commons.logging.Log;
8
import org.apache.commons.logging.LogFactory;
9
import org.junit.Before;
10
import org.junit.Ignore;
11
import org.junit.Test;
12
import org.junit.runner.RunWith;
13
import org.springframework.boot.test.context.SpringBootTest;
14
import org.springframework.core.io.ClassPathResource;
15
import org.springframework.core.io.Resource;
16
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
17

  
18
import static org.junit.Assert.assertEquals;
19

  
20
@Ignore
21
@SpringBootTest
22
@RunWith(SpringJUnit4ClassRunner.class)
23
public class ProjectsControllerTest {
24

  
25
	private static final Log log = LogFactory.getLog(ProjectsControllerTest.class);
26
	private String queryTemplate = "/eu/dnetlib/openaire/exporter/sql/projects_fundings.sql.st";
27

  
28
	private Resource expectedQueryTemplate = new ClassPathResource("/eu/dnetlib/openaire/exporter/sql/expected_projects_fundings.sql.st");
29

  
30
	private ProjectsController controller;
31
	private ProjectQueryParams params;
32

  
33
	@Before
34
	public void setup() {
35
		controller = new ProjectsController();
36
		Resource template = new ClassPathResource(queryTemplate);
37

  
38
		//TODO reimplement bean injection for testing
39
		//controller.setProjectsFundingQueryTemplate(template);
40
		params = new ProjectQueryParams();
41
	}
42

  
43
	@Test
44
	public void testObtainFP7Query() throws IllegalArgumentException, IOException {
45
		params.setFundingProgramme("FP7");
46
		params.setFundingPath(null);
47
		String res = controller.obtainQuery(params);
48
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
49
		st.setAttribute("fundingprefix", "ec__________::EC::FP7");
50
		log.debug(res);
51
		log.debug(st);
52
		assertEquals(st.toString(), res);
53
	}
54

  
55
	@Test
56
	public void testObtainFP7QuerySP1() throws IllegalArgumentException, IOException {
57
		params.setFundingProgramme("FP7");
58
		params.setFundingPath("SP1");
59
		String res = controller.obtainQuery(params);
60
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
61
		st.setAttribute("fundingprefix", "ec__________::EC::FP7::SP1");
62
		log.debug(res);
63
		assertEquals(st.toString(), res);
64
	}
65

  
66
	@Test
67
	public void testObtainFP7QueryHealth() throws IllegalArgumentException, IOException {
68
		params.setFundingProgramme("FP7");
69
		params.setFundingPath("SP1::HEALTH");
70
		String res = controller.obtainQuery(params);
71
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
72
		st.setAttribute("fundingprefix", "ec__________::EC::FP7::SP1::HEALTH");
73
		log.debug(res);
74
		assertEquals(st.toString(), res);
75
	}
76

  
77
	@Test
78
	public void testObtainFP7QueryHealth2() throws IllegalArgumentException, IOException {
79
		params.setFundingProgramme("FP7");
80
		params.setFundingPath("%::HEALTH");
81
		String res = controller.obtainQuery(params);
82
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
83
		st.setAttribute("fundingprefix", "ec__________::EC::FP7::%::HEALTH");
84
		log.debug(res);
85
		assertEquals(st.toString(), res);
86
	}
87

  
88
	@Test
89
	public void testObtainWellcomeTrustQuery() throws IllegalArgumentException, IOException {
90
		params.setFundingProgramme("WT");
91
		params.setFundingPath(null);
92
		String res = controller.obtainQuery(params);
93
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
94
		st.setAttribute("fundingprefix", "wt__________::WT");
95
		log.debug(res);
96
		assertEquals(st.toString(), res);
97
	}
98

  
99
	@Test
100
	public void testObtainFCTQuery() throws IllegalArgumentException, IOException {
101
		params.setFundingProgramme("FCT");
102
		params.setFundingPath(null);
103
		String res = controller.obtainQuery(params);
104
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
105
		st.setAttribute("fundingprefix", "fct_________::FCT");
106
		log.debug(res);
107
		assertEquals(st.toString(), res);
108
	}
109

  
110
	@Test
111
	public void testQueryWithDateParams() throws IllegalArgumentException, IOException {
112
		params.setFundingProgramme("WT");
113
		params.setFundingPath(null);
114
		params.setStartFrom("2015-05-04");
115
		String res = controller.obtainQuery(params);
116
		log.debug(res);
117
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
118
		st.setAttribute("fundingprefix", "wt__________::WT");
119
		String q = st.toString() + " AND startdate >= '2015-05-04'";
120
		assertEquals(q, res);
121
	}
122

  
123
	@Test
124
	public void testObtainSNSFQuery() throws IllegalArgumentException, IOException {
125
		params.setFundingProgramme("SNSF");
126
		params.setFundingPath(null);
127
		String res = controller.obtainQuery(params);
128
		final StringTemplate st = new StringTemplate(IOUtils.toString(expectedQueryTemplate.getInputStream(),  ProjectsController.UTF8));
129
		st.setAttribute("fundingprefix", "snsf________::SNSF");
130
		log.debug(res);
131
		assertEquals(st.toString(), res);
132
	}
133

  
134
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/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/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/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/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/test/resources/eu/dnetlib/openaire/exporter/sql/expected_projects_fundings.sql.st
1
SELECT
2
	funder,
3
	jurisdiction,
4
	fundingpathid,
5
	acronym,
6
	title,
7
	code,
8
	startdate,
9
	enddate
10
FROM projects_api
11
WHERE fundingpathid like '$fundingprefix$%'
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/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/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/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/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/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/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/test/resources/logback-test.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<configuration>
3
	<include resource="org/springframework/boot/logging/logback/base.xml"/>
4
	<logger name="org.springframework" level="OFF">
5
		<appender-ref ref="CONSOLE" />
6
	</logger>
7
	<logger name="root" level="OFF">
8
		<appender-ref ref="CONSOLE" />
9
	</logger>
10
	<logger name="eu.dnetlib" level="INFO">
11
		<appender-ref ref="CONSOLE" />
12
	</logger>
13
	<logger name="eu.dnetlib.openaire.exporter" level="INFO">
14
		<appender-ref ref="CONSOLE" />
15
	</logger>
16
</configuration>
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/swagger/configuration/SwaggerDocumentationConfig.java
1
package eu.dnetlib.swagger.configuration;
2

  
3
import eu.dnetlib.OpenaireExporterConfig;
4
import eu.dnetlib.OpenaireExporterConfig.Swagger;
5
import eu.dnetlib.common.rmi.DNetRestDocumentation;
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.context.annotation.Bean;
8
import org.springframework.context.annotation.Configuration;
9
import springfox.documentation.builders.ApiInfoBuilder;
10
import springfox.documentation.builders.RequestHandlerSelectors;
11
import springfox.documentation.service.ApiInfo;
12
import springfox.documentation.service.Contact;
13
import springfox.documentation.spi.DocumentationType;
14
import springfox.documentation.spring.web.plugins.Docket;
15
import springfox.documentation.swagger2.annotations.EnableSwagger2;
16

  
17
@Configuration
18
@EnableSwagger2
19
public class SwaggerDocumentationConfig {
20

  
21
	@Autowired
22
	private OpenaireExporterConfig config;
23

  
24
    @Bean
25
    public Docket customImplementation() {
26
        return new Docket(DocumentationType.SWAGGER_2)
27
                .select()
28
		            .apis(RequestHandlerSelectors.withClassAnnotation(DNetRestDocumentation.class))
29
                    .build()
30
                .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
31
                .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
32
                .apiInfo(apiInfo());
33
    }
34

  
35
	private ApiInfo apiInfo() {
36
		final Swagger swag = config.getSwagger();
37
		return new ApiInfoBuilder()
38
				.title(swag.getApiTitle())
39
				.description(swag.getApiDescription())
40
				.license(swag.getApiLicense())
41
				.licenseUrl(swag.getApiLicenseUrl())
42
				.termsOfServiceUrl("")
43
				.version("1.0.0")
44
				.contact(new Contact(
45
						swag.getApiContactName(),
46
						swag.getApiContactUrl(),
47
						swag.getApiContactEmail()))
48
				.build();
49
	}
50

  
51
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/swagger/configuration/RFC3339DateFormat.java
1
package eu.dnetlib.swagger.configuration;
2

  
3
import java.text.FieldPosition;
4
import java.util.Date;
5

  
6
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
7
import com.fasterxml.jackson.databind.util.ISO8601Utils;
8

  
9
public class RFC3339DateFormat extends ISO8601DateFormat {
10

  
11
  // Same as ISO8601DateFormat but serializing milliseconds.
12
  @Override
13
  public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
14
    String value = ISO8601Utils.format(date, true);
15
    toAppendTo.append(value);
16
    return toAppendTo;
17
  }
18

  
19
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/Utils.java
1
package eu.dnetlib;
2

  
3
import java.util.Iterator;
4
import java.util.Spliterator;
5
import java.util.Spliterators;
6
import java.util.stream.Stream;
7
import java.util.stream.StreamSupport;
8

  
9
/**
10
 * Created by claudio on 13/04/2017.
11
 */
12
public class Utils {
13

  
14
	public static <T> Stream<T> stream(Iterator<T> iterator) {
15
		return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false);
16
	}
17

  
18
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/OpenaireExporterConfig.java
1
package eu.dnetlib;
2

  
3
import org.springframework.beans.factory.annotation.Value;
4
import org.springframework.boot.context.properties.ConfigurationProperties;
5
import org.springframework.core.io.ClassPathResource;
6
import org.springframework.core.io.Resource;
7
import org.springframework.stereotype.Component;
8

  
9
/**
10
 * Created by Alessia Bardi on 31/03/17.
11
 *
12
 * @author Alessia Bardi
13
 */
14
@Component
15
@ConfigurationProperties(prefix = "openaire.exporter")
16
public class OpenaireExporterConfig {
17

  
18
	// ISLOOKUP
19
	private ClassPathResource findSolrIndexUrl;
20
	private ClassPathResource findIndexDsInfo;
21
	private String isLookupUrl;
22
	private int requestWorkers = 100;
23
	private int requestTimeout = 10;
24

  
25
	private Datasource datasource;
26
	private Project project;
27
	private Jdbc jdbc;
28
	private Swagger swagger;
29
	private Vocabularies vocabularies;
30

  
31
	public static class Datasource {
32
		// MONGODB
33
		private String mongoHost;
34
		private int mongoPort;
35
		private String mongoCollectionName;
36
		private String mongoDbName;
37
		private int mongoConnectionsPerHost;
38
		private int mongoQueryLimit;
39

  
40
		public String getMongoHost() {
41
			return mongoHost;
42
		}
43

  
44
		public void setMongoHost(final String mongoHost) {
45
			this.mongoHost = mongoHost;
46
		}
47

  
48
		public int getMongoPort() {
49
			return mongoPort;
50
		}
51

  
52
		public void setMongoPort(final int mongoPort) {
53
			this.mongoPort = mongoPort;
54
		}
55

  
56
		public String getMongoCollectionName() {
57
			return mongoCollectionName;
58
		}
59

  
60
		public void setMongoCollectionName(final String mongoCollectionName) {
61
			this.mongoCollectionName = mongoCollectionName;
62
		}
63

  
64
		public String getMongoDbName() {
65
			return mongoDbName;
66
		}
67

  
68
		public void setMongoDbName(final String mongoDbName) {
69
			this.mongoDbName = mongoDbName;
70
		}
71

  
72
		public int getMongoConnectionsPerHost() {
73
			return mongoConnectionsPerHost;
74
		}
75

  
76
		public void setMongoConnectionsPerHost(final int mongoConnectionsPerHost) {
77
			this.mongoConnectionsPerHost = mongoConnectionsPerHost;
78
		}
79

  
80
		public int getMongoQueryLimit() {
81
			return mongoQueryLimit;
82
		}
83

  
84
		public void setMongoQueryLimit(final int mongoQueryLimit) {
85
			this.mongoQueryLimit = mongoQueryLimit;
86
		}
87
	}
88

  
89
	public static class Project {
90

  
91
		private int flushSize;
92
		private String tsvFields;
93
		private Resource projectsFundingQueryTemplate;
94
		private Resource dspaceTemplate;
95
		private Resource dspaceHeadTemplate;
96
		private Resource dspaceTailTemplate;
97
		private Resource eprintsTemplate;
98

  
99
		public int getFlushSize() {
100
			return flushSize;
101
		}
102

  
103
		public void setFlushSize(final int flushSize) {
104
			this.flushSize = flushSize;
105
		}
106

  
107
		public String getTsvFields() {
108
			return tsvFields;
109
		}
110

  
111
		public void setTsvFields(final String tsvFields) {
112
			this.tsvFields = tsvFields;
113
		}
114

  
115
		public Resource getProjectsFundingQueryTemplate() {
116
			return projectsFundingQueryTemplate;
117
		}
118

  
119
		public void setProjectsFundingQueryTemplate(final Resource projectsFundingQueryTemplate) {
120
			this.projectsFundingQueryTemplate = projectsFundingQueryTemplate;
121
		}
122

  
123
		public Resource getDspaceTemplate() {
124
			return dspaceTemplate;
125
		}
126

  
127
		public void setDspaceTemplate(final Resource dspaceTemplate) {
128
			this.dspaceTemplate = dspaceTemplate;
129
		}
130

  
131
		public Resource getDspaceHeadTemplate() {
132
			return dspaceHeadTemplate;
133
		}
134

  
135
		public void setDspaceHeadTemplate(final Resource dspaceHeadTemplate) {
136
			this.dspaceHeadTemplate = dspaceHeadTemplate;
137
		}
138

  
139
		public Resource getDspaceTailTemplate() {
140
			return dspaceTailTemplate;
141
		}
142

  
143
		public void setDspaceTailTemplate(final Resource dspaceTailTemplate) {
144
			this.dspaceTailTemplate = dspaceTailTemplate;
145
		}
146

  
147
		public Resource getEprintsTemplate() {
148
			return eprintsTemplate;
149
		}
150

  
151
		public void setEprintsTemplate(final Resource eprintsTemplate) {
152
			this.eprintsTemplate = eprintsTemplate;
153
		}
154
	}
155

  
156
	public static class Jdbc {
157

  
158
		// JDBC
159
		@Value("${spring.datasource.driverClassName}")
160
		private String driverClassName;
161

  
162
		private String url;
163
		private String user;
164
		private String pwd;
165
		private int minIdle;
166
		private int maxidle;
167
		private int maxRows;
168

  
169
		public String getDriverClassName() {
170
			return driverClassName;
171
		}
172

  
173
		public String getUrl() {
174
			return url;
175
		}
176

  
177
		public void setUrl(final String url) {
178
			this.url = url;
179
		}
180

  
181
		public String getUser() {
182
			return user;
183
		}
184

  
185
		public void setUser(final String user) {
186
			this.user = user;
187
		}
188

  
189
		public String getPwd() {
190
			return pwd;
191
		}
192

  
193
		public void setPwd(final String pwd) {
194
			this.pwd = pwd;
195
		}
196

  
197
		public int getMinIdle() {
198
			return minIdle;
199
		}
200

  
201
		public void setMinIdle(final int minIdle) {
202
			this.minIdle = minIdle;
203
		}
204

  
205
		public int getMaxidle() {
206
			return maxidle;
207
		}
208

  
209
		public void setMaxidle(final int maxidle) {
210
			this.maxidle = maxidle;
211
		}
212

  
213
		public int getMaxRows() {
214
			return maxRows;
215
		}
216

  
217
		public void setMaxRows(final int maxRows) {
218
			this.maxRows = maxRows;
219
		}
220
	}
221

  
222
	public static class Swagger {
223
		private String apiTitle;
224
		private String apiDescription;
225
		private String apiLicense;
226
		private String apiLicenseUrl;
227
		private String apiContactName;
228
		private String apiContactUrl;
229
		private String apiContactEmail;
230

  
231
		public String getApiTitle() {
232
			return apiTitle;
233
		}
234

  
235
		public void setApiTitle(final String apiTitle) {
236
			this.apiTitle = apiTitle;
237
		}
238

  
239
		public String getApiDescription() {
240
			return apiDescription;
241
		}
242

  
243
		public void setApiDescription(final String apiDescription) {
244
			this.apiDescription = apiDescription;
245
		}
246

  
247
		public String getApiLicense() {
248
			return apiLicense;
249
		}
250

  
251
		public void setApiLicense(final String apiLicense) {
252
			this.apiLicense = apiLicense;
253
		}
254

  
255
		public String getApiLicenseUrl() {
256
			return apiLicenseUrl;
257
		}
258

  
259
		public void setApiLicenseUrl(final String apiLicenseUrl) {
260
			this.apiLicenseUrl = apiLicenseUrl;
261
		}
262

  
263
		public String getApiContactName() {
264
			return apiContactName;
265
		}
266

  
267
		public void setApiContactName(final String apiContactName) {
268
			this.apiContactName = apiContactName;
269
		}
270

  
271
		public String getApiContactUrl() {
272
			return apiContactUrl;
273
		}
274

  
275
		public void setApiContactUrl(final String apiContactUrl) {
276
			this.apiContactUrl = apiContactUrl;
277
		}
278

  
279
		public String getApiContactEmail() {
280
			return apiContactEmail;
281
		}
282

  
283
		public void setApiContactEmail(final String apiContactEmail) {
284
			this.apiContactEmail = apiContactEmail;
285
		}
286
	}
287

  
288
	public static class Vocabularies {
289
		private String countriesEndpoint;
290

  
291
		public String getCountriesEndpoint() {
292
			return countriesEndpoint;
293
		}
294

  
295
		public void setCountriesEndpoint(final String countriesEndpoint) {
296
			this.countriesEndpoint = countriesEndpoint;
297
		}
298
	}
299

  
300
	public ClassPathResource getFindSolrIndexUrl() {
301
		return findSolrIndexUrl;
302
	}
303

  
304
	public void setFindSolrIndexUrl(final ClassPathResource findSolrIndexUrl) {
305
		this.findSolrIndexUrl = findSolrIndexUrl;
306
	}
307

  
308
	public ClassPathResource getFindIndexDsInfo() {
309
		return findIndexDsInfo;
310
	}
311

  
312
	public void setFindIndexDsInfo(final ClassPathResource findIndexDsInfo) {
313
		this.findIndexDsInfo = findIndexDsInfo;
314
	}
315

  
316
	public String getIsLookupUrl() {
317
		return isLookupUrl;
318
	}
319

  
320
	public void setIsLookupUrl(final String isLookupUrl) {
321
		this.isLookupUrl = isLookupUrl;
322
	}
323

  
324
	public int getRequestWorkers() {
325
		return requestWorkers;
326
	}
327

  
328
	public void setRequestWorkers(final int requestWorkers) {
329
		this.requestWorkers = requestWorkers;
330
	}
331

  
332
	public int getRequestTimeout() {
333
		return requestTimeout;
334
	}
335

  
336
	public void setRequestTimeout(final int requestTimeout) {
337
		this.requestTimeout = requestTimeout;
338
	}
339

  
340
	public Datasource getDatasource() {
341
		return datasource;
342
	}
343

  
344
	public void setDatasource(final Datasource datasource) {
345
		this.datasource = datasource;
346
	}
347

  
348
	public Project getProject() {
349
		return project;
350
	}
351

  
352
	public void setProject(final Project project) {
353
		this.project = project;
354
	}
355

  
356
	public Jdbc getJdbc() {
357
		return jdbc;
358
	}
359

  
360
	public void setJdbc(final Jdbc jdbc) {
361
		this.jdbc = jdbc;
362
	}
363

  
364
	public Swagger getSwagger() {
365
		return swagger;
366
	}
367

  
368
	public void setSwagger(final Swagger swagger) {
369
		this.swagger = swagger;
370
	}
371

  
372
	public Vocabularies getVocabularies() {
373
		return vocabularies;
374
	}
375

  
376
	public void setVocabularies(final Vocabularies vocabularies) {
377
		this.vocabularies = vocabularies;
378
	}
379

  
380
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/aop/DatasourceApiProfiler.java
1
package eu.dnetlib.openaire.exporter.aop;
2

  
3
import io.prometheus.client.Gauge;
4
import org.aspectj.lang.ProceedingJoinPoint;
5
import org.aspectj.lang.annotation.Around;
6
import org.aspectj.lang.annotation.Aspect;
7
import org.springframework.stereotype.Component;
8

  
9
/**
10
 * Created by claudio on 25/07/2017.
11
 */
12
@Aspect
13
@Component
14
public class DatasourceApiProfiler {
15

  
16
	private static final Gauge datasourceByIdGauge = Gauge.build()
17
			.name("DSM_getDsById_requests_latency_seconds")
18
			.help("Request latency in seconds for invocations of the method eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.getDs()")
19
			.register();
20

  
21
	@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.getDs(..))")
22
	public Object logTimeGetDsById(final ProceedingJoinPoint joinPoint) throws Throwable {
23
		final Gauge.Timer requestTimer = datasourceByIdGauge.startTimer();
24
		try {
25
			return joinPoint.proceed();
26
		} finally {
27
			requestTimer.setDuration();
28
		}
29
	}
30

  
31
	private static final Gauge datasourceByName = Gauge.build()
32
			.name("DSM_searchDsByName_requests_latency_seconds")
33
			.help("Request latency in seconds for invocations of the method eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.searchByName()")
34
			.register();
35

  
36
	@Around("execution(* eu.dnetlib.openaire.exporter.datasource.DatasourcesApiController.searchByName(..))")
37
	public Object logTimeSearchDsByName(final ProceedingJoinPoint joinPoint) throws Throwable {
38
		final Gauge.Timer requestTimer = datasourceByName.startTimer();
39
		try {
40
			return joinPoint.proceed();
41
		} finally {
42
			requestTimer.setDuration();
43
		}
44
	}
45

  
46

  
47
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/vocabularies/Country.java
1
package eu.dnetlib.openaire.exporter.vocabularies;
2

  
3
/**
4
 * Created by claudio on 15/09/2017.
5
 */
6
public class Country {
7

  
8
	private String code;
9

  
10
	private String name;
11

  
12
	public Country() {
13
	}
14

  
15
	public Country(final String code, final String name) {
16
		this.code = code;
17
		this.name = name;
18
	}
19

  
20
	public String getCode() {
21
		return code;
22
	}
23

  
24
	public void setCode(final String code) {
25
		this.code = code;
26
	}
27

  
28
	public String getName() {
29
		return name;
30
	}
31

  
32
	public void setName(final String name) {
33
		this.name = name;
34
	}
35
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/vocabularies/Term.java
1
package eu.dnetlib.openaire.exporter.vocabularies;
2

  
3
/**
4
 * Created by claudio on 15/09/2017.
5
 */
6
public class Term {
7
	private String englishName;
8
	private String code;
9

  
10
	public Term() {
11
	}
12

  
13
	public String getEnglishName() {
14
		return englishName;
15
	}
16

  
17
	public void setEnglishName(final String englishName) {
18
		this.englishName = englishName;
19
	}
20

  
21
	public String getCode() {
22
		return code;
23
	}
24

  
25
	public void setCode(final String code) {
26
		this.code = code;
27
	}
28

  
29
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/vocabularies/Vocabulary.java
1
package eu.dnetlib.openaire.exporter.vocabularies;
2

  
3
import java.util.List;
4
import java.util.Map;
5

  
6
import com.google.common.collect.Maps;
7
import org.apache.commons.logging.Log;
8
import org.apache.commons.logging.LogFactory;
9

  
10
/**
11
 * Created by claudio on 15/09/2017.
12
 */
13
public class Vocabulary {
14

  
15
	private static final Log log = LogFactory.getLog(Vocabulary.class);
16

  
17
	private List<Term> terms;
18

  
19
	public Vocabulary() {
20
	}
21

  
22
	private static Map<String, Term> byCode = Maps.newConcurrentMap();
23

  
24
	public String getEnglishName(final String code) {
25
		if (byCode.isEmpty()) {
26
			hashByCode();
27
		}
28
		final Term term = byCode.get(code);
29
		return term != null ? term.getEnglishName() : null;
30
	}
31

  
32
	private void hashByCode() {
33
		log.info("hashing vocabulary by code ...");
34
		getTerms().forEach(term -> {
35
			byCode.put(term.getCode(), term);
36
		});
37
		log.info("hashing vocabulary by code ... done!");
38
	}
39

  
40
	public List<Term> getTerms() {
41
		return terms;
42
	}
43

  
44
	public void setTerms(final List<Term> terms) {
45
		this.terms = terms;
46
	}
47
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/AbstractExporterController.java
1
package eu.dnetlib.openaire.exporter;
2

  
3
import org.apache.commons.lang3.StringUtils;
4
import org.apache.commons.lang3.exception.ExceptionUtils;
5
import org.apache.commons.logging.Log;
6
import org.apache.commons.logging.LogFactory;
7
import org.springframework.http.HttpStatus;
8
import org.springframework.web.bind.annotation.ExceptionHandler;
9
import org.springframework.web.bind.annotation.ResponseBody;
10
import org.springframework.web.bind.annotation.ResponseStatus;
11

  
12
/**
13
 * Created by claudio on 18/07/2017.
14
 */
15
public abstract class AbstractExporterController {
16

  
17
	private static final Log log = LogFactory.getLog(AbstractExporterController.class); // NOPMD by marko on 11/24/08 5:02 PM
18

  
19
	@ResponseBody
20
	@ExceptionHandler({Exception.class, Throwable.class})
21
	@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
22
	public ErrorMessage handleSqlException(final Exception e) {
23
		log.debug(e.getMessage(), e);
24
		if (StringUtils.containsIgnoreCase(ExceptionUtils.getRootCauseMessage(e), "Broken pipe")) {
25
			return null;        //socket is closed, cannot return any response
26
		} else {
27
			return new ErrorMessage(e);
28
		}
29
	}
30

  
31
	public class ErrorMessage {
32

  
33
		private final String message;
34
		private final String stacktrace;
35

  
36
		public ErrorMessage(final Exception e) {
37
			this(e.getMessage(), ExceptionUtils.getStackTrace(e));
38
		}
39

  
40
		public ErrorMessage(final String message, final String stacktrace) {
41
			this.message = message;
42
			this.stacktrace = stacktrace;
43
		}
44

  
45
		public String getMessage() {
46
			return this.message;
47
		}
48

  
49
		public String getStacktrace() {
50
			return this.stacktrace;
51
		}
52
	}
53

  
54
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/model/project/ProjectApi.java
1
package eu.dnetlib.openaire.exporter.model.project;
2

  
3
import java.sql.Date;
4
import java.util.ArrayList;
5
import javax.persistence.Entity;
6
import javax.persistence.Id;
7
import javax.persistence.Table;
8

  
9
import com.fasterxml.jackson.annotation.JsonIgnore;
10
import com.google.common.base.Splitter;
11
import com.google.common.collect.Lists;
12
import io.swagger.annotations.ApiModel;
13
import org.apache.commons.lang3.StringUtils;
14

  
15
/**
16
 * Created by claudio on 20/09/16.
17
 */
18
@Entity
19
@Table(name = "projects_api")
20
@ApiModel(value = "Project api model", description = "Project api model used by DSpace and Eprints exporter")
21
public class ProjectApi {
22

  
23
	public static final String INFO_EU_REPO_GRANT_AGREEMENT = "info:eu-repo/grantAgreement/";
24

  
25
	@Id
26
	@JsonIgnore
27
	private String id;
28

  
29
	private String code;
30
	private String acronym;
31
	private String title;
32
	private String funder;
33
	private String jurisdiction;
34
	private Date startdate;
35
	private Date enddate;
36
	private String fundingpathid;
37

  
38
	public ProjectApi() { }
39

  
40
	public String getIdnamespace() {
41
		String res = INFO_EU_REPO_GRANT_AGREEMENT + getFunder()+"/";
42
		final String fundingProgram = asFundingProgram(getFundingpathid());
43
		if (StringUtils.isNotBlank(fundingProgram)) {
44
			res += fundingProgram;
45
		}
46
		res += "/" + escapeCode(getCode());
47
		if (StringUtils.isNotBlank(getJurisdiction())) {
48
			res += "/" + getJurisdiction();
49
		}
50
		return res;
51
	}
52

  
53
	public String getListLabel() {
54
		return String.format("for:value:component:_%s_project_id", asFunder(getFunder()));
55
	}
56

  
57
	private String asFunder(final String legalshortname) {
58
		switch (legalshortname.toLowerCase()) {
59
		case "ec":
60
			return asFundingProgram(getFundingpathid()).toLowerCase();
61
		default:
62
			return legalshortname.toLowerCase();
63
		}
64
	}
65

  
66
	private String escapeCode(final String code) {
67
		return replaceSlash(code);
68
	}
69

  
70
	private String asFundingProgram(final String fundingpathid) {
71
		final ArrayList<String> strings = Lists.newArrayList(Splitter.on("::").split(fundingpathid));
72
		if(strings.size() <= 1) throw new IllegalStateException("Unexpected funding id: "+fundingpathid);
73
		if(strings.size() == 2) return "";
74
		else return replaceSlash(strings.get(2));
75
	}
76

  
77
	private String replaceSlash(final String s) {
78
		return s.replaceAll("/", "%2F");
79
	}
80

  
81
	public String getId() {
82
		return id;
83
	}
84

  
85
	public void setId(final String id) {
86
		this.id = id;
87
	}
88

  
89
	public String getCode() {
90
		return code;
91
	}
92

  
93
	public void setCode(final String code) {
94
		this.code = code;
95
	}
96

  
97
	public String getAcronym() {
98
		return acronym;
99
	}
100

  
101
	public void setAcronym(final String acronym) {
102
		this.acronym = acronym;
103
	}
104

  
105
	public String getTitle() {
106
		return title;
107
	}
108

  
109
	public void setTitle(final String title) {
110
		this.title = title;
111
	}
112

  
113
	public String getFunder() {
114
		return funder;
115
	}
116

  
117
	public void setFunder(final String funder) {
118
		this.funder = funder;
119
	}
120

  
121
	public String getJurisdiction() {
122
		return jurisdiction;
123
	}
124

  
125
	public void setJurisdiction(final String jurisdiction) {
126
		this.jurisdiction = jurisdiction;
127
	}
128

  
129
	public Date getStartdate() {
130
		return startdate;
131
	}
132

  
133
	public void setStartdate(final Date startdate) {
134
		this.startdate = startdate;
135
	}
136

  
137
	public Date getEnddate() {
138
		return enddate;
139
	}
140

  
141
	public void setEnddate(final Date enddate) {
142
		this.enddate = enddate;
143
	}
144

  
145
	public String getFundingpathid() {
146
		return fundingpathid;
147
	}
148

  
149
	public void setFundingpathid(final String fundingpathid) {
150
		this.fundingpathid = fundingpathid;
151
	}
152
}
modules/dnet-openaire-exporter/tags/dnet-openaire-exporter-1.0.10/src/main/java/eu/dnetlib/openaire/exporter/model/project/ProjectTsv.java
1
package eu.dnetlib.openaire.exporter.model.project;
2

  
3
import java.sql.Date;
4
import java.util.List;
5
import javax.persistence.Column;
6
import javax.persistence.Entity;
7
import javax.persistence.Id;
8
import javax.persistence.Table;
9

  
10
import com.fasterxml.jackson.annotation.JsonIgnore;
11
import com.google.common.collect.Lists;
12
import io.swagger.annotations.ApiModel;
13
import org.apache.commons.lang3.StringUtils;
14

  
15
/**
16
 * Created by claudio on 05/07/2017.
17
 */
18
@Entity
19
@Table(name = "projects_tsv")
20
@ApiModel(value = "Project TSV model", description = "project TSV model description")
21
public class ProjectTsv {
22

  
23
	@Id
24
	@JsonIgnore
25
	private long rowid;
26
	private String code;
27
	private String acronym;
28
	private String title;
29
	@Column(name = "call_identifier")
30
	private String callIdentifier;
31
	private Date startdate;
32
	private Date enddate;
33
	@Column(name = "ec_sc39")
34
	private Boolean ecSc39;
35
	@Column(name = "oa_mandate_for_publications")
36
	private Boolean oaMandateForPublications;
37
	@Column(name = "oa_mandate_for_datasets")
38
	private Boolean oaMandateForDatasets;
39
	@JsonIgnore
40
	private String fundingpathid;
41
	private String description;
42
	@Column(name = "legalname")
43
	private String orgLegalname;
44
	@Column(name = "country")
45
	private String orgCountry;
46
	@Column(name = "role")
47
	private String orgRole;
48
	private String contactfullname;
49
	private String contactemail;
50

  
51
	public ProjectTsv() {}
52

  
53
	public List<String> asList() {
54
		return Lists.newArrayList(
55
				clean(getCode()),
56
				clean(getAcronym()),
57
				clean(getTitle()),
58
				clean(getCallIdentifier()),
59
				clean(getStartdate() != null ? getStartdate().toString() : ""),
60
				clean(getEnddate() != null ? getEnddate().toString() : ""),
61
				clean(String.valueOf(isOaMandateForPublications())),
62
				clean(String.valueOf(isOaMandateForDatasets())),
63
				clean(getDescription()),
64
				clean(getOrgLegalname()),
65
				clean(getOrgCountry()),
66
				clean(getOrgRole()),
67
				clean(getContactfullname()),
68
				clean(getContactemail()));
69
	}
70

  
71
	private String clean(final String s) {
72
		return StringUtils.isNotBlank(s) ? "\"" + s.replaceAll("\\n|\\t|\\s+", " ").replace("\"","\"\"").trim() + "\"" : "";
73
	}
74

  
75
	public long getRowid() {
76
		return rowid;
77
	}
78

  
79
	public void setRowid(final long rowid) {
80
		this.rowid = rowid;
81
	}
82

  
83
	public String getCode() {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff