Project

General

Profile

« Previous | Next » 

Revision 50032

fixed scholix version and Date mapping

View differences:

CrossRefParserJSON.java
3 3
 */
4 4
package eu.dnetlib.dli.resolver;
5 5

  
6
import java.util.ArrayList;
6 7
import java.util.List;
7 8

  
8 9
import com.google.common.collect.Lists;
......
36 37

  
37 38
		if (record == null) return null;
38 39
		JsonElement jElement = new JsonParser().parse(record);
39
		final JsonObject message = jElement.getAsJsonObject();
40
//		if (mainObj.get("message").isJsonNull()) {
41
//			return null;
42
//		}
43
//		JsonObject message = mainObj.getAsJsonObject("message");
40

  
41
		JsonElement source = jElement.getAsJsonObject().get("_source");
42
		if (source== null || !source.isJsonObject())
43
			return null;
44

  
45
		final JsonObject message = source.getAsJsonObject();
44 46
        DLIResolvedObject currentObject = new DLIResolvedObject();
45 47

  
46 48
		if (message.get("DOI") != null) {
......
54 56
			currentObject.setDate(message.getAsJsonObject("created").get("date-time").getAsString());
55 57
		}
56 58

  
57
		if (message.get("title")!= null && !message.get("title").isJsonNull()) {
58
			currentObject.setTitles(Lists.newArrayList(message.get("title").toString().replace("[", "").replace("]", "")));
59
		if (message.get("title")!= null && !message.get("title").isJsonNull() && message.get("title").isJsonArray() ) {
60
			final List<String> titles = new ArrayList<>();
61
			message.get("title").getAsJsonArray().forEach(
62
					it ->titles.add(it.getAsString())
63
			);
64
			currentObject.setTitles(titles);
59 65
		}
60 66

  
61 67
		if (message.get("author") != null && !message.get("author").isJsonNull()) {

Also available in: Unified diff