Skip to content
Snippets Groups Projects
Commit 145199d8 authored by Mathieu Massaviol's avatar Mathieu Massaviol
Browse files

Improve requests #68

parent bbb2db3c
Branches
No related tags found
1 merge request!79Resolve "Investiguer / Optimiser les temps de réponse des requêtes Virtuoso"
Pipeline #10820 passed
......@@ -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")
}
`,
......
......@@ -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.
}
}
`,
......
......@@ -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.
}
`,
......
......@@ -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.
}
}
`,
......
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
......@@ -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.
}
`,
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment