Projects >> VIVO-Harvester >>f1fc9ada142d860ab3714f79c10b8de7e0956885

Chunk
Conflicting content
			} else {
			log.debug(matchQuery);
			scorePaperResult = executeQuery(this.scoreInput.getJenaModel(), matchQuery);
			
<<<<<<< HEAD:src/main/java/org/vivoweb/ingest/score/Score.java
			// ensure first name and last name are not blank
			if (lastNameNode.toString() == null || foreNameNode.toString() == null) {
				log.info("Incomplete name, skipping");
			} else {
				scoreMatch = lastNameNode.toString();
				
				// Select all matching authors from vivo store
				queryString = "PREFIX foaf:  " + "SELECT ?x ?firstName " + "WHERE { ?x foaf:lastName" + " \"" + scoreMatch + "\" . ?x foaf:firstName ?firstName}";
				
				log.debug(queryString);
				
				vivoResult = executeQuery(this.vivo.getJenaModel(), queryString);
				// Loop thru results and only keep if the last name, and first initial match
				while(vivoResult.hasNext()) {
					vivoSolution = vivoResult.next();
					log.trace(vivoSolution.toString());
					loopNode = vivoSolution.get("firstName");
					if(loopNode.toString().length() >= 1 && foreNameNode.toString().length() >= 1) {
						log.trace("Checking " + loopNode);
						if(foreNameNode.toString().substring(0, 1).equals(loopNode.toString().substring(0, 1))) {
							matchNodes.add(vivoSolution);
						} else {
							// do nothing
						}
					}
				}
=======
			if (scorePaperResult.hasNext()) {
				scorePaperSolution = scorePaperResult.next();
				paperNode = scorePaperSolution.get("paper");
				paperResource = scorePaperSolution.getResource("paper");
				//go to next one, can't find paper
				log.error("Can't find paper for " + authorNode);
				continue;
			}
			
			matchNodes.clear();
			matchNode = null;
			
			//reset minChars if first name is less than than the passed in minimum
			if (foreNameNode.toString().length() < minChars) {
				minimum = foreNameNode.toString().length();
			}
			
			//support middlename parse out of forename or from pubmed
			if (middleNameNode != null) {
				log.trace("Checking for " + lastNameNode.toString() + ", " + foreNameNode.toString() + " " + middleNameNode.toString() + " from " + paperNode.toString() + " in VIVO");
				pubmedInitials = foreNameNode.toString().substring(0,1) + middleNameNode.toString().substring(0,1);
				log.trace("Using " + pubmedInitials + " as first and middle initial");			
			} else {
				log.trace("Checking for " + lastNameNode.toString() + ", " + foreNameNode.toString() + " from " + paperNode.toString() + " in VIVO");
			
				//parse out middle initial / name from foreName
				String splitName[] = foreNameNode.toString().split(" ");
				
				if (splitName.length == 2) {
					lastName = splitName[0];
					middleName = splitName[1];
					pubmedInitials = lastName.substring(0,1) + middleName.substring(0,1);
					log.trace("Using " + pubmedInitials + " as first and middle initial");
				} else {
					lastName = null;
					middleName = null;
					pubmedInitials = null;
				}
			}
			
			// ensure first name and last name are not blank
			if (lastNameNode.toString() == null || foreNameNode.toString() == null) {
				log.trace("Incomplete name, skipping");
			} else {
				scoreMatch = lastNameNode.toString();
				
				// Select all matching authors from vivo store
				queryString = "PREFIX foaf:  " + "PREFIX core:  " + "SELECT REDUCED ?x ?firstName ?middleName " + "WHERE { ?x foaf:lastName" + " \"" + scoreMatch + "\" . ?x foaf:firstName ?firstName . OPTIONAL { ?x core:middleName ?middleName}}";
				
				log.debug(queryString);
				
				vivoResult = executeQuery(this.vivo.getJenaModel(), queryString);
				
				// Loop thru results and only keep if the last name, and first initial match
				while(vivoResult.hasNext()) {
					vivoSolution = vivoResult.next();
					log.trace(vivoSolution.toString());
					loopNode = vivoSolution.get("firstName");
					middleNameNode = vivoSolution.get("middleName");
					
					if(loopNode.toString().length() >= 1 && foreNameNode.toString().length() >= 1) {
						if (middleNameNode != null) {
							log.trace("Checking " + loopNode + " " + middleNameNode.toString() + " " + vivoSolution.get("x"));
						}
						else {
							log.trace("Checking " + loopNode + " " + vivoSolution.get("x"));
						}
						if(foreNameNode.toString().substring(0, 1).equals(loopNode.toString().substring(0, 1))) {
							matchNodes.add(vivoSolution);
						} else {
							// do nothing
						}
					}
				}
>>>>>>> 2868ebe492f287ad46d55326e80021abfdad45f8:src/main/java/org/vivoweb/harvester/score/Score.java
				
				// Did we find a keeper? if so, store if meets threshold
				// if more than 1 person find, keep the highest "best" match
Solution content
			log.debug(matchQuery);
			scorePaperResult = executeQuery(this.scoreInput.getJenaModel(), matchQuery);
			
			if (scorePaperResult.hasNext()) {
				scorePaperSolution = scorePaperResult.next();
				paperNode = scorePaperSolution.get("paper");
				paperResource = scorePaperSolution.getResource("paper");
			} else {
				//go to next one, can't find paper
				log.error("Can't find paper for " + authorNode);
				continue;
			}
			
			matchNodes.clear();
			matchNode = null;
			
			//reset minChars if first name is less than than the passed in minimum
			if (foreNameNode.toString().length() < minChars) {
				minimum = foreNameNode.toString().length();
			}
			
			//support middlename parse out of forename or from pubmed
			if (middleNameNode != null) {
				log.trace("Checking for " + lastNameNode.toString() + ", " + foreNameNode.toString() + " " + middleNameNode.toString() + " from " + paperNode.toString() + " in VIVO");
				pubmedInitials = foreNameNode.toString().substring(0,1) + middleNameNode.toString().substring(0,1);
				log.trace("Using " + pubmedInitials + " as first and middle initial");			
			} else {
				log.trace("Checking for " + lastNameNode.toString() + ", " + foreNameNode.toString() + " from " + paperNode.toString() + " in VIVO");
			
				//parse out middle initial / name from foreName
				String splitName[] = foreNameNode.toString().split(" ");
				
				if (splitName.length == 2) {
					lastName = splitName[0];
					middleName = splitName[1];
					pubmedInitials = lastName.substring(0,1) + middleName.substring(0,1);
					log.trace("Using " + pubmedInitials + " as first and middle initial");
				} else {
					lastName = null;
					middleName = null;
					pubmedInitials = null;
				}
			}
			
			// ensure first name and last name are not blank
			if (lastNameNode.toString() == null || foreNameNode.toString() == null) {
				log.trace("Incomplete name, skipping");
			} else {
				scoreMatch = lastNameNode.toString();
				
				// Select all matching authors from vivo store
				queryString = "PREFIX foaf:  " + "PREFIX core:  " + "SELECT REDUCED ?x ?firstName ?middleName " + "WHERE { ?x foaf:lastName" + " \"" + scoreMatch + "\" . ?x foaf:firstName ?firstName . OPTIONAL { ?x core:middleName ?middleName}}";
				
				log.debug(queryString);
				
				vivoResult = executeQuery(this.vivo.getJenaModel(), queryString);
				
				// Loop thru results and only keep if the last name, and first initial match
				while(vivoResult.hasNext()) {
					vivoSolution = vivoResult.next();
					log.trace(vivoSolution.toString());
					loopNode = vivoSolution.get("firstName");
					middleNameNode = vivoSolution.get("middleName");
					
					if(loopNode.toString().length() >= 1 && foreNameNode.toString().length() >= 1) {
						if (middleNameNode != null) {
							log.trace("Checking " + loopNode + " " + middleNameNode.toString() + " " + vivoSolution.get("x"));
						}
						else {
							log.trace("Checking " + loopNode + " " + vivoSolution.get("x"));
						}
						if(foreNameNode.toString().substring(0, 1).equals(loopNode.toString().substring(0, 1))) {
							matchNodes.add(vivoSolution);
						} else {
							// do nothing
						}
					}
				}
				
				// Did we find a keeper? if so, store if meets threshold
				// if more than 1 person find, keep the highest "best" match
File
Score.java
Developer's decision
Version 2
Kind of conflict
Comment
If statement
Method invocation
Variable
While statement
Chunk
Conflicting content
				while(matches.hasNext()) {
					vivoSolution = matches.next();
					loopNode = vivoSolution.get("firstName");
<<<<<<< HEAD:src/main/java/org/vivoweb/ingest/score/Score.java
=======
					
>>>>>>> 2868ebe492f287ad46d55326e80021abfdad45f8:src/main/java/org/vivoweb/harvester/score/Score.java
					loop = 0;
					while(loopNode.toString().regionMatches(true, 0, foreNameNode.toString(), 0, loop)) {
						loop++;
Solution content
				while(matches.hasNext()) {
					vivoSolution = matches.next();
					loopNode = vivoSolution.get("firstName");
					
					loop = 0;
					while(loopNode.toString().regionMatches(true, 0, foreNameNode.toString(), 0, loop)) {
						loop++;
File
Score.java
Developer's decision
Version 1
Kind of conflict
Blank
Chunk
Conflicting content
						loop++;
					}
					loop--;
<<<<<<< HEAD:src/main/java/org/vivoweb/ingest/score/Score.java
					if(loop < minChars) {
						log.trace(loopNode.toString() + " only matched " + loop + " of " + foreNameNode.toString().length() + ". Minimum needed to match is " + minChars);
					} else {
						// if loopNode matches more of foreNameNode, it's the new best match
						// TODO Nicholas: Fix the preference for the first "best" match
						if(matchNode == null || !matchNode.toString().regionMatches(true, 0, foreNameNode.toString(), 0, loop)) {
							log.trace("Setting " + loopNode.toString() + " as best match, matched " + loop + " of " + foreNameNode.toString().length());
							matchNode = loopNode;
							authorNode = vivoSolution.get("x");
=======
					
					middleName = "";
					
					//Grab the initials, and check that as best match
					middleNameNode = vivoSolution.get("middleName");
					if (middleNameNode != null) {
						middleName = middleNameNode.toString();
						vivoInitials = loopNode.toString().substring(0,1) + middleNameNode.toString().substring(0,1);
						log.trace(loopNode.toString() + " has first and middle initial of " + vivoInitials);
						
						//If initials match, set as match, unless we've matched to a name below of at least 2 chars
						// TODO Nicholas: Fix the preference for the last "best" match
						if (vivoInitials.equalsIgnoreCase(pubmedInitials) && (matchNode == null && (minimum == 1 || loopNode.toString().length() == 1))) {
							log.trace("Setting " + loopNode.toString()  + " " + middleName + " as best match, matched initials " + vivoInitials);
							matchNode = loopNode;
							authorNode = vivoSolution.get("x");
						}
					} else {
						middleName = "";
						vivoInitials = "";
					}
					
					if(loop < minimum) {
						log.trace(loopNode.toString() + " only matched " + loop + " of " + foreNameNode.toString().length() + ". Minimum needed to match is " + minChars);
					} else {
						// if loopNode matches more of foreNameNode, it's the new best match
						//loopNode must also not cotradict Pubmed
						// TODO Nicholas: Fix the preference for the first "best" match
						if ((matchNode == null || !matchNode.toString().regionMatches(true, 0, foreNameNode.toString(), 0, loop)) && (vivoInitials.equalsIgnoreCase(pubmedInitials) || vivoInitials.isEmpty())) {
							log.trace("Setting " + loopNode.toString() + " " + middleName + " as best match, matched " + loop + " of " + foreNameNode.toString().length());
							matchNode = loopNode;
							authorNode = vivoSolution.get("x");
						} else {
							log.trace(loopNode.toString() + " matched " + loop + " of " + foreNameNode.toString().length());
>>>>>>> 2868ebe492f287ad46d55326e80021abfdad45f8:src/main/java/org/vivoweb/harvester/score/Score.java
						}
					}
				}
Solution content
						} else {
						loop++;
					}
					loop--;
					
					middleName = "";
					
					//Grab the initials, and check that as best match
					middleNameNode = vivoSolution.get("middleName");
					if (middleNameNode != null) {
						middleName = middleNameNode.toString();
						vivoInitials = loopNode.toString().substring(0,1) + middleNameNode.toString().substring(0,1);
						log.trace(loopNode.toString() + " has first and middle initial of " + vivoInitials);
						
						//If initials match, set as match, unless we've matched to a name below of at least 2 chars
						// TODO Nicholas: Fix the preference for the last "best" match
						if (vivoInitials.equalsIgnoreCase(pubmedInitials) && (matchNode == null && (minimum == 1 || loopNode.toString().length() == 1))) {
							log.trace("Setting " + loopNode.toString()  + " " + middleName + " as best match, matched initials " + vivoInitials);
							matchNode = loopNode;
							authorNode = vivoSolution.get("x");
						}
					} else {
						middleName = "";
						vivoInitials = "";
					}
					
					if(loop < minimum) {
						log.trace(loopNode.toString() + " only matched " + loop + " of " + foreNameNode.toString().length() + ". Minimum needed to match is " + minChars);
					} else {
						// if loopNode matches more of foreNameNode, it's the new best match
						//loopNode must also not cotradict Pubmed
						// TODO Nicholas: Fix the preference for the first "best" match
						if ((matchNode == null || !matchNode.toString().regionMatches(true, 0, foreNameNode.toString(), 0, loop)) && (vivoInitials.equalsIgnoreCase(pubmedInitials) || vivoInitials.isEmpty())) {
							log.trace("Setting " + loopNode.toString() + " " + middleName + " as best match, matched " + loop + " of " + foreNameNode.toString().length());
							matchNode = loopNode;
							authorNode = vivoSolution.get("x");
							log.trace(loopNode.toString() + " matched " + loop + " of " + foreNameNode.toString().length());
						}
					}
				}
File
Score.java
Developer's decision
Version 2
Kind of conflict
Comment
If statement
Method invocation
Variable
Chunk
Conflicting content
	/**
	 * Test method for {@link org.vivoweb.harvester.fetch.PubmedFetch#main(java.lang.String[]) main(String... args)}.
	 */
<<<<<<< HEAD:src/test/java/org/vivoweb/test/ingest/fetch/PubmedSOAPFetchTest.java
	public final void testPubmedSOAPFetchMain() {	
=======
	public final void testPubmedFetchMain() {
>>>>>>> 2868ebe492f287ad46d55326e80021abfdad45f8:src/test/java/org/vivoweb/test/harvester/fetch/PubmedFetchTest.java
		try {
			DocumentBuilder docB;
			
Solution content
	/**
	 * Test method for {@link org.vivoweb.harvester.fetch.PubmedFetch#main(java.lang.String[]) main(String... args)}.
	 */
	public final void testPubmedFetchMain() {
		try {
File
PubmedFetchTest.java
Developer's decision
Version 2
Kind of conflict
Method signature
Chunk
Conflicting content
			DocumentBuilder docB;
			
			this.rh = RecordHandler.parseConfig(this.configFile.getAbsolutePath());
<<<<<<< HEAD:src/test/java/org/vivoweb/test/ingest/fetch/PubmedSOAPFetchTest.java
			//test 1 record
			PubmedSOAPFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "1", "-b", "1", "-o", this.configFile.getAbsolutePath()});
=======
			
			//test 1 record
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "1", "-b", "1", "-o", this.configFile.getAbsolutePath()});
>>>>>>> 2868ebe492f287ad46d55326e80021abfdad45f8:src/test/java/org/vivoweb/test/harvester/fetch/PubmedFetchTest.java
			assertTrue(this.rh.iterator().hasNext());
			docB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			for(Record r : this.rh) {
Solution content
			this.rh = RecordHandler.parseConfig(this.configFile.getAbsolutePath());
			
			//test 1 record
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "1", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			DocumentBuilder docB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			for(Record r : this.rh) {
File
PubmedFetchTest.java
Developer's decision
Version 2
Kind of conflict
Comment
Method invocation
Chunk
Conflicting content
			}
			
			//test 0 records, batch 1
<<<<<<< HEAD:src/test/java/org/vivoweb/test/ingest/fetch/PubmedSOAPFetchTest.java
			PubmedSOAPFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			
			//test 1 records, batch 0
			PubmedSOAPFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());

			//test 0 records, batch 0
			PubmedSOAPFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "0", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			
			//test 1200 records, batch 500
			PubmedSOAPFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "1200", "-b", "500", "-o", this.configFile.getAbsolutePath()});
=======
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			
			//test 1 records, batch 0
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());

			//test 0 records, batch 0
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "0", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			
			//test 1200 records, batch 500
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "1200", "-b", "500", "-o", this.configFile.getAbsolutePath()});
>>>>>>> 2868ebe492f287ad46d55326e80021abfdad45f8:src/test/java/org/vivoweb/test/harvester/fetch/PubmedFetchTest.java
			assertTrue(this.rh.iterator().hasNext());
		} catch(Exception e) {
			log.error(e.getMessage(), e);
Solution content
			}
			
			//test 0 records, batch 1
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			
			//test 1 records, batch 0
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "1", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());

			//test 0 records, batch 0
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "0", "-b", "0", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
			
			//test 1200 records, batch 500
			PubmedFetch.main(new String[]{"-m", "test@test.com", "-t", "1:8000[dp]", "-n", "1200", "-b", "500", "-o", this.configFile.getAbsolutePath()});
			assertTrue(this.rh.iterator().hasNext());
		} catch(Exception e) {
			log.error(e.getMessage(), e);
File
PubmedFetchTest.java
Developer's decision
Version 2
Kind of conflict
Comment
Method invocation