@Test public void testClearingGraph() throws ParseException { String queryStr = "CLEAR SILENT GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(this.graphStore); Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH); Assert.assertTrue(referredGraphs.toArray()[0].equals(TEST_GRAPH)); }
public Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph) throws ParseException { Set<IRI> referredGraphs; JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString)); SparqlUnit sparqlUnit; sparqlUnit = parser.parse(); boolean referringVariableNamedGraph = false; if (sparqlUnit.isQuery()) { Query q = sparqlUnit.getQuery(); DataSet dataSet = q.getDataSet(); if (dataSet != null) { referredGraphs = dataSet.getDefaultGraphs(); referredGraphs.addAll(dataSet.getNamedGraphs()); } else { referredGraphs = new HashSet<IRI>(); } GroupGraphPattern queryPattern = q.getQueryPattern(); if (queryPattern != null) { Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns(); for (GraphPattern graphPattern : graphPatterns) { } } referringVariableNamedGraph = referringVariableNamedGraph(q); } else { Update u = sparqlUnit.getUpdate(); referredGraphs = u.getReferredGraphs(defaultGraph, graphStore); } if (referredGraphs.isEmpty()) { if (referringVariableNamedGraph) { return null; } referredGraphs.add(defaultGraph); } return referredGraphs; }
SparqlPreParser { public Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph) throws ParseException { Set<IRI> referredGraphs; JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString)); SparqlUnit sparqlUnit; sparqlUnit = parser.parse(); boolean referringVariableNamedGraph = false; if (sparqlUnit.isQuery()) { Query q = sparqlUnit.getQuery(); DataSet dataSet = q.getDataSet(); if (dataSet != null) { referredGraphs = dataSet.getDefaultGraphs(); referredGraphs.addAll(dataSet.getNamedGraphs()); } else { referredGraphs = new HashSet<IRI>(); } GroupGraphPattern queryPattern = q.getQueryPattern(); if (queryPattern != null) { Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns(); for (GraphPattern graphPattern : graphPatterns) { } } referringVariableNamedGraph = referringVariableNamedGraph(q); } else { Update u = sparqlUnit.getUpdate(); referredGraphs = u.getReferredGraphs(defaultGraph, graphStore); } if (referredGraphs.isEmpty()) { if (referringVariableNamedGraph) { return null; } referredGraphs.add(defaultGraph); } return referredGraphs; } }
SparqlPreParser { public Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph) throws ParseException { Set<IRI> referredGraphs; JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString)); SparqlUnit sparqlUnit; sparqlUnit = parser.parse(); boolean referringVariableNamedGraph = false; if (sparqlUnit.isQuery()) { Query q = sparqlUnit.getQuery(); DataSet dataSet = q.getDataSet(); if (dataSet != null) { referredGraphs = dataSet.getDefaultGraphs(); referredGraphs.addAll(dataSet.getNamedGraphs()); } else { referredGraphs = new HashSet<IRI>(); } GroupGraphPattern queryPattern = q.getQueryPattern(); if (queryPattern != null) { Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns(); for (GraphPattern graphPattern : graphPatterns) { } } referringVariableNamedGraph = referringVariableNamedGraph(q); } else { Update u = sparqlUnit.getUpdate(); referredGraphs = u.getReferredGraphs(defaultGraph, graphStore); } if (referredGraphs.isEmpty()) { if (referringVariableNamedGraph) { return null; } referredGraphs.add(defaultGraph); } return referredGraphs; } SparqlPreParser();  SparqlPreParser(GraphStore graphStore); }
SparqlPreParser { public Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph) throws ParseException { Set<IRI> referredGraphs; JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString)); SparqlUnit sparqlUnit; sparqlUnit = parser.parse(); boolean referringVariableNamedGraph = false; if (sparqlUnit.isQuery()) { Query q = sparqlUnit.getQuery(); DataSet dataSet = q.getDataSet(); if (dataSet != null) { referredGraphs = dataSet.getDefaultGraphs(); referredGraphs.addAll(dataSet.getNamedGraphs()); } else { referredGraphs = new HashSet<IRI>(); } GroupGraphPattern queryPattern = q.getQueryPattern(); if (queryPattern != null) { Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns(); for (GraphPattern graphPattern : graphPatterns) { } } referringVariableNamedGraph = referringVariableNamedGraph(q); } else { Update u = sparqlUnit.getUpdate(); referredGraphs = u.getReferredGraphs(defaultGraph, graphStore); } if (referredGraphs.isEmpty()) { if (referringVariableNamedGraph) { return null; } referredGraphs.add(defaultGraph); } return referredGraphs; } SparqlPreParser();  SparqlPreParser(GraphStore graphStore); Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph); }
SparqlPreParser { public Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph) throws ParseException { Set<IRI> referredGraphs; JavaCCGeneratedSparqlPreParser parser = new JavaCCGeneratedSparqlPreParser(new StringReader(queryString)); SparqlUnit sparqlUnit; sparqlUnit = parser.parse(); boolean referringVariableNamedGraph = false; if (sparqlUnit.isQuery()) { Query q = sparqlUnit.getQuery(); DataSet dataSet = q.getDataSet(); if (dataSet != null) { referredGraphs = dataSet.getDefaultGraphs(); referredGraphs.addAll(dataSet.getNamedGraphs()); } else { referredGraphs = new HashSet<IRI>(); } GroupGraphPattern queryPattern = q.getQueryPattern(); if (queryPattern != null) { Set<GraphPattern> graphPatterns = queryPattern.getGraphPatterns(); for (GraphPattern graphPattern : graphPatterns) { } } referringVariableNamedGraph = referringVariableNamedGraph(q); } else { Update u = sparqlUnit.getUpdate(); referredGraphs = u.getReferredGraphs(defaultGraph, graphStore); } if (referredGraphs.isEmpty()) { if (referringVariableNamedGraph) { return null; } referredGraphs.add(defaultGraph); } return referredGraphs; } SparqlPreParser();  SparqlPreParser(GraphStore graphStore); Set<IRI> getReferredGraphs(String queryString, IRI defaultGraph);  }