Through the design process, and dealing with Jena, a wrapper was found necessary to remove repetitive code and to make the tool more intuitive. It provides a unified interface to handle the Jena models and has command line arguments that can clear or do SPARQL queries on Jena models.

modelSource - Provides the information needed for the connection to the source data model, which is the model that will be searched and possibly modified.

  • model.conf.xml
  • parameter=Value

sparqlQuery - This is the sparql query being applied to the model. Since the query is provided in a command line string, it is possible to use bash to express a file as that string.

  • "SELECT ?s ?p ?o WHERE { ?s ?p ?o } "

displayResultFormat - Since RDF can be expressed in several different format, this parameter is where the format is specified.

RS_XML RS_TEXT CSV RS_JSON RS_RDF - for select

RDF/XML RDF/XML-ABBREV N3 N-TRIPLE TTL - for construct and describe

  • RDF/XML

outputfile - This specifies the output file for the results of the query. If it isn't specified then it is sent to the command line output.

  • path/Filename

dataset - This flag signals that the query should be done against the data set and not the model.

  • true

truncate - This flag means that the tool will truncate or clear the given jena model. This would be used for clearing out the model for a fresh harvest or trying to correct after data corruption.

  • true

Overview

Short Option

Long Option

Parameter Value Map

Description

Required

j

jena

CONFIG_FILE

config file for jena model

false

J

jenaOverride

override of the JENA_PARAM of jena model config using VALUE

false

q

query

SPARQL_QUERY

sparql query to execute

false

Q

queryResultFormat

RESULT_FORMAT

the format to return the results in ('RS_RDF',etc for select queries / 'RDF/XML',etc for construct/describe queries)

false

d

dataset

 

execute query against dataset rather than model

false

t

truncate

 

empty the jena model

false

Usage

Within the harvester the connections to the jena models are done through the JenaConnect wrapping class.

Running a SPARQL query from the command line

JenaConnect can run a query and output it to the console.

shell> source scripts/env
shell> $JenaConnect -j vivoConfigFile.xml -q "Query text"

Using both asserted and inferred data

VIVO stores asserted data and inferred data in two different data models. JenaConnect connects only to one, the one specified by the modelName parameter in the config file. There is a special model that is the union of all models, called "urn:x-arq:UnionGraph". Use this model with JenaConnect in order for SPARQL queries to recognize inferred data.

To override the model from the config file, use -JmodelName. For example:

shell> $JenaConnect -j vivoConfigFile.xml -JmodelName=urn:x-arq-:UnionGraph -q "Query text"