-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenexa-parameter
More file actions
executable file
·37 lines (32 loc) · 1.12 KB
/
enexa-parameter
File metadata and controls
executable file
·37 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
set -eu
DIR="$(dirname "$(realpath "$0")")"/
ENEXA_PARAMETER_IRI="$1"
# If the graph is not set, use an empty string
GRAPH="${ENEXA_META_DATA_GRAPH:-}"
# If the graph variable is not set or it is emtpy
if [ -z "$GRAPH" ]; then
GRAPH_PART1=""
GRAPH_PART2=""
else
GRAPH_PART1="GRAPH <$GRAPH> {"
GRAPH_PART2="}"
fi
QUERY="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX enexa: <http://w3id.org/dice-research/enexa/ontology#>
SELECT ?v WHERE {
$GRAPH_PART1
{<$ENEXA_MODULE_INSTANCE_IRI> <$ENEXA_PARAMETER_IRI> ?l FILTER(isLiteral(?l)) BIND(str(?l) AS ?v)}
UNION
{<$ENEXA_MODULE_INSTANCE_IRI> <$ENEXA_PARAMETER_IRI> [rdf:value ?v]}
UNION
{<$ENEXA_MODULE_INSTANCE_IRI> <$ENEXA_PARAMETER_IRI> [sd:endpoint ?v]}
UNION
{<$ENEXA_MODULE_INSTANCE_IRI> <$ENEXA_PARAMETER_IRI> [enexa:location ?l] BIND(REPLACE(?l, 'enexa-dir:/', '$ENEXA_SHARED_DIRECTORY') AS ?v)}
$GRAPH_PART2}"
# For debugging
echo $QUERY >&2
echo $QUERY \
|"$DIR"/sparql-select "$ENEXA_META_DATA_ENDPOINT" \
|awk '(NR==2) { gsub(/^"|"$/, ""); print }'