-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
basil/src/main/java/uk/ac/open/kmi/basil/invoke/DirectExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package uk.ac.open.kmi.basil.invoke; | ||
|
||
import com.hp.hpl.jena.query.Query; | ||
import com.hp.hpl.jena.query.QueryExecution; | ||
import com.hp.hpl.jena.query.QueryExecutionFactory; | ||
|
||
import uk.ac.open.kmi.basil.core.InvocationResult; | ||
import uk.ac.open.kmi.basil.core.exceptions.ApiInvocationException; | ||
|
||
/** | ||
* | ||
* @author enridaga | ||
* | ||
*/ | ||
public class DirectExecutor implements QueryExecutor { | ||
|
||
@Override | ||
public InvocationResult execute(Query q, String endpoint) throws ApiInvocationException { | ||
QueryExecution qe = QueryExecutionFactory.sparqlService(endpoint, q); | ||
if (q.isSelectType()) { | ||
return new InvocationResult(qe.execSelect(), q); | ||
} else if (q.isConstructType()) { | ||
return new InvocationResult(qe.execConstruct(), q); | ||
} else if (q.isAskType()) { | ||
return new InvocationResult(qe.execAsk(), q); | ||
} else if (q.isDescribeType()) { | ||
return new InvocationResult(qe.execDescribe(), q); | ||
} else { | ||
throw new ApiInvocationException("Unsupported query type: " + q.getQueryType()); | ||
} | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
basil/src/main/java/uk/ac/open/kmi/basil/invoke/QueryExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package uk.ac.open.kmi.basil.invoke; | ||
|
||
import com.hp.hpl.jena.query.Query; | ||
|
||
import uk.ac.open.kmi.basil.core.InvocationResult; | ||
import uk.ac.open.kmi.basil.core.exceptions.ApiInvocationException; | ||
|
||
public interface QueryExecutor { | ||
|
||
public InvocationResult execute(Query query, String endpoint) throws ApiInvocationException; | ||
} |