sparqlGraphLibrary/src/main/java/com/ge/research/semtk/sparqlToXLib/SparqlToXLibUtil.java
public static String generateSparqlFromOrUsing(String tab, String fromOrUsing, SparqlConnection conn, OntologyInfo oInfo) throws Exception {
		
		// do nothing if no conn
		if (conn == null) return "";
		if (conn.isOwlImportsEnabled() && oInfo == null) {
			throw new Exception("Internal error: Can't generate SPARQL for owlImport-enabled connection and no OntologyInfo.  Validate or inflate nodegroup first.");
		}
		
		// multiple ServerURLs is not implemented
		conn.confirmSingleServerURL();
		
		// get graphs/datasets for first model server.  All others must be equal
		ArrayList<String> datasets = conn.getAllGraphsForServer(conn.getDataInterface(0).getServerAndPort());
		
		// add graphs from owlImports
		if (oInfo != null) {
			ArrayList<String> owlImports = oInfo.getImportedGraphs();
			for (String g : owlImports) {
				datasets.add(g);
			}
		}
				
		StringBuilder sparql = new StringBuilder().append("\n");
		// No optimization: always "from" all datasets
		tab = SparqlToXUtils.tabIndent(tab);
		for (int i=0; i < datasets.size(); i++) {
			sparql.append(tab + fromOrUsing + " <" + datasets.get(i) + ">\n");
		}
		tab = SparqlToXUtils.tabOutdent(tab);
		
		return sparql.toString();
	}
/**
	 * FROM or USING clause logic
	 * Generates clauses if this.conn has
	 *     - exactly 1 serverURL
	 */
FROM or USING clause logic
Generates clauses if this.conn has
- exactly 1 serverURL
FROM or USING clause logic Generates clauses if this . conn has - exactly 1 serverURL
public static String generateSparqlFromOrUsing(String tab, String fromOrUsing, SparqlConnection conn, OntologyInfo oInfo) throws Exception {
		if (conn == null) return "";
		if (conn.isOwlImportsEnabled() && oInfo == null) {
			throw new Exception("Internal error: Can't generate SPARQL for owlImport-enabled connection and no OntologyInfo.  Validate or inflate nodegroup first.");
		}
		conn.confirmSingleServerURL();
		ArrayList<String> datasets = conn.getAllGraphsForServer(conn.getDataInterface(0).getServerAndPort());
		if (oInfo != null) {
			ArrayList<String> owlImports = oInfo.getImportedGraphs();
			for (String g : owlImports) {
				datasets.add(g);
			}
		}
		StringBuilder sparql = new StringBuilder().append("\n");
		tab = SparqlToXUtils.tabIndent(tab);
		for (int i=0; i < datasets.size(); i++) {
			sparql.append(tab + fromOrUsing + " <" + datasets.get(i) + ">\n");
		}
		tab = SparqlToXUtils.tabOutdent(tab);
		return sparql.toString();
	}
public static String generateSparqlFromOrUsing ( String tab , String fromOrUsing , SparqlConnection conn , OntologyInfo oInfo ) throws Exception { if ( conn == null ) return "" ; if ( conn . isOwlImportsEnabled ( ) && oInfo == null ) { throw new Exception ( "Internal error: Can't generate SPARQL for owlImport-enabled connection and no OntologyInfo.  Validate or inflate nodegroup first." ) ; } conn . confirmSingleServerURL ( ) ; ArrayList < String > datasets = conn . getAllGraphsForServer ( conn . getDataInterface ( 0 ) . getServerAndPort ( ) ) ; if ( oInfo != null ) { ArrayList < String > owlImports = oInfo . getImportedGraphs ( ) ; for ( String g : owlImports ) { datasets . add ( g ) ; } } StringBuilder sparql = new StringBuilder ( ) . append ( "\n" ) ; tab = SparqlToXUtils . tabIndent ( tab ) ; for ( int i = 0 ; i < datasets . size ( ) ; i ++ ) { sparql . append ( tab + fromOrUsing + " <" + datasets . get ( i ) + ">\n" ) ; } tab = SparqlToXUtils . tabOutdent ( tab ) ; return sparql . toString ( ) ; }
FROM or USING clause logic
 Generates clauses if this.conn has
     - exactly 1 serverURL
FROM or USING clause logic Generates clauses if this . conn has - exactly 1 serverURL
// do nothing if no conn // multiple ServerURLs is not implemented // get graphs/datasets for first model server.  All others must be equal // add graphs from owlImports // No optimization: always "from" all datasets