Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
# A conversational API for running SPARQL queries
`edu.cornell.mannlib.vitro.webapp.utils.sparqlrunner` provides a syntactically simple
way to manipulate and execute SPARQL queries. The query may be run against a Jena `Model`
or a Vitro `RDFService`.
The API supports the most common tasks:
+ bind URI values to variables in the query.
+ bind plain literal values to variables in the query.
+ execute a CONSTRUCT query and return a Jena model.
+ execute a SELECT query and return the results in a variety of formats:
+ a List of String values
+ a Set of String values
+ a List of Maps of String values
+ a JSON-formatted output stream
+ the output of a custom parser class.
The API could reasonably be extended to perform other operations, or to produce
additional forms of output. It currently provides only the functionality that
was immediately useful at the time of writing.
## Usage Examples
In general, the usage pattern is to
+ create the query context
+ optionally bind values to variables in the query
+ execute
+ transform the results
### SELECT to a List of Strings
Run a SELECT query, binding a value to the variable `?uri` and returning
a List of the values that are returned for the variable `?partner`.
List values = createSelectQueryContext(rdfService, queryString)
.bindVariableToUri("uri", uri)
.execute()
.toStringFields("partner")
.flatten();
### SELECT to a List of Maps
Example: Run a SELECT query, returning a list of maps of strings. Each map
represents a record in the ResultSet, with variable names mapped to the
value in that record, translated to a String.
List