src/main/java/org/vivoweb/harvester/ingest/AcademicFetchFromED.java
/**
		 * @param pb  the people bean with all the data that has to be inserted from ED
		 * @return true or false based on whether the people exist in VIVO
		 * @throws IOException exception likely to be thrown by SDBJenaConnect
		 */
@param pb  the people bean with all the data that has to be inserted from ED
@return true or false based on whether the people exist in VIVO
@throws IOException exception likely to be thrown by SDBJenaConnect
@param pb the people bean with all the data that has to be inserted from ED @return true or false based on whether the people exist in VIVO @throws IOException exception likely to be thrown by SDBJenaConnect
private boolean checkPeopleInVivo(PeopleBean pb) throws IOException {
			int count = 0;
			String sparqlQuery = "PREFIX rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" +
									"PREFIX foaf:     <http://xmlns.com/foaf/0.1/> \n" +
									"SELECT  (count(rdf:type) as ?c) \n" +
									"WHERE {\n" +
									"GRAPH <http://vitro.mannlib.cornell.edu/a/graph/wcmcPeople> {\n" +
									"<" + this.vivoNamespace + "cwid-" + pb.getCwid().trim() + "> rdf:type foaf:Person . \n" +
									"}}";
			log.info(sparqlQuery);
			if(ingestType.equals(IngestType.VIVO_API.toString())) {
				try {
					String response = this.vivoClient.vivoQueryApi(sparqlQuery);
					log.info(response);
					JSONObject obj = new JSONObject(response);
					JSONArray bindings = obj.getJSONObject("results").getJSONArray("bindings");
					count = bindings.getJSONObject(0).getJSONObject("c").getInt("value");
				} catch(Exception e) {
					log.error("Api Exception", e);
				}
			} else if(ingestType.equals(IngestType.SDB_DIRECT.toString())){
				TDBJenaConnect vivoJena = this.tcf.getConnectionfromPool("dataSet");
				ResultSet rs = runSparqlTemplate(sparqlQuery, vivoJena);
				QuerySolution qs = rs.nextSolution();
				count = Integer.parseInt(qs.get("c").toString().replace("^^http://www.w3.org/2001/XMLSchema#integer", ""));
				if(vivoJena != null)
					this.tcf.returnConnectionToPool(vivoJena, "dataSet");
			} else {
				TDBJenaConnect vivoJena = this.tcf.createNewDataSetConnectionForPool();
				try{
				ResultSet rs = runTDBSparqlTemplate(sparqlQuery, vivoJena);
				QuerySolution qs = rs.nextSolution();
				count = Integer.parseInt(qs.get("c").toString().replace("^^http://www.w3.org/2001/XMLSchema#integer", ""));
				} catch(JenaTransactionException e) {
					log.error("TDB Exception with uid: ", e);
				}
				if(vivoJena != null)
					vivoJena.getDataset().close();
			}
			if(count > 0)
				return true;
			else
				return false;			
		}
private boolean checkPeopleInVivo ( PeopleBean pb ) throws IOException { int count = 0 ; String sparqlQuery = "PREFIX rdf:      <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "PREFIX foaf:     <http://xmlns.com/foaf/0.1/> \n" + "SELECT  (count(rdf:type) as ?c) \n" + "WHERE {\n" + "GRAPH <http://vitro.mannlib.cornell.edu/a/graph/wcmcPeople> {\n" + "<" + this . vivoNamespace + "cwid-" + pb . getCwid ( ) . trim ( ) + "> rdf:type foaf:Person . \n" + "}}" ; log . info ( sparqlQuery ) ; if ( ingestType . equals ( IngestType . VIVO_API . toString ( ) ) ) { try { String response = this . vivoClient . vivoQueryApi ( sparqlQuery ) ; log . info ( response ) ; JSONObject obj = new JSONObject ( response ) ; JSONArray bindings = obj . getJSONObject ( "results" ) . getJSONArray ( "bindings" ) ; count = bindings . getJSONObject ( 0 ) . getJSONObject ( "c" ) . getInt ( "value" ) ; } catch ( Exception e ) { log . error ( "Api Exception" , e ) ; } } else if ( ingestType . equals ( IngestType . SDB_DIRECT . toString ( ) ) ) { TDBJenaConnect vivoJena = this . tcf . getConnectionfromPool ( "dataSet" ) ; ResultSet rs = runSparqlTemplate ( sparqlQuery , vivoJena ) ; QuerySolution qs = rs . nextSolution ( ) ; count = Integer . parseInt ( qs . get ( "c" ) . toString ( ) . replace ( "^^http://www.w3.org/2001/XMLSchema#integer" , "" ) ) ; if ( vivoJena != null ) this . tcf . returnConnectionToPool ( vivoJena , "dataSet" ) ; } else { TDBJenaConnect vivoJena = this . tcf . createNewDataSetConnectionForPool ( ) ; try { ResultSet rs = runTDBSparqlTemplate ( sparqlQuery , vivoJena ) ; QuerySolution qs = rs . nextSolution ( ) ; count = Integer . parseInt ( qs . get ( "c" ) . toString ( ) . replace ( "^^http://www.w3.org/2001/XMLSchema#integer" , "" ) ) ; } catch ( JenaTransactionException e ) { log . error ( "TDB Exception with uid: " , e ) ; } if ( vivoJena != null ) vivoJena . getDataset ( ) . close ( ) ; } if ( count > 0 ) return true ; else return false ; }
@param pb  the people bean with all the data that has to be inserted from ED
 @return true or false based on whether the people exist in VIVO
 @throws IOException exception likely to be thrown by SDBJenaConnect
@param pb the people bean with all the data that has to be inserted from ED @return true or false based on whether the people exist in VIVO @throws IOException exception likely to be thrown by SDBJenaConnect