Class SPARQL
java.lang.Object
it.uniroma2.art.semanticturkey.services.STServiceAdapter
it.uniroma2.art.semanticturkey.services.core.SPARQL
- All Implemented Interfaces:
NewerNewStyleService
,STService
This class provides services for SPARQL queries/updates.
- Author:
- Manuel Fiorelli
-
Nested Class Summary
-
Field Summary
Fields inherited from class it.uniroma2.art.semanticturkey.services.STServiceAdapter
applicationEventPublisher, cfManager, stServiceContext
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureOperation
(boolean includeInferred, Map<String, org.eclipse.rdf4j.model.Value> bindings, int maxExecTime, org.eclipse.rdf4j.model.IRI[] defaultGraphs, org.eclipse.rdf4j.model.IRI[] namedGraphs, org.eclipse.rdf4j.model.IRI defaultInsertGraph, org.eclipse.rdf4j.model.IRI[] defaultRemoveGraphs, org.eclipse.rdf4j.query.Operation preparedUpdate) com.fasterxml.jackson.databind.JsonNode
evaluateQuery
(String query, org.eclipse.rdf4j.query.QueryLanguage ql, boolean includeInferred, Map<String, org.eclipse.rdf4j.model.Value> bindings, int maxExecTime, org.eclipse.rdf4j.model.IRI[] defaultGraphs, org.eclipse.rdf4j.model.IRI[] namedGraphs) Evaluates a query.void
executeUpdate
(String query, org.eclipse.rdf4j.query.QueryLanguage ql, boolean includeInferred, Map<String, org.eclipse.rdf4j.model.Value> bindings, int maxExecTime, org.eclipse.rdf4j.model.IRI[] defaultGraphs, org.eclipse.rdf4j.model.IRI[] namedGraphs, org.eclipse.rdf4j.model.IRI defaultInsertGraph, org.eclipse.rdf4j.model.IRI[] defaultRemoveGraphs) Executes an update.void
exportGraphQueryResultAsRdf
(jakarta.servlet.http.HttpServletResponse oRes, String query, org.eclipse.rdf4j.query.QueryLanguage ql, boolean includeInferred, Map<String, org.eclipse.rdf4j.model.Value> bindings, int maxExecTime, org.eclipse.rdf4j.model.IRI[] defaultGraphs, org.eclipse.rdf4j.model.IRI[] namedGraphs, TransformationPipeline filteringPipeline, String outputFormat, PluginSpecification deployerSpec, PluginSpecification reformattingExporterSpec) Evaluates a graph query and dumps its result (a graph) to an RDF file, using our filtered export mechanism (seeExport
).void
exportQueryResultAsSpreadsheet
(jakarta.servlet.http.HttpServletResponse oRes, String format, String query, org.eclipse.rdf4j.query.QueryLanguage ql, boolean includeInferred, Map<String, org.eclipse.rdf4j.model.Value> bindings, int maxExecTime, org.eclipse.rdf4j.model.IRI[] defaultGraphs, org.eclipse.rdf4j.model.IRI[] namedGraphs) Exports the query result as spreadsheetMethods inherited from class it.uniroma2.art.semanticturkey.services.STServiceAdapter
addValue, checkNotLocallyDefined, createQueryBuilder, generateIRI, generateNatureSPARQLSelectPart, generateNatureSPARQLWherePart, generateResourceWithCustomConstructor, getCodaLexModeForSearchFromLexicalizationModel, getDeleteGraph, getGraphFromNature, getInitializedCodaCore, getManagedConnection, getMetadataGraph, getPlatformTransactionManager, getProject, getRepository, getRoleFromNature, getUserNamedGraphs, getWorkingGraph, instantiateSearchStrategy, instantiateSearchStrategy, parseReference, publishResourceDeleted, publishResourceDeleted, removeReifiedValue, retrieveResources, shutDownCodaCore, updateTriplePredicate
-
Constructor Details
-
SPARQL
public SPARQL()
-
-
Method Details
-
evaluateQuery
@STServiceOperation(method=POST) @Read @PreAuthorize("@auth.isAuthorized(\'rdf(sparql)\', \'R\')") public com.fasterxml.jackson.databind.JsonNode evaluateQuery(String query, @Optional(defaultValue="SPARQL") org.eclipse.rdf4j.query.QueryLanguage ql, @Optional(defaultValue="true") boolean includeInferred, @Optional(defaultValue="{}") Map<String, org.eclipse.rdf4j.model.Value> bindings, @Optional(defaultValue="0") int maxExecTime, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] defaultGraphs, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] namedGraphs) throws IOExceptionEvaluates a query. The parameters controlling the dataset (i.e.defaultGraphs
andnamedGraphs
) are not orthogonal: seeDataset
for an explanation of their meaning.- Parameters:
query
- the queryql
- the query language (seeQueryLanguage
. Default value isSPARQL
includeInferred
- indicates whether inferred statements should be included in the evaluation of the query. Default value istrue
bindings
- variable to value bindingsmaxExecTime
- maximum execution time measured in seconds (a zero or negative value indicates an unlimited execution time). Default value is0
defaultGraphs
- the graphs that constitute the default graph. The default value is the empty set.namedGraphs
- the graphs that constitute the set of named graphs.- Returns:
- Throws:
IOException
-
executeUpdate
@STServiceOperation(method=POST) @Write @PreAuthorize("@auth.isAuthorized(\'rdf(sparql)\', \'U\')") public void executeUpdate(String query, @Optional(defaultValue="SPARQL") org.eclipse.rdf4j.query.QueryLanguage ql, @Optional(defaultValue="true") boolean includeInferred, @Optional(defaultValue="{}") Map<String, org.eclipse.rdf4j.model.Value> bindings, @Optional(defaultValue="0") int maxExecTime, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] defaultGraphs, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] namedGraphs, @Optional org.eclipse.rdf4j.model.IRI defaultInsertGraph, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] defaultRemoveGraphs) Executes an update. The parameters controlling the dataset (i.e.defaultGraphs
,namedGraphs
,defaultInsertGraph
anddefaultRemoveGraphs
are not orthogonal): seeDataset
for an explanation of their meaning.- Parameters:
query
- the queryql
- the query language (seeQueryLanguage
. Default value isSPARQL
includeInferred
- indicates whether inferred statements should be included in the evaluation of the query. Default value istrue
bindings
- variable to value bindingsmaxExecTime
- maximum execution time measured in seconds (a zero or negative value indicates an unlimited execution time). Default value is0
defaultGraphs
- the graphs that constitute the default graph. The default value is the empty set.namedGraphs
- the graphs that constitute the set of named graphs.defaultInsertGraph
- the default insert graph to be used. The default value isnull
.defaultRemoveGraphs
- the default remove graphs.
-
exportQueryResultAsSpreadsheet
@STServiceOperation(method=POST) @Read @PreAuthorize("@auth.isAuthorized(\'rdf(sparql)\', \'R\')") public void exportQueryResultAsSpreadsheet(jakarta.servlet.http.HttpServletResponse oRes, String format, String query, @Optional(defaultValue="SPARQL") org.eclipse.rdf4j.query.QueryLanguage ql, @Optional(defaultValue="true") boolean includeInferred, @Optional(defaultValue="{}") Map<String, org.eclipse.rdf4j.model.Value> bindings, @Optional(defaultValue="0") int maxExecTime, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] defaultGraphs, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] namedGraphs) throws IOExceptionExports the query result as spreadsheet- Parameters:
oRes
-format
- xlsx for Microsoft Excel spreadsheet or ods for LibreOffice spreadsheetquery
-ql
-includeInferred
-bindings
-maxExecTime
-defaultGraphs
-namedGraphs
-- Throws:
IOException
-
exportGraphQueryResultAsRdf
@STServiceOperation(method=POST) @Read @PreAuthorize("@auth.isAuthorized(\'rdf(sparql)\', \'R\')") public void exportGraphQueryResultAsRdf(jakarta.servlet.http.HttpServletResponse oRes, String query, @Optional(defaultValue="SPARQL") org.eclipse.rdf4j.query.QueryLanguage ql, @Optional(defaultValue="true") boolean includeInferred, @Optional(defaultValue="{}") Map<String, org.eclipse.rdf4j.model.Value> bindings, @Optional(defaultValue="0") int maxExecTime, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] defaultGraphs, @Optional(defaultValue="") org.eclipse.rdf4j.model.IRI[] namedGraphs, @Optional(defaultValue="[]") TransformationPipeline filteringPipeline, @Optional String outputFormat, @Optional PluginSpecification deployerSpec, @Optional PluginSpecification reformattingExporterSpec) throws IOException, WrongPropertiesException, ExportPreconditionViolationException, IllegalArgumentException, STPropertyAccessException, InvalidConfigurationException, NoSuchExtensionException, ReformattingExceptionEvaluates a graph query and dumps its result (a graph) to an RDF file, using our filtered export mechanism (seeExport
). SeeevaluateQuery(String, QueryLanguage, boolean, Map, int, IRI[], IRI[])
andExport#export(HttpServletResponse, IRI[], TransformationPipeline, boolean, RDFFormat, boolean)
for the meaning of the parameters. The results of the query are stored in a randomly named graph, which would appear in the output if the output format supports named graphs.- Parameters:
oRes
-query
-ql
-includeInferred
-bindings
-maxExecTime
-defaultGraphs
-namedGraphs
-filteringPipeline
-outputFormat
-deployerSpec
-reformattingExporterSpec
-- Throws:
IOException
WrongPropertiesException
ClassNotFoundException
ExportPreconditionViolationException
STPropertyAccessException
IllegalArgumentException
InvalidConfigurationException
ReformattingException
NoSuchExtensionException
Exception
-
configureOperation
protected void configureOperation(boolean includeInferred, Map<String, org.eclipse.rdf4j.model.Value> bindings, int maxExecTime, org.eclipse.rdf4j.model.IRI[] defaultGraphs, org.eclipse.rdf4j.model.IRI[] namedGraphs, @Nullable org.eclipse.rdf4j.model.IRI defaultInsertGraph, @Nullable org.eclipse.rdf4j.model.IRI[] defaultRemoveGraphs, org.eclipse.rdf4j.query.Operation preparedUpdate) -
suggestEndpointsForFederation
@STServiceOperation(method=GET) @Read @PreAuthorize("@auth.isAuthorized(\'rdf(sparql)\', \'R\')") public List<SPARQL.FederatedEndpointSuggestion> suggestEndpointsForFederation(String query) throws ProjectAccessException, PropertyNotFoundException, InvalidProjectNameException, IOException -
tokenize
- Throws:
IOException
-