Project

General

Profile

« Previous | Next » 

Revision 8784

all full-text queries for ORCID, but it isn't that great because we might have a"PISCO" creator that shows us in may different orcid profiles...false matches.

View differences:

test/edu/ucsb/nceas/metacat/annotation/OrcidServiceTest.java
64 64
	
65 65
	public void testLookup() {
66 66
		String[] otherNames = new String[] {"Matthew Bentley Jones"};
67
		String orcid = OrcidService.lookupOrcid(null, null, otherNames);
67
		String orcid = OrcidService.lookupOrcid(null, null, null, otherNames);
68 68
		assertEquals("http://orcid.org/0000-0003-0077-4738", orcid);
69 69
	}
70 70
	
......
75 75

  
76 76
		List<String> creators = OrcidService.lookupCreators(true);
77 77
		for (String creator: creators) {
78
			String orcid = OrcidService.lookupOrcid(null, null, Arrays.asList(creator).toArray(new String[0]));
78
			String orcid = OrcidService.lookupOrcid(null, null, null, Arrays.asList(creator).toArray(new String[0]));
79 79
			if (orcid != null) {
80 80
				matches.put(orcid, creator);
81 81
				count++;
src/edu/ucsb/nceas/metacat/annotation/OrcidService.java
37 37
	 * @param otherNames
38 38
	 * @return
39 39
	 */
40
	public static String lookupOrcid(String surName, String[] givenNames, String[] otherNames) {
40
	public static String lookupOrcid(String text, String surName, String[] givenNames, String[] otherNames) {
41 41
		
42 42
		String url = null;
43 43

  
44 44
		try {
45 45
			
46 46
			String urlParameters = "";
47
			if (surName != null) {
48
//				surName = surName.replaceAll(" ", "%20");
49
				urlParameters += "+family-name:\"" + surName + "\"";
50
			}
51
			if (otherNames != null) {
52
				for (String otherName: otherNames) {
53
//					otherName = otherName.replaceAll(" ", "%20");
54
					urlParameters += "+other-names:\"" + otherName + "\""; 
47
			
48
			if (text != null) {
49
				urlParameters += "\"" + text + "\""; 
50
			} else {
51
				if (surName != null) {
52
//					surName = surName.replaceAll(" ", "%20");
53
					urlParameters += "+family-name:\"" + surName + "\"";
55 54
				}
56
			}
57
			if (givenNames != null) {
58
				for (String givenName: givenNames) {
59
//					givenName = givenName.replaceAll(" ", "%20");
60
					urlParameters += "+given-names:\"" + givenName + "\""; 
55
				if (otherNames != null) {
56
					for (String otherName: otherNames) {
57
//						otherName = otherName.replaceAll(" ", "%20");
58
						urlParameters += "+other-names:\"" + otherName + "\""; 
59
					}
61 60
				}
61
				if (givenNames != null) {
62
					for (String givenName: givenNames) {
63
//						givenName = givenName.replaceAll(" ", "%20");
64
						urlParameters += "+given-names:\"" + givenName + "\""; 
65
					}
66
				}
62 67
			}
63 68
			
64 69
			urlParameters = URLEncoder.encode(urlParameters, "UTF-8");
src/edu/ucsb/nceas/metacat/annotation/DatapackageSummarizer.java
296 296
		//creators = Arrays.asList("Matthew Jones");
297 297
		if (creators != null && creators.size() > 0) {	
298 298
			// use an orcid if we can find one from their system
299
			String orcidUri = OrcidService.lookupOrcid(null, null, creators.toArray(new String[0]));
299
			String orcidUri = OrcidService.lookupOrcid(null, null, null, creators.toArray(new String[0]));
300 300
			if (orcidUri != null) {
301 301
				p1 = m.createIndividual(orcidUri, personClass);
302 302
				p1.addProperty(identifierProperty, orcidUri);

Also available in: Unified diff