Class RunHttpQuery
java.lang.Object
org.apache.jena.cmd.CommandLineBase
org.apache.jena.cmd.CmdLineArgs
org.apache.jena.cmd.CmdMain
org.apache.jena.cmd.CmdArgModule
org.apache.jena.cmd.CmdGeneral
se.liu.ida.hefquin.cli.RunHttpQuery
public class RunHttpQuery
extends org.apache.jena.cmd.CmdGeneral
A command-line tool that interacts with a HeFQUIN service to execute a SPARQL
query over the federation for which the service is set up, and prints the query result
returned by the service.
The tool sends a SPARQL SELECT query to a given HTTP endpoint using a
standard HTTP POST request with SPARQL Protocol encoding. It expects the
endpoint to return results in SPARQL JSON Results format, which is then
parsed into a Jena
ResultSet.
The resulting solution mappings are printed to standard output or written
to a file in a user-selected results format.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.jena.cmd.ArgDeclprotected static final Patternprotected final ModPlanPrintingprotected final ModQueryprotected final ModResultsOutExtprotected final arq.cmdline.ModTimeFields inherited from class org.apache.jena.cmd.CmdGeneral
cmdName, modGeneral, modVersionFields inherited from class org.apache.jena.cmd.CmdLineArgs
argMap, args, positionals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidexec()Executes the HTTP SPARQL query command.protected voidexec(String serverURI, org.apache.jena.query.Query query, PrintStream out) Executes a SPARQL query against a remote SPARQL endpoint using HTTP.protected StringReturns the command name used to invoke the tool.protected org.apache.jena.query.QuerygetQuery()Returns the SPARQL query to be executed.protected StringReturns the usage summary string of the command, showing the required arguments.static voidprotected static StringprepareQuery(org.apache.jena.query.Query query) Prepares a SPARQL query for HTTP transmission by ensuring that any base URI defined in the query prologue is explicitly included in the serialized query.protected voidprintPlans(org.apache.jena.atlas.json.JsonObject obj) Prints any query planning and execution artifacts contained in the given response object using the printers configured in the plan printing module.protected voidRegisters HeFQUIN-specific integrations with the Jena framework.Methods inherited from class org.apache.jena.cmd.CmdGeneral
add, addModule, getUsage, help, isDebug, isQuiet, isVerbose, printHelp, processModulesAndArgs, usage, usageMethods inherited from class org.apache.jena.cmd.CmdArgModule
processMethods inherited from class org.apache.jena.cmd.CmdMain
cmdError, cmdError, mainAndExit, mainMethod, mainRun, mainRun, mainRunMethods inherited from class org.apache.jena.cmd.CmdLineArgs
add, add, add, addArg, addArg, addPositional, clear, contains, contains, containsMultiple, containsMultiple, getArg, getArg, getNumPositional, getPositional, getPositionalArg, getPositionalOrStdin, getValue, getValue, getValues, getValues, handleUnrecognizedArg, hasArg, hasArg, hasArgs, hasPositional, hasValueOfFalse, hasValueOfTrue, indirect, indirect, matchesIndirect, matchesIndirect, removeArg, removeArg, removeArgAll, reset, toStringMethods inherited from class org.apache.jena.cmd.CommandLineBase
apply, getArg, getArgList, setArgs
-
Field Details
-
modTime
protected final arq.cmdline.ModTime modTime -
modPlanPrinting
-
modQuery
-
modResultsExt
-
argServerAddress
protected final org.apache.jena.cmd.ArgDecl argServerAddress -
BASE_PATTERN
-
-
Constructor Details
-
RunHttpQuery
-
-
Method Details
-
main
-
getSummary
Returns the usage summary string of the command, showing the required arguments.- Specified by:
getSummaryin classorg.apache.jena.cmd.CmdGeneral- Returns:
- A string that describes the usage of the command.
-
getCommandName
Returns the command name used to invoke the tool.- Specified by:
getCommandNamein classorg.apache.jena.cmd.CmdMain- Returns:
- The name of the command.
-
exec
protected void exec()Executes the HTTP SPARQL query command. This method parses command-line arguments, prepares the output stream (either standard output or a file if specified) and delegates query execution to the HTTP request handler. It ensures that any file-based output streams are properly closed after execution, even if an error occurs during query processing.- Specified by:
execin classorg.apache.jena.cmd.CmdMain
-
exec
Executes a SPARQL query against a remote SPARQL endpoint using HTTP. The query is sent using the SPARQL Protocol over HTTP and the results are expected to be returned in SPARQL JSON Results format. This method handles HTTP request creation, response validation, error handling and conversion of the result set into a printable format. Successful results are written to the provided output stream. -
registerHeFQUINJenaIntegration
protected void registerHeFQUINJenaIntegration()Registers HeFQUIN-specific integrations with the Jena framework. This method ensures that queries written in the HeFQUIN syntax are correctly parsed into Jena's internal query representation and that query serialization correctly falls back to standard SPARQL 1.2 behaviour when needed. -
getQuery
protected org.apache.jena.query.Query getQuery()Returns the SPARQL query to be executed.- Returns:
- the
Queryobject - Throws:
org.apache.jena.cmd.TerminationException- if the query file could not be found
-
prepareQuery
Prepares a SPARQL query for HTTP transmission by ensuring that any base URI defined in the query prologue is explicitly included in the serialized query.If the query already contains an explicit
BASE <...>declaration, it is left unchanged. Otherwise, if a base URI is present in the query prologue (e.g., provided via the--baseargument), it is injected as a leadingBASEclause. -
printPlans
protected void printPlans(org.apache.jena.atlas.json.JsonObject obj) Prints any query planning and execution artifacts contained in the given response object using the printers configured in the plan printing module.- Parameters:
obj- JSON response object returned by the HeFQUIN service
-