diff --git a/src/sparql/agents.ts b/src/sparql/agents.ts index 538eda1dd614f0148816c2d76c51cf63961ef8c5..fb36d81407cd18c345e39a6b16d179bddf985540 100644 --- a/src/sparql/agents.ts +++ b/src/sparql/agents.ts @@ -8,10 +8,9 @@ export const queryPersons = async (query: string, auth?: Credentials) => { FROM <https://www.irit.fr/opencommon/agents> WHERE { ?person a foaf:Person; - foaf:familyName ?familyName; - foaf:firstName ?firstName; - ?p ?o. - FILTER (regex(?familyName, "${query}", "i") || regex(?firstName, "${query}", "i")) + foaf:familyName|foaf:firstName ?name; + ?p ?o. + FILTER (regex(?name, "${query}", "i")) } `, { @@ -54,8 +53,8 @@ export const queryOrganizations = async (query: string, auth?: Credentials) => { FROM <https://www.irit.fr/opencommon/agents> WHERE { ?organization a foaf:Organization; - foaf:name ?name; - ?p ?o. + foaf:name ?name; + ?p ?o. FILTER regex(?name, "${query}", "i") } `, diff --git a/src/sparql/catalog.ts b/src/sparql/catalog.ts index 2508a2e98c6aa07bb60264efac74a050c3422982..ff5af15782155b8d5177e47214fc49713873a6a7 100644 --- a/src/sparql/catalog.ts +++ b/src/sparql/catalog.ts @@ -32,17 +32,19 @@ export const getCatalogSummary = async (identifier: string, auth?: Credentials) oct:graph ?g. } WHERE { - VALUES ?p { - rdf:type - dct:title - dct:description - dcat:catalog - } - ?catalog a dcat:Catalog; - ?p ?o. GRAPH ?g { - ?catalog dct:identifier ?identifier + ?catalog a dcat:Catalog; + dct:identifier ?identifier. FILTER (STR(?identifier) = "${identifier}") + + VALUES ?p { + rdf:type + dct:title + dct:description + dcat:catalog + } + + ?catalog ?p ?o. } } `, @@ -74,10 +76,16 @@ export const getCatalogSummaryFromUri = async (uri: string, auth?: Credentials) oct:graph ?g. } WHERE { - <${uri}> a dcat:Catalog; - ?p ?o. GRAPH ?g { - <${uri}> dct:identifier ?identifier + <${uri}> a dcat:Catalog. + VALUES ?p { + dct:identifier + rdf:type + dct:title + dct:description + dcat:catalog + } + <${uri}> ?p ?o. } } `, @@ -107,14 +115,20 @@ export const getCatalogSummaryFromParentUri = async (uri: string, auth?: Credent ` CONSTRUCT { ?node ?p ?o; - oct:graph ?g. + oct:graph ?g. } WHERE { <${uri}> a dcat:Catalog; dcat:catalog ?node. - ?node ?p ?o. GRAPH ?g { - ?node dct:identifier ?identifier + VALUES ?p { + dct:identifier + rdf:type + dct:title + dct:description + dcat:catalog + } + ?node ?p ?o. } } `, @@ -137,14 +151,21 @@ export const getCatalogSummaryFromChildUri = async (uri: string, auth?: Credenti ` CONSTRUCT { ?node ?p ?o; - oct:graph ?g. + oct:graph ?g. } WHERE { ?node a dcat:Catalog; - dcat:catalog <${uri}>. - ?node ?p ?o. + dcat:catalog <${uri}>. + GRAPH ?g { - ?node dct:identifier ?identifier + VALUES ?p { + dct:identifier + rdf:type + dct:title + dct:description + dcat:catalog + } + ?node ?p ?o. } } `, @@ -301,15 +322,15 @@ export async function getCatalog(identifier: string, auth?: Credentials): Promis ` CONSTRUCT { ?catalog ?p ?o; - oct:graph ?g. + oct:graph ?g. } WHERE { - ?catalog a dcat:Catalog; - ?p ?o. - ?catalog dct:identifier ?identifier. - FILTER (str(?identifier) = "${identifier}"). GRAPH ?g { - ?node dct:identifier ?identifier + ?catalog a dcat:Catalog; + dct:identifier ?identifier. + FILTER (str(?identifier) = "${identifier}") + + ?catalog ?p ?o. } } `, diff --git a/src/sparql/communities.ts b/src/sparql/communities.ts index a2185979b701aa762d4e9ba699d0a9281942a374..19655ab00eb0000b36c3b247777988097618a9dc 100644 --- a/src/sparql/communities.ts +++ b/src/sparql/communities.ts @@ -44,7 +44,7 @@ export const getCommunityList = async (auth?: Credentials) => { ` CONSTRUCT { ?space ?p ?o. } WHERE { - ?space a oct:Space; + ?space a oct:Community; ?p ?o. } `, diff --git a/src/sparql/resource.ts b/src/sparql/resource.ts index b2092c8c028649467327a51a88cae63dec5ddaf7..8aa36dbd0e3104d33a4fc3e406ee4b49ef42cabf 100644 --- a/src/sparql/resource.ts +++ b/src/sparql/resource.ts @@ -41,15 +41,13 @@ export async function getResource(identifier: string, auth?: Credentials): Promi ` CONSTRUCT { ?resource ?p ?o. - ?resource oct:graph ?g. + oct:graph ?g. } WHERE { - ?resource ?p ?o. - ?resource dct:identifier ?id. - filter (STR(?id) = "${identifier}") - GRAPH ?g { - ?resource dct:identifier ?id + ?resource dct:identifier ?id. + FILTER (STR(?id) = "${identifier}") + ?resource ?p ?o. } } `, diff --git a/src/sparql/service.ts b/src/sparql/service.ts index cb4b1f721d68c6e82bd54013da5a5498835b2541..a4ce6d69a53f4f5798bc2ca72f83e0de6fc41293 100644 --- a/src/sparql/service.ts +++ b/src/sparql/service.ts @@ -1,8 +1,8 @@ -import type { Credentials, OcService, OcJsonLdDocument } from "@/declarations" +import type { Credentials, OcService } from "@/declarations" import { executeSparqlConstruct } from "./sparql" import type { ContextDefinition } from "jsonld" -const sereviceContext: ContextDefinition = { +const serviceContext: ContextDefinition = { "identifier": { "@id": "http://purl.org/dc/terms/identifier", "@type": "http://www.w3.org/2000/01/rdf-schema#Literal" @@ -13,21 +13,21 @@ const sereviceContext: ContextDefinition = { }, } -export const queryService = async (query: string, locale: string, auth?: Credentials): Promise<OcJsonLdDocument<OcService>> => { +export const queryService = async (query: string, locale: string, auth?: Credentials): Promise<OcService[]> => { return executeSparqlConstruct<OcService>( ` CONSTRUCT {?s ?p ?o.} WHERE { ?s a dcat:DataService; - dct:title ?title; - ?p ?o. - FILTER regex(?title, "${query}", "i"). - FILTER(LANG(?title) = "${locale}" || LANG(?title) = ""). + dct:title ?title. + FILTER regex(?title, "${query}", "i") + FILTER(LANG(?title) = "${locale}" || LANG(?title) = "") + ?s ?p ?o. } `, { auth: auth, - context: sereviceContext + context: serviceContext } ) } \ No newline at end of file diff --git a/src/sparql/vocabularies.ts b/src/sparql/vocabularies.ts index 2390646363e2d04915791b7b62b45a709e8d93e7..29a6be9298aa538950f0f7b62f24a96f5e41a6fe 100644 --- a/src/sparql/vocabularies.ts +++ b/src/sparql/vocabularies.ts @@ -40,8 +40,8 @@ export const getVocabularyList = (scheme: string, auth?: Credentials) => { CONSTRUCT {?s skos:prefLabel ?label.} WHERE { ?s a skos:Concept; - skos:prefLabel ?label; - skos:inScheme <${scheme}>. + skos:prefLabel ?label; + skos:inScheme <${scheme}>. } `, { @@ -74,8 +74,9 @@ export const queryVocabulary = ( CONSTRUCT {?s skos:prefLabel ?label.} WHERE { ?s a skos:Concept; - skos:prefLabel ?label; - skos:inScheme <${scheme}>. + skos:inScheme <${scheme}>; + skos:prefLabel ?label. + FILTER regex(?label, "${query}", "i"). FILTER(LANG(?label) = "${locale}" || LANG(?title) = ""). } @@ -96,9 +97,9 @@ export const getConceptChildren = (scheme: string, parentTerm?: string, auth?: C } WHERE { ?s a skos:Concept; - skos:prefLabel ?label; - skos:broader|^skos:narrower <${parentTerm}>; - skos:inScheme <${scheme}>. + skos:prefLabel ?label; + skos:broader|^skos:narrower <${parentTerm}>; + skos:inScheme <${scheme}>. OPTIONAL { ?s skos:narrower|^skos:broader ?narrower } @@ -120,8 +121,8 @@ export const getVocabularyRootConcepts = async (scheme: string, auth?: Credentia } WHERE { ?s a skos:Concept; - skos:prefLabel ?label; - skos:topConceptOf|^skos:hasTopConcept <${scheme}>. + skos:topConceptOf|^skos:hasTopConcept <${scheme}>; + skos:prefLabel ?label. OPTIONAL { ?s skos:narrower|^skos:broader ?narrower } @@ -163,18 +164,18 @@ export const getLocaleList = () => { return executeSparqlConstruct<OcLocale>( ` CONSTRUCT { - ?s ?p ?o. + ?s skos:prefLabel ?prefLabel. ?s <http://publications.europa.eu/ontology/authority/legacy-code> ?codeValue. } WHERE { ?s a skos:Concept; - ?p ?o; - <http://publications.europa.eu/ontology/authority/op-mapped-code> ?code; - skos:inScheme <http://publications.europa.eu/resource/authority/language>. - FILTER(?p in (skos:prefLabel)) + skos:inScheme <http://publications.europa.eu/resource/authority/language>; + <http://publications.europa.eu/ontology/authority/op-mapped-code> ?code; + skos:prefLabel ?prefLabel. + ?code ?p2 ?o2; - dc:source 'iso-639-1'; - <http://publications.europa.eu/ontology/authority/legacy-code> ?codeValue. + dc:source 'iso-639-1'; + <http://publications.europa.eu/ontology/authority/legacy-code> ?codeValue. } `, { @@ -204,9 +205,9 @@ export const getLicenseList = () => { } WHERE { ?s a skos:Concept; - skos:prefLabel ?prefLabel; - skos:altLabel ?altLabel; - skos:inScheme <http://publications.europa.eu/resource/authority/licence>. + skos:inScheme <http://publications.europa.eu/resource/authority/licence>; + skos:prefLabel ?prefLabel; + skos:altLabel ?altLabel. } `, {