From 8c4272d338a718f243a84315a048d474893d649c Mon Sep 17 00:00:00 2001
From: Mathieu Massaviol <mathieu.massaviol@univ-amu.fr>
Date: Wed, 20 Nov 2024 11:38:04 +0100
Subject: [PATCH] Fix publisher reloading #35

---
 src/sparql/catalog.ts | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/sparql/catalog.ts b/src/sparql/catalog.ts
index 1eb219e..7ecb484 100644
--- a/src/sparql/catalog.ts
+++ b/src/sparql/catalog.ts
@@ -246,7 +246,7 @@ export async function updateCatalog(catalog: OcCatalog, profile: OcPerson, auth?
       OPTIONAL {
         <${catalog['@id']}> dct:temporal ?temporal.
         ?temporal ?p2 ?o2.
-        filter isblank(?temporal)
+        FILTER isblank(?temporal)
       }
       <${catalog['@id']}> ?p ?o.
     };
@@ -388,8 +388,8 @@ export async function getCatalog(identifier: string, auth?: Credentials): Promis
     }
     WHERE {
       <${catalogUri}> dct:creator ?creator.
+      VALUES ?p1 { rdf:type foaf:familyName foaf:name foaf:givenName foaf:firstName foaf:lastName foaf:mbox }
       ?creator ?p1 ?o1.
-      FILTER (?p1 IN (rdf:type, foaf:familyName, foaf:name, foaf:givenName, foaf:firstName, foaf:lastName, foaf:mbox))
     }
     `,
     {
@@ -407,8 +407,8 @@ export async function getCatalog(identifier: string, auth?: Credentials): Promis
     }
     WHERE {
       <${catalogUri}> dcat:contactPoint ?contactPoint.
+      VALUES ?p1 { rdf:type foaf:familyName foaf:name foaf:givenName foaf:firstName foaf:lastName foaf:mbox }
       ?contactPoint ?p1 ?o1.
-      FILTER (?p1 IN (rdf:type, foaf:familyName, foaf:name, foaf:givenName, foaf:firstName, foaf:lastName, foaf:mbox))
     }
     `,
     {
@@ -551,6 +551,26 @@ export async function getCatalog(identifier: string, auth?: Credentials): Promis
     }
   )
 
+  /**
+   * Publisher
+   */
+  const catalogPublisherPromise = executeSparqlConstruct<OcOrganization>(
+    `
+    CONSTRUCT {
+      ?publisher ?p ?o.
+    }
+    WHERE {
+      <${catalogUri}> dct:publisher ?publisher.
+        VALUES ?p { dct:identifier rdf:type dct:title dct:description foaf:name }
+        ?publisher ?p ?o.
+    }
+    `,
+    {
+      auth,
+      context: resourceContext
+    }
+  )
+
   const catalogResponse = await Promise.all([
     catalogTemporalPromise, // 0
     catalogStatusPromise, // 1
@@ -561,7 +581,8 @@ export async function getCatalog(identifier: string, auth?: Credentials): Promis
     catalogLanguagePromise, // 6
     catalogTypePromise, // 7
     catalogSubsPromise, // 8
-    catalogDatasetsPromise // 9
+    catalogDatasetsPromise, // 9
+    catalogPublisherPromise // 10
   ])
 
   catalog.temporal = catalogResponse[0].map<[Date, Date]>((temporal) => [
@@ -577,6 +598,7 @@ export async function getCatalog(identifier: string, auth?: Credentials): Promis
   catalog.type = catalogResponse[7][0]
   catalog.catalogs = catalogResponse[8]
   catalog.datasets = catalogResponse[9]
+  catalog.publisher = catalogResponse[10][0]
 
   return catalog
 }
-- 
GitLab