diff --git a/CHANGELOG.md b/CHANGELOG.md
index b3bc1f3c..0855a824 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated onto-deside configuration 2025-04-09 (#202).
- In the configuration file: per query `httpProxies` setting replaces global `httpProxy` setting (#4, #47).
+- Error message when query has no sources was replaced with an application message in the empty result list (#204).
## [1.7.0] - 2025-04-09
diff --git a/main/configs/test/config.json b/main/configs/test/config.json
index be6270d7..e937cb35 100644
--- a/main/configs/test/config.json
+++ b/main/configs/test/config.json
@@ -525,6 +525,17 @@
"httpProxy": "http://localhost:8000/"
}
]
+ },
+ {
+ "id": "9140",
+ "queryGroupId": "gr-test",
+ "queryLocation": "components_materials.rq",
+ "name": "Sources from an index file - no sources",
+ "description": "Test what happens if the sourceIndex query results in 0 sources.",
+ "sourcesIndex": {
+ "url": "http://localhost:8080/example/index-example-file-does-not-exist",
+ "queryLocation": "/sourceQueries/index_example_common_lt.rq"
+ }
}
]
}
\ No newline at end of file
diff --git a/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx b/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx
index 4984a717..f00debfc 100644
--- a/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx
+++ b/main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx
@@ -50,7 +50,7 @@ function QueryResultList(props) {
disableAuthentication={true} // needed to overrule the default, which is to force logging in
title=" "
actions={ }
- empty={}
+ empty={}
queryOptions={{
keepPreviousData: false,
meta: {
@@ -78,12 +78,13 @@ const Aside = (props) => {
);
}
-const NoValuesDisplay = () => {
+const NoValuesDisplay = (props) => {
+ const msg = props?.query?.comunicaContext?.sources?.length ? "The result list is empty." : "The result list is empty (no sources found).";
return (
- The result list is empty.
+ {msg}
);
@@ -96,7 +97,7 @@ const MyDatagrid = (props) => {
if (isLoading) {
return ;
}
-
+
let values = {};
if (!isLoading && data && data.length > 0) {
data.forEach((record) => {
diff --git a/main/src/dataProvider/SparqlDataProvider.js b/main/src/dataProvider/SparqlDataProvider.js
index 857e8553..7ee91449 100644
--- a/main/src/dataProvider/SparqlDataProvider.js
+++ b/main/src/dataProvider/SparqlDataProvider.js
@@ -53,7 +53,11 @@ export default {
// LOG console.log(`reusing listCache.results: ${JSON.stringify(listCache.results, null, 2)}`);
results = listCache.results;
} else {
- results = await executeQuery(query);
+ if (query.comunicaContext?.sources?.length) {
+ results = await executeQuery(query);
+ } else {
+ results = [];
+ }
listCache.hash = hash;
listCache.results = results;
// LOG console.log(`new listCache.results: ${JSON.stringify(listCache.results, null, 2)}`);
@@ -285,10 +289,6 @@ async function getSourcesFromSourcesIndex(sourcesIndex, httpProxies) {
throw new Error(`Error adding sources from index: ${error.message}`);
}
- if (sourcesList.length == 0) {
- throw new Error(`The resulting list of sources is empty`);
- }
-
return sourcesList;
}
diff --git a/test/cypress/e2e/sources-from-indexfile.cy.js b/test/cypress/e2e/sources-from-indexfile.cy.js
index 87eea1be..278293d8 100644
--- a/test/cypress/e2e/sources-from-indexfile.cy.js
+++ b/test/cypress/e2e/sources-from-indexfile.cy.js
@@ -106,4 +106,16 @@ describe("Sources from index file", () => {
cy.contains("Material 1").should("exist");
})
+ it("Sources obtained only from sourcesIndex, but no sources found", () => {
+ cy.visit("/");
+
+ // Navigate to correct query
+ cy.contains("For testing only").click();
+ cy.contains("Sources from an index file - no sources").click();
+
+ // Check for the expected message
+ cy.get('span').contains("The result list is empty (no sources found).").should("exist");
+
+ });
+
});