Using the ENAPSO View Management Service
ENAPSO together provides a View Management Service to manage SPARQL queries with embedded JavaScript processing. This allows users to create dynamic queries that include preprocessing of input variables and post-processing of results before displaying them. The service consists of multiple operations:
Creating a SPARQL Template
To create a SPARQL template, you need to define:
The template name
The SPARQL query
Optional pre and post-processing scripts in JavaScript
Variables must be used in the format
${variableName}
inside the SPARQL template
API Endpoint:
v1/create-template
Request Body Example:
{
"records": [
{
"name": "getUtteranceStyles2Enrich",
"preJSScript":"",
"postJSScript":"",
"template": " `select ?s ?utteranceStyle ?definition ?intention ?typicalReactions where { ?s rdf:type <http://ont.enapso.com/companion#UtteranceStyle>. ?s rdfs:label ?utteranceStyle. ?s <http://ont.enapso.com/companion#defintion> ?definition. ?s <http://ont.enapso.com/companion#intention> ?intention. ?s <http://ont.enapso.com/companion#expectedResponse> ?typicalReactions. }`"
}
]
}
Creating a Variable
A variable used in the template (e.g., ${variableName}) must be created separately before being assigned to the template.
API Endpoint:
v1/create-variable
Request Body Example:
Assigning a Variable to a Template
Once a variable is created, it must be explicitly linked to a SPARQL template.
API Endpoint:
Request Body Example:
Executing a SPARQL Template
After creating and linking the necessary variables, you can execute a template by passing its name and required input variables.
API Endpoint:
Request Body Example:
Use Case Example
Scenario: A user retrieves utterance styles, definitions, intentions, and expected reactions from the knowledge graph.
Steps:
Create a SPARQL template named
getUtteranceStyles2Enrich
.Create and assign required variables.
Execute the template by calling
v1/execute-template-by-name
with the necessary parameters.Receive the processed data, ready for application use.
Summary
Use
v1/create-template
to define reusable SPARQL queries.Use
v1/create-variable
to define dynamic variables.Use
v1/add-variable-to-template
to link variables to templates.Use
v1/execute-template-by-name
to run those queries dynamically.Pre and post-processing scripts allow greater flexibility in handling input and output data.
(C) Copyright 2014-2024 INNOTRADE GmbH, Herzogenrath, NRW, Germany (all rights reserved)