src/main/java/org/vivoweb/harvester/operations/DeleteProfile.java
/**
	 * This method will check from the list of publications published by the individual to see any of the publication has any other additional WCMC authors. 
	 */
This method will check from the list of publications published by the individual to see any of the publication has any other additional WCMC authors.
This method will check from the list of publications published by the individual to see any of the publication has any other additional WCMC authors .
private  void checkAdditionalWCMCAuthoredPubs( List<PublicationBean> publications) {
		Iterator<PublicationBean> i = publications.iterator();
		logger.info("Check for Additional WCMC Authored pubs.");
		while(i.hasNext())
		{
			PublicationBean pub = i.next();
			String sparqlQuery = "PREFIX vivo: <http://vivoweb.org/ontology/core#> \n" + 
				 "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + 
				 "SELECT (count(?AuthorCount) as ?count) \n" +
				 "WHERE { \n"+
				 "GRAPH <http://vitro.mannlib.cornell.edu/a/graph/wcmcPublications> {\n" +
				 "<" + pub.getPubUrl() + "> vivo:relatedBy ?authors . \n" +
				 "?authors vivo:relates ?AuthorCount . \n" +
				 "FILTER(REGEX(STR(?AuthorCount),\"cwid\",\"i\")) \n" +
				 "}}";
			if(ingestType.equals(IngestType.VIVO_API.toString())) {
				try {
					String response = this.vivoClient.vivoQueryApi(sparqlQuery);
					logger.info(response);
					JSONObject obj = new JSONObject(response);
					JSONArray bindings = obj.getJSONObject("results").getJSONArray("bindings");
					if(bindings != null && !bindings.isEmpty()) {
						int count = bindings.getJSONObject(0).getJSONObject("count").getInt("value");
						if(count <= 1) 
							pub.setAdditionalWcmcAuthorFlag(false);
						else
							pub.setAdditionalWcmcAuthorFlag(true);
					}
				} catch(Exception e) {
					logger.error("Api Exception", e);
				}
			} else if(ingestType.equals(IngestType.SDB_DIRECT.toString())){
				SDBJenaConnect vivoJena = this.jcf.getConnectionfromPool("dataSet");
				ResultSet rs;
				try {
					rs = vivoJena.executeSelectQuery(sparqlQuery, true);
					int count = Integer.parseInt(rs.nextSolution().get("count").toString().replace("^^http://www.w3.org/2001/XMLSchema#integer", ""));
					if(count <= 1) 
						pub.setAdditionalWcmcAuthorFlag(false);
					else
						pub.setAdditionalWcmcAuthorFlag(true);
				} catch(IOException e) {
					logger.error("Error Connecting to Jena Database" , e);
				}
				this.jcf.returnConnectionToPool(vivoJena, "dataSet");
			}
		}
	}
private void checkAdditionalWCMCAuthoredPubs ( List < PublicationBean > publications ) { Iterator < PublicationBean > i = publications . iterator ( ) ; logger . info ( "Check for Additional WCMC Authored pubs." ) ; while ( i . hasNext ( ) ) { PublicationBean pub = i . next ( ) ; String sparqlQuery = "PREFIX vivo: <http://vivoweb.org/ontology/core#> \n" + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n" + "SELECT (count(?AuthorCount) as ?count) \n" + "WHERE { \n" + "GRAPH <http://vitro.mannlib.cornell.edu/a/graph/wcmcPublications> {\n" + "<" + pub . getPubUrl ( ) + "> vivo:relatedBy ?authors . \n" + "?authors vivo:relates ?AuthorCount . \n" + "FILTER(REGEX(STR(?AuthorCount),\"cwid\",\"i\")) \n" + "}}" ; if ( ingestType . equals ( IngestType . VIVO_API . toString ( ) ) ) { try { String response = this . vivoClient . vivoQueryApi ( sparqlQuery ) ; logger . info ( response ) ; JSONObject obj = new JSONObject ( response ) ; JSONArray bindings = obj . getJSONObject ( "results" ) . getJSONArray ( "bindings" ) ; if ( bindings != null && ! bindings . isEmpty ( ) ) { int count = bindings . getJSONObject ( 0 ) . getJSONObject ( "count" ) . getInt ( "value" ) ; if ( count <= 1 ) pub . setAdditionalWcmcAuthorFlag ( false ) ; else pub . setAdditionalWcmcAuthorFlag ( true ) ; } } catch ( Exception e ) { logger . error ( "Api Exception" , e ) ; } } else if ( ingestType . equals ( IngestType . SDB_DIRECT . toString ( ) ) ) { SDBJenaConnect vivoJena = this . jcf . getConnectionfromPool ( "dataSet" ) ; ResultSet rs ; try { rs = vivoJena . executeSelectQuery ( sparqlQuery , true ) ; int count = Integer . parseInt ( rs . nextSolution ( ) . get ( "count" ) . toString ( ) . replace ( "^^http://www.w3.org/2001/XMLSchema#integer" , "" ) ) ; if ( count <= 1 ) pub . setAdditionalWcmcAuthorFlag ( false ) ; else pub . setAdditionalWcmcAuthorFlag ( true ) ; } catch ( IOException e ) { logger . error ( "Error Connecting to Jena Database" , e ) ; } this . jcf . returnConnectionToPool ( vivoJena , "dataSet" ) ; } } }
This method will check from the list of publications published by the individual to see any of the publication has any other additional WCMC authors.
This method will check from the list of publications published by the individual to see any of the publication has any other additional WCMC authors .