Skip to content

Commit 602bec8

Browse files
authored
Merge pull request #154 from SolidLabResearch/fix/78-indirect-variables-custom-feature
Fix/78 indirect variables custom feature
2 parents 8bc4ebd + ffd4edc commit 602bec8

30 files changed

+1494
-270
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Templated queries can now have values for variables as a result of a query ("Indirect variables") (#78).
13+
1214
### Changed
1315

1416
- Refactoring: isolated the Comunica engine with accompanying operations into a wrapper class (#152).
1517

1618
### Fixed
1719

18-
- Correct error display when the queryLocation is a non existing file or faultive (#147).
20+
- Correct error display when the queryLocation is a non existing file or faulty (#147).
1921
- Fixed a bug where editing a custom query did not correctly remove unchecked options (#150).
2022

2123
## [1.2.3] - 2024-07-11

README.md

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Table of contents:
1111
* [Specifying sources](#specifying-sources)
1212
* [Adding variable type](#adding-variable-type)
1313
* [Templated queries](#templated-queries)
14+
* [Templated queries with fixed values for the template variables](#templated-queries-with-fixed-values-for-the-template-variables)
15+
* [Templated queries with values for the template variables to be derived from the data](#templated-queries-with-values-for-the-template-variables-to-be-derived-from-the-data)
1416
* [Query icons](#query-icons)
1517
* [Custom queries](#custom-queries)
1618
* [Representation Mapper](#representation-mapper)
@@ -120,8 +122,16 @@ The configuration file follows a simple structure.
120122
},
121123
"variables": {
122124
"variableExampleString": ["\"String1\"", "\"String2\""],
123-
"variableExampleUri": ["<https://example.com/uri1>", "<https://example.com/uri2>"]
125+
"variableExampleUri": ["<https://example.com/uri1>", "<https://example.com/uri2>"],
126+
"variableExampleInteger": ["1", "2"]
124127
},
128+
"indirectVariables": {
129+
"queryLocations": [
130+
"Path to the location, relative to 'queryFolder' of a query yielding some template variable values",
131+
...
132+
]
133+
},
134+
125135
"askQuery": {
126136
"trueText": "The text that is to be shown when the query result is true (in ASK queries).",
127137
"falseText": "The text that is to be shown when the query result is false (in ASK queries)."
@@ -159,18 +169,51 @@ The underscore `_` here is crucial to make a clear distinction between name and
159169

160170
### Templated queries
161171

162-
This application supports queries whose contents are not completely fixed upfront: they contain variables whose value can be set interactively.
172+
This application supports templated queries: queries whose contents are not completely fixed upfront.
173+
They can contain *template variables*.
174+
A template variable is an identifier preceded by a `$` sign, e.g. `$genre`.
175+
Before submitting the SPARQL query, each template variable will be replaced by the actual value assigned to it interactively.
176+
177+
#### Templated queries with fixed values for the template variables
163178

164-
To change a query into a templated query:
165-
- replace the fixed portion(s) of the query with (a) variable(s); a variable is an identifier preceded by a `$` sign, e.g. `$genre`
166-
- add a `variables` object in the query's entry in the configuration file
167-
- in the `variables` object, for each variable, add a property with name equal to the variable's identifier
168-
- set each such property's value to an array of possible values for the corresponding variable
179+
If all possible values for the template variables are fixed and hence can be written in the config file, proceed as follows.
169180

170-
Note that variables' values are not restricted to strings: URIs for example are alo possible.
181+
- Replace the fixed portion(s) of the original query with (a) template variable(s).
182+
- In the config file:
183+
- Add a `variables` object in the query's entry in the configuration file.
184+
- In the `variables` object, for each template variable, add a property with name equal to the template variable's identifier.
185+
- Set each such property's value to an array strings, where each string is a possible value for the corresponding template variable.
186+
187+
Note that template variables' values are not restricted to strings: URIs for example are also possible.
171188
As a consequence, for strings the surround double quotes `"` must be added to the values in the list.
189+
For URIs you must add surrounding angle brackets `<>`.
190+
Other literals (integers for example) don't have to be surrounded with extra delimiters.
172191
This is shown in the configuration structure above.
173192

193+
#### Templated queries with values for the template variables to be derived from the data
194+
195+
In most cases, the values for the template variables are not fixed, but depend on *the data to query*.
196+
For those cases, these values can be specified indirectly, by referring to one or more auxiliary queries.
197+
Proceed as follows.
198+
199+
- Write one or more auxiliary queries that yield the values of the template variable(s).
200+
The variable names in the SELECT statement must match the template variable names (e.g `?genre` for template variable `$genre`).
201+
- Replace the fixed portion(s) of the original query with (a) template variable(s).
202+
- In the config file:
203+
- Add an `indirectVariables` object in the query's entry in the configuration file.
204+
- In the `indirectVariables` object, add a property `queryLocations`: this must be an *array*,
205+
listing the location(s) of the one or more auxiliary queries that you wrote.
206+
207+
An example auxiliary query for the variable `$genre`, as used in one of the provided example templated queries:
208+
209+
```text
210+
PREFIX schema: <http://schema.org/>
211+
212+
SELECT DISTINCT ?genre WHERE {
213+
?list schema:genre ?genre;
214+
}
215+
```
216+
174217
### Query icons
175218

176219
In the selection menu the name of the query is proceeded by an icon.

0 commit comments

Comments
 (0)