From 2ead4efd8e93fdbb993736886a72754b54f0bfda Mon Sep 17 00:00:00 2001
From: Mathieu Massaviol <mathieu.massaviol@univ-amu.fr>
Date: Tue, 12 Nov 2024 14:28:13 +0100
Subject: [PATCH] Improve tree browsing request #68

---
 src/sparql/tree.ts | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/sparql/tree.ts b/src/sparql/tree.ts
index 5c12524..0fe89a2 100644
--- a/src/sparql/tree.ts
+++ b/src/sparql/tree.ts
@@ -59,21 +59,24 @@ export const getTreeNodesFromParentNodeURI = async (parentNodeUri: string, auth?
 
   return await executeSparqlConstruct<OcTreeNode>(
     `
-        CONSTRUCT {
+      CONSTRUCT {
+        <${parentNodeUri}> ?p ?o.
+        ?node ?p2 ?o2.
+        ?node oct:graph ?g.
+      }
+      WHERE {
+        {
+          VALUES ?p { dcat:catalog dcat:dataset dcat:distribution dct:title dct:identifier rdf:type }
           <${parentNodeUri}> ?p ?o.
-          ?node ?p2 ?o2.
-          ?node oct:graph ?g.
-        }
-        WHERE {
-                VALUES ?p { dcat:catalog dcat:dataset dcat:distribution dct:title dct:identifier rdf:type }
-                VALUES ?p2 { dcat:catalog dcat:dataset dcat:distribution dct:title dct:identifier rdf:type }
-                <${parentNodeUri}> ?p ?o.
-                <${parentNodeUri}> (dcat:catalog|dcat:dataset|dcat:distribution){0,1} ?node.
-                ?node ?p2 ?o2
+        } UNION {
+          VALUES ?p2 { dcat:catalog dcat:dataset dcat:distribution dct:title dct:identifier rdf:type }
+          <${parentNodeUri}> (dcat:catalog|dcat:dataset|dcat:distribution){0,1} ?node.
+          ?node ?p2 ?o2 .
           GRAPH ?g {
-                ?node dct:identifier ?id
+            ?node dct:identifier ?id
           }
         }
+      }
     `,
     {
       context,
-- 
GitLab