@Override protected boolean _contains(String varName) { return querySolution.contains(varName); }
@Override public SPARQLExecutionResult call() { Map<String, Set<String>> resultSet = new HashMap<>(); markers.forEach(marker -> resultSet.put(marker, new HashSet<>())); Model unionModel = ModelFactory.createDefaultModel(); SPARQLServiceConverter converter = new SPARQLServiceConverter(schema); String sparqlQuery = converter.getSelectQuery(query, inputSubset, rootType); logger.info(sparqlQuery); Query jenaQuery = QueryFactory.create(sparqlQuery); QueryExecution qexec = QueryExecutionFactory.create(jenaQuery, model); ResultSet results = qexec.execSelect(); results.forEachRemaining(solution -> { markers.forEach(marker ->{ if(solution.contains(marker)) { resultSet.get(marker).add(solution.get(marker).asResource().getURI()); } }); Model model = this.sparqlEndpointService.getModelFromResults(query, solution, schema); unionModel.add(model); }); return new SPARQLExecutionResult(resultSet, unionModel); }
@Override public SPARQLExecutionResult call() { Map<String, Set<String>> resultSet = new HashMap<>(); markers.forEach(marker -> resultSet.put(marker, new HashSet<>())); Model unionModel = ModelFactory.createDefaultModel(); SPARQLServiceConverter converter = new SPARQLServiceConverter(schema); String sparqlQuery = converter.getSelectQuery(query, inputSubset, rootType); logger.info(sparqlQuery); Query jenaQuery = QueryFactory.create(sparqlQuery); QueryExecution qexec = QueryExecutionFactory.create(jenaQuery, model); ResultSet results = qexec.execSelect(); results.forEachRemaining(solution -> { markers.forEach(marker ->{ if(solution.contains(marker)) { resultSet.get(marker).add(solution.get(marker).asResource().getURI()); } }); Model model = this.sparqlEndpointService.getModelFromResults(query, solution, schema); unionModel.add(model); }); return new SPARQLExecutionResult(resultSet, unionModel); }
private Map<String, Long> getStats(String sparqlQuery, QueryExecutionFactory qef) { Map<String, Long> stats = new HashMap<>(); try (QueryExecution qe = qef.createQueryExecution(sparqlQuery)) { qe.execSelect().forEachRemaining( qs -> { String s = qs.get("stats").toString(); int c = 0; if (qs.contains("count")) { c = qs.get("count").asLiteral().getInt(); } stats.put(s, (long) c); }); } return stats; } }
private Map<String, Long> getStats(String sparqlQuery, QueryExecutionFactory qef) { Map<String, Long> stats = new HashMap<>(); try (QueryExecution qe = qef.createQueryExecution(sparqlQuery)) { qe.execSelect().forEachRemaining( qs -> { String s = qs.get("stats").toString(); int c = 0; if (qs.contains("count")) { c = qs.get("count").asLiteral().getInt(); } stats.put(s, (long) c); }); } return stats; } }
while (results.hasNext()) { QuerySolution solution = results.nextSolution(); if (solution.contains("cause")) { RDFNode node = solution.get("cause"); if (node.isResource()) {
if (row.contains(p.getId())) { RDFNode n = row.get(p.getId()); Binding b;
if (qs.contains("contentNode")) { contentNodes.add(qs.get("contentNode").asResource());
if (row.contains(p.getId())) { RDFNode n = row.get(p.getId()); Binding b;
@Override protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, TestCase testCase) throws TestCaseExecutionException { Collection<TestCaseResult> testCaseResults = new ArrayList<>(); try (QueryExecution qe = testSource.getExecutionFactory().createQueryExecution(queryGenerationFactory.getSparqlQuery(testCase))) { qe.execSelect().forEachRemaining( qs -> { RDFNode focusNode = qs.get("this"); String message = testCase.getResultMessage(); if (qs.contains("message")) { message = qs.get("message").toString(); } RLOGLevel logLevel = testCase.getLogLevel(); testCaseResults.add(new ShaclLiteTestCaseResultImpl(testCase.getTestURI(), logLevel, message, focusNode)); }); } catch (QueryExceptionHTTP e) { checkQueryResultStatus(e); } return testCaseResults; }
@Override protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, TestCase testCase) throws TestCaseExecutionException { Collection<TestCaseResult> testCaseResults = new ArrayList<>(); try (QueryExecution qe = testSource.getExecutionFactory().createQueryExecution(queryGenerationFactory.getSparqlQuery(testCase))) { qe.execSelect().forEachRemaining( qs -> { RDFNode focusNode = qs.get("this"); String message = testCase.getResultMessage(); if (qs.contains("message")) { message = qs.get("message").toString(); } RLOGLevel logLevel = testCase.getLogLevel(); testCaseResults.add(new ShaclLiteTestCaseResultImpl(testCase.getTestURI(), logLevel, message, focusNode)); }); } catch (QueryExceptionHTTP e) { checkQueryResultStatus(e); } return testCaseResults; }
@Override public PropertyBags query(String query) { String query1 = adjustedQuery(query); PropertyBags results = new PropertyBags(); // Because Jena in-memory does not support default graph // as the union of named graphs // We use the dataset for maintaining separate graphs, // but query in general against union // Only query against dataset if we found a GRAPH clause in the query text try (QueryExecution q = queryExecutionFromQueryText(query1)) { // If we want to analyze the algebra of the query, // set ARQ.symLogExec to true in the query context ResultSet r = q.execSelect(); List<String> names = r.getResultVars(); while (r.hasNext()) { QuerySolution s = r.next(); PropertyBag result = new PropertyBag(names); names.forEach(name -> { if (s.contains(name)) { result.put(name, stringValue(s.get(name))); } }); if (!result.isEmpty()) { results.add(result); } } } return results; }
String graphField = qsol1.contains("graphField") ? qsol1.getLiteral("graphField").getLexicalForm() : null; String langField = qsol1.contains("langField") ? qsol1.getLiteral("langField").getLexicalForm() : null; String defaultField = qsol1.contains("dftField") ? qsol1.getLiteral("dftField").getLexicalForm() : null ; String uniqueIdField = qsol1.contains("uidField") ? qsol1.getLiteral("uidField").getLexicalForm() : null;
String graphField = qsol1.contains("graphField") ? qsol1.getLiteral("graphField").getLexicalForm() : null; String langField = qsol1.contains("langField") ? qsol1.getLiteral("langField").getLexicalForm() : null; String defaultField = qsol1.contains("dftField") ? qsol1.getLiteral("dftField").getLexicalForm() : null ; String uniqueIdField = qsol1.contains("uidField") ? qsol1.getLiteral("uidField").getLexicalForm() : null;
@Test public void testInitialBindings7() { // JENA-1354 Query query = QueryFactory.create("SELECT DISTINCT ?x WHERE {}"); Dataset ds = DatasetFactory.create(); QuerySolutionMap initialBinding = new QuerySolutionMap(); initialBinding.add("a", ResourceFactory.createTypedLiteral(Boolean.TRUE)); try ( QueryExecution qexec = QueryExecutionFactory.create(query, ds, initialBinding) ) { assertFalse(qexec.execSelect().next().contains("a")); } }
private UserAccount parseSolution(QuerySolution solution) { UserAccount user = new UserAccount(); user.setUri(getUriFromSolution(solution)); user.setEmailAddress(solution.getLiteral("email").getString()); user.setFirstName(ifLiteralPresent(solution, "firstName", "")); user.setLastName(ifLiteralPresent(solution, "lastName", "")); user.setMd5Password(ifLiteralPresent(solution, "md5pwd", "")); user.setArgon2Password(ifLiteralPresent(solution, "a2pwd", "")); user.setPasswordLinkExpires(ifLongPresent(solution, "expire", 0L)); user.setLoginCount(ifIntPresent(solution, "count", 0)); user.setLastLoginTime(ifLongPresent(solution, "lastLogin", 0)); user.setStatus(parseStatus(solution, "status", null)); user.setRootUser(solution.contains("isRoot")); return user; }
Iterator<String> vars = result.varNames(); while (vars.hasNext()) { assertTrue(result.contains(vars.next()));