Project

General

Profile

« Previous | Next » 

Revision 8788

use separate surName and givenNames to lookup ORCIDs.

View differences:

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

  
76 76
		List<String> creators = OrcidService.lookupCreators(true);
77 77
		for (String creator: creators) {
78
			String orcid = OrcidService.lookupOrcid(null, null, null, Arrays.asList(creator).toArray(new String[0]));
78
			String orcid = OrcidService.lookupOrcid(null, null, null, Arrays.asList(creator));
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 text, String surName, String[] givenNames, String[] otherNames) {
40
	public static String lookupOrcid(String text, String surName, List<String> givenNames, List<String> otherNames) {
41 41
		
42 42
		String url = null;
43 43

  
src/edu/ucsb/nceas/metacat/annotation/DatapackageSummarizer.java
21 21
import org.ecoinformatics.datamanager.parser.Attribute;
22 22
import org.ecoinformatics.datamanager.parser.DataPackage;
23 23
import org.ecoinformatics.datamanager.parser.Entity;
24
import org.ecoinformatics.datamanager.parser.Party;
24 25
import org.ecoinformatics.datamanager.parser.generic.DataPackageParserInterface;
25 26
import org.ecoinformatics.datamanager.parser.generic.Eml200DataPackageParser;
26 27

  
......
292 293
		Individual p1 = null;
293 294
		
294 295
		// look up creators from the EML metadata
295
		List<String> creators = dataPackage.getCreators();
296
		List<Party> creators = dataPackage.getCreators();
296 297
		//creators = Arrays.asList("Matthew Jones");
297 298
		if (creators != null && creators.size() > 0) {	
298 299
			// use an orcid if we can find one from their system
299
			String orcidUri = OrcidService.lookupOrcid(null, null, null, creators.toArray(new String[0]));
300
			String orcidUri = OrcidService.lookupOrcid(creators.get(0).getOrganization(), creators.get(0).getSurName(), creators.get(0).getGivenNames(), null);
300 301
			if (orcidUri != null) {
301 302
				p1 = m.createIndividual(orcidUri, personClass);
302 303
				p1.addProperty(identifierProperty, orcidUri);
......
304 305
				p1 = m.createIndividual(ont.getURI() + "#person", personClass);
305 306
			}
306 307
			// include the name we have in the metadata
307
			p1.addProperty(nameProperty, creators.get(0));
308
			if (creators.get(0).getSurName() != null) {
309
				p1.addProperty(nameProperty, creators.get(0).getSurName());
310
			} else if (creators.get(0).getOrganization() != null) {
311
				p1.addProperty(nameProperty, creators.get(0).getOrganization());
312
			}
308 313
		}
309 314
		
310 315
		// attribute the package to this creator if we have one

Also available in: Unified diff