package fr.insee.rmes.api.concepts;

public class ConceptsQueries {
	
	public static String getConceptsByLabel(String label) {
		return "SELECT ?id ?uri ?intitule ?remplace ?estRemplacePar WHERE { \n"
				+ "?uri skos:inScheme ?conceptScheme . \n"
				+ "FILTER(REGEX(STR(?conceptScheme),'/concepts/definitions/scheme')) \n"
				+ "?uri skos:notation ?id . \n"
				+ "?uri skos:prefLabel ?intitule . \n"
				+ "FILTER(lang(?intitule) = 'fr') \n"
				+ "FILTER(REGEX(STR(?intitule),\"" + label + "\",'i'))"
				+ "OPTIONAL{ ?uri dcterms:replaces ?remplace } \n"
				+ "OPTIONAL{ ?estRemplacePar dcterms:replaces ?uri } \n"
				+ "}"
				+ "ORDER BY ?intitule";
	}
	
	public static String getConceptById(String id) {
		return "SELECT ?uri ?intitule ?remplace ?estRemplacePar WHERE { \n"
				+ "?uri skos:inScheme ?conceptScheme . \n"
				+ "FILTER(REGEX(STR(?conceptScheme),'/concepts/definitions/scheme')) \n"
				+ "?uri skos:notation '" + id + "' . \n"
				+ "?uri skos:prefLabel ?intitule . \n"
				+ "FILTER(lang(?intitule) = 'fr') \n"
				+ "OPTIONAL{ ?uri dcterms:replaces ?remplace } \n"
				+ "OPTIONAL{ ?estRemplacePar dcterms:replaces ?uri } \n"
				+ "}"
				+ "ORDER BY ?intitule";
	}

}

@@ -449,29 +449,38 @@
 %09%09+ %22FILTER(
-REGEX
+CONTAINS(LCASE
 (STR(?intitu
@@ -482,16 +482,17 @@
 ntitule)
+)
 ,%5C%22%22 + l
@@ -499,18 +499,28 @@
 abel
+.toLowerCase()
  + %22%5C%22
-,'i'
 ))%22%0A

Fix concepts query