Project

General

Profile

« Previous | Next » 

Revision 44352

fixed bug

View differences:

DataciteResolver.java
7 7
import com.google.gson.JsonElement;
8 8
import com.google.gson.JsonObject;
9 9
import com.google.gson.JsonParser;
10
import eu.dnetlib.resolver.model.CompletionStatus;
11
import eu.dnetlib.resolver.model.ObjectProvenance;
12
import eu.dnetlib.resolver.model.ObjectType;
13
import eu.dnetlib.resolver.model.ResolvedObject;
10
import eu.dnetlib.resolver.model.*;
14 11
import org.apache.commons.logging.Log;
15 12
import org.apache.commons.logging.LogFactory;
16 13

  
......
20 17

  
21 18
public class DataciteResolver extends AbstractPIDResolver {
22 19

  
23
	public static final String DATACITE_NS_PREFIX = "dli_datacite";
20
	public static final String DATACITE_NS_PREFIX = "datacite____";
24 21

  
25 22
	/**
26 23
	 * The Constant log.
......
30 27
	/**
31 28
	 * The Constant baseURL.
32 29
	 */
33
	private final static String baseURL = "http://search.datacite.org/api?wt=json&fl=doi,title,contributor,creator,publisher&q=doi:";
30
	private final static String baseURL = "http://search.datacite.org/api?wt=json&q=doi:";
34 31

  
35 32
	private ResolvedObject parseResponse(final String response) {
36 33
		if (response == null) return null;
......
54 51
				responseObj.setType(ObjectType.dataset);
55 52
				List<String> authors = Lists.newArrayList();
56 53
				List<String> titles = Lists.newArrayList();
54
				List<SubjectType> subjects = Lists.newArrayList();
57 55

  
56
				// ADDING SUBJECTS
57
				final JsonElement subjectElement = ((JsonObject) elem).get("subject");
58
				if (subjectElement != null) {
59
					JsonArray subjectArray = subjectElement.getAsJsonArray();
60
					for (int i = 0; i < subjectArray.size(); i++) {
61
						subjects.add(new SubjectType("unknown", subjectArray.get(i).getAsString()));
62
					}
63
				}
64
				responseObj.setSubjects(subjects);
65

  
58 66
				// ADDING TITLES
59 67
				JsonElement titleElement = ((JsonObject) elem).get("title");
60 68
				if (titleElement != null) {
......
64 72
					}
65 73
				}
66 74
				responseObj.setTitles(titles);
75

  
76
				//ADDING DESCRIPTION
77

  
78
				JsonElement descriptionElement = ((JsonObject) elem).get("description");
79
				if (descriptionElement != null) {
80
					JsonArray descriptionArray = descriptionElement.getAsJsonArray();
81
					if (descriptionArray.size() > 0)
82
						responseObj.setDescription(descriptionArray.get(0).getAsString());
83
				}
84

  
67 85
				// ADDING AUTHORS
68 86
				JsonElement contributorElement = ((JsonObject) elem).get("contributor");
69 87
				if (contributorElement != null) {
......
82 100
				}
83 101
				responseObj.setAuthors(authors);
84 102

  
85
				ObjectProvenance provenance = new ObjectProvenance(DATACITE_NS_PREFIX, "resolved", "complete", null, null, true);
103
				ObjectProvenance provenance = new ObjectProvenance();
104
				setDatasourceProvenace(provenance, DATACITE_NS_PREFIX);
86 105

  
87 106
				JsonElement publisherElement = ((JsonObject) elem).get("publisher");
88 107
				if (publisherElement != null && !publisherElement.isJsonNull()) {

Also available in: Unified diff