Project

General

Profile

« Previous | Next » 

Revision 57270

Added by Enrico Ottonello about 5 years ago

added firstname and surname in case of authors without orcid id, extracted from fullname, needed for propagation

View differences:

modules/dnet-mapreduce-jobs/trunk/src/test/java/eu/dnetlib/data/mapreduce/actions/OrcidToActionsTest.java
28 28
import eu.dnetlib.data.mapreduce.hbase.dataimport.DumpToActionsUtility;
29 29
import eu.dnetlib.data.mapreduce.hbase.dataimport.OrcidToActions;
30 30
import eu.dnetlib.data.proto.OafProtos.Oaf;
31
import eu.dnetlib.miscutils.collections.Pair;
32
import eu.dnetlib.pace.model.Person;
31 33

  
32 34
public class OrcidToActionsTest {
33 35

  
......
36 38
	private Reporter reporter;
37 39

  
38 40
	private final String generatedJson =
39
			"{\"kind\": \"entity\",\"entity\": {\"type\": \"result\",\"result\": {\"metadata\": {\"title\": [{\"value\": \"Factors influencing accuracy of referral and the likelihood of false positive referral by optometrists in Bradford, United Kingdom.\",\"qualifier\": {\"classid\": \"main title\",\"classname\": \"main title\",\"schemeid\": \"dnet:dataCite_title\",\"schemename\": \"dnet:dataCite_title\"}}],\"relevantdate\": [{\"value\": \"2015-11-01\",\"qualifier\": {\"classid\": \"issued\",\"classname\": \"issued\",\"schemeid\": \"dnet:dataCite_date\",\"schemename\": \"dnet:dataCite_date\"}}],\"dateofacceptance\": {\"value\": \"2015-11-01\"},\"resulttype\": {\"classid\": \"publication\",\"classname\": \"publication\",\"schemeid\": \"dnet:result_typologies\",\"schemename\": \"dnet:result_typologies\"},\"resourcetype\": {\"classid\": \"journal-article\",\"classname\": \"journal-article\",\"schemeid\": \"dnet:dataCite_resource\",\"schemename\": \"dnet:dataCite_resource\"},\"source\": [{\"value\": \"Europe PubMed Central\"}],\"author\": [{\"fullname\": \"Christopher Davey\",\"name\": \"Christopher\",\"surname\": \"Davey\",\"rank\": 1,\"pid\": [{\"key\": \"ORCID\",\"value\": \"0000-0002-9050-379X\"}]},{\"fullname\": \"Scally AJ\",\"rank\": 2},{\"fullname\": \"Green C\",\"rank\": 3},{\"fullname\": \"Mitchell ES\",\"rank\": 4},{\"fullname\": \"Elliott DB\",\"rank\": 5}]},\"instance\": [{\"accessright\": {\"classid\": \"UNKNOWN\",\"classname\": \"UNKNOWN\",\"schemeid\": \"dnet:access_modes\",\"schemename\": \"dnet:access_modes\"},\"instancetype\": {\"classid\": \"0001\",\"classname\": \"Article\",\"schemeid\": \"dnet:publication_resource\",\"schemename\": \"dnet:publication_resource\"},\"hostedby\": {\"key\": \"10|openaire____::55045bd2a65019fd8e6741a755395c8c\",\"value\": \"Unknown Repository\"},\"url\": [\"http://europepmc.org/abstract/med/26614021\"],\"collectedfrom\": {\"key\": \"10|openaire____::806360c771262b4d6770e7cdf04b5c5a\",\"value\": \"ORCID\"},\"dateofacceptance\": {\"value\": \"2015-11-01\"}}]},\"originalId\": [\"24099977\"],\"collectedfrom\": [{\"key\": \"10|openaire____::806360c771262b4d6770e7cdf04b5c5a\",\"value\": \"ORCID\"}],\"pid\": [{\"value\": \"26614021\",\"qualifier\": {\"classid\": \"pmid\",\"classname\": \"pmid\",\"schemeid\": \"dnet:pid_types\",\"schemename\": \"dnet:pid_types\"}}],\"dateofcollection\": \"2018-10-22\",\"id\": \"50|orcid____::57b8b813748049402c0900d3d17f1c23\",\"dateoftransformation\": \"2019-06-21T11:16:10+02:00\"},\"dataInfo\": {\"inferred\": false,\"deletedbyinference\": false,\"trust\": \"0.9\",\"provenanceaction\": {\"classid\": \"sysimport:actionset:orcidworks-no-doi\",\"classname\": \"sysimport:actionset:orcidworks-no-doi\",\"schemeid\": \"dnet:provenanceActions\",\"schemename\": \"dnet:provenanceActions\"}},\"lastupdatetimestamp\": 1561108570991}\n"
40
					+
41
					"";
41
			"{\"kind\": \"entity\",\"entity\": {\"type\": \"result\",\"result\": {\"metadata\": {\"title\": [{\"value\": \"Cryptogenic fibrosing alveolitis in Bergen Hospital district\",\"qualifier\": {\"classid\": \"main title\",\"classname\": \"main title\",\"schemeid\": \"dnet:dataCite_title\",\"schemename\": \"dnet:dataCite_title\"}}],\"relevantdate\": [{\"value\": \"1999-01-01\",\"qualifier\": {\"classid\": \"issued\",\"classname\": \"issued\",\"schemeid\": \"dnet:dataCite_date\",\"schemename\": \"dnet:dataCite_date\"}}],\"dateofacceptance\": {\"value\": \"1999-01-01\"},\"resulttype\": {\"classid\": \"publication\",\"classname\": \"publication\",\"schemeid\": \"dnet:result_typologies\",\"schemename\": \"dnet:result_typologies\"},\"resourcetype\": {\"classid\": \"conference-abstract\",\"classname\": \"conference-abstract\",\"schemeid\": \"dnet:dataCite_resource\",\"schemename\": \"dnet:dataCite_resource\"},\"source\": [{\"value\": \"University of Southern Denmark\"}],\"author\": [{\"fullname\": \"Christian von Plessen\",\"name\": \"Christian\",\"surname\": \"von Plessen\",\"rank\": 1,\"pid\": [{\"key\": \"ORCID\",\"value\": \"0000-0002-6134-6780\"}]},{\"fullname\": \"Grinde, Ø.\",\"name\": \"Ø.\",\"surname\": \"Grinde\",\"rank\": 2},{\"fullname\": \"Gulsvik, A.\",\"name\": \"A.\",\"surname\": \"Gulsvik\",\"rank\": 3}]},\"instance\": [{\"accessright\": {\"classid\": \"UNKNOWN\",\"classname\": \"UNKNOWN\",\"schemeid\": \"dnet:access_modes\",\"schemename\": \"dnet:access_modes\"},\"instancetype\": {\"classid\": \"0004\",\"classname\": \"Conference object\",\"schemeid\": \"dnet:publication_resource\",\"schemename\": \"dnet:publication_resource\"},\"hostedby\": {\"key\": \"10|openaire____::55045bd2a65019fd8e6741a755395c8c\",\"value\": \"Unknown Repository\"},\"url\": [\"http://findresearcher.sdu.dk/portal/en/publications/cryptogenic-fibrosing-alveolitis-in-bergen-hospital-district(14a8eea6-ddf6-4055-9e7e-a82525ae36c2).html\"],\"collectedfrom\": {\"key\": \"10|openaire____::806360c771262b4d6770e7cdf04b5c5a\",\"value\": \"ORCID\"},\"dateofacceptance\": {\"value\": \"1999-01-01\"}}]},\"originalId\": [\"29721246\"],\"collectedfrom\": [{\"key\": \"10|openaire____::806360c771262b4d6770e7cdf04b5c5a\",\"value\": \"ORCID\"}],\"pid\": [{\"value\": \"14a8eea6-ddf6-4055-9e7e-a82525ae36c2\",\"qualifier\": {\"classid\": \"orcidworkid\",\"classname\": \"orcidworkid\",\"schemeid\": \"dnet:pid_types\",\"schemename\": \"dnet:pid_types\"}}],\"dateofcollection\": \"2018-10-22\",\"id\": \"50|orcid_______::01d661c1f7824215e5150d59b30f7cf7\",\"dateoftransformation\": \"2019-10-04T12:14:24+02:00\"},\"dataInfo\": {\"inferred\": false,\"deletedbyinference\": false,\"trust\": \"0.9\",\"provenanceaction\": {\"classid\": \"sysimport:actionset:orcidworks-no-doi\",\"classname\": \"sysimport:actionset:orcidworks-no-doi\",\"schemeid\": \"dnet:provenanceActions\",\"schemename\": \"dnet:provenanceActions\"}},\"lastupdatetimestamp\": 1570184064208}\n" + 
42
			"";
42 43

  
43 44
	@Before
44 45
	public void setup() {
......
122 123
			i += 1;
123 124
		}
124 125
	}
125

  
126
	
126 127
	@Test
127 128
	public void testGeneratedJson() throws ParseException {
128 129
		final JsonParser parser = new JsonParser();
......
132 133
		final List<JsonObject> pids = DumpToActionsUtility.getArrayObjects(entity, "pid");
133 134
		pids.forEach(pid -> {
134 135
			final JsonObject qualifier = pid.getAsJsonObject("qualifier");
135
			assertTrue(qualifier.get("classid").getAsString().matches("(ark|arxiv|pmc|pmid|source-work-id|urn)"));
136
			assertTrue(qualifier.get("classid").getAsString().matches("(ark|arxiv|pmc|pmid|orcidworkid|urn)"));
136 137
		});
137 138
		assertEquals(getStringValue(entity, "type"), "result");
138 139
		assertNotNull(getStringValue(entity, "id"));
......
154 155
		});
155 156

  
156 157
	}
158
	
157 159
}
modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/dataimport/OrcidToActions.java
20 20
import com.google.gson.JsonArray;
21 21
import com.google.gson.JsonElement;
22 22
import com.google.gson.JsonObject;
23
import com.googlecode.protobuf.format.JsonFormat;
23 24

  
24 25
import eu.dnetlib.actionmanager.actions.ActionFactory;
25 26
import eu.dnetlib.actionmanager.actions.AtomicAction;
......
40 41
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions;
41 42
import eu.dnetlib.miscutils.collections.Pair;
42 43
import eu.dnetlib.miscutils.datetime.DateUtils;
44
import eu.dnetlib.pace.model.Person;
43 45

  
44 46
public class OrcidToActions {
45 47

  
......
248 250

  
249 251
		actionList.add(factory.createAtomicAction(setName, agent, oaf.getEntity().getId(), "result", "body", oaf.build().toByteArray()));
250 252

  
251
		// System.out.println(JsonFormat.printToString(oaf.build()));
253
//		 System.out.println(JsonFormat.printToString(oaf.build()));
252 254
		return actionList;
253 255

  
254 256
	}
......
300 302
							result.setSurname(surname);
301 303
						}
302 304
					} else {
305
						String fullname = "";
303 306
						if (StringUtils.isNotBlank(name)) {
304
							result.setFullname(name);
307
							fullname = name;
305 308
						} else {
306 309
							if (StringUtils.isNotBlank(surname)) {
307
								result.setFullname(surname);
310
								fullname = surname;
308 311
							}
309 312
						}
313
						Person p = new Person(fullname, false);
314
						if (p.isAccurate()) {
315
							result.setName(p.getNormalisedFirstName());
316
							result.setSurname(p.getNormalisedSurname());
317
							result.setFullname(p.getNormalisedFullname());
318
						}
319
						else {
320
							result.setFullname(fullname);
321
						}
310 322
					}
311 323
				}
312 324
				result.setRank(rank);

Also available in: Unified diff