Project

General

Profile

« Previous | Next » 

Revision 54059

[maven-release-plugin] copy for tag dnet-directindex-api-1.1.6

View differences:

modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/deploy.info
1
{"type_source": "SVN", "goal": "package -U source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-directindex-api/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", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-directindex-api"}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/java/eu/dnetlib/msro/openaireplus/api/OpenAIRESubmitterUtilsTest.java
1
package eu.dnetlib.msro.openaireplus.api;
2

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

  
6
import org.junit.Test;
7

  
8
import eu.dnetlib.openaire.directindex.api.OpenAIRESubmitterUtils;
9

  
10
/**
11
 * Created by Alessia Bardi on 26/05/2017.
12
 *
13
 * @author Alessia Bardi
14
 */
15
public class OpenAIRESubmitterUtilsTest {
16

  
17
	private OpenAIRESubmitterUtils utils = new OpenAIRESubmitterUtils();
18

  
19
	final String fullProject = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble";
20
	final String minimalProject = "info:eu-repo/grantAgreement/EC/FP7/244909///WorkAble";
21
	final String onlyId = "info:eu-repo/grantAgreement/EC/FP7/244909/";
22
	final String onlyTitle = "info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work";
23

  
24
	@Test
25
	public void testCalculateProjectInfoFull() {
26
		final Map<String, String> project = utils.calculateProjectInfo(fullProject);
27
		print(project);
28
	}
29

  
30
	@Test
31
	public void testCalculateProjectInfoOnlyId() {
32
		final Map<String, String> project = utils.calculateProjectInfo(onlyId);
33
		print(project);
34
	}
35

  
36
	@Test
37
	public void testCalculateProjectInfoMinimalAcro() {
38
		final Map<String, String> project = utils.calculateProjectInfo(minimalProject);
39
		print(project);
40
	}
41

  
42
	@Test
43
	public void testCalculateProjectInfoOnlyTitle() {
44
		final Map<String, String> project = utils.calculateProjectInfo(onlyTitle);
45
		print(project);
46
	}
47

  
48
	private void print(final Map<String, String> map) {
49
		for (final Entry e : map.entrySet()) {
50
			System.out.println(e.getKey() + " = " + e.getValue());
51
		}
52
	}
53
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/java/eu/dnetlib/msro/openaireplus/api/objects/ResultEntryTest.java
1
package eu.dnetlib.msro.openaireplus.api.objects;
2

  
3
import java.io.InputStreamReader;
4
import java.io.StringReader;
5
import java.util.ArrayList;
6
import java.util.Arrays;
7
import java.util.Properties;
8

  
9
import com.google.gson.Gson;
10
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
11
import eu.dnetlib.openaire.directindex.api.DirecIndexApiException;
12
import eu.dnetlib.openaire.directindex.objects.PidEntry;
13
import eu.dnetlib.openaire.directindex.objects.ResultEntry;
14
import org.apache.commons.lang3.StringEscapeUtils;
15
import org.apache.velocity.app.VelocityEngine;
16
import org.dom4j.Document;
17
import org.dom4j.io.OutputFormat;
18
import org.dom4j.io.SAXReader;
19
import org.dom4j.io.XMLWriter;
20
import org.junit.Before;
21
import org.junit.Test;
22
import org.junit.runner.RunWith;
23
import org.mockito.Mock;
24
import org.mockito.runners.MockitoJUnitRunner;
25

  
26
import static org.mockito.Matchers.anyString;
27
import static org.mockito.Mockito.when;
28

  
29
/**
30
 * Created by michele on 14/12/15.
31
 */
32
@RunWith(MockitoJUnitRunner.class)
33
public class ResultEntryTest {
34

  
35
	private VelocityEngine ve;
36

  
37
	@Mock
38
	private ISLookUpService lookUpService;
39

  
40
	@Before
41
	public void setUp() throws Exception {
42

  
43
		final Properties props = new Properties();
44
		props.setProperty("resource.loader", "class");
45
		props.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
46
		props.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.Log4JLogChute");
47
		ve = new VelocityEngine();
48
		ve.init(props);
49

  
50
		when(lookUpService.quickSearchProfile(anyString())).thenAnswer(invocation -> {
51
			final String query = invocation.getArguments()[0].toString();
52
			if (query.contains("dnet:result_typologies")) {
53
				return Arrays.asList("publication @@@ publication", "dataset @@@ dataset", "software @@@ software", "other @@@ other");
54
			} else if (query.contains("dnet:access_modes")) {
55
				return Arrays.asList("OPEN @@@ Open Access");
56
			} else if (query.contains("dnet:publication_resource")) {
57
				return Arrays.asList("0001 @@@ Journal Article");
58
			} else if (query.contains("dnet:pid_types")) {
59
				return Arrays.asList("oai @@@ Open Archive Initiative", "doi @@@ Digital object identifier");
60
			} else if (query.contains("dnet:languages")) {
61
				return Arrays.asList("ita @@@ Italian");
62
			} else if (query.contains("ContextDSResourceType")) {
63
				return Arrays.asList(
64
						"egi::classification::natsc::math::stats @@@ Statistics and Probability",
65
						"egi::classification::natsc::math::pure @@@ Pure Mathematics",
66
						"egi::classification::natsc::math @@@ Mathematics",
67
						"egi::classification::natsc @@@ Natural Sciences",
68
						"egi::classification @@@ EGI classification scheme",
69
						"egi @@@ EGI");
70
			} else {
71
				return new ArrayList<String>();
72
			}
73
		});
74

  
75
		when(lookUpService.getResourceProfileByQuery(anyString())).thenAnswer(invocation -> "REPO NAME @@@ repo________");
76
	}
77

  
78
	@Test
79
	public void testAsIndexRecord() throws Exception {
80
		final ResultEntry pub = new ResultEntry();
81
		pub.setOriginalId("ORIG_ID_1234");
82
		pub.setTitle("TEST TITLE <test>");
83
		pub.getAuthors().add("Michele Artini");
84
		pub.getAuthors().add("Claudio Atzori");
85
		pub.getAuthors().add("Alessia Bardi");
86
		pub.setPublisher("Test publisher");
87
		pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION ");
88
		pub.setLanguage("ita");
89
		pub.setLicenseCode("OPEN");
90
		pub.setResourceType("0001");
91
		pub.setUrl("http://test.it/a=1&b=2");
92
		pub.getPids().add(new PidEntry("doi", "10.000/xyz-123"));
93
		pub.getPids().add(new PidEntry("oai", "oai:1234"));
94
		pub.setCollectedFromId("test________::zenodo");
95
		pub.setHostedById("test________::UNKNOWN");
96
		pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus");
97
		pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble");
98
		pub.getContexts().add("egi::classification::natsc::math::pure");
99
		pub.getContexts().add("egi::classification::natsc::math::stats");
100
		final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd");
101

  
102
		final Document doc = new SAXReader().read(new StringReader(xml));
103

  
104
		final OutputFormat format = OutputFormat.createPrettyPrint();
105

  
106
		final XMLWriter writer = new XMLWriter(System.out, format);
107

  
108
		writer.write(doc);
109

  
110
		/* writer.close(); */
111

  
112
	}
113

  
114
	@Test
115
	public void testAsIndexRecordAccessRight() throws Exception {
116
		final ResultEntry pub = new ResultEntry();
117
		pub.setOriginalId("ORIG_ID_1234");
118
		pub.setTitle("TEST TITLE <test>");
119
		pub.getAuthors().add("Michele Artini");
120
		pub.getAuthors().add("Claudio Atzori");
121
		pub.getAuthors().add("Alessia Bardi");
122
		pub.setPublisher("Test publisher");
123
		pub.setDescription("DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION & DESCRIPTION ");
124
		pub.setLanguage("ita");
125
		pub.setLicenseCode("CLOSED");
126
		pub.setAccessRightCode("OPEN");
127
		pub.setResourceType("0001");
128
		pub.setUrl("http://test.it/a=1&b=2");
129
		pub.getPids().add(new PidEntry("doi", "10.000/xyz-123"));
130
		pub.getPids().add(new PidEntry("oai", "oai:1234"));
131
		pub.setCollectedFromId("test________::zenodo");
132
		pub.setHostedById("test________::UNKNOWN");
133
		pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus");
134
		pub.getLinksToProjects().add("info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble");
135
		pub.getContexts().add("egi::classification::natsc::math::pure");
136
		pub.getContexts().add("egi::classification::natsc::math::stats");
137
		final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd");
138

  
139
		final Document doc = new SAXReader().read(new StringReader(xml));
140

  
141
		final OutputFormat format = OutputFormat.createPrettyPrint();
142

  
143
		final XMLWriter writer = new XMLWriter(System.out, format);
144

  
145
		writer.write(doc);
146

  
147
		/* writer.close(); */
148

  
149
	}
150

  
151

  
152
	@Test
153
	public void testAsIndexRecord_json() throws Exception {
154
		testAsIndexRecord_json("test_record.json");
155

  
156
	}
157

  
158
	@Test
159
	public void testAsIndexRecord_json_with_greek_chars() throws Exception {
160

  
161
		testAsIndexRecord_json("test_record_with_greek_chars.json");
162

  
163
	}
164

  
165
	@Test
166
	public void testAsIndexRecord_openaireId() throws Exception {
167

  
168
		testAsIndexRecord_json("test_record_openaireId.json");
169

  
170
	}
171

  
172
	@Test(expected = DirecIndexApiException.class)
173
	public void testAsIndexRecord_wrongOpenaireId() throws Exception {
174

  
175
		testAsIndexRecord_json("test_record_wrong_openaireId.json");
176

  
177
	}
178

  
179
	@Test
180
	public void testAsIndexRecord_json_zenodo() throws Exception {
181

  
182
		testAsIndexRecord_json("test_zenodo.json");
183

  
184
	}
185

  
186
	@Test
187
	public void testAsIndexRecord_json_zenodoWithAmpersand() throws Exception {
188

  
189
		testAsIndexRecord_json("test_zenodoAmpersandEverywhere.json");
190

  
191
	}
192

  
193
	@Test
194
	public void testAsIndexRecord_json_software() throws Exception {
195

  
196
		testAsIndexRecord_json("test_record_software.json");
197

  
198
	}
199

  
200
	@Test
201
	public void testAsIndexRecord_json_orp() throws Exception {
202

  
203
		testAsIndexRecord_json("test_record_orp.json");
204

  
205
	}
206

  
207
	private void testAsIndexRecord_json(final String filename) throws Exception {
208
		final ResultEntry pub =
209
				new Gson().fromJson(new InputStreamReader(getClass().getResourceAsStream(filename)), ResultEntry.class);
210

  
211
		final String xml = pub.asOafRecord(ve, lookUpService, "http://oaf/oaf.xsd");
212
		System.out.println(xml);
213

  
214
		final Document doc = new SAXReader().read(new StringReader(xml));
215

  
216
		final OutputFormat format = OutputFormat.createPrettyPrint();
217

  
218
		final XMLWriter writer = new XMLWriter(System.out, format);
219

  
220
		writer.write(doc);
221

  
222
		/* writer.close(); */
223
	}
224

  
225
	@Test
226
	public void testEscapeUnicode() {
227
		final String unicodeTxt =
228
				"i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$";
229
		System.out.println(StringEscapeUtils.escapeXml11(unicodeTxt));
230
	}
231

  
232
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_software.json
1
{
2
  "openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982951",
3
  "originalId": "oai:rudar.ruc.dk:1800/24691",
4
  "type": "software",
5
  "title": "Software test",
6
  "authors": [
7
	"Sloan, Patrick Alexander Raaby",
8
	"Strange, Gustav Valdemar"
9
  ],
10
  "publisher": "",
11
  "description": "This is for testing software",
12
  "language": "eng",
13
  "pids": [],
14
  "licenseCode": "OPEN SOURCE",
15
  "resourceType": "0000",
16
  "url": "http://rudar.ruc.dk/handle/1800/24691",
17
  "collectedFromId": "opendoar____::278",
18
  "hostedById": "opendoar____::278",
19
  "linksToProjects": [],
20
  "contexts": []
21
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_wrong_openaireId.json
1
{
2
  "openaireId":"dedup_wf_001::ab42e811",
3
  "originalId": "ORIG_ID_TEST",
4
  "type": "publication",
5
  "title": "TEST TITLE",
6
  "authors": [
7
	"Michele Artini",
8
	"Claudio Atzori",
9
	"Alessia Bardi"
10
  ],
11
  "publisher": "Test publisher",
12
  "description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
13
  "language": "ita",
14
  "pids": [
15
	{
16
	  "type": "doi",
17
	  "value": "10.000/xyz-123"
18
	},
19
	{
20
	  "type": "oai",
21
	  "value": "oai:1234"
22
	}
23
  ],
24
  "licenseCode": "EMBARGO",
25
  "embargoEndDate": "2018-02-02",
26
  "resourceType": "0001",
27
  "url": "http://test.it/xyz",
28
  "collectedFromId": "opendoar____::2659",
29
  "hostedById": "opendoar____::2659",
30
  "linksToProjects": [
31
	"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
32
	"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
33
  ],
34
  "contexts": [
35
	"egi::classification::natsc::math::pure",
36
	"egi::classification::natsc::math::stats"
37
  ]
38
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_openaireId.json
1
{
2
  "openaireId":"dedup_wf_001::ab42e8116f4ae3c4021fb7c643a8167a",
3
  "originalId": "ORIG_ID_TEST",
4
  "type": "publication",
5
  "title": "TEST TITLE",
6
  "authors": [
7
	"Michele Artini",
8
	"Claudio Atzori",
9
	"Alessia Bardi"
10
  ],
11
  "publisher": "Test publisher",
12
  "description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
13
  "language": "ita",
14
  "pids": [
15
	{
16
	  "type": "doi",
17
	  "value": "10.000/xyz-123"
18
	},
19
	{
20
	  "type": "oai",
21
	  "value": "oai:1234"
22
	}
23
  ],
24
  "accessRightCode": "EMBARGO",
25
  "licenseCode": "OPEN",
26
  "embargoEndDate": "2018-02-02",
27
  "resourceType": "0001",
28
  "url": "http://test.it/xyz",
29
  "collectedFromId": "opendoar____::2659",
30
  "hostedById": "opendoar____::2659",
31
  "linksToProjects": [
32
	"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
33
	"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
34
  ],
35
  "contexts": [
36
	"egi::classification::natsc::math::pure",
37
	"egi::classification::natsc::math::stats"
38
  ]
39
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record.json
1
{
2
  "originalId": "ORIG_ID_12345",
3
  "title": "TEST TITLE",
4
  "authors": [
5
	"Michele Artini",
6
	"Claudio Atzori",
7
	"Alessia Bardi"
8
  ],
9
  "publisher": "Test publisher",
10
  "description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
11
  "language": "ita",
12
  "pids": [
13
	{
14
	  "type": "doi",
15
	  "value": "10.000/xyz-123"
16
	},
17
	{
18
	  "type": "oai",
19
	  "value": "oai:1234"
20
	}
21
  ],
22
  "accessRightCode": "OPEN",
23
  "resourceType": "0001",
24
  "url": "http://test.it/xyz",
25
  "collectedFromId": "opendoar____::2659",
26
  "hostedById": "opendoar____::2367",
27
  "linksToProjects": [
28
	"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
29
	"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
30
  ],
31
  "contexts": [
32
	"egi::classification::natsc::math::pure",
33
	"egi::classification::natsc::math::stats"
34
  ]
35
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_orp.json
1
{
2
  "openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982951",
3
  "originalId": "oai:rudar.ruc.dk:1800/24691",
4
  "type": "other",
5
  "title": "Other test record",
6
  "authors": [
7
    "Sloan, Patrick Alexander Raaby",
8
    "Strange, Gustav Valdemar"
9
  ],
10
  "publisher": "",
11
  "description": "This is for testing software",
12
  "language": "eng",
13
  "pids": [],
14
  "licenseCode": "OPEN SOURCE",
15
  "resourceType": "0000",
16
  "url": "http://rudar.ruc.dk/handle/1800/24691",
17
  "collectedFromId": "opendoar____::278",
18
  "hostedById": "opendoar____::278",
19
  "linksToProjects": [],
20
  "contexts": []
21
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodo.json
1
{
2
  "authors":[
3
	"Alouges, Fran\u00e7ois",
4
	"Di Fratta, Giovanni"
5
  ],
6
  "collectedFromId":"opendoar____::2659",
7
  "description":"The paper is about the parking 3-sphere swimmer ($\\text{sPr}_3$). This is a low-Reynolds number model swimmer composed of three balls of equal radii. The three balls can move along three horizontal axes (supported in the same plane) that mutually meet at the center of $\\text{sPr}_3$ with angles of $120^{\u2218}$ . The governing dynamical system is introduced and the implications of its geometric symmetries revealed. It is then shown that, in the first order range of small strokes, optimal periodic strokes are ellipses embedded in 3d space, i.e. closed curves of the form $t\ud835\udfc4 [0,2\u03c0] \u21a6 (\\cos t)u + (\\sin t)v$ for suitable orthogonal vectors $u$ and $v$ of $\u211d^3$. A simple analytic expression for the vectors $u$ and $v$ is derived. The results of the paper are used in a second article where the real physical dynamics of $\\text{sPr}_3$ is analyzed in the asymptotic range of very long arms. ; Comment: 17 pages, 4 figures",
8
  "hostedById":"opendoar____::2659",
9
  "licenseCode":"OPEN",
10
  "originalId":"oai:zenodo.org:996201",
11
  "pids":[
12
	{
13
	  "type":"oai",
14
	  "value":"oai:zenodo.org:996201"
15
	},
16
	{
17
	  "type":"doi",
18
	  "value":"10.5281/zenodo.996201"
19
	}
20
  ],
21
  "publisher":"Zenodo",
22
  "resourceType":"0020",
23
  "title":"Parking 3-sphere swimmer. I. Energy minimizing strokes",
24
  "type":"publication",
25
  "url":"https://zenodo.org/record/996201"
26
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_zenodoAmpersandEverywhere.json
1
{
2
  "authors": [
3
	"Conradt, Tobias",
4
	"& members of the ISIMIP project (original data provision), cf. Hempel et al. 2013, https://doi.org/10.5194/esd-4-219-2013"
5
  ],
6
  "collectedFromId": "re3data_____::r3d100010468",
7
  "description": "<p>ISIMIP-2a climate data cutout provided for Sardinia in the framework of SIM4NEXUS & X<\/p>",
8
  "hostedById": "re3data_____::r3d100010468",
9
  "licenseCode": "OPEN",
10
  "linksToProjects": ["info:eu-repo/grantAgreement/EC/H2020/689150//Sustainable Integrated Management FOR the NEXUS of water-land-food-energy-climate for a resource-efficient Europe & beyond/SIM4NEXUS"],
11
  "originalId": "10.5281/zenodo.1460665",
12
  "pids": [
13
	{
14
	  "type": "oai",
15
	  "value": "oai:zenodo.org:1460665"
16
	},
17
	{
18
	  "type": "doi",
19
	  "value": "10.5281/zenodo.1460665"
20
	}
21
  ],
22
  "publisher": "Zenodo & Zenodo",
23
  "resourceType": "0021",
24
  "title": "sardinia_tasmax_MIROC-ESM-CHEM_rcp4p5_2006-2099_daily.nc4 & the title has && in it",
25
  "type": "dataset",
26
  "url": "https://zenodo.org/record/1460665"
27
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_ariadne.json
1
{
2
  "openaireId":"od_______278::d5b39693ac6c2197e8cf48008a982950",
3
  "originalId": "oai:rudar.ruc.dk:1800/24690",
4
  "type": "publication",
5
  "title": "Autofiktion",
6
  "authors": [
7
	"Sloan, Patrick Alexander Raaby",
8
	"Strange, Gustav Valdemar",
9
	"Freund-Jensen, Sofie",
10
	"Canvin, Emilie Meistrup",
11
	"Faaborg, Ida Selvejer",
12
	"Kruse, Mikkel"
13
  ],
14
  "publisher": "",
15
  "description": "The following paper is a project on the autofictional book Færdig med Eddy Bellegueule by Édouard Louis (2015). The main focus is to ascertain how the novel is an expression of the author’s effort to connect social life and literature, and what part autofiction as a genre plays in this process. A textual analysis will describe the narrator’s position, and the aesthetic grip of the novel. Furthermore, we will analyze the central themes in Louis’ novel with theories by sociologist Pierre Bourdieu, gender theorist Judith Butler and postcolonial theorist Gayatri Spivak. This includes symbolic violence, gender roles, language and suppression. With use of classic literary theory and the more recent and specific theory on autofiction, the paper concludes, that Færdig med Eddy Bellegueule is based on non-fictional events, but presents these events through a fictionalization that raise the story into a literary work of art. The genre autofiction encircles a current tendency to blend non-fictional events and characters into literature, and Færdig med Eddy Bellegueule writes itself perfectly into this twilight zone between fact and fiction.",
16
  "language": "eng",
17
  "pids": [],
18
  "licenseCode": "OPEN",
19
  "resourceType": "0006",
20
  "url": "http://rudar.ruc.dk/handle/1800/24690",
21
  "collectedFromId": "opendoar____::278",
22
  "hostedById": "opendoar____::278",
23
  "linksToProjects": [],
24
  "contexts": []
25
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/submit_test_record.sh
1
#!/bin/bash
2

  
3
curl -H "Content-Type: application/json" --data @test_record.json "http://localhost:8280/app/mvc/api/publications/feedObject"
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_complete.json
1
{
2
  "originalId": "ORIG_ID_TEST",
3
  "type": "publication",
4
  "title": "TEST TITLE",
5
  "authors": [
6
	"Michele Artini",
7
	"Claudio Atzori",
8
	"Alessia Bardi"
9
  ],
10
  "publisher": "Test publisher",
11
  "description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
12
  "language": "ita",
13
  "pids": [
14
	{
15
	  "type": "doi",
16
	  "value": "10.000/xyz-123"
17
	},
18
	{
19
	  "type": "oai",
20
	  "value": "oai:1234"
21
	}
22
  ],
23
  "accessRightCode": "EMBARGO",
24
  "embargoEndDate": "2018-02-02",
25
  "resourceType": "0001",
26
  "url": "http://test.it/xyz",
27
  "collectedFromId": "opendoar____::2659",
28
  "hostedById": "opendoar____::2659",
29
  "linksToProjects": [
30
	"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
31
	"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
32
  ],
33
  "contexts": [
34
	"egi::classification::natsc::math::pure",
35
	"egi::classification::natsc::math::stats"
36
  ]
37
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/eu/dnetlib/msro/openaireplus/api/objects/test_record_with_greek_chars.json
1
{
2
  "originalId": "ORIG_ID_12345",
3
  "title": "TEST TITLE WITH Greek Characters",
4
  "authors": [
5
	"αβγδεζηθικλμ νξοπρσςτυφχψω",
6
	"ΑΒΓΔΕΖΗΘΙΚΛ ΜΝΞΟΠΡΣΤΥΦΧΨΩ"
7
  ],
8
  "publisher": "âââââââ",
9
  "description": "Αν περιμένατε να βρίσκεται εδώ μια σελίδα και δεν υπάρχει, η σελίδα μπορεί να μην εμφανίζεται λόγω καθυστέρησης στην ανανέωση της βάσης δεδομένων, ή μπορεί να έχει διαγραφεί. (Δείτε την γρήγορη διαγραφή σελίδων για πιθανούς λόγους). Μπορείτε να δοκιμάστε την λειτουργία εκκαθάρισης, και να ελέγξετε το αρχείο διαγραφών.",
10
  "language": "ell",
11
  "pids": [
12
	{
13
	  "type": "doi",
14
	  "value": "10.000/xyz-123-gr"
15
	}
16
  ],
17
  "licenseCode": "EMBARGO",
18
  "embargoEndDate": "2018-02-02",
19
  "resourceType": "0001",
20
  "url": "http://test.it/xyz",
21
  "collectedFromId": "opendoar____::2659",
22
  "hostedById": "opendoar____::2367",
23
  "linksToProjects": [
24
	"info:eu-repo/grantAgreement/EC/FP7/123456/EU//Test"
25
  ],
26
  "contexts": [
27
	"egi::classification::natsc::math::stats"
28
  ]
29
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/test/resources/log4j.properties
1
### Root Level ###
2
log4j.rootLogger=WARN, CONSOLE
3
### Configuration for the CONSOLE appender ###
4
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
5
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
6
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d %c - %m%n
7
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
8
### Application Level ###
9
log4j.logger.eu.dnetlib=INFO
10
log4j.logger.eu.dnetlib.msro.openaireplus.workflows.nodes.contexts=DEBUG
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/main/java/eu/dnetlib/openaire/directindex/utils/OafToIndexRecordFactory.java
1
package eu.dnetlib.openaire.directindex.utils;
2

  
3
import java.io.IOException;
4
import java.io.StringReader;
5
import java.io.StringWriter;
6
import javax.annotation.Resource;
7
import javax.xml.transform.Transformer;
8
import javax.xml.transform.TransformerException;
9
import javax.xml.transform.TransformerFactory;
10
import javax.xml.transform.stream.StreamResult;
11
import javax.xml.transform.stream.StreamSource;
12

  
13
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
14
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
15
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
16
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
17
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
18
import org.apache.commons.io.IOUtils;
19
import org.springframework.beans.factory.annotation.Required;
20
import org.springframework.core.io.ClassPathResource;
21

  
22
/**
23
 * Created by michele on 15/12/15.
24
 */
25
public class OafToIndexRecordFactory {
26

  
27
	private ClassPathResource layoutToRecord;
28

  
29
	@Resource
30
	private UniqueServiceLocator serviceLocator;
31

  
32
	public ApplyXslt newTransformer(final String format) throws ISLookUpException, IOException, TransformerException {
33
		final TransformerFactory factory = TransformerFactory.newInstance();
34
		final Transformer layoutTransformer = factory.newTransformer(readLayoutToRecord());
35

  
36
		final StreamResult layoutToXsltXslt = new StreamResult(new StringWriter());
37

  
38
		layoutTransformer.setParameter("format", format);
39
		layoutTransformer.transform(new StreamSource(new StringReader(getLayoutSource(format))), layoutToXsltXslt);
40

  
41
		return new ApplyXslt(layoutToXsltXslt.getWriter().toString());
42
	}
43

  
44
	private StreamSource readLayoutToRecord() throws IOException {
45
		return new StreamSource(new StringReader(IOUtils.toString(layoutToRecord.getInputStream())));
46
	}
47

  
48
	private String getLayoutSource(final String format) throws ISLookUpDocumentNotFoundException, ISLookUpException {
49
		return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(
50
				"collection('/db/DRIVER/MDFormatDSResources/MDFormatDSResourceType')[.//NAME='" + format + "']//LAYOUT[@name='index']");
51
	}
52

  
53
	public ClassPathResource getLayoutToRecord() {
54
		return layoutToRecord;
55
	}
56

  
57
	@Required
58
	public void setLayoutToRecord(final ClassPathResource layoutToRecord) {
59
		this.layoutToRecord = layoutToRecord;
60
	}
61

  
62
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/main/java/eu/dnetlib/openaire/directindex/api/OpenaireResultSubmitter.java
1
package eu.dnetlib.openaire.directindex.api;
2

  
3
import com.google.common.collect.Lists;
4
import com.google.common.collect.Maps;
5
import com.google.gson.Gson;
6
import eu.dnetlib.common.rmi.DNetRestDocumentation;
7
import eu.dnetlib.data.index.CloudIndexClient;
8
import eu.dnetlib.data.index.CloudIndexClientException;
9
import eu.dnetlib.data.index.CloudIndexClientFactory;
10
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
11
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
12
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
13
import eu.dnetlib.openaire.directindex.objects.ResultEntry;
14
import eu.dnetlib.openaire.directindex.utils.OafToIndexRecordFactory;
15
import org.apache.commons.io.IOUtils;
16
import org.apache.commons.lang.exception.ExceptionUtils;
17
import org.apache.commons.logging.Log;
18
import org.apache.commons.logging.LogFactory;
19
import org.apache.velocity.app.VelocityEngine;
20
import org.springframework.beans.factory.annotation.Value;
21
import org.springframework.core.io.ClassPathResource;
22
import org.springframework.http.HttpStatus;
23
import org.springframework.stereotype.Controller;
24
import org.springframework.web.bind.annotation.*;
25

  
26
import javax.annotation.Resource;
27
import java.io.IOException;
28
import java.util.List;
29
import java.util.Map;
30
import java.util.concurrent.*;
31

  
32
/**
33
 * Created by michele on 11/11/15.
34
 */
35
@Controller
36
@DNetRestDocumentation
37
public class OpenaireResultSubmitter {
38

  
39
	private static final Log log = LogFactory.getLog(OpenaireResultSubmitter.class);
40

  
41
	public class IndexDsInfo {
42

  
43
		private final String indexBaseUrl;
44
		private final String indexDsId;
45
		private final String format;
46
		private final String coll;
47

  
48
		public IndexDsInfo(final String indexBaseUrl, final String indexDsId, final String format, final String coll) {
49
			this.indexBaseUrl = indexBaseUrl;
50
			this.indexDsId = indexDsId;
51
			this.format = format;
52
			this.coll = coll;
53
		}
54

  
55
		public String getIndexBaseUrl() {
56
			return indexBaseUrl;
57
		}
58

  
59
		public String getIndexDsId() {
60
			return indexDsId;
61
		}
62

  
63
		public String getFormat() {
64
			return format;
65
		}
66

  
67
		public String getColl() {
68
			return coll;
69
		}
70

  
71
	}
72

  
73
	@Value(value = "oaf.schema.location")
74
	private String oafSchemaLocation;
75

  
76
	@Resource
77
	private UniqueServiceLocator serviceLocator;
78

  
79
	@Resource
80
	private OafToIndexRecordFactory oafToIndexRecordFactory;
81

  
82
	@Resource
83
	private RecentResultsQueue recentResultsQueue;
84

  
85
	@Resource(name = "openaireplusApisVelocityEngine")
86
	private VelocityEngine velocityEngine;
87

  
88
	@Value(value = "${openaire.api.directindex.findSolrIndexUrl.xquery}")
89
	private ClassPathResource findSolrIndexUrl;
90

  
91
	@Value(value = "${openaire.api.directindex.findIndexDsInfo.xquery}")
92
	private ClassPathResource findIndexDsInfo;
93

  
94
	private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
95

  
96
	@Value(value = "${openaire.api.directindex.autocommit.active}")
97
	private boolean autocommitactive;
98

  
99
	@Value(value = "${openaire.api.directindex.autocommit.frequency}")
100
	private long commitfrquency = 60;
101

  
102
	private ScheduledFuture task = null;
103

  
104
	public OpenaireResultSubmitter() {
105

  
106
		updateSchedule();
107
	}
108

  
109
	private void updateSchedule() {
110

  
111
		if (task != null) {
112
			task.cancel(true);
113
		}
114
		task = executor.scheduleAtFixedRate(doCommit(), 0, getCommitfrquency(), TimeUnit.SECONDS);
115
	}
116

  
117
	private Runnable doCommit() {
118
		return () -> {
119

  
120
			//TODO perform the commit only if there are pending documents, e.g. query /solr/admin/metrics?group=core&prefix=UPDATE.updateHandler to inspect if there are any.
121
			if (isAutocommitactive()) {
122
				try {
123
					for (Map.Entry<IndexDsInfo, CloudIndexClient> e : getClients().entrySet()) {
124
						final IndexDsInfo i = e.getKey();
125
						try(final CloudIndexClient client = e.getValue()) {
126

  
127
							log.info("performing commit on " + i.getColl());
128
							client.commit();
129
						}
130
					}
131
				} catch (DirecIndexApiException | CloudIndexClientException | IOException e) {
132

  
133
					//TODO perhaps we could send an email to notify this failure.
134
					throw new RuntimeException(e);
135

  
136
				}
137
			}
138
		};
139
	}
140

  
141

  
142
	@RequestMapping(value = { "/api/admin/autocommit/active" }, method = RequestMethod.GET)
143
	public @ResponseBody Boolean getAutocommit() throws DirecIndexApiException {
144
		return isAutocommitactive();
145
	}
146

  
147
	@RequestMapping(value = { "/api/admin/autocommit/active" }, method = RequestMethod.POST)
148
	public @ResponseBody Boolean setAutocommit(@RequestParam(value = "active", required = true) final Boolean active) throws DirecIndexApiException {
149
		setAutocommitactive(active);
150
		log.info(String.format("automatic commit, active '%s', frequency '%s'", isAutocommitactive(), getCommitfrquency()));
151
		return isAutocommitactive();
152
	}
153

  
154
	@RequestMapping(value = { "/api/admin/autocommit/frequency" }, method = RequestMethod.GET)
155
	public @ResponseBody long getAutocommitFrequency() throws DirecIndexApiException {
156
		return getCommitfrquency();
157
	}
158

  
159
	@RequestMapping(value = { "/api/admin/autocommit/frequency" }, method = RequestMethod.POST)
160
	public @ResponseBody long setAutocommitFrequency(@RequestParam(value = "frequency", required = true) final Integer frequency) throws DirecIndexApiException {
161
		setCommitfrquency(frequency);
162
		log.info(String.format("automatic commit, active '%s', frequency '%s'", isAutocommitactive(), getCommitfrquency()));
163
		return getCommitfrquency();
164
	}
165

  
166
	@Deprecated
167
	@RequestMapping(value = { "/api/publications/feedJson", "/api/results/feedJson" }, method = RequestMethod.POST)
168
	public @ResponseBody String feedObjectJson(@RequestParam(value = "json", required = true) final String json,
169
			@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirecIndexApiException {
170
		final ResultEntry pub = new Gson().fromJson(json, ResultEntry.class);
171
		return feedObject(pub, commit);
172
	}
173

  
174
	@RequestMapping(value = { "/api/results/feedObject" }, method = RequestMethod.POST)
175
	public @ResponseBody String feedResult(@RequestBody final ResultEntry pub,
176
			@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit)
177
			throws DirecIndexApiException {
178
		return feed(pub, commit);
179
	}
180

  
181
	@Deprecated
182
	@RequestMapping(value = { "/api/publications/feedObject" }, method = RequestMethod.POST)
183
	public @ResponseBody String feedObject(@RequestBody final ResultEntry pub,
184
			@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit)
185
			throws DirecIndexApiException {
186
		return feed(pub, commit);
187
	}
188

  
189

  
190
	@RequestMapping(value = "/api/result/{openaireId}", method = RequestMethod.DELETE)
191
	public @ResponseBody boolean deleteResultWithOpenaireId(
192
			@PathVariable(value = "openaireId") final String openaireId,
193
			@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws DirecIndexApiException {
194

  
195
		return deleteResult(openaireId, commit);
196
	}
197

  
198
	@RequestMapping(value = "/api/results", method = RequestMethod.DELETE)
199
	public @ResponseBody boolean deleteResultWithOriginalId(
200
			@RequestParam(value = "originalId", required = true) final String originalId,
201
			@RequestParam(value = "collectedFromId", required = true) final String collectedFromId,
202
			@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception {
203

  
204
		final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class));
205
		return deleteResult(openaireId, commit);
206
	}
207

  
208
	@Deprecated
209
	@RequestMapping(value = { "/api/publications/deleteObject", "/api/results/delete" }, method = RequestMethod.POST)
210
	public @ResponseBody boolean deleteResultPost(
211
			@RequestParam(value = "originalId", required = true) final String originalId,
212
			@RequestParam(value = "collectedFromId", required = true) final String collectedFromId,
213
			@RequestParam(value = "commit", required = false, defaultValue = "true") final boolean commit) throws Exception {
214

  
215
		final String openaireId = ResultEntry.calculateOpenaireId(originalId, collectedFromId, serviceLocator.getService(ISLookUpService.class));
216
		return deleteResult(openaireId, commit);
217
	}
218

  
219
	@Deprecated
220
	private String feed(final ResultEntry pub, final boolean commit) throws DirecIndexApiException {
221
		return feed(pub);
222
	}
223

  
224
	private String feed(final ResultEntry pub) throws DirecIndexApiException {
225
		try {
226
			final String oafRecord = pub.asOafRecord(velocityEngine, serviceLocator.getService(ISLookUpService.class), oafSchemaLocation);
227

  
228
			for(Map.Entry<IndexDsInfo, CloudIndexClient> e : getClients().entrySet()) {
229
				final IndexDsInfo idx = e.getKey();
230
				final CloudIndexClient client = e.getValue();
231
				client.feed(oafRecord, idx.getIndexDsId(), oafToIndexRecordFactory.newTransformer(idx.getFormat()), false);
232
				client.close();
233
			}
234

  
235
			recentResultsQueue.add(oafRecord);
236

  
237
			return pub.getOpenaireId();
238
		} catch (final Throwable e) {
239
			log.error("Error saving record", e);
240
			log.debug(pub.toString());
241
			throw new DirecIndexApiException("Error adding publication: " + e.getMessage(), e);
242
		}
243
	}
244

  
245
	private boolean deleteResult(final String openaireId, final boolean commit) throws DirecIndexApiException {
246
		try {
247
			for(Map.Entry<IndexDsInfo, CloudIndexClient> e : getClients().entrySet()) {
248
				final IndexDsInfo idx = e.getKey();
249
				final CloudIndexClient client = e.getValue();
250
				client.remove(openaireId, false);
251
				log.info("Deleted result with id: " + openaireId + " from: " + idx.getIndexBaseUrl());
252
				client.close();
253
			}
254

  
255
			recentResultsQueue.remove(openaireId);
256
			return true;
257
		} catch (Throwable e) {
258
			throw new DirecIndexApiException("Error deleting publication: " + e.getMessage(), e);
259
		}
260
	}
261

  
262
	private Map<IndexDsInfo, CloudIndexClient> getClients() throws DirecIndexApiException {
263
		try {
264
			final List<IndexDsInfo> idxList = calculateCurrentIndexDsInfo();
265

  
266
			if (idxList == null || idxList.isEmpty()) {
267
				throw new DirecIndexApiException("Cannot commit index: no public Search Service found");
268
			}
269
			if (idxList.size() > 1) {
270
				log.warn("Found more than 1 public search service");
271
			}
272

  
273
			final Map<IndexDsInfo, CloudIndexClient> clients = Maps.newHashMap();
274
			for(IndexDsInfo i : idxList) {
275
				clients.put(i, CloudIndexClientFactory.newIndexClient(i.getIndexBaseUrl(), i.getColl(), false));
276
			}
277
			return clients;
278

  
279
		} catch (IOException | ISLookUpException | CloudIndexClientException e) {
280
			throw new DirecIndexApiException(e);
281
		}
282
	}
283

  
284
	private List<IndexDsInfo> calculateCurrentIndexDsInfo() throws IOException, ISLookUpException {
285
		final List<IndexDsInfo> list = Lists.newArrayList();
286

  
287
		final String queryUrl = IOUtils.toString(findSolrIndexUrl.getInputStream());
288
		final String queryDs = IOUtils.toString(findIndexDsInfo.getInputStream());
289

  
290
		final ISLookUpService lu = serviceLocator.getService(ISLookUpService.class);
291
		final String indexBaseUrl = lu.getResourceProfileByQuery(queryUrl);
292

  
293
		final List<String> idxDs = lu.quickSearchProfile(queryDs);
294
		for (final String idx : idxDs) {
295
			final String[] arr = idx.split("@@@");
296
			list.add(new IndexDsInfo(indexBaseUrl, arr[0].trim(), arr[1].trim(), arr[2].trim()));
297
		}
298
		return list;
299
	}
300

  
301
	@ExceptionHandler(Exception.class)
302
	@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
303
	public @ResponseBody ErrorMessage handleException(final Exception e) {
304
		log.error("Error in direct index API", e);
305
		return new ErrorMessage(e);
306
	}
307

  
308
	public class ErrorMessage {
309

  
310
		private final String message;
311
		private final String stacktrace;
312

  
313
		public ErrorMessage(final Exception e) {
314
			this(e.getMessage(), ExceptionUtils.getStackTrace(e));
315
		}
316

  
317
		public ErrorMessage(final String message, final String stacktrace) {
318
			this.message = message;
319
			this.stacktrace = stacktrace;
320
		}
321

  
322
		public String getMessage() {
323
			return this.message;
324
		}
325

  
326
		public String getStacktrace() {
327
			return this.stacktrace;
328
		}
329

  
330
	}
331

  
332
	public boolean isAutocommitactive() {
333
		return autocommitactive;
334
	}
335

  
336
	public synchronized void setAutocommitactive(boolean autocommitactive) {
337
		this.autocommitactive = autocommitactive;
338
	}
339

  
340
	public long getCommitfrquency() {
341
		return commitfrquency;
342
	}
343

  
344
	public synchronized void setCommitfrquency(long commitfrquency) {
345
		this.commitfrquency = commitfrquency;
346
		updateSchedule();
347
	}
348
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/main/java/eu/dnetlib/openaire/directindex/api/OpenAIRESubmitterUtils.java
1
package eu.dnetlib.openaire.directindex.api;
2

  
3
import java.io.StringWriter;
4
import java.util.ArrayList;
5
import java.util.HashMap;
6
import java.util.List;
7
import java.util.Map;
8

  
9
import com.google.common.base.Function;
10
import com.google.common.collect.Lists;
11
import eu.dnetlib.miscutils.functional.hash.Hashing;
12
import org.apache.commons.lang.StringUtils;
13

  
14
/**
15
 * Created by michele on 15/01/16.
16
 */
17
public class OpenAIRESubmitterUtils {
18

  
19
	private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(OpenAIRESubmitterUtils.class);
20

  
21
	public Map<String, String> calculateProjectInfo(final String link) {
22
		final Map<String, String> info = new HashMap<String, String>();
23
		final String[] arr = link.split("/");
24
		// info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble
25

  
26
		if (arr.length > 4) {
27
			final String acronym = arr.length > 7 ? arr[7] : "";
28
			final String title = arr.length > 6 ? StringUtils.isNotBlank(arr[6]) ? arr[6] : acronym : "";
29
			final String jurisdiction = arr.length > 5 ? arr[5] : "";
30
			final String funderId = calculateFunderId(arr[2], arr[3]);
31
			info.put("id", calculateProjectId(arr[2], arr[3], arr[4]));
32
			info.put("funderShortName", arr[2]);
33
			info.put("fundingName", arr[3]);
34
			info.put("code", arr[4]);
35
			info.put("jurisdiction", jurisdiction);
36
			info.put("title", title);
37
			info.put("acronym", acronym);
38
			info.put("funderId", funderId);
39
			info.put("funderName", calculateFunderName(arr[2]));
40
			info.put("fundingId", funderId + "::" + arr[3]);
41
		}
42
		return info;
43
	}
44

  
45
	protected String calculateFunderPrefix(final String funderShortName, final String funding){
46
		switch(funderShortName.toLowerCase()){
47
		case "conicyt":
48
			return "conicytf____::";
49
		case "ec":
50
			if (funding.equalsIgnoreCase("fp7")) {
51
				return "corda_______::";
52
			} else {
53
				return "corda__h2020::";
54
			}
55
		case "hrzz":
56
		case "mzos":
57
			return "irb_hr______::";
58
		case "tara":
59
			return "taraexp_____::";
60
		case "tubitak":
61
			return "tubitakf____::";
62
		default:
63
			String prefix = funderShortName.toLowerCase();
64
			//ensure we have 12 chars
65
			while(prefix.length() < 12) prefix += "_";
66
			return prefix +"::";
67
		}
68
	}
69

  
70
	protected String calculateProjectId(final String funderShortName, final String funding, final String code) {
71
		final String suffix = Hashing.md5(code);
72
		final String funderPrefix = calculateFunderPrefix(funderShortName, funding);
73
		return funderPrefix + suffix;
74
	}
75

  
76
	protected String calculateFunderId(final String funderShortName, final String funding) {
77
		switch (funderShortName.toLowerCase()) {
78
		case "ec":
79
			return "ec__________::EC";
80
		default:
81
			String prefix = calculateFunderPrefix(funderShortName, funding);
82
			return prefix + funderShortName.toUpperCase();
83
		}
84
	}
85

  
86

  
87
	protected String calculateFunderName(final String funderShortName) {
88

  
89
		switch (funderShortName.toLowerCase()) {
90
		case "aff":
91
		case "aka":
92
			return "Academy of Finland";
93
		case "arc":
94
			return "Australian Research Council (ARC)";
95
		case "conicyt":
96
			return "Comisión Nacional de Investigación Científica y Tecnológica";
97
		case "ec":
98
			return "European Commission";
99
		case "fct":
100
			return "Fundação para a Ciência e a Tecnologia, I.P.";
101
		case "fwf":
102
			return "Austrian Science Fund (FWF)";
103
		case "hrzz":
104
			return "Croatian Science Foundation (CSF)";
105
		case "mestd":
106
			return "Ministry of Education, Science and Technological Development of Republic of Serbia";
107
		case "miur":
108
			return "Ministero dell'Istruzione dell'Università e della Ricerca";
109
		case "mzos":
110
			return "Ministry of Science, Education and Sports of the Republic of Croatia (MSES)";
111
		case "nhmrc":
112
			return "National Health and Medical Research Council (NHMRC)";
113
		case "nih":
114
			return "National Institutes of Health";
115
		case "nsf":
116
			return "National Science Foundation";
117
		case "nwo":
118
			return "Netherlands Organisation for Scientific Research (NWO)";
119
		case "rcuk":
120
			return "Research Council UK";
121
		case "sfi":
122
			return "Science Foundation Ireland";
123
		case "sgov":
124
			return "Gobierno de España";
125
		case "snsf":
126
			return "Swiss National Science Foundation";
127
		case "tara":
128
			return "Tara Expeditions Foundation";
129
		case "tubitak":
130
			return "Türkiye Bilimsel ve Teknolojik Araştırma Kurumu";
131
		case "wt":
132
			return "Wellcome Trust";
133
		default:
134
			log.error("Funder short name '"+funderShortName+"' not managed");
135
			return "";
136
		}
137
	}
138

  
139
	public List<ContextInfo> processContexts(final List<String> list) {
140
		return Lists.newArrayList(Lists.transform(list, new Function<String, ContextInfo>() {
141

  
142
			@Override
143
			public ContextInfo apply(final String s) {
144
				return createContextInfo(s.split("::"), 0);
145
			}
146

  
147
			private ContextInfo createContextInfo(final String[] arr, final int pos) {
148
				final StringWriter id = new StringWriter();
149
				id.write(arr[0]);
150
				for (int i = 0; i < pos; i++) {
151
					id.write("::");
152
					id.write(arr[i + 1]);
153
				}
154
				final String elem = (pos == 0) ? "context" : (pos == 1) ? "category" : "concept";
155
				final ContextInfo info = new ContextInfo(elem, id.toString());
156
				if ((pos + 1) < arr.length) {
157
					info.getChildren().add(createContextInfo(arr, pos + 1));
158
				}
159
				return info;
160
			}
161
		}));
162

  
163
	}
164

  
165
	public class ContextInfo {
166

  
167
		private String elem;
168
		private String id;
169
		private List<ContextInfo> children = new ArrayList<ContextInfo>();
170

  
171
		public ContextInfo(final String elem,
172
				final String id) {
173
			this.elem = elem;
174
			this.id = id;
175
		}
176

  
177
		public String getElem() {
178
			return elem;
179
		}
180

  
181
		public void setElem(final String elem) {
182
			this.elem = elem;
183
		}
184

  
185
		public String getId() {
186
			return id;
187
		}
188

  
189
		public void setId(final String id) {
190
			this.id = id;
191
		}
192

  
193
		public List<ContextInfo> getChildren() {
194
			return children;
195
		}
196

  
197
		public void setChildren(final List<ContextInfo> children) {
198
			this.children = children;
199
		}
200

  
201
		public boolean isRoot() {
202
			return elem.equals("context");
203
		}
204
	}
205
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/main/java/eu/dnetlib/openaire/directindex/api/DirecIndexApiException.java
1
package eu.dnetlib.openaire.directindex.api;
2

  
3
import eu.dnetlib.common.rmi.RMIException;
4

  
5
public class DirecIndexApiException extends RMIException {
6

  
7
	/**
8
	 *
9
	 */
10
	private static final long serialVersionUID = -3888037031334809448L;
11

  
12
	public DirecIndexApiException(final String string) {
13
		super(string);
14
	}
15

  
16
	public DirecIndexApiException(final String string, final Throwable exception) {
17
		super(string, exception);
18
	}
19

  
20
	public DirecIndexApiException(final Throwable exception) {
21
		super(exception);
22
	}
23

  
24
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/main/java/eu/dnetlib/openaire/directindex/api/RecentResultsQueue.java
1
package eu.dnetlib.openaire.directindex.api;
2

  
3
import java.io.StringReader;
4
import java.util.Iterator;
5
import java.util.List;
6

  
7
import com.mongodb.*;
8
import eu.dnetlib.miscutils.datetime.DateUtils;
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
11
import org.dom4j.io.SAXReader;
12
import org.springframework.beans.factory.annotation.Required;
13

  
14
/**
15
 * Created by michele on 11/11/15.
16
 */
17
public class RecentResultsQueue implements Iterable<String> {
18

  
19
	private static final Log log = LogFactory.getLog(RecentResultsQueue.class);
20

  
21
	private DB db;
22
	private String collection;
23

  
24
	public void init() {
25
		if (!db.collectionExists(collection)) {
26
			log.info(String.format("creating collection %s", collection));
27
			db.createCollection(collection, new BasicDBObject());
28
		}
29
	}
30

  
31
	@Override
32
	public Iterator<String> iterator() {
33

  
34
		final DBCursor cursor = db.getCollection(collection).find();
35

  
36
		return new Iterator<String>() {
37

  
38
			@Override
39
			public boolean hasNext() {
40
				return cursor.hasNext();
41
			}
42

  
43
			@Override
44
			public String next() {
45
				final DBObject obj = cursor.next();
46
				return ((obj != null) && obj.containsField("record")) ? obj.get("record").toString() : "";
47
			}
48

  
49
			@Override
50
			public void remove() {
51
				throw new RuntimeException("NOT IMPLEMENTED");
52
			}
53
		};
54
	}
55

  
56
	synchronized public void add(final String oaf) throws Exception {
57
		final String id = (new SAXReader()).read(new StringReader(oaf)).valueOf("//*[local-name() = 'objIdentifier']");
58

  
59
		log.info("Saving record " + id + " in db: " + db.getName() + ", coll: " + collection);
60

  
61
		final DBCollection coll = db.getCollection(collection);
62
		final DBObject obj = BasicDBObjectBuilder.start()
63
				.append("id", id)
64
				.append("record", oaf)
65
				.append("date", DateUtils.now())
66
				.get();
67
		coll.update(new BasicDBObject("id", id), obj, true, false);
68
	}
69

  
70
	public void remove(final List<String> list) {
71
		final DBCollection coll = db.getCollection(collection);
72
		for (final String id : list) {
73
			coll.remove(new BasicDBObject("id", id));
74
		}
75
	}
76

  
77
	public void remove(final String... ids) {
78
		final DBCollection coll = db.getCollection(collection);
79
		for (final String id : ids) {
80
			coll.remove(new BasicDBObject("id", id));
81
		}
82
	}
83

  
84
	public DB getDb() {
85
		return db;
86
	}
87

  
88
	@Required
89
	public void setDb(final DB db) {
90
		this.db = db;
91
	}
92

  
93
	public String getCollection() {
94
		return collection;
95
	}
96

  
97
	@Required
98
	public void setCollection(final String collection) {
99
		this.collection = collection;
100
	}
101
}
modules/dnet-directindex-api/tags/dnet-directindex-api-1.1.6/src/main/java/eu/dnetlib/openaire/directindex/objects/ResultEntry.java
1
package eu.dnetlib.openaire.directindex.objects;
2

  
3
import java.text.SimpleDateFormat;
4
import java.util.ArrayList;
5
import java.util.Date;
6
import java.util.HashMap;
7
import java.util.List;
8
import java.util.Map;
9
import java.util.concurrent.TimeUnit;
10

  
11
import org.apache.commons.lang.StringUtils;
12
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.LogFactory;
14
import org.apache.velocity.app.VelocityEngine;
15
import org.springframework.ui.velocity.VelocityEngineUtils;
16

  
17
import com.google.gson.Gson;
18

  
19
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
20
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
21
import eu.dnetlib.miscutils.datetime.DateUtils;
22
import eu.dnetlib.miscutils.functional.hash.Hashing;
23
import eu.dnetlib.miscutils.functional.string.EscapeXml;
24
import eu.dnetlib.openaire.directindex.api.DirecIndexApiException;
25
import eu.dnetlib.openaire.directindex.api.OpenAIRESubmitterUtils;
26
import io.swagger.annotations.ApiModelProperty;
27

  
28
/**
29
 * Created by michele on 02/12/15.
30
 */
31
public class ResultEntry {
32

  
33
	private String openaireId;
34
	private String originalId;
35
	private String title;
36
	private List<String> authors = new ArrayList<>();
37
	private String publisher;
38
	private String description;
39
	private String language;
40
	private List<PidEntry> pids = new ArrayList<>();
41
	/**
42
	 * @Deprecated: use accessRightCode
43
	 */
44
	@Deprecated
45
	private String licenseCode;
46
	private String accessRightCode;
47
	private String embargoEndDate;
48
	/**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff