Groovy
This page discusses using Groovy to interact with Stardog.
Page Contents
Overview
Groovy is an agile and dynamic programming language for the JVM, making popular programming features such as closures available to Java developers. Stardog’s Groovy support makes life easier for developers who need to work with RDF, SPARQL, and OWL by way of Stardog.
The Groovy for Stardog source code is available on Github.
Binary releases are available on via Maven central using the following dependency declaration (Gradle style): com.complexible.stardog:stardog-groovy:6.1.0
.
Stardog-Groovy can be included via com.complexible.stardog:stardog-groovy:6.1.0
from Maven central.
You must include our public repository in your build script to get the Stardog client dependencies into your local repository.
The Stardog-Groovy version always matches the Stardog release, e.g. for Stardog 6.1.0 use stardog-groovy-6.1.0.
API Overview
Groovy for Stardog provides a set of Groovy API wrappers for developers to build applications with Stardog and take advantage of native Groovy features. For example, you can create a Stardog connection pool in a single line, much like Groovy SQL support. In Groovy for Stardog, queries can be iterated over using closures and transaction safe closures can be executed over a connection.
Groovy for Stardog includes com.complexible.stardog.ext.groovy.Stardog
with the following methods:
Stardog(map)
constructor for managing Stardog connection poolseach(String, Closure)
for executing a closure over a query’s results, including projecting SPARQL result variables into the closure.query(String, Closure)
for executing a closure over a query’s results, passing the BindingSet to the closureinsert(List)
for inserting a list of vars as a triple, or a list of list of triples for insertionremove(List)
for removing a triple from the databasewithConnection
for executing a closure with a transaction safe instance of Connection.