@Test public void testSelect() { Set<String> resources = SPARQLExecutor.executeSelect("SELECT ?s FROM <http: Object[] actual = resources.toArray(); Arrays.sort(actual); assertArrayEquals(getGoldenArray1(), actual); resources = SPARQLExecutor.executeSelect("SELECT ?o FROM <http: actual = resources.toArray(); Arrays.sort(actual); assertArrayEquals(getGoldenArray2(), actual); }
@Deprecated public static Results executeSelect(final String query, final String endpoint) { QueryExecution qeExe = QueryExecutionFactory.sparqlService(endpoint, query); ResultSet rs = qeExe.execSelect(); Results res = new Results(); res.header.addAll(rs.getResultVars()); while(rs.hasNext()) { QuerySolution sol = rs.nextSolution(); res.table.add(new ArrayList<String>()); for(String head: res.header) { String answer = ""; if(sol.get(head).isResource()) { answer = sol.getResource(head).toString(); } else { String temp = sol.get(head).toString(); if(temp.contains("@")) { answer = "\"" + temp.substring(0, temp.indexOf("@")) + "\"" + temp.substring(temp.indexOf("@")); } else if (temp.contains("^^")){ answer = "\"" + temp.substring(0, temp.indexOf("^")) + "\"^^<" + temp.substring(temp.indexOf("^")+2) + ">"; } else { answer = temp; } } res.table.get(res.table.size()-1).add(answer); } } return res; }
SPARQLExecutor { @Deprecated public static Results executeSelect(final String query, final String endpoint) { QueryExecution qeExe = QueryExecutionFactory.sparqlService(endpoint, query); ResultSet rs = qeExe.execSelect(); Results res = new Results(); res.header.addAll(rs.getResultVars()); while(rs.hasNext()) { QuerySolution sol = rs.nextSolution(); res.table.add(new ArrayList<String>()); for(String head: res.header) { String answer = ""; if(sol.get(head).isResource()) { answer = sol.getResource(head).toString(); } else { String temp = sol.get(head).toString(); if(temp.contains("@")) { answer = "\"" + temp.substring(0, temp.indexOf("@")) + "\"" + temp.substring(temp.indexOf("@")); } else if (temp.contains("^^")){ answer = "\"" + temp.substring(0, temp.indexOf("^")) + "\"^^<" + temp.substring(temp.indexOf("^")+2) + ">"; } else { answer = temp; } } res.table.get(res.table.size()-1).add(answer); } } return res; } }
SPARQLExecutor { @Deprecated public static Results executeSelect(final String query, final String endpoint) { QueryExecution qeExe = QueryExecutionFactory.sparqlService(endpoint, query); ResultSet rs = qeExe.execSelect(); Results res = new Results(); res.header.addAll(rs.getResultVars()); while(rs.hasNext()) { QuerySolution sol = rs.nextSolution(); res.table.add(new ArrayList<String>()); for(String head: res.header) { String answer = ""; if(sol.get(head).isResource()) { answer = sol.getResource(head).toString(); } else { String temp = sol.get(head).toString(); if(temp.contains("@")) { answer = "\"" + temp.substring(0, temp.indexOf("@")) + "\"" + temp.substring(temp.indexOf("@")); } else if (temp.contains("^^")){ answer = "\"" + temp.substring(0, temp.indexOf("^")) + "\"^^<" + temp.substring(temp.indexOf("^")+2) + ">"; } else { answer = temp; } } res.table.get(res.table.size()-1).add(answer); } } return res; }  }
SPARQLExecutor { @Deprecated public static Results executeSelect(final String query, final String endpoint) { QueryExecution qeExe = QueryExecutionFactory.sparqlService(endpoint, query); ResultSet rs = qeExe.execSelect(); Results res = new Results(); res.header.addAll(rs.getResultVars()); while(rs.hasNext()) { QuerySolution sol = rs.nextSolution(); res.table.add(new ArrayList<String>()); for(String head: res.header) { String answer = ""; if(sol.get(head).isResource()) { answer = sol.getResource(head).toString(); } else { String temp = sol.get(head).toString(); if(temp.contains("@")) { answer = "\"" + temp.substring(0, temp.indexOf("@")) + "\"" + temp.substring(temp.indexOf("@")); } else if (temp.contains("^^")){ answer = "\"" + temp.substring(0, temp.indexOf("^")) + "\"^^<" + temp.substring(temp.indexOf("^")+2) + ">"; } else { answer = temp; } } res.table.get(res.table.size()-1).add(answer); } } return res; }  @Deprecated static boolean isEndpointAlive(final String endpoint); @Deprecated static Results executeSelect(final String query, final String endpoint); @Deprecated static Boolean executeAsk(final String query, final String endpoint); @Deprecated static Set<RDFNode> sparql(final String service, final String query); }
SPARQLExecutor { @Deprecated public static Results executeSelect(final String query, final String endpoint) { QueryExecution qeExe = QueryExecutionFactory.sparqlService(endpoint, query); ResultSet rs = qeExe.execSelect(); Results res = new Results(); res.header.addAll(rs.getResultVars()); while(rs.hasNext()) { QuerySolution sol = rs.nextSolution(); res.table.add(new ArrayList<String>()); for(String head: res.header) { String answer = ""; if(sol.get(head).isResource()) { answer = sol.getResource(head).toString(); } else { String temp = sol.get(head).toString(); if(temp.contains("@")) { answer = "\"" + temp.substring(0, temp.indexOf("@")) + "\"" + temp.substring(temp.indexOf("@")); } else if (temp.contains("^^")){ answer = "\"" + temp.substring(0, temp.indexOf("^")) + "\"^^<" + temp.substring(temp.indexOf("^")+2) + ">"; } else { answer = temp; } } res.table.get(res.table.size()-1).add(answer); } } return res; }  @Deprecated static boolean isEndpointAlive(final String endpoint); @Deprecated static Results executeSelect(final String query, final String endpoint); @Deprecated static Boolean executeAsk(final String query, final String endpoint); @Deprecated static Set<RDFNode> sparql(final String service, final String query);  }