Skip to content

Commit b0c7dbd

Browse files
author
anquetil
committed
removed dependencies to ASTQuery
1 parent 0cbead4 commit b0c7dbd

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/main/java/fr/inria/corese/command/utils/coreseCoreWrapper/KgramQuery.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import fr.inria.corese.core.kgram.core.Query;
77
import fr.inria.corese.core.query.QueryProcess;
88
import fr.inria.corese.core.sparql.exceptions.EngineException;
9-
import fr.inria.corese.core.sparql.triple.parser.ASTQuery;
9+
import fr.inria.corese.core.sparql.triple.update.ASTUpdate;
1010

1111
/**
1212
* Wrapper class for corese core KGRAM query
@@ -29,10 +29,6 @@ public KgramQuery(String query) throws EngineException {
2929
this.query = exec.compile( query);
3030
}
3131

32-
public ASTQuery getAST() {
33-
return query.getAST();
34-
}
35-
3632
public List<Node> getFrom() {
3733
return query.getFrom();
3834
}
@@ -46,4 +42,17 @@ public boolean containsFromClause() {
4642
return query.getFrom() != null && !query.getFrom().isEmpty();
4743
}
4844

45+
/**
46+
* Checks if the query is an update query.
47+
*
48+
* @return true if the query is an update, false otherwise
49+
*/
50+
public boolean isSPARQLUpdate() {
51+
return query.getAST().isSPARQLUpdate();
52+
}
53+
54+
public ASTUpdate getUpdate() {
55+
return query.getAST().getUpdate();
56+
}
57+
4958
}

src/main/java/fr/inria/corese/command/utils/http/SparqlHttpClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private void validateQuery(String queryString, List<String> defaultGraphUris, Li
212212

213213
if (!this.requestMethodIsDefinedByUser) {
214214
// Check if the query is an update query.
215-
if (query.getAST().isSPARQLUpdate()) {
215+
if (query.isSPARQLUpdate()) {
216216
// If it is an update query, set the request method to POST_Encoded.
217217
this.requestMethod = EnumRequestMethod.POST_URLENCODED;
218218
} else {
@@ -224,7 +224,7 @@ private void validateQuery(String queryString, List<String> defaultGraphUris, Li
224224
// Check if the query is an update query and the method is GET
225225
// which is not allowed by the SPARQL specification
226226
// (see https://www.w3.org/TR/sparql11-protocol/#update-operation)
227-
if (this.requestMethod == EnumRequestMethod.GET && query.getAST().isSPARQLUpdate()) {
227+
if (this.requestMethod == EnumRequestMethod.GET && query.isSPARQLUpdate()) {
228228
throw new IllegalArgumentException(
229229
"SPARQL query is an update query, but GET method is used. Please use a POST method instead.");
230230
}
@@ -242,7 +242,7 @@ private void validateQuery(String queryString, List<String> defaultGraphUris, Li
242242
// which is not allowed by the SPARQL specification
243243
// (see https://www.w3.org/TR/sparql11-protocol/#update-operation)
244244
List<String> sparqlConstants = new ArrayList<>();
245-
ASTUpdate astUpdate = query.getAST().getUpdate();
245+
ASTUpdate astUpdate = query.getUpdate();
246246
if (astUpdate != null) {
247247
for (Update update : astUpdate.getUpdates()) {
248248
Composite composite = update.getComposite();

0 commit comments

Comments
 (0)