Skip to content

Commit 6642529

Browse files
committed
Merge branch 'fix/54-CE-bis' of https://github.com/SolidLabResearch/generic-data-viewer-react-admin into fix/54-CE-bis
2 parents 56117ea + 4df496c commit 6642529

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
### Fixed
2020

2121
- Forced CSS's to not return content type application/ld+json, which induced a CORS error on some CSS server versions (#131).
22+
- Queries based on index file now work for any variable, not just ?object (#136).
2223

2324
## [1.2.1] - 2024-06-17
2425

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ The set of sources over which a query will be executed is derived from two *opti
141141

142142
If both inputs are present, the query will be executed over the superset of sources.
143143

144-
The (auxiliary) query provided in `sourceIndex.queryLocation` is executed on `sourceIndex.url` and must result in the list of sources.
144+
The (auxiliary) query provided in `sourceIndex.queryLocation` is executed on `sourceIndex.url` and must result in the list of source URLs.
145145

146146
If `sourceIndex` is used and there is no `comunicaContext.lenient` property found, one will be created with value `true`.
147147
This makes sure that the (main) query can succeed if not all obtained sources are accessible.

src/components/Dashboard/CustomQueryEditor/customEditor.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ WHERE {
4242
?s ?p ?o
4343
}`;
4444
const defaultSparqlQueryIndexSources = `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
45-
SELECT ?object
45+
SELECT ?source
4646
WHERE {
47-
?s rdfs:seeAlso ?object
47+
?s rdfs:seeAlso ?source
4848
}`;
4949
const defaultExtraComunicaContext = JSON.stringify({ "lenient": true }, null, 2);
5050
const defaultAskQueryDetails = JSON.stringify({"trueText": "this displays when true.", "falseText": "this displays when false."}, null, 2);

src/dataProvider/SparqlDataProvider.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,15 @@ const addComunicaContextSourcesFromSourcesIndex = async (sourcesIndex) => {
356356
});
357357

358358
await new Promise((resolve, reject) => {
359-
bindingsStream.on('data', (binding) => {
360-
const source = binding.get('object').value;
361-
if (!sourcesList.includes(source)) {
362-
sourcesList.push(source);
359+
bindingsStream.on('data', (bindings) => {
360+
// the bindings should have exactly one key (any name is allowed) and we accept the value as a source
361+
if (bindings.size == 1) {
362+
for (const term of bindings.values()) {
363+
const source = term.value;
364+
if (!sourcesList.includes(source)) {
365+
sourcesList.push(source);
366+
}
367+
}
363368
}
364369
});
365370
bindingsStream.on('end', resolve);
@@ -370,6 +375,10 @@ const addComunicaContextSourcesFromSourcesIndex = async (sourcesIndex) => {
370375
throw new Error(`Error adding sources from index: ${error.message}`);
371376
}
372377

378+
if (sourcesList.length == 0) {
379+
throw new Error(`The resulting list of sources is empty`);
380+
}
381+
373382
return sourcesList;
374383
};
375384

0 commit comments

Comments
 (0)